Browse Source

Fixes #2394 ensures uncommitted parent is HEAD

main
Eric Amodio 1 year ago
parent
commit
66d3c411b1
4 changed files with 14 additions and 3 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +4
    -0
      src/git/gitProviderService.ts
  3. +5
    -3
      src/git/models/commit.ts
  4. +4
    -0
      src/git/models/reference.ts

+ 1
- 0
CHANGELOG.md View File

@ -39,6 +39,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed ### Fixed
- Fixes [#2394](https://github.com/gitkraken/vscode-gitlens/issues/2394) - Work in progress file diff compares working tree with working tree, instead of working tree with head
- Fixes [#2207](https://github.com/gitkraken/vscode-gitlens/issues/2207) - Error when trying to push individual commit - Fixes [#2207](https://github.com/gitkraken/vscode-gitlens/issues/2207) - Error when trying to push individual commit
- Fixes [#2301](https://github.com/gitkraken/vscode-gitlens/issues/2301) - Create Worktree button doesn't work in certain cases - Fixes [#2301](https://github.com/gitkraken/vscode-gitlens/issues/2301) - Create Worktree button doesn't work in certain cases
- Fixes [#2382](https://github.com/gitkraken/vscode-gitlens/issues/2382) - commits disappearing from commit details view when they shouldn't - Fixes [#2382](https://github.com/gitkraken/vscode-gitlens/issues/2382) - commits disappearing from commit details view when they shouldn't

+ 4
- 0
src/git/gitProviderService.ts View File

@ -2303,6 +2303,10 @@ export class GitProviderService implements Disposable {
pathOrUri?: string | Uri, pathOrUri?: string | Uri,
options?: { timeout?: number }, options?: { timeout?: number },
) { ) {
if (pathOrUri != null && GitRevision.isUncommittedParent(ref)) {
ref = 'HEAD';
}
if ( if (
!ref || !ref ||
ref === GitRevision.deletedOrMissing || ref === GitRevision.deletedOrMissing ||

+ 5
- 3
src/git/models/commit.ts View File

@ -173,9 +173,11 @@ export class GitCommit implements GitRevisionReference {
private _resolvedPreviousSha: string | undefined; private _resolvedPreviousSha: string | undefined;
get unresolvedPreviousSha(): string { get unresolvedPreviousSha(): string {
return (
this._resolvedPreviousSha ?? (this.file != null ? this.file.previousSha : this.parents[0]) ?? `${this.sha}^`
);
const previousSha =
this._resolvedPreviousSha ??
(this.file != null ? this.file.previousSha : this.parents[0]) ??
`${this.sha}^`;
return GitRevision.isUncommittedParent(previousSha) ? 'HEAD' : previousSha;
} }
private _etagFileSystem: number | undefined; private _etagFileSystem: number | undefined;

+ 4
- 0
src/git/models/reference.ts View File

@ -47,6 +47,10 @@ export namespace GitRevision {
return ref === uncommitted || ref === uncommittedStaged || (!exact && isMatch(uncommittedRegex, ref)); return ref === uncommitted || ref === uncommittedStaged || (!exact && isMatch(uncommittedRegex, ref));
} }
export function isUncommittedParent(ref: string | undefined) {
return ref === `${uncommitted}^` || ref === `${uncommittedStaged}^`;
}
export function isUncommittedStaged(ref: string | undefined, exact: boolean = false): boolean { export function isUncommittedStaged(ref: string | undefined, exact: boolean = false): boolean {
return ref === uncommittedStaged || (!exact && isMatch(uncommittedStagedRegex, ref)); return ref === uncommittedStaged || (!exact && isMatch(uncommittedStagedRegex, ref));
} }

Loading…
Cancel
Save