Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set-parent returns panic: runtime error: index out of range [0] with length 0 #2562

Closed
heyitsaamir opened this issue Oct 10, 2023 · 11 comments · Fixed by #2623
Closed

set-parent returns panic: runtime error: index out of range [0] with length 0 #2562

heyitsaamir opened this issue Oct 10, 2023 · 11 comments · Fixed by #2623
Labels

Comments

@heyitsaamir
Copy link

heyitsaamir commented Oct 10, 2023

git town set-parent
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/git-town/git-town/v9/src/git.determineSyncStatus({0xc002394d27?, 0xc002394d27?}, {0xc002394d27?, 0x3?})
        /home/kevlar/git-town/src/git/backend_commands.go:117 +0x227
github.com/git-town/git-town/v9/src/git.ParseVerboseBranchesOutput({0xc002308000, 0xb57b83})
        /home/kevlar/git-town/src/git/backend_commands.go:104 +0x1da
github.com/git-town/git-town/v9/src/git.(*BackendCommands).BranchesSyncStatus(0xc00003e510)
        /home/kevlar/git-town/src/git/backend_commands.go:81 +0x85
github.com/git-town/git-town/v9/src/execute.LoadBranches(0xc00003e500, {0xc8?})
        /home/kevlar/git-town/src/execute/load_branches.go:10 +0x6a
github.com/git-town/git-town/v9/src/cmd.setParent(0x0)
        /home/kevlar/git-town/src/cmd/set_parent.go:45 +0x1c5
github.com/git-town/git-town/v9/src/cmd.setParentCommand.func1(0xc0001c1500?, {0xf7f160?, 0x0?, 0x0?})
        /home/kevlar/git-town/src/cmd/set_parent.go:24 +0x25
github.com/spf13/cobra.(*Command).execute(0xc0001c1500, {0xf7f160, 0x0, 0x0})
        /home/kevlar/git-town/vendor/github.com/spf13/cobra/command.go:916 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0xc0001ac000)
        /home/kevlar/git-town/vendor/github.com/spf13/cobra/command.go:1044 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
        /home/kevlar/git-town/vendor/github.com/spf13/cobra/command.go:968
github.com/git-town/git-town/v9/src/cmd.Execute()
        /home/kevlar/git-town/src/cmd/core.go:48 +0x6e8
main.main()
        /home/kevlar/git-town/main.go:20 +0x25

All i did was install git-town (my first time), and try to run git town set-parent.

I'm also using an internal-hosted version of git (so not it's not github, gitlab etc). Does this matter?

@kevgo
Copy link
Contributor

kevgo commented Oct 11, 2023

Thanks for sending this bug report and sorry for the problem! I can see the issue in the codebase. I'd like to reproduce the problem to make sure the fix works on your machine. Can you please post the output of running git branch -vva? Also, which Git version do you use, and is there a language other than US English configured? Thanks! 🙏

Using a custom Git hosting service shouldn't be a problem as long as it is at the origin remote. Run git remote -v to verify. The only thing that might not work is git new-pull-request but you can work around this by creating pull requests manually as you already do without Git Town.

Btw (pro tip) you shouldn't need to run git town set-parent much. Git Town will ask you for the parent when you run git sync or git hack the first time on a branch for which it doesn't know the parent.

@heyitsaamir
Copy link
Author

heyitsaamir commented Oct 13, 2023

Thanks kev!

Sorry about the late response.

Here is the partial response from git branch -vva

  aamirj/MP-QueryCmdsToAC                                                                                                                                                                                          73188fb6b782 [
origin/aamirj/MP-QueryCmdsToAC] fix strings
  aamirj/makeScrollable                                                                                                                                                                                            e0ec7f8b0aa8 [
origin/aamirj/makeScrollable] revert
* aamirj/renderCorrectResults                                                                                                                                                                                      2c421da6e579 [
origin/aamirj/renderCorrectResults] Render correct results
  aamirj/renderSearchForm                                                                                                                                                                                          f2700ca2924b [
origin/aamirj/renderSearchForm] fix tests
  master                                                                                                                                                                                                           cabf8897282e [
origin/master: behind 470] Merged PR 866236: [T2.1] Update voice admin settings local cache on mutation update

I work on a massive codebase, so the actual result is extremely long (thousands of remote branches). I wonder if this is because of that? I really only care about remote branches that are prefixed with my branches (aamirj/.*)

The stack I want is:
master -> aamirj/MP-QueryCmdsToAC -> aamirj/renderSearchForm -> aamirj/renderCorrectResults -> aamirj/makeScrollable.

git version 2.42.0

As for langauage, i've never modified the language here, but this is what i get:

> echo $LANG               
C.UTF-8

Also thank you for the tip for git sync!

@kevgo
Copy link
Contributor

kevgo commented Oct 16, 2023

Hmm, that's really strange. Below is the format I get on my machines (and what Git Town expects). Have you configured Git in special ways, or set up any filters or aliases for Git commands?

