1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-31 03:11:14 +02:00

stop checking out branches when doing a rename. Instead just move the cursor to the new position

This commit is contained in:
Jesse Duffield 2021-04-06 15:13:40 +10:00
parent a3b0efb82e
commit 0719a3e36e
28 changed files with 43 additions and 38 deletions

View File

@ -428,9 +428,6 @@ func (gui *Gui) handleRenameBranch() error {
return nil
}
// TODO: find a way to not checkout the branch here if it's not the current branch (i.e. find some
// way to get it to show up in the reflog)
promptForNewName := func() error {
return gui.prompt(promptOpts{
title: gui.Tr.NewBranchNamePrompt + " " + branch.Name + ":",
@ -439,13 +436,21 @@ func (gui *Gui) handleRenameBranch() error {
if err := gui.GitCommand.RenameBranch(branch.Name, newBranchName); err != nil {
return gui.surfaceError(err)
}
// need to checkout so that the branch shows up in our reflog and therefore
// doesn't get lost among all the other branches when we switch to something else
if err := gui.GitCommand.Checkout(newBranchName, commands.CheckoutOptions{Force: false}); err != nil {
return gui.surfaceError(err)
// need to find where the branch is now so that we can re-select it. That means we need to refetch the branches synchronously and then find our branch
gui.refreshBranches()
// now that we've got our stuff again we need to find that branch and reselect it.
for i, newBranch := range gui.State.Branches {
if newBranch.Name == newBranchName {
gui.State.Panels.Branches.SetSelectedLineIdx(i)
if err := gui.State.Contexts.Branches.HandleRender(); err != nil {
return err
}
}
}
return gui.refreshSidePanels(refreshOptions{mode: ASYNC})
return nil
},
})
}

View File

@ -1 +1 @@
ref: refs/heads/123
ref: refs/heads/blah

View File

@ -1,11 +1,9 @@
0000000000000000000000000000000000000000 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684760 +1000 commit (initial): file0
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684760 +1000 checkout: moving from master to new-branch
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684760 +1000 checkout: moving from new-branch to new-branch-2
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684760 +1000 checkout: moving from new-branch-2 to new-branch-3
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684760 +1000 checkout: moving from new-branch-3 to old-branch
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684760 +1000 checkout: moving from old-branch to old-branch-2
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684760 +1000 checkout: moving from old-branch-2 to old-branch-3
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 0000000000000000000000000000000000000000 CI <CI@example.com> 1617684766 +1000 Branch: renamed refs/heads/old-branch-3 to refs/heads/old-branch-10
0000000000000000000000000000000000000000 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684766 +1000 Branch: renamed refs/heads/old-branch-3 to refs/heads/old-branch-10
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684766 +1000 checkout: moving from old-branch-10 to old-branch-10
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684772 +1000 checkout: moving from old-branch-10 to 123
0000000000000000000000000000000000000000 6b4faf392c2938a01ce7256111dd23cfbb43e8cc CI <CI@example.com> 1617685961 +1000 commit (initial): file0
6b4faf392c2938a01ce7256111dd23cfbb43e8cc 6b4faf392c2938a01ce7256111dd23cfbb43e8cc CI <CI@example.com> 1617685961 +1000 checkout: moving from master to new-branch
6b4faf392c2938a01ce7256111dd23cfbb43e8cc 6b4faf392c2938a01ce7256111dd23cfbb43e8cc CI <CI@example.com> 1617685961 +1000 checkout: moving from new-branch to new-branch-2
6b4faf392c2938a01ce7256111dd23cfbb43e8cc 6b4faf392c2938a01ce7256111dd23cfbb43e8cc CI <CI@example.com> 1617685961 +1000 checkout: moving from new-branch-2 to new-branch-3
6b4faf392c2938a01ce7256111dd23cfbb43e8cc 6b4faf392c2938a01ce7256111dd23cfbb43e8cc CI <CI@example.com> 1617685961 +1000 checkout: moving from new-branch-3 to old-branch
6b4faf392c2938a01ce7256111dd23cfbb43e8cc 6b4faf392c2938a01ce7256111dd23cfbb43e8cc CI <CI@example.com> 1617685961 +1000 checkout: moving from old-branch to old-branch-2
6b4faf392c2938a01ce7256111dd23cfbb43e8cc 6b4faf392c2938a01ce7256111dd23cfbb43e8cc CI <CI@example.com> 1617685961 +1000 checkout: moving from old-branch-2 to old-branch-3
6b4faf392c2938a01ce7256111dd23cfbb43e8cc 0000000000000000000000000000000000000000 CI <CI@example.com> 1617685967 +1000 Branch: renamed refs/heads/old-branch-3 to refs/heads/blah
0000000000000000000000000000000000000000 6b4faf392c2938a01ce7256111dd23cfbb43e8cc CI <CI@example.com> 1617685967 +1000 Branch: renamed refs/heads/old-branch-3 to refs/heads/blah

View File

@ -1,2 +0,0 @@
0000000000000000000000000000000000000000 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684760 +1000 branch: Created from HEAD
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684772 +1000 Branch: renamed refs/heads/old-branch-2 to refs/heads/123

View File

@ -0,0 +1,2 @@
0000000000000000000000000000000000000000 6b4faf392c2938a01ce7256111dd23cfbb43e8cc CI <CI@example.com> 1617685961 +1000 branch: Created from HEAD
6b4faf392c2938a01ce7256111dd23cfbb43e8cc 6b4faf392c2938a01ce7256111dd23cfbb43e8cc CI <CI@example.com> 1617685967 +1000 Branch: renamed refs/heads/old-branch-3 to refs/heads/blah

View File

@ -0,0 +1,2 @@
0000000000000000000000000000000000000000 6b4faf392c2938a01ce7256111dd23cfbb43e8cc CI <CI@example.com> 1617685961 +1000 branch: Created from HEAD
6b4faf392c2938a01ce7256111dd23cfbb43e8cc 6b4faf392c2938a01ce7256111dd23cfbb43e8cc CI <CI@example.com> 1617685976 +1000 Branch: renamed refs/heads/old-branch to refs/heads/haha

View File

@ -1 +1 @@
0000000000000000000000000000000000000000 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684760 +1000 commit (initial): file0
0000000000000000000000000000000000000000 6b4faf392c2938a01ce7256111dd23cfbb43e8cc CI <CI@example.com> 1617685961 +1000 commit (initial): file0

View File

@ -1 +1 @@
0000000000000000000000000000000000000000 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684760 +1000 branch: Created from HEAD
0000000000000000000000000000000000000000 6b4faf392c2938a01ce7256111dd23cfbb43e8cc CI <CI@example.com> 1617685961 +1000 branch: Created from HEAD

View File

@ -1 +1 @@
0000000000000000000000000000000000000000 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684760 +1000 branch: Created from HEAD
0000000000000000000000000000000000000000 6b4faf392c2938a01ce7256111dd23cfbb43e8cc CI <CI@example.com> 1617685961 +1000 branch: Created from HEAD

View File

@ -1 +1 @@
0000000000000000000000000000000000000000 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684760 +1000 branch: Created from HEAD
0000000000000000000000000000000000000000 6b4faf392c2938a01ce7256111dd23cfbb43e8cc CI <CI@example.com> 1617685961 +1000 branch: Created from HEAD

View File

@ -1 +0,0 @@
0000000000000000000000000000000000000000 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684760 +1000 branch: Created from HEAD

View File

@ -1,2 +0,0 @@
0000000000000000000000000000000000000000 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684760 +1000 branch: Created from HEAD
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276 CI <CI@example.com> 1617684766 +1000 Branch: renamed refs/heads/old-branch-3 to refs/heads/old-branch-10

View File

@ -0,0 +1 @@
0000000000000000000000000000000000000000 6b4faf392c2938a01ce7256111dd23cfbb43e8cc CI <CI@example.com> 1617685961 +1000 branch: Created from HEAD

View File

@ -0,0 +1,2 @@
x�ΝA
Β0@QΧ9Ε왉ΣID„®z�¤™`΅!¥Dπψφn?ώ�j];σ¥f@v7 IUsΆ!HΜd†c*\Π§\Ό+³wρΣίν€i†Η4ΏμλΎΩmiυ $dT®„�ξ¬η¤Ϋ�ά•u3t?ήC+ώ

View File

@ -1 +0,0 @@
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276

View File

@ -0,0 +1 @@
6b4faf392c2938a01ce7256111dd23cfbb43e8cc

View File

@ -0,0 +1 @@
6b4faf392c2938a01ce7256111dd23cfbb43e8cc

View File

@ -1 +1 @@
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276
6b4faf392c2938a01ce7256111dd23cfbb43e8cc

View File

@ -1 +1 @@
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276
6b4faf392c2938a01ce7256111dd23cfbb43e8cc

View File

@ -1 +1 @@
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276
6b4faf392c2938a01ce7256111dd23cfbb43e8cc

View File

@ -1 +1 @@
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276
6b4faf392c2938a01ce7256111dd23cfbb43e8cc

View File

@ -1 +0,0 @@
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276

View File

@ -1 +0,0 @@
764ffd4a377531ac55c5c0a1ce0b5f8dfedb3276

View File

@ -0,0 +1 @@
6b4faf392c2938a01ce7256111dd23cfbb43e8cc

View File

@ -1 +1 @@
{"KeyEvents":[{"Timestamp":550,"Mod":0,"Key":259,"Ch":0},{"Timestamp":919,"Mod":0,"Key":256,"Ch":82},{"Timestamp":1568,"Mod":0,"Key":259,"Ch":0},{"Timestamp":1792,"Mod":0,"Key":259,"Ch":0},{"Timestamp":1984,"Mod":0,"Key":259,"Ch":0},{"Timestamp":2152,"Mod":0,"Key":259,"Ch":0},{"Timestamp":2304,"Mod":0,"Key":259,"Ch":0},{"Timestamp":2464,"Mod":0,"Key":259,"Ch":0},{"Timestamp":2624,"Mod":0,"Key":259,"Ch":0},{"Timestamp":2800,"Mod":0,"Key":259,"Ch":0},{"Timestamp":2968,"Mod":0,"Key":259,"Ch":0},{"Timestamp":3151,"Mod":0,"Key":259,"Ch":0},{"Timestamp":3327,"Mod":0,"Key":259,"Ch":0},{"Timestamp":3512,"Mod":0,"Key":259,"Ch":0},{"Timestamp":3696,"Mod":0,"Key":259,"Ch":0},{"Timestamp":3872,"Mod":0,"Key":259,"Ch":0},{"Timestamp":4064,"Mod":0,"Key":259,"Ch":0},{"Timestamp":4743,"Mod":0,"Key":127,"Ch":127},{"Timestamp":5112,"Mod":0,"Key":256,"Ch":49},{"Timestamp":5208,"Mod":0,"Key":256,"Ch":48},{"Timestamp":5543,"Mod":0,"Key":13,"Ch":13},{"Timestamp":6256,"Mod":0,"Key":258,"Ch":0},{"Timestamp":6919,"Mod":0,"Key":256,"Ch":82},{"Timestamp":7896,"Mod":0,"Key":271,"Ch":0},{"Timestamp":8048,"Mod":0,"Key":271,"Ch":0},{"Timestamp":8175,"Mod":0,"Key":271,"Ch":0},{"Timestamp":8311,"Mod":0,"Key":271,"Ch":0},{"Timestamp":8440,"Mod":0,"Key":271,"Ch":0},{"Timestamp":8584,"Mod":0,"Key":271,"Ch":0},{"Timestamp":8720,"Mod":0,"Key":271,"Ch":0},{"Timestamp":8856,"Mod":0,"Key":271,"Ch":0},{"Timestamp":8991,"Mod":0,"Key":271,"Ch":0},{"Timestamp":9136,"Mod":0,"Key":271,"Ch":0},{"Timestamp":9280,"Mod":0,"Key":271,"Ch":0},{"Timestamp":9424,"Mod":0,"Key":271,"Ch":0},{"Timestamp":9560,"Mod":0,"Key":271,"Ch":0},{"Timestamp":10200,"Mod":2,"Key":21,"Ch":21},{"Timestamp":11079,"Mod":0,"Key":256,"Ch":49},{"Timestamp":11287,"Mod":0,"Key":256,"Ch":50},{"Timestamp":11383,"Mod":0,"Key":256,"Ch":51},{"Timestamp":11728,"Mod":0,"Key":13,"Ch":13},{"Timestamp":12423,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]}
{"KeyEvents":[{"Timestamp":819,"Mod":0,"Key":259,"Ch":0},{"Timestamp":1562,"Mod":0,"Key":256,"Ch":82},{"Timestamp":2260,"Mod":0,"Key":271,"Ch":0},{"Timestamp":2394,"Mod":0,"Key":271,"Ch":0},{"Timestamp":2515,"Mod":0,"Key":271,"Ch":0},{"Timestamp":2658,"Mod":0,"Key":271,"Ch":0},{"Timestamp":2794,"Mod":0,"Key":271,"Ch":0},{"Timestamp":2922,"Mod":0,"Key":271,"Ch":0},{"Timestamp":3066,"Mod":0,"Key":271,"Ch":0},{"Timestamp":3203,"Mod":0,"Key":271,"Ch":0},{"Timestamp":3338,"Mod":0,"Key":271,"Ch":0},{"Timestamp":3475,"Mod":0,"Key":271,"Ch":0},{"Timestamp":3603,"Mod":0,"Key":271,"Ch":0},{"Timestamp":3738,"Mod":0,"Key":271,"Ch":0},{"Timestamp":3883,"Mod":0,"Key":271,"Ch":0},{"Timestamp":4507,"Mod":2,"Key":21,"Ch":21},{"Timestamp":5218,"Mod":0,"Key":256,"Ch":98},{"Timestamp":5363,"Mod":0,"Key":256,"Ch":108},{"Timestamp":5491,"Mod":0,"Key":256,"Ch":97},{"Timestamp":5570,"Mod":0,"Key":256,"Ch":104},{"Timestamp":5843,"Mod":0,"Key":13,"Ch":13},{"Timestamp":7098,"Mod":0,"Key":258,"Ch":0},{"Timestamp":7858,"Mod":0,"Key":258,"Ch":0},{"Timestamp":9563,"Mod":0,"Key":256,"Ch":82},{"Timestamp":10835,"Mod":0,"Key":271,"Ch":0},{"Timestamp":10994,"Mod":0,"Key":271,"Ch":0},{"Timestamp":11130,"Mod":0,"Key":271,"Ch":0},{"Timestamp":11274,"Mod":0,"Key":271,"Ch":0},{"Timestamp":11411,"Mod":0,"Key":271,"Ch":0},{"Timestamp":11562,"Mod":0,"Key":271,"Ch":0},{"Timestamp":11707,"Mod":0,"Key":271,"Ch":0},{"Timestamp":11858,"Mod":0,"Key":271,"Ch":0},{"Timestamp":12019,"Mod":0,"Key":271,"Ch":0},{"Timestamp":12235,"Mod":0,"Key":271,"Ch":0},{"Timestamp":12443,"Mod":0,"Key":271,"Ch":0},{"Timestamp":13050,"Mod":2,"Key":21,"Ch":21},{"Timestamp":13778,"Mod":0,"Key":256,"Ch":104},{"Timestamp":13874,"Mod":0,"Key":256,"Ch":97},{"Timestamp":13979,"Mod":0,"Key":256,"Ch":104},{"Timestamp":14082,"Mod":0,"Key":256,"Ch":97},{"Timestamp":14426,"Mod":0,"Key":13,"Ch":13},{"Timestamp":15915,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]}

View File

@ -1 +1 @@
{ "description": "Checking out a branch with name suggestions", "speed": 100 }
{ "description": "Checking out a branch with name suggestions", "speed": 10 }