fast-import: Fix incorrect fanout level when modifying existing notes refs
This fixes the bug uncovered by the tests added in the previous two patches. When an existing notes ref was loaded into the fast-import machinery, the num_notes counter associated with that ref remained == 0, even though the true number of notes in the loaded ref was higher. This caused a fanout level of 0 to be used, although the actual fanout of the tree could be > 0. Manipulating the notes tree at an incorrect fanout level causes removals to silently fail, and modifications of existing notes to instead produce an additional note (leaving the old object in place at a different fanout level). This patch fixes the bug by explicitly counting the number of notes in the notes tree whenever it looks like the num_notes counter could be wrong (when num_notes == 0). There may be false positives (i.e. triggering the counting when the notes tree is truly empty), but in those cases, the counting should not take long. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
9ff5e21f0e
commit
1838685780
@ -536,7 +536,7 @@ EXPECT_END
|
||||
j=$(($j + 1))
|
||||
done
|
||||
|
||||
test_expect_failure 'change a few existing notes' '
|
||||
test_expect_success 'change a few existing notes' '
|
||||
|
||||
git fast-import <input &&
|
||||
GIT_NOTES_REF=refs/notes/many_notes git log -n3 refs/heads/many_commits |
|
||||
@ -545,7 +545,7 @@ test_expect_failure 'change a few existing notes' '
|
||||
|
||||
'
|
||||
|
||||
test_expect_failure 'verify that changing notes respect existing fanout' '
|
||||
test_expect_success 'verify that changing notes respect existing fanout' '
|
||||
|
||||
# None of the entries in the top-level notes tree should be a full SHA1
|
||||
git ls-tree --name-only refs/notes/many_notes |
|
||||
@ -594,7 +594,7 @@ EXPECT_END
|
||||
i=$(($i - 1))
|
||||
done
|
||||
|
||||
test_expect_failure 'remove lots of notes' '
|
||||
test_expect_success 'remove lots of notes' '
|
||||
|
||||
git fast-import <input &&
|
||||
GIT_NOTES_REF=refs/notes/many_notes git log refs/heads/many_commits |
|
||||
@ -603,7 +603,7 @@ test_expect_failure 'remove lots of notes' '
|
||||
|
||||
'
|
||||
|
||||
test_expect_failure 'verify that removing notes trigger fanout consolidation' '
|
||||
test_expect_success 'verify that removing notes trigger fanout consolidation' '
|
||||
|
||||
# All entries in the top-level notes tree should be a full SHA1
|
||||
git ls-tree --name-only -r refs/notes/many_notes |
|
||||
|
Reference in New Issue
Block a user