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 <redacted>
Original-test-by: Brandon Williams <redacted>
Signed-off-by: René Scharfe <redacted>
Reviewed-by: Luke Diamand <redacted>
Signed-off-by: Junio C Hamano <redacted>