Notice index that has path and path/file and refuse to write such a tree.
authorJunio C Hamano <junkio@cox.net>
Sat, 7 May 2005 19:22:02 +0000 (12:22 -0700)
committerJunio C Hamano <junkio@cox.net>
Sat, 7 May 2005 19:22:02 +0000 (12:22 -0700)
commit8eef4d3ed13d7604056b26ce58d0db007be530dd
treed80a3eea7b95b9ac11932ee6b6efe877fb5184cf
parent36997b45adeb8915978de5a927130873073683dd
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>
write-tree.c