Notice index that has path and path/file and refuse to write such a tree.
Kay Sievers noticed that you can have both path and path/file in
the cache and write-tree happily creates a tree object from such
a state. Since a merge can result in such situation and the
user should be able to see the situation by looking at the
cache, rather than forbidding add_cache_entry() to create such
conflicts, fix it by making write-tree refuse to write such an
nonsensical tree. Here is a test case.
-- test case --
$ ls -a
./ ../
$ git-init-db
defaulting to local storage area
$ date >path
$ git-update-cache --add path
$ rm path
$ mkdir path
$ date >path/file
$ git-update-cache --add path/file
$ git-ls-files --stage
100644
1738f2536b1201218c41153941da065cc26174c9 0 path
100644
620c72f1c1de15f56ff9d63d6d7cdc69e828f1e3 0 path/file
$ git-ls-tree $(git-write-tree) ;# using old one
100644 blob
1738f2536b1201218c41153941da065cc26174c9 path
040000 tree
ec116937f223e3df95aeac9f076902ae1618ae98 path
$ ../git-write-tree ;# using new one
You have both path and path/file
fatal: write-tree: not able to write tree
$ exit
Signed-off-by: Junio C Hamano <junkio@cox.net>