Repository navigation
repo: compare a created branch against where it forked - #8510
Merged
Merged
Conversation
unknwon
added a commit
that referenced
this pull request
Nov 12, 2026
unknwon
added a commit
that referenced
this pull request
Nov 12, 2026
unknwon
added a commit
that referenced
this pull request
Nov 12, 2026
unknwon
added a commit
that referenced
this pull request
Nov 12, 2026
unknwon
force-pushed
the
jc/compare-unknown-base
branch
from
November 12, 2026 03:59
a7a83d2 to
0c80750
Compare
unknwon
changed the base branch from
jc/internal-git-sha256
to
jc/internal-git-functional-options
November 12, 2026 03:59
unknwon
changed the base branch from
jc/internal-git-functional-options
to
jc/internal-git-hook-tracing
November 12, 2026 23:27
unknwon
added a commit
that referenced
this pull request
Nov 12, 2026
unknwon
force-pushed
the
jc/compare-unknown-base
branch
from
November 12, 2026 23:29
0c80750 to
e467f33
Compare
unknwon
added a commit
that referenced
this pull request
Nov 13, 2026
unknwon
force-pushed
the
jc/compare-unknown-base
branch
from
November 13, 2026 02:00
e467f33 to
02cc21a
Compare
A mirror sync that creates a branch recorded a compare URL from the empty ID, so the "Compare N commits" link in the news feed led to a 500 with "fatal: bad object 0000000...". MirrorSyncPush now leaves the compare URL empty for new references, as CommitRepo already does. CatFileCommit returns ErrRevisionNotExist for a full-length object ID that does not exist, and the compare page checks its base commit, so links already recorded with the empty ID and any other unknown base or head render as not found instead of a server error.
The compare page treats an empty base ID, which the news feed links to for a branch created by a mirror sync, as the merge base of the branch and the default branch. When they share no history, it compares against the empty tree and lists every commit of the branch. MirrorSyncPush keeps recording the compare URL for new references, so the link shows what the branch adds instead of a 404.
unknwon
force-pushed
the
jc/compare-unknown-base
branch
from
November 13, 2026 02:27
02cc21a to
7996a21
Compare
The base of a compare against the empty tree is not a commit, so its label linked to a commit page that does not exist. CatFileCommit only reports a revision as not existing when Git says the object is a bad file, so other failures, e.g., an unreadable repository, are still reported as errors.
A branch created by a mirror sync recorded up to 10 of its latest commits in the news feed, including ones from the default branch, so the feed did not match the compare page it links to. It now records the commits since the branch forked from the default branch, or all of its commits when they share no history, with the count of all of them. The compare page logs its new 500 errors where they happen.
A mirror sync that created the default branch, e.g., the first push to an empty mirror, recorded no commits, because the branch is its own merge base with the default branch. Such a branch, or one at the head of the default branch, now records all of its commits, and its compare page shows them against the empty tree.
3 of 4 tasks
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.
Describe the pull request
When a mirror sync creates a branch, its "Compare N commits" link in the news feed points to
compare/0000000...<sha>, and opening it returns a 500 withfatal: bad object 0000000000000000000000000000000000000000. This also happens onmain.CatFileCommitreturnsErrRevisionNotExistwhengit cat-filereports a bad file, i.e., the object does not exist or is not a commit. Other failures, e.g., an unreadable repository, are still errors.git rev-parsepasses a full-length ID through without checking that the object exists, so an unknown 40- or 64-character ID used to surface as a raw Git error. The compare page checks its base commit as well as its head, so an unknown base or head renders as not found.Link to the issue: n/a
Checklist
Test plan
TestObjectFormat_EmptyTreeIDchecks both empty tree IDs againstgit hash-object -t tree.TestRepository_CatFileCommitexpectsErrRevisionNotExistfor the empty ID, an unknown full-length ID and a tree ID, and fails without the fix.In a prod build on SQLite with Git 2.55, a mirror of a repository with
main(3 commits) synced three new branches, recording feed entries that link tocompare/0000000...<head>:feature, 2 commits on top ofmain~1feature commit 1and2,feat.txtonlyorphan, 2 commits with no shared historyo.txtaddedsame, at the head ofmainIn a SHA-256 repository, a 64- and a 40-character empty base both resolve to the merge base with
main, and an orphan branch compares against the SHA-256 empty tree.On SQLite, the compare page of an orphan branch against the empty ID shows the empty tree base as a plain label, and the head as a link. A forked branch still links both.
With an unreadable
objectsdirectory,git cat-fileexits 128 with "not a git repository" instead of "bad file", so it is no longer mistaken for a missing revision.On SQLite, the first push to an empty mirror recorded all 3 commits of
main, and so did a branch created at its head. Their compare pages list the same 3.On SQLite, a mirror synced two new branches.
feature2, 2 commits on top ofmain~1, recorded 2 commits in the feed, and its compare page lists 2.orphan2, 12 commits with no shared history, recorded a count of 12 and kept the latest 5 for display, and its compare page lists 12.Tests under
./internal/...and./cmd/...pass, and lint is clean.Screenshots
New branch from a mirror sync, compared against where it forked from
main:Orphan branch, compared against the empty tree:
AI usage
Claude Code