Skip to content

Commit 679be99

Browse files
committed
path-walk API: avoid adding a root tree more than once (#5195)
When adding tree objects, we are very careful to avoid adding the same tree object more than once. There was one small gap in that logic, though: when adding a root tree object. Two refs can easily share the same root tree object, and we should still not add it more than once.
2 parents db700bd + 60f4ef1 commit 679be99

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

t/t6601-path-walk.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,26 @@ test_expect_success 'trees are reported exactly once' '
397397
test_line_count = 1 out-filtered
398398
'
399399

400+
test_expect_success 'trees are reported exactly once' '
401+
test_when_finished "rm -rf unique-trees" &&
402+
test_create_repo unique-trees &&
403+
(
404+
cd unique-trees &&
405+
mkdir initial &&
406+
test_commit initial/file &&
407+
408+
git switch -c move-to-top &&
409+
git mv initial/file.t ./ &&
410+
test_tick &&
411+
git commit -m moved &&
412+
413+
git update-ref refs/heads/other HEAD
414+
) &&
415+
416+
test-tool -C unique-trees path-walk -- --all >out &&
417+
tree=$(git -C unique-trees rev-parse HEAD:) &&
418+
grep "$tree" out >out-filtered &&
419+
test_line_count = 1 out-filtered
420+
'
421+
400422
test_done

0 commit comments

Comments
 (0)