Skip to content

Commit 09cbaf2

Browse files
committed
Make stash loading work in filtering mode
This broke with the introduction of the age in the stashes list in bc330b8 (which was included in 0.41, so 12 minor versions ago). This makes it work again when filtering by file, but it still doesn't work when filtering by folder (and never has). We'll fix that next.
1 parent 0dfa078 commit 09cbaf2

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

pkg/commands/git_commands/stash_loader.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (self *StashLoader) GetStashEntries(filterPath string) []*models.StashEntry
3232
return self.getUnfilteredStashEntries()
3333
}
3434

35-
cmdArgs := NewGitCmd("stash").Arg("list", "--name-only", "--pretty=%ct|%gs").ToArgv()
35+
cmdArgs := NewGitCmd("stash").Arg("list", "--name-only", "--pretty=%gd:%ct|%gs").ToArgv()
3636
rawString, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput()
3737
if err != nil {
3838
return self.getUnfilteredStashEntries()
@@ -41,19 +41,19 @@ func (self *StashLoader) GetStashEntries(filterPath string) []*models.StashEntry
4141
var currentStashEntry *models.StashEntry
4242
lines := utils.SplitLines(rawString)
4343
isAStash := func(line string) bool { return strings.HasPrefix(line, "stash@{") }
44-
re := regexp.MustCompile(`stash@\{(\d+)\}`)
44+
re := regexp.MustCompile(`^stash@\{(\d+)\}:(.*)$`)
4545

4646
outer:
4747
for i := 0; i < len(lines); i++ {
48-
if !isAStash(lines[i]) {
48+
match := re.FindStringSubmatch(lines[i])
49+
if match == nil {
4950
continue
5051
}
51-
match := re.FindStringSubmatch(lines[i])
5252
idx, err := strconv.Atoi(match[1])
5353
if err != nil {
5454
return self.getUnfilteredStashEntries()
5555
}
56-
currentStashEntry = stashEntryFromLine(lines[i], idx)
56+
currentStashEntry = stashEntryFromLine(match[2], idx)
5757
for i+1 < len(lines) && !isAStash(lines[i+1]) {
5858
i++
5959
if lines[i] == filterPath {

pkg/integration/tests/stash/filter_by_path.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,10 @@ var FilterByPath = NewIntegrationTest(NewIntegrationTestArgs{
4444
filterBy("file1")
4545

4646
t.Views().Stash().
47-
/* EXPECTED:
4847
Lines(
4948
Contains("file1 again"),
5049
Contains("file1"),
5150
)
52-
ACTUAL: */
53-
IsEmpty()
5451

5552
t.GlobalPress(keys.Universal.Return)
5653
filterBy("subdir")

0 commit comments

Comments
 (0)