Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
fix(git): list exact local branch names when a tag shares the name (#34997)
OrcaWina90398508228
diff --git a/src/main/git/checkout-branch-identity-real-git.test.ts b/src/main/git/checkout-branch-identity-real-git.test.tsnew file mode 100644index 00000000000..88cc2e12b6c--- /dev/null+++ b/src/main/git/checkout-branch-identity-real-git.test.ts@@ -0,0 +1,48 @@+import { mkdtemp, rm } from 'node:fs/promises'+import { tmpdir } from 'node:os'+import { join } from 'node:path'+import { runProcess } from '@orca/process-host'+import { afterEach, beforeEach, describe, expect, it } from 'vitest'+import { installRealWorkerThreadChildProcesses } from '../worker-thread-child-process/worker-thread-child-process-real.test-fixtures'+import { checkoutBranch, listLocalBranches } from './checkout'++let directory: string++async function git(...args: string[]): Promise<string> {+ const result = await runProcess({ program: 'git', args, cwd: directory })+ if (result.code !== 0) {+ throw new Error(result.stderr)+ }+ return result.stdout.trim()+}++beforeEach(async () => {+ directory = await mkdtemp(join(tmpdir(), 'orca-branch-identity-'))+ await git('init', '-q')+ await git('symbolic-ref', 'HEAD', 'refs/heads/main')+ await git('config', 'user.name', 'Audit')+ await git('config', 'user.email', '[email protected]')+ await git('config', 'commit.gpgsign', 'false')+ await git('config', 'core.hooksPath', '')+})++afterEach(async () => {+ await rm(directory, { recursive: true, force: true })+})++describe('local branch picker identities', () => {+ it('keeps HEAD attached when selecting a branch that shares a name with a tag', async () => {+ await git('commit', '--allow-empty', '-qm', 'base')+ await git('branch', 'release')+ await git('commit', '--allow-empty', '-qm', 'tag target')+ await git('tag', 'release')+ const listing = await listLocalBranches(directory)+ expect(listing.branches).toEqual(['main', 'release'])++ await checkoutBranch(directory, listing.branches[1])++ expect(await git('symbolic-ref', '--quiet', 'HEAD')).toBe('refs/heads/release')+ })+})++installRealWorkerThreadChildProcesses()diff --git a/src/main/git/checkout.ts b/src/main/git/checkout.tsindex c71dc9aa5da..557a99531ef 100644--- a/src/main/git/checkout.ts+++ b/src/main/git/checkout.ts@@ -28,7 +28,7 @@ export async function listLocalBranches(options: GitRuntimeOptions = {}): Promise<{ current: string | null; branches: string[] }> {const { stdout } = await gitExecFileAsync(- ['for-each-ref', '--format=%(HEAD)%09%(refname:short)', 'refs/heads/'],+ ['for-each-ref', '--format=%(HEAD)%09%(refname:lstrip=2)', 'refs/heads/'],gitOptionsForWorktree(worktreePath, options))let current: string | null = null