Skip to content

fix(git): recognize local SHA-256 workspace bases - #35010

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/git-sha256-local-base
Oct 30, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/git-sha256-local-base

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​11 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​11
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 0

Problem

In SHA-256 repositories, full commit IDs are 64 hex characters, but isFullGitObjectId (src/main/git/commit-object-ref.ts) only accepted 40. A saved commit used as a workspace base was therefore treated as missing locally, which triggered an unnecessary origin fetch during prefetch and could make resolveWorktreeCreateBase fall back to the default branch, creating the workspace from the wrong commit.

Fix

Accept exactly 40 or 64 hex characters. The existing rev-parse --verify --quiet <id>^{commit} check is unchanged, so an accepted ID must still resolve to a local commit (no new false positives). No wire-shape, RPC, or folder-workspace changes.

Validation

  • New unit test commit-object-ref.test.ts: accepts 40/64-hex IDs, rejects 63/65; fails on the old regex.
  • pnpm test for commit-object-ref, worktree-base-ref-probe, and worktree-create-base-prefetch: 22/22 pass.
  • pnpm check:changed --maxWorkers=2 passes.

isFullGitObjectId only matched 40-hex IDs, so a saved 64-hex commit base in a SHA-256 repo was treated as missing, triggering an unneeded origin fetch and a fallback to the default branch.
@OrcaWin
OrcaWin force-pushed the OrcaWin/git-sha256-local-base branch from 8e33fcc to 0b6306b Compare October 30, 2026 13:31
@OrcaWin
OrcaWin marked this pull request as ready for review October 30, 2026 13:32
@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a7f5e379-4cf8-4ebb-8be4-6e00ec479a14
Commits

Reviewing files that changed from the base of the PR and between 5a92596 and 0b6306b.

Files selected for processing: 2
  • src/main/git/commit-object-ref.test.ts
  • src/main/git/commit-object-ref.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Walkthrough

The isFullGitObjectId pattern now accepts 40- or 64-character hexadecimal IDs, case-insensitively. Tests cover accepted IDs of both lengths and rejected inputs of 63 and 65 characters.

Priority: Normal

Merge Risk: Minimal · up to 0b630

The change safely recognizes valid SHA-256 commit IDs while preserving local commit resolution.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description explains the problem, fix, mechanism, scope, and validation results. However, it omits the required Linked Issue section and does not provide the required Visual Proof response, Testin… Add the required template sections. Include an actual linked issue after “Fixes #”, state N/A with a reason for Visual Proof if there is no visual change, document testing platforms and manual-test status, and complete the remaining check…
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: recognizing local SHA-256 workspace bases in Git.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.

Full details: Description check

Explanation

The description explains the problem, fix, mechanism, scope, and validation results. However, it omits the required Linked Issue section and does not provide the required Visual Proof response, Testing checklist details, or repository checklist information.

Resolution

Add the required template sections. Include an actual linked issue after “Fixes #”, state N/A with a reason for Visual Proof if there is no visual change, document testing platforms and manual-test status, and complete the remaining checklist sections or mark them not applicable with reasons.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OrcaWin
OrcaWin merged commit 5655698 into main Oct 30, 2026
71 checks passed
@OrcaWin
OrcaWin deleted the OrcaWin/git-sha256-local-base branch October 30, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant