Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(git-history): tolerate gits without --end-of-options — old remote hosts showed empty history

enes692712e6e7ff
diff --git a/src/shared/git-history.test.ts b/src/shared/git-history.test.ts
index ba04cc0b2..61d3b1316 100644
--- a/src/shared/git-history.test.ts
+++ b/src/shared/git-history.test.ts
@@ -38,4 +38,31 @@ describe('loadGitHistoryFromExecutor', () => {
it('uses the documented commit format', () => {
expect(GIT_HISTORY_COMMIT_FORMAT).toContain('%H%n')
})
+
+ // Gits older than ~2.25 (Ubuntu 18.04 / Debian 10 era — still common on SSH hosts) reject
+ // `--end-of-options` with "unknown option", which made the HEAD probe read as "no commits":
+ // a silently EMPTY history panel while the rest of Source Control worked. The flag only guards
+ // refs that start with '-', which every caller already refuses, so falling back without it
+ // loses no safety.
+ it('falls back for old gits that reject --end-of-options instead of showing empty history', async () => {
+ const head = 'c'.repeat(40)
+ const record = [head, 'Dev', '[email protected]', '1700000000', '1700000000', '', 'HEAD -> refs/heads/main', 'Init'].join('\n')
+ const flagless = makeGit({
+ 'rev-parse --verify HEAD^{commit}': head,
+ 'symbolic-ref --quiet --short HEAD': 'main',
+ 'for-each-ref': '',
+ 'rev-parse --symbolic-full-name': '',
+ 'log': record + '\0'
+ })
+ const oldGit = async (args: string[]) => {
+ if (args.includes('--end-of-options')) throw new Error("error: unknown option `end-of-options'")
+ return flagless(args)
+ }
+
+ const result = await loadGitHistoryFromExecutor(oldGit, '/repo', { limit: 10 })
+
+ expect(result.items).toHaveLength(1)
+ expect(result.items[0]!.subject).toBe('Init')
+ expect(result.currentRef?.name).toBe('main')
+ })
})
diff --git a/src/shared/git-history.ts b/src/shared/git-history.ts
index 1862bf613..73dcf0a42 100644
--- a/src/shared/git-history.ts
+++ b/src/shared/git-history.ts
@@ -47,6 +47,30 @@ function clampHistoryLimit(limit: number | undefined): number {
)
}
+/**
+ * `git rev-parse <flags> --end-of-options <ref>`, retrying WITHOUT the flag when the first call
+ * fails: gits older than ~2.25 (Ubuntu 18.04 / Debian 10 era — still common on the SSH hosts
+ * this loader now reaches) reject `--end-of-options` as an unknown option, and a rejected HEAD
+ * probe reads as "no commits" — a silently empty history panel. The flag only guards
+ * option-injection via a ref that starts with '-', and every caller refuses those refs before
+ * calling, so the fallback loses no safety. A legitimately missing ref costs one extra rev-parse
+ * and still throws, which is what callers expect.
+ */
+async function revParseCompat(
+ git: GitHistoryExecutor,
+ cwd: string,
+ flags: string[],
+ ref: string
+): Promise<string> {
+ try {
+ const { stdout } = await git(['rev-parse', ...flags, '--end-of-options', ref], cwd)
+ return stdout
+ } catch {
+ const { stdout } = await git(['rev-parse', ...flags, ref], cwd)
+ return stdout
+ }
+}
+
async function resolveCommit(
git: GitHistoryExecutor,
cwd: string,
@@ -56,10 +80,7 @@ async function resolveCommit(
return null
}
try {
- const { stdout } = await git(
- ['rev-parse', '--verify', '--end-of-options', `${ref}^{commit}`],
- cwd
- )
+ const stdout = await revParseCompat(git, cwd, ['--verify'], `${ref}^{commit}`)
const oid = stdout.trim()
return oid || null
} catch {
@@ -76,10 +97,7 @@ async function resolveSymbolicFullName(
return null
}
try {
- const { stdout } = await git(
- ['rev-parse', '--symbolic-full-name', '--end-of-options', ref],
- cwd
- )
+ const stdout = await revParseCompat(git, cwd, ['--symbolic-full-name'], ref)
return stdout.trim().split(/\r?\n/).find(Boolean) ?? null
} catch {
return null