]> git.ipfire.org Git - thirdparty/git.git/commit
fsck: report non-consecutive duplicate names in trees
authorRené Scharfe <l.s.r@web.de>
Sun, 10 May 2020 16:12:16 +0000 (18:12 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 11 May 2020 15:40:28 +0000 (08:40 -0700)
commit9068cfb20f5699fd639a559af14affaefe43a812
tree5c58d3b928060326346888b9e0fb05a019d18059
parent7397ca33730626f682845f8691b39c305535611e
fsck: report non-consecutive duplicate names in trees

Tree entries are sorted in path order, meaning that directory names get
a slash ('/') appended implicitly.  Git fsck checks if trees contains
consecutive duplicates, but due to that ordering there can be
non-consecutive duplicates as well if one of them is a directory and the
other one isn't.  Such a tree cannot be fully checked out.

Find these duplicates by recording candidate file names on a stack and
check candidate directory names against that stack to find matches.

Suggested-by: Brandon Williams <bwilliamseng@gmail.com>
Original-test-by: Brandon Williams <bwilliamseng@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Reviewed-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
fsck.c
t/t1450-fsck.sh