diff --git a/src/git/models/status.ts b/src/git/models/status.ts index b5dfe49..dee4a0a 100644 --- a/src/git/models/status.ts +++ b/src/git/models/status.ts @@ -13,6 +13,8 @@ export interface GitStatusUpstreamState { } export class GitStatus { + readonly detached: boolean; + constructor( public readonly repoPath: string, public readonly branch: string, @@ -21,11 +23,16 @@ export class GitStatus { public readonly state: GitStatusUpstreamState, public readonly upstream?: string ) { - if (GitBranch.isDetached(branch)) { + this.detached = GitBranch.isDetached(branch); + if (this.detached) { this.branch = GitBranch.formatDetached(this.sha); } } + get ref() { + return this.detached ? this.sha : this.branch; + } + private _diff?: { added: number; deleted: number; diff --git a/src/quickpicks/repoStatusQuickPick.ts b/src/quickpicks/repoStatusQuickPick.ts index 86e8f53..66c69d3 100644 --- a/src/quickpicks/repoStatusQuickPick.ts +++ b/src/quickpicks/repoStatusQuickPick.ts @@ -391,9 +391,9 @@ export class RepoStatusQuickPick { }, Commands.ShowQuickBranchHistory, [ - GitUri.fromRepoPath(status.repoPath, `${status.upstream}..${status.branch}`), + GitUri.fromRepoPath(status.repoPath, `${status.upstream}..${status.ref}`), { - branch: status.branch, + branch: status.ref, maxCount: 0, goBackCommand: currentCommand } as ShowQuickBranchHistoryCommandArgs @@ -421,7 +421,7 @@ export class RepoStatusQuickPick { }, Commands.ShowQuickBranchHistory, [ - GitUri.fromRepoPath(status.repoPath, `${status.branch}..${status.upstream}`), + GitUri.fromRepoPath(status.repoPath, `${status.ref}..${status.upstream}`), { branch: status.upstream, maxCount: 0, diff --git a/src/views/nodes/statusNode.ts b/src/views/nodes/statusNode.ts index 1cdfe97..fcc155e 100644 --- a/src/views/nodes/statusNode.ts +++ b/src/views/nodes/statusNode.ts @@ -38,7 +38,7 @@ export class StatusNode extends ExplorerNode { } if (status.state.ahead || (status.files.length !== 0 && this.includeWorkingTree)) { - const range = status.upstream ? `${status.upstream}..${status.branch}` : undefined; + const range = status.upstream ? `${status.upstream}..${status.ref}` : undefined; children.push(new StatusFilesNode(status, range, this.explorer, this.active)); } } diff --git a/src/views/nodes/statusUpstreamNode.ts b/src/views/nodes/statusUpstreamNode.ts index 60909b2..544f0d6 100644 --- a/src/views/nodes/statusUpstreamNode.ts +++ b/src/views/nodes/statusUpstreamNode.ts @@ -25,8 +25,8 @@ export class StatusUpstreamNode extends ExplorerNode { async getChildren(): Promise { const range = this.direction === 'ahead' - ? `${this.status.upstream}..${this.status.branch}` - : `${this.status.branch}..${this.status.upstream}`; + ? `${this.status.upstream}..${this.status.ref}` + : `${this.status.ref}..${this.status.upstream}`; let log = await Container.git.getLog(this.uri.repoPath!, { maxCount: 0, ref: range }); if (log === undefined) return [];