Support for large monorepos is definitely on Git Town's roadmap. Any feedback of problems you run into are appreciated!

~/d/git-town [kg-alphavet] > git branch -vva                                                                                                          (base) 
* kg-alphavet                             261a0e0d [origin/kg-alphavet] gitea_test.go github_test.go gitlab.go gitlab_test.go backend_runner.go frontend_runner.go branch_changes.go branch_span.go config_diff.go create_undo_list.go knows_branch_ancestry.go core.go update_proposal_target.go program.go runstate.go
  main                                    4890a652 [origin/main] Remove json tags (#2591)
  remotes/origin/HEAD                     -> origin/main
  remotes/origin/kg-alphavet              261a0e0d gitea_test.go github_test.go gitlab.go gitlab_test.go backend_runner.go frontend_runner.go branch_changes.go branch_span.go config_diff.go create_undo_list.go knows_branch_ancestry.go core.go update_proposal_target.go program.go runstate.go
  remotes/origin/kg-azure-devops          83ba220a Merge branch 'main' into kg-azure-devops
  remotes/origin/kg-fix-initial-pos       3d0c4c13 Merge branch 'main' into kg-fix-initial-pos
  remotes/origin/kg-improve-error-message abca5249 Improve the error message for git switch
  remotes/origin/kg-survey-v2             47fb71df Merge branch 'main' into kg-survey-v2
  remotes/origin/kg-upstream-pr           9cf52b0d Merge branch 'main' into kg-upstream-pr
  remotes/origin/kg-workspace-support     d9d850e6 Improve debug output (#2307)
  remotes/origin/main                     4890a652 Remove json tags (#2591)
  remotes/origin/public                   1ea6b7a7 Better type correctness (#2336)

@heyitsaamir
Copy link
Author

Hm, everything should be out of the box. I haven't really done anything special, I don't think... What about specifying the format that git-town expects? If i do:

$ git branch -vva --format='%(refname:short) %(upstream) %(committerdate) %(contents:subject)'

aamirj/MP-QueryCmdsToAC refs/remotes/origin/aamirj/MP-QueryCmdsToAC Mon Oct 16 23:30:38 2023 +0000 fix
aamirj/makeScrollable refs/remotes/origin/aamirj/makeScrollable Fri Oct 13 22:14:57 2023 +0000 revert
aamirj/renderCorrectResults refs/remotes/origin/aamirj/renderCorrectResults Mon Oct 16 23:52:24 2023 +0000 Merge branch 'aamirj/renderSearchForm' into aamirj/renderCorrectResults
aamirj/renderSearchForm refs/remotes/origin/aamirj/renderSearchForm Mon Oct 16 23:52:06 2023 +0000 fix
master refs/remotes/origin/master Thu Oct 12 01:10:12 2023 +0000 Merged PR 866236: [T2.1] Update voice admin settings local cache on mutation update
origin/'NEWTC_1789177'  Mon Dec 12 19:48:08 2022 +0530 For NX Pipeline run.
origin/0541867a-on-jinglu-avatar_MRU_test  Fri Jun 10 08:24:09 2022 +0000 Merged PR 536469: [Perceived Performance, Maglev T2.1] Animate in each slot, once its respective CRITICAL phase is complete. Transition on app switches, chat/channel switches, etc.
origin/05cdf3af-on-praneta-test-auto-cp1  Tue Jul 25 19:26:04 2023 +0000 Merged PR 817323: Updated readme.md
...

@heyitsaamir
Copy link
Author

Oh the wrapping might be messing up my copy-paste:
image

@kevgo
Copy link
Contributor

kevgo commented Oct 27, 2023

Hey Amir, I have just merged a preliminary fix for this issue. Also some code that will print additional output when this problem happens again. Both will be released as v10 soon. Thanks!

@heyitsaamir
Copy link
Author

Hey Amir, I have just merged a preliminary fix for this issue. Also some code that will print additional output when this problem happens again. Both will be released as v10 soon. Thanks!

Thanks! Can't wait to try it :). I've switched to git machete for the time being. Thank you for addressing so fast!

@heyitsaamir
Copy link
Author

Btw @kevgo , any timeline for v10?

@kevgo
Copy link
Contributor

kevgo commented Nov 1, 2023

@heyitsaamir v10 is ready to go. I did some QA the last couple of days to verify that everything works ... on my machine 😆. I was setting up some more release automation but that'll take at least a few more days. So I think I'm going to make a manual release tomorrow.

@heyitsaamir
Copy link
Author

@heyitsaamir v10 is ready to go. I did some QA the last couple of days to verify that everything works ... on my machine 😆. I was setting up some more release automation but that'll take at least a few more days. So I think I'm going to make a manual release tomorrow.

Amazing! Can't wait :)

@kevgo
Copy link
Contributor

kevgo commented Nov 2, 2023

v10 is out, please take it for a spin! As I said earlier, I think I have fixed only half the problem. If the issue still occurs, the error message should be different/more precise. Please share it here, so that we'll corner this bug together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants