Skip to content

Commit 1c757e5

Browse files
committed
Compute oldest timestamp for stashes including parent commit dates
(#4401, #4468)
1 parent 8a76151 commit 1c757e5

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
88

99
### Fixed
1010

11+
- Fixes stashes with parent commits older than the oldest stash not being visible on branches ([#4401](https://github.com/gitkraken/vscode-gitlens/issues/4401))
1112
- Fixes editing search result in Search & Compare view failure ([#4431](https://github.com/gitkraken/vscode-gitlens/issues/4431))
1213

1314
## [17.2.1] - 2025-06-26

src/env/node/git/sub-providers/stash.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export class StashGitSubProvider implements GitStashSubProvider {
166166
// Create a copy because we are going to modify it and we don't want to mutate the cache
167167
const stashes = new Map(stash.stashes);
168168

169-
const oldestStashDate = new Date(min(stash.stashes.values(), c => c.date.getTime())).toISOString();
169+
const oldestStashDate = new Date(findOldestStashTimestamp(stash.stashes.values())).toISOString();
170170

171171
const result = await this.git.exec(
172172
{ cwd: repoPath, cancellation: cancellation, errors: GitErrorHandling.Ignore },
@@ -481,3 +481,22 @@ function createStash(container: Container, s: ParsedStash, repoPath: string): Gi
481481
onRef,
482482
) as GitStashCommit;
483483
}
484+
485+
/**
486+
* Finds the oldest timestamp among stash commits and their parent commits.
487+
* This includes both the stash commit dates and all parent commit timestamps (author and committer dates).
488+
*
489+
* @param stashes - Collection of stash commits to analyze
490+
* @returns The oldest timestamp in milliseconds, or Infinity if no stashes provided
491+
*/
492+
export function findOldestStashTimestamp(stashes: Iterable<GitStashCommit>): number {
493+
return min(stashes, c => {
494+
return Math.min(
495+
c.date.getTime(),
496+
...(c.parentTimestamps
497+
?.flatMap(p => [p.authorDate, p.committerDate])
498+
.filter((x): x is number => x != null)
499+
.map(x => x * 1000) ?? []),
500+
);
501+
});
502+
}

0 commit comments

Comments
 (0)