Skip to content

fix(reference): read linked worktree commit provenance - #677

Merged
morluto merged 1 commit into
morluto:mainfrom
rudycelekli:fix/rea-linked-worktree-provenance-20261006
Oct 6, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
rudycelekli:fix/rea-linked-worktree-provenance-20261006

Conversation

@rudycelekli

Copy link
Copy Markdown

Problem

Reference-source import reports vcs.kind: unknown for a normal linked Git worktree on a branch, losing its commit provenance. Its HEAD is local to the worktree while the branch ref lives in Git's common directory.

Change

Read gitfile and commondir metadata without executing Git. Resolve the worktree's own HEAD against shared loose/packed refs; preserve detached HEAD and Git's private per-worktree ref namespaces. Do not infer dirty state.

The routing follows Git's repository layout.

Verification

Native Git creates an owned repository and a linked branch with a genuinely different commit:

before: native git rev-parse HEAD returns linked branch commit
        readReferenceSourceVcs(linked) => { kind: "unknown", head: null, dirty: null }
after:  reader => { kind: "git", head: <exact linked branch commit>, dirty: null }
  • Baseline regression fails on the linked branch.
  • npm run test:focused -- tests/boundary/filesystem/referenceSourceVcs.test.ts: passed. Also checks primary checkout, packed refs, detached linked HEAD, relative gitfile with CRLF and cancellation. The repository and worktree are temporary and cleaned through the repository fixture.
  • npm run check: all five tasks passed.
  • No contract/schema, packaging or provider changes. No Hopper/Ghidra verification was run or claimed.

AI-assisted reproduction, implementation and independent source review.

@morluto morluto left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve: linked-worktree HEAD resolution via gitfile pointer + commondir fallback matches gitrepository-layout, preserving detached-HEAD/packed-refs and abort/dirty semantics. Real git init/worktree/pack-refs/detach + CRLF + abort test coverage. Checks green.

@morluto
morluto merged commit d565ecd into morluto:main Oct 6, 2026
18 checks passed
@morluto

morluto commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Thanks, @rudycelekli, for your work on “fix(reference): read linked worktree commit provenance.” I appreciate your contribution to REA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants