Repository navigation
Report a fetch's null object id as null, as Push() does [patch] - #274
Merged
Merged
Conversation
git fetch --porcelain writes the all-zero id for the side of an update that does not exist: the old side of a created ref and the new side of a pruned one. GitFetchParser converted both fields unconditionally, so Fetch() returned a GitCommitSha of zeroes where Push(), Worktrees() and Submodules() return null. Map any null id (SHA-1 or SHA-256) to null. Fixes #273 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QixWHg8N55ALkBwbNXMhUp
|
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.



Fixes #273
What was wrong
git fetch --porcelainwrites git's null object id for whichever side of an update does not exist: the old side of a created ref and the new side of a pruned one.GitFetchParser.ReadUpdateconverted both fields toGitCommitShawithout checking for it. A created ref therefore came back withOldSha = 0000…0000, and a pruned ref withNewSha = 0000…0000.Push(),Worktrees()andSubmodules()all returnnullin that case.Change
GitFetchParser.ReadObjectIdreturnsnullwhenGitParseValues.IsNullObjectIdis true. Otherwise it converts the id the same way as before, so a malformed id still throwsGitParseException.OldShaandNewShaboth go through it. The check counts zeroes rather than comparing against a fixed string, so SHA-1 (40 zeroes) and SHA-256 (64 zeroes) repositories are both covered.Tests (
GitFetchParserTests)ReportsANullOldIdAsNullForACreatedRef: a*record with a null old id, SHA-1 and SHA-256.OldShais null andNewShais kept.ReportsANullNewIdAsNullForAPrunedRef: a-record with a null new id, SHA-1 and SHA-256.NewShais null andOldShais kept.Generated by Claude Code