Skip to content

Commit d3db970

Browse files
committed
"Fixes" missing stashes from Graph
There has to be a better way to do this
1 parent 61ae55f commit d3db970

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

src/env/node/git/git.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,15 +769,19 @@ export class Git {
769769
);
770770
}
771771

772-
log2(repoPath: string, ref: string | undefined, ...args: unknown[]) {
772+
log2(repoPath: string, ref: string | undefined, stdin: string | undefined, ...args: unknown[]) {
773773
const params = ['log', ...args];
774774

775775
if (ref && !GitRevision.isUncommittedStaged(ref)) {
776776
params.push(ref);
777777
}
778778

779+
if (stdin) {
780+
params.push('--stdin');
781+
}
782+
779783
return this.git<string>(
780-
{ cwd: repoPath, configs: ['-c', 'diff.renameLimit=0', '-c', 'log.showSignature=false'] },
784+
{ cwd: repoPath, configs: ['-c', 'diff.renameLimit=0', '-c', 'log.showSignature=false'], stdin: stdin },
781785
...params,
782786
'--',
783787
);

src/env/node/git/localGitProvider.ts

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ import { countStringLength, filterMap } from '../../../system/array';
110110
import { TimedCancellationSource } from '../../../system/cancellation';
111111
import { gate } from '../../../system/decorators/gate';
112112
import { debug, getLogScope, log } from '../../../system/decorators/log';
113-
import { filterMap as filterMapIterable, find, first, last, some } from '../../../system/iterable';
113+
import { filterMap as filterMapIterable, find, first, join, last, map, some } from '../../../system/iterable';
114114
import {
115115
commonBaseIndex,
116116
dirname,
@@ -1611,6 +1611,17 @@ export class LocalGitProvider implements GitProvider, Disposable {
16111611
): Promise<GitGraph> {
16121612
const scope = getLogScope();
16131613

1614+
let stdin: string | undefined;
1615+
1616+
// // TODO@eamodio this is insanity -- there *HAS* to be a better way to get git log to return stashes
1617+
const stash = await this.getStash(repoPath);
1618+
if (stash != null) {
1619+
stdin = join(
1620+
map(stash.commits.values(), c => c.sha.substring(0, 7)),
1621+
'\n',
1622+
);
1623+
}
1624+
16141625
let getLogForRefFn;
16151626
if (options?.ref != null) {
16161627
async function getLogForRef(this: LocalGitProvider): Promise<GitLog | undefined> {
@@ -1626,6 +1637,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
16261637
ordering: 'date',
16271638
limit: 0,
16281639
extraArgs: [`--since="${Number(commit.date)}"`, '--boundary'],
1640+
stdin: stdin,
16291641
});
16301642

16311643
let found = log?.commits.has(commit.sha) ?? false;
@@ -1668,25 +1680,34 @@ export class LocalGitProvider implements GitProvider, Disposable {
16681680
}
16691681
return (
16701682
log ??
1671-
this.getLog(repoPath, { all: options?.mode !== 'single', ordering: 'date', limit: options?.limit })
1683+
this.getLog(repoPath, {
1684+
all: options?.mode !== 'single',
1685+
ordering: 'date',
1686+
limit: options?.limit,
1687+
stdin: stdin,
1688+
})
16721689
);
16731690
}
16741691

16751692
getLogForRefFn = getLogForRef;
16761693
}
16771694

1678-
const [logResult, stashResult, remotesResult] = await Promise.allSettled([
1695+
const [logResult, remotesResult] = await Promise.allSettled([
16791696
getLogForRefFn?.call(this) ??
1680-
this.getLog(repoPath, { all: options?.mode !== 'single', ordering: 'date', limit: options?.limit }),
1681-
this.getStash(repoPath),
1697+
this.getLog(repoPath, {
1698+
all: options?.mode !== 'single',
1699+
ordering: 'date',
1700+
limit: options?.limit,
1701+
stdin: stdin,
1702+
}),
16821703
this.getRemotes(repoPath),
16831704
]);
16841705

16851706
return this.getCommitsForGraphCore(
16861707
repoPath,
16871708
asWebviewUri,
16881709
getSettledValue(logResult),
1689-
getSettledValue(stashResult),
1710+
stash,
16901711
getSettledValue(remotesResult),
16911712
options,
16921713
);
@@ -2326,6 +2347,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
23262347
since?: number | string;
23272348
until?: number | string;
23282349
extraArgs?: string[];
2350+
stdin?: string;
23292351
},
23302352
): Promise<GitLog | undefined> {
23312353
const scope = getLogScope();
@@ -2386,7 +2408,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
23862408
args.push(`-n${limit + 1}`);
23872409
}
23882410

2389-
const data = await this.git.log2(repoPath, options?.ref, ...args);
2411+
const data = await this.git.log2(repoPath, options?.ref, options?.stdin, ...args);
23902412

23912413
// const parser = GitLogParser.defaultParser;
23922414

0 commit comments

Comments
 (0)