[2.51.0 Bug] Missing singleton objects in 'git repack -adf --path-walk' #796
+88
−30
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.
This is a port of gitgitgadget#1956, and I deem it one of the blockers against making a full release of Microsoft Git v2.51. Here is what Stolee wrote in the cover letter:
Now that the
--path-walk
feature forgit repack
is out in the wild and getting more visibility than it did in the Git for Windows fork, the following issue was brought to my attention:Some folks would report missing objects after
git repack -adf --path-walk
!It turns out that this snuck through the cracks because it was pretty difficult to create a reproducing test case (patch 1) but it boils down to:
It is also something where users don't necessarily notice the missing objects until they fetch and a missing object is used as a delta base. Doing normal checkouts doesn't cause changes to these files, so they are never opened by Git. Users hitting this issue can usually recover using
git fetch --refetch
to repopulate the missing objects from a remote (unless they never had a remote at all).Patch 1 introduces the fix for this issue, which is related to forgetting to initialize a struct indicator when walking the pending objects.
When reflecting on the ways that I missed this when building the feature, I think the core issue was an overreliance on using bare repos in testing. I also think that the way that the UNINTERESTING object exploration was implemented was particularly fragile to missing updates to the initialization of the struct, so patch 2 adds a new initializer to reduce duplicate code and to help avoid this mistake in the future.