diff options
Diffstat (limited to 't/t1001-read-tree-m-2way.sh')
-rwxr-xr-x | t/t1001-read-tree-m-2way.sh | 85 |
1 files changed, 67 insertions, 18 deletions
diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh index b01b0037a0..6327d205cb 100755 --- a/t/t1001-read-tree-m-2way.sh +++ b/t/t1001-read-tree-m-2way.sh @@ -5,7 +5,7 @@ test_description='Two way merge with read-tree -m $H $M -This test tries two-way merge (aka fast forward with carry forward). +This test tries two-way merge (aka fast-forward with carry forward). There is the head (called H) and another commit (called M), which is simply ahead of H. The index and the work tree contains a state that @@ -26,14 +26,12 @@ read_tree_twoway () { git read-tree -m "$1" "$2" && git ls-files --stage } -_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' -_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" compare_change () { sed -n >current \ -e '/^--- /d; /^+++ /d; /^@@ /d;' \ -e 's/^\([-+][0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /p' \ "$1" - git diff expected current + test_cmp expected current } check_cache_at () { @@ -51,7 +49,7 @@ check_cache_at () { } cat >bozbar-old <<\EOF -This is a sample file used in two-way fast forward merge +This is a sample file used in two-way fast-forward merge tests. Its second line ends with a magic word bozbar which will be modified by the merged head to gnusto. It has some extra lines so that external tools can @@ -86,7 +84,7 @@ test_expect_success \ 'rm -f .git/index && read_tree_twoway $treeH $treeM && git ls-files --stage >1-3.out && - git diff M.out 1-3.out && + test_cmp M.out 1-3.out && check_cache_at bozbar dirty && check_cache_at frotz dirty && check_cache_at nitfol dirty' @@ -101,7 +99,7 @@ test_expect_success \ git update-index --add yomin && read_tree_twoway $treeH $treeM && git ls-files --stage >4.out || return 1 - git diff M.out 4.out >4diff.out + git diff --no-index M.out 4.out >4diff.out compare_change 4diff.out expected && check_cache_at yomin clean' @@ -115,7 +113,7 @@ test_expect_success \ echo yomin yomin >yomin && read_tree_twoway $treeH $treeM && git ls-files --stage >5.out || return 1 - git diff M.out 5.out >5diff.out + git diff --no-index M.out 5.out >5diff.out compare_change 5diff.out expected && check_cache_at yomin dirty' @@ -127,7 +125,7 @@ test_expect_success \ git update-index --add frotz && read_tree_twoway $treeH $treeM && git ls-files --stage >6.out && - git diff M.out 6.out && + test_cmp M.out 6.out && check_cache_at frotz clean' test_expect_success \ @@ -140,7 +138,7 @@ test_expect_success \ echo frotz frotz >frotz && read_tree_twoway $treeH $treeM && git ls-files --stage >7.out && - git diff M.out 7.out && + test_cmp M.out 7.out && check_cache_at frotz dirty' test_expect_success \ @@ -171,7 +169,7 @@ test_expect_success \ git update-index --add rezrov && read_tree_twoway $treeH $treeM && git ls-files --stage >10.out && - git diff M.out 10.out' + test_cmp M.out 10.out' test_expect_success \ '11 - dirty path removed.' \ @@ -216,7 +214,7 @@ test_expect_success \ git update-index --add nitfol && read_tree_twoway $treeH $treeM && git ls-files --stage >14.out || return 1 - git diff M.out 14.out >14diff.out + git diff --no-index M.out 14.out >14diff.out compare_change 14diff.out expected && check_cache_at nitfol clean' @@ -230,7 +228,7 @@ test_expect_success \ echo nitfol nitfol nitfol >nitfol && read_tree_twoway $treeH $treeM && git ls-files --stage >15.out || return 1 - git diff M.out 15.out >15diff.out + git diff --no-index M.out 15.out >15diff.out compare_change 15diff.out expected && check_cache_at nitfol dirty' @@ -262,7 +260,7 @@ test_expect_success \ git update-index --add bozbar && read_tree_twoway $treeH $treeM && git ls-files --stage >18.out && - git diff M.out 18.out && + test_cmp M.out 18.out && check_cache_at bozbar clean' test_expect_success \ @@ -275,7 +273,7 @@ test_expect_success \ echo gnusto gnusto >bozbar && read_tree_twoway $treeH $treeM && git ls-files --stage >19.out && - git diff M.out 19.out && + test_cmp M.out 19.out && check_cache_at bozbar dirty' test_expect_success \ @@ -287,7 +285,7 @@ test_expect_success \ git update-index --add bozbar && read_tree_twoway $treeH $treeM && git ls-files --stage >20.out && - git diff M.out 20.out && + test_cmp M.out 20.out && check_cache_at bozbar dirty' test_expect_success \ @@ -300,7 +298,7 @@ test_expect_success \ echo gnusto gnusto >bozbar && if read_tree_twoway $treeH $treeM; then false; else :; fi' -# This fails with straight two-way fast forward. +# This fails with straight two-way fast-forward. test_expect_success \ '22 - local change cache updated.' \ 'rm -f .git/index && @@ -337,8 +335,59 @@ test_expect_success \ git update-index --add DF && read_tree_twoway $treeDF $treeDFDF && git ls-files --stage >DFDFcheck.out && - git diff DFDF.out DFDFcheck.out && + test_cmp DFDF.out DFDFcheck.out && check_cache_at DF/DF dirty && :' +test_expect_success \ + 'a/b (untracked) vs a case setup.' \ + 'rm -f .git/index && + : >a && + git update-index --add a && + treeM=`git write-tree` && + echo treeM $treeM && + git ls-tree $treeM && + git ls-files --stage >treeM.out && + + rm -f a && + git update-index --remove a && + mkdir a && + : >a/b && + treeH=`git write-tree` && + echo treeH $treeH && + git ls-tree $treeH' + +test_expect_success \ + 'a/b (untracked) vs a, plus c/d case test.' \ + '! git read-tree -u -m "$treeH" "$treeM" && + git ls-files --stage && + test -f a/b' + +test_expect_success \ + 'a/b vs a, plus c/d case setup.' \ + 'rm -f .git/index && + rm -fr a && + : >a && + mkdir c && + : >c/d && + git update-index --add a c/d && + treeM=`git write-tree` && + echo treeM $treeM && + git ls-tree $treeM && + git ls-files --stage >treeM.out && + + rm -f a && + mkdir a + : >a/b && + git update-index --add --remove a a/b && + treeH=`git write-tree` && + echo treeH $treeH && + git ls-tree $treeH' + +test_expect_success \ + 'a/b vs a, plus c/d case test.' \ + 'git read-tree -u -m "$treeH" "$treeM" && + git ls-files --stage | tee >treeMcheck.out && + test_cmp treeM.out treeMcheck.out' + test_done |