From b155725daeec48436d1fcbec4854ffd317408a6e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 25 Jun 2005 02:25:29 -0700 Subject: [PATCH] Fix oversimplified optimization for add_cache_entry(). An earlier change to optimize directory-file conflict check broke what "read-tree --emu23" expects. This is fixed by this commit. (1) Introduces an explicit flag to tell add_cache_entry() not to check for conflicts and use it when reading an existing tree into an empty stage --- by definition this case can never introduce such conflicts. (2) Makes read-cache.c:has_file_name() and read-cache.c:has_dir_name() aware of the cache stages, and flag conflict only with paths in the same stage. Signed-off-by: Junio C Hamano Signed-off-by: Linus Torvalds --- t/t1005-read-tree-m-2way-emu23.sh | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 't') diff --git a/t/t1005-read-tree-m-2way-emu23.sh b/t/t1005-read-tree-m-2way-emu23.sh index a026977cd6..d80752ddd5 100644 --- a/t/t1005-read-tree-m-2way-emu23.sh +++ b/t/t1005-read-tree-m-2way-emu23.sh @@ -366,6 +366,7 @@ test_expect_success \ treeDF=`git-write-tree` && echo treeDF $treeDF && git-ls-tree $treeDF && + git-ls-files --stage >DF.out rm -f DF && mkdir DF && @@ -377,7 +378,7 @@ test_expect_success \ git-ls-files --stage >DFDF.out' test_expect_success \ - 'DF vs DF/DF case test.' \ + 'DF vs DF/DF case test (#1)' \ 'rm -f .git/index && rm -fr DF && echo DF >DF && @@ -388,10 +389,24 @@ test_expect_success \ check_cache_at DF/DF clean && # different from pure 2-way :' +# The other way around +test_expect_success \ + 'DF vs DF/DF case test (#2)' \ + 'rm -f .git/index && + rm -fr DF && + mkdir DF && + echo DF/DF >DF/DF && + git-update-cache --add DF/DF && + read_tree_twoway $treeDFDF $treeDF && + git-ls-files --stage >DFDFcheck.out && + diff -u DF.out DFDFcheck.out && + check_cache_at DF clean && # different from pure 2-way + :' + # Emu23 can grok I having more than H. Make sure we did not -# botch the conflict tests (Linus code botches this test). +# botch the conflict tests (fixed). test_expect_success \ - 'DF vs DF/DF case test (#2).' \ + 'DF vs DF/DF case test (#3).' \ 'rm -f .git/index && rm -fr DF && mkdir DF && @@ -400,8 +415,8 @@ test_expect_success \ # This should fail because I and H have a conflict # at DF. if git-read-tree --emu23 $treeDF $treeDFDF - then true ;# should be false - else false ;# should be true + then false + else true fi' test_done -- cgit v1.2.3