diff --git a/web/main.ts b/web/main.ts index 29c23c82..f3652928 100644 --- a/web/main.ts +++ b/web/main.ts @@ -244,7 +244,7 @@ class GitGraphView { // Filter any branches that are currently selected, but no longer exist const globPatterns = this.config.customBranchGlobPatterns.map((pattern) => pattern.glob); this.currentBranches = this.currentBranches.filter((branch) => - this.gitBranches.includes(branch) || globPatterns.includes(branch) + branch === HEAD_BRANCH || this.gitBranches.includes(branch) || globPatterns.includes(branch) ); } if (this.currentBranches === null || this.currentBranches.length === 0) { @@ -529,6 +529,9 @@ class GitGraphView { if (includeShowAll) { options.push({ name: 'Show All', value: SHOW_ALL_BRANCHES }); } + if (this.gitBranchHead !== null) { + options.push({ name: 'HEAD (' + this.gitBranchHead + ')', value: HEAD_BRANCH }); + } for (let i = 0; i < this.config.customBranchGlobPatterns.length; i++) { options.push({ name: 'Glob: ' + this.config.customBranchGlobPatterns[i].name, value: this.config.customBranchGlobPatterns[i].glob }); } @@ -538,6 +541,15 @@ class GitGraphView { return options; } + private resolveHeadBranches(): string[] { + return this.currentBranches!.map((branch) => { + if (branch === HEAD_BRANCH && this.gitBranchHead !== null) { + return this.gitBranchHead; + } + return branch; + }); + } + public getCommitId(hash: string) { return typeof this.commitLookup[hash] === 'number' ? this.commitLookup[hash] : null; } @@ -608,7 +620,7 @@ class GitGraphView { command: 'loadCommits', repo: this.currentRepo, refreshId: ++this.currentRepoRefreshState.loadCommitsRefreshId, - branches: this.currentBranches === null || (this.currentBranches.length === 1 && this.currentBranches[0] === SHOW_ALL_BRANCHES) ? null : this.currentBranches, + branches: this.currentBranches === null || (this.currentBranches.length === 1 && this.currentBranches[0] === SHOW_ALL_BRANCHES) ? null : this.resolveHeadBranches(), maxCommits: this.maxCommits, showTags: getShowTags(repoState.showTags), showRemoteBranches: getShowRemoteBranches(repoState.showRemoteBranchesV2), diff --git a/web/utils.ts b/web/utils.ts index a63b64c8..d7928906 100644 --- a/web/utils.ts +++ b/web/utils.ts @@ -65,6 +65,7 @@ const ELLIPSIS = '…'; const SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; const UNCOMMITTED = '*'; const SHOW_ALL_BRANCHES = ''; +const HEAD_BRANCH = 'HEAD'; const COLUMN_HIDDEN = -100; const COLUMN_AUTO = -101;