Skip to content

Report a fetch's null object id as null, as Push() does [patch] - #274

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/273-fetch-null-object-id
Oct 20, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/273-fetch-null-object-id

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #273

What was wrong

git fetch --porcelain writes 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.ReadUpdate converted both fields to GitCommitSha without checking for it. A created ref therefore came back with OldSha = 0000…0000, and a pruned ref with NewSha = 0000…0000. Push(), Worktrees() and Submodules() all return null in that case.

Change

  • New private GitFetchParser.ReadObjectId returns null when GitParseValues.IsNullObjectId is true. Otherwise it converts the id the same way as before, so a malformed id still throws GitParseException.
  • OldSha and NewSha both 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. OldSha is null and NewSha is kept.
  • ReportsANullNewIdAsNullForAPrunedRef: a - record with a null new id, SHA-1 and SHA-256. NewSha is null and OldSha is kept.
  • With the parser change reverted, all 4 new cases fail ("Expected value to be null"). With the change, the full suite passes, 921/921 locally on net10.0.

Generated by Claude Code

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
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit afc786a into main Oct 20, 2026
17 checks passed
@matt-edmondson
matt-edmondson deleted the fix/273-fetch-null-object-id branch October 20, 2026 01:08
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.

Fetch() reports the all-zero object id as OldSha for a created ref and NewSha for a pruned one, where Push() reports null

2 participants