Subject: Re: [PATCH v5 05/18] mktree tests: test that "mode" is passed when sorting

From: Junio C Hamano <[email-masked]>
Date: Wed, 31 Mar 2021 16:04:25 -0700

Ævar Arnfjörð Bjarmason  <[email-masked]> writes:

> Add a test for the mode being passed to ent_compare(). That code dates
> back to 83f50539a9 (git-mktree: reverse of git-ls-tree., 2006-02-20)
> and there's never been a test for that particular edge case. Now we
> have one.
>
> I don't see how anything could run into this in practice. In order for
> that mode sorting to matter as a tiebreaker we need to have a
> duplicate entry in the tree, i.e. two "foo" entries, one a blob and
> one a tree. This asserts that if that happens we'll sort on the modes
> we encounter in such an invalid entry, i.e. we expect the tree entry
> before the blob.

It is more like "in a tree with 'foo.' and 'foo0' (both of which are
blobs), a 'foo' that is a tree should appear after 'foo.' and before
'foo0', because it sorts as if it were 'foo/'.  If 'foo' is a blob,
it sorts the first before 'foo.' and 'foo0'".  

Checking a broken tree with both 'foo' (blob) and 'foo' (tree) that
does not even pass fsck is not very valuable, but the sort order of
these two trees (i.e. one with foo as tree, the other with foo as
blob) do need to be tested, as the unpack_trees merge machinery will
need to walk such pair of trees correctly.

Thanks.