Skip to content

Commit 31e54ea

Browse files
authored
Fix incorrect stash diff after rename (#4213)
- **PR Description** Reproduction: ```bash git init git commit --allow-empty -m "first commit" touch file1 git add . git stash push -m "stash1" touch file2 git add . git stash push -m "stash2" lazygit ``` Navigate to the Stash view and rename stash 1 ![image](https://github.com/user-attachments/assets/f43b065c-9d28-4375-a5d7-cfe39a4bf216) Manually refreshing fixes the diff. - **Please check if the PR fulfills these requirements** * [ ] Cheatsheets are up-to-date (run `go generate ./...`) * [x] Code has been formatted (see [here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting)) * [x] Tests have been added/updated (see [here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md) for the integration test guide) * [ ] Text is internationalised (see [here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation)) * [ ] If a new UserConfig entry was added, make sure it can be hot-reloaded (see [here](https://github.com/jesseduffield/lazygit/blob/master/docs/dev/Codebase_Guide.md#using-userconfig)) * [ ] Docs have been updated if necessary * [x] You've read through your own file changes for silly mistakes etc
2 parents 5dff9af + 02ca07a commit 31e54ea

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pkg/gui/controllers/stash_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,13 @@ func (self *StashController) handleRenameStashEntry(stashEntry *models.StashEntr
201201
HandleConfirm: func(response string) error {
202202
self.c.LogAction(self.c.Tr.Actions.RenameStash)
203203
err := self.c.Git().Stash.Rename(stashEntry.Index, response)
204-
_ = self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STASH}})
205204
if err != nil {
205+
_ = self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STASH}})
206206
return err
207207
}
208208
self.context().SetSelection(0) // Select the renamed stash
209209
self.context().FocusLine()
210-
return nil
210+
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STASH}})
211211
},
212212
})
213213

pkg/integration/tests/stash/rename.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@ var Rename = NewIntegrationTest(NewIntegrationTestArgs{
3131
t.ExpectPopup().Prompt().Title(Equals("Rename stash: stash@{1}")).Type(" baz").Confirm()
3232
}).
3333
SelectedLine(Contains("On master: foo baz"))
34+
35+
t.Views().Main().Content(Contains("file-1"))
3436
},
3537
})

0 commit comments

Comments
 (0)