fix(bench-compare): validate remote git references#19569
Merged
Conversation
Previously, `validate_refs()` only checked local branches, tags, and
commits by explicitly specifying ref paths (refs/heads/, refs/tags/).
This caused validation to fail for remote-only branches even after
`git fetch --all` successfully fetched them.
Simplified the validation to use `git rev-parse --verify {ref}` which
leverages git's built-in reference resolution, matching the behavior
of `git checkout`. This allows the tool to recognize:
- Local branches
- Remote branches (e.g., origin/feature-branch)
- Tags
- Commit hashes
Fixes the error: "Git reference 'X' does not exist as branch, tag, or commit"
when using remote branches that haven't been checked out locally.
…h origin/ fallback
Use git rev-parse --verify {ref}^{commit} and fall back to origin/{ref}^{commit} so remote-only branches (e.g. origin/yk/compute_trie2) validate like git checkout DWIM. Keep clear errors showing attempted forms.
…-only branch Spin up a temporary bare repo and a clone, create a remote-only branch, and verify validate_refs accepts it. Also add a negative test. Use tempfile as a dev-dependency.
Keep the validate_refs DWIM fix; drop the temporary integration tests and the tempfile dev-dep per request.
shekhirin
approved these changes
Nov 7, 2025
yongkangc
added a commit
that referenced
this pull request
Nov 7, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This should now work without requiring the branch to be checked out locally first.
Problem
The tool was failing with this error when trying to use remote branches:
Even though
git fetch --allsuccessfully fetched the remote branch, the validation step only checked:refs/heads/...)refs/tags/...)This meant remote-only branches (like
origin/feature-branch) would fail validation.Solution
Simplified
validate_refs()to usegit rev-parse --verify {ref}which leverages git's built-in reference resolution - the same logic used bygit checkout. This now recognizes:origin/featureor justfeature)