1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-25 00:46:54 +02:00

Add unambigious refs/ prefix to all stash references

Pretty basic fix, didn't seem to have any complications.
I only added the refs/ prefix to the FullRefName() method
to align with other similar methods, and to make this change
not impact any user facing modals.

Fixes: https://github.com/jesseduffield/lazygit/issues/4634

Also adds a test demonstrating that the stash show behavior is now fixed
This commit is contained in:
Chris McDonnell
2025-06-12 21:18:27 -04:00
committed by Stefan Haller
parent aa23a6e2b5
commit 265557afa2
12 changed files with 74 additions and 17 deletions

View File

@ -32,21 +32,21 @@ func (self *StashCommands) DropNewest() error {
}
func (self *StashCommands) Drop(index int) error {
cmdArgs := NewGitCmd("stash").Arg("drop", fmt.Sprintf("stash@{%d}", index)).
cmdArgs := NewGitCmd("stash").Arg("drop", fmt.Sprintf("refs/stash@{%d}", index)).
ToArgv()
return self.cmd.New(cmdArgs).Run()
}
func (self *StashCommands) Pop(index int) error {
cmdArgs := NewGitCmd("stash").Arg("pop", fmt.Sprintf("stash@{%d}", index)).
cmdArgs := NewGitCmd("stash").Arg("pop", fmt.Sprintf("refs/stash@{%d}", index)).
ToArgv()
return self.cmd.New(cmdArgs).Run()
}
func (self *StashCommands) Apply(index int) error {
cmdArgs := NewGitCmd("stash").Arg("apply", fmt.Sprintf("stash@{%d}", index)).
cmdArgs := NewGitCmd("stash").Arg("apply", fmt.Sprintf("refs/stash@{%d}", index)).
ToArgv()
return self.cmd.New(cmdArgs).Run()
@ -90,7 +90,7 @@ func (self *StashCommands) ShowStashEntryCmdObj(index int) *oscommands.CmdObj {
Arg(fmt.Sprintf("--unified=%d", self.AppState.DiffContextSize)).
ArgIf(self.AppState.IgnoreWhitespaceInDiffView, "--ignore-all-space").
Arg(fmt.Sprintf("--find-renames=%d%%", self.AppState.RenameSimilarityThreshold)).
Arg(fmt.Sprintf("stash@{%d}", index)).
Arg(fmt.Sprintf("refs/stash@{%d}", index)).
Dir(self.repoPaths.worktreePath).
ToArgv()
@ -152,7 +152,7 @@ func (self *StashCommands) SaveStagedChanges(message string) error {
}
if err := self.cmd.New(
NewGitCmd("stash").Arg("apply", "stash@{1}").ToArgv(),
NewGitCmd("stash").Arg("apply", "refs/stash@{1}").ToArgv(),
).Run(); err != nil {
return err
}
@ -165,7 +165,7 @@ func (self *StashCommands) SaveStagedChanges(message string) error {
}
if err := self.cmd.New(
NewGitCmd("stash").Arg("drop", "stash@{1}").ToArgv(),
NewGitCmd("stash").Arg("drop", "refs/stash@{1}").ToArgv(),
).Run(); err != nil {
return err
}