diff options
Diffstat (limited to 't/t6026-merge-attr.sh')
-rwxr-xr-x | t/t6026-merge-attr.sh | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/t/t6026-merge-attr.sh b/t/t6026-merge-attr.sh index 5e439972be..8f9b48a493 100755 --- a/t/t6026-merge-attr.sh +++ b/t/t6026-merge-attr.sh @@ -11,7 +11,7 @@ test_expect_success setup ' for f in text binary union do - echo Initial >$f && git add $f || break + echo Initial >$f && git add $f || return 1 done && test_tick && git commit -m Initial && @@ -19,7 +19,7 @@ test_expect_success setup ' git branch side && for f in text binary union do - echo Master >>$f && git add $f || break + echo Master >>$f && git add $f || return 1 done && test_tick && git commit -m Master && @@ -27,7 +27,7 @@ test_expect_success setup ' git checkout side && for f in text binary union do - echo Side >>$f && git add $f || break + echo Side >>$f && git add $f || return 1 done && test_tick && git commit -m Side && @@ -85,11 +85,12 @@ test_expect_success 'retry the merge with longer context' ' cat >./custom-merge <<\EOF #!/bin/sh -orig="$1" ours="$2" theirs="$3" exit="$4" +orig="$1" ours="$2" theirs="$3" exit="$4" path=$5 ( echo "orig is $orig" echo "ours is $ours" echo "theirs is $theirs" + echo "path is $path" echo "=== orig ===" cat "$orig" echo "=== ours ===" @@ -110,7 +111,7 @@ test_expect_success 'custom merge backend' ' git reset --hard anchor && git config --replace-all \ - merge.custom.driver "./custom-merge %O %A %B 0" && + merge.custom.driver "./custom-merge %O %A %B 0 %P" && git config --replace-all \ merge.custom.name "custom merge driver for testing" && @@ -121,7 +122,7 @@ test_expect_success 'custom merge backend' ' o=$(git unpack-file master^:text) && a=$(git unpack-file side^:text) && b=$(git unpack-file master:text) && - sh -c "./custom-merge $o $a $b 0" && + sh -c "./custom-merge $o $a $b 0 'text'" && sed -e 1,3d $a >check-2 && cmp check-1 check-2 && rm -f $o $a $b @@ -131,7 +132,7 @@ test_expect_success 'custom merge backend' ' git reset --hard anchor && git config --replace-all \ - merge.custom.driver "./custom-merge %O %A %B 1" && + merge.custom.driver "./custom-merge %O %A %B 1 %P" && git config --replace-all \ merge.custom.name "custom merge driver for testing" && @@ -148,9 +149,12 @@ test_expect_success 'custom merge backend' ' o=$(git unpack-file master^:text) && a=$(git unpack-file anchor:text) && b=$(git unpack-file master:text) && - sh -c "./custom-merge $o $a $b 0" && + sh -c "./custom-merge $o $a $b 0 'text'" && sed -e 1,3d $a >check-2 && cmp check-1 check-2 && + sed -e 1,3d -e 4q $a >check-3 && + echo "path is text" >expect && + cmp expect check-3 && rm -f $o $a $b ' @@ -172,8 +176,32 @@ test_expect_success 'up-to-date merge without common ancestor' ' test_tick && ( cd repo1 && - git pull ../repo2 master + git fetch ../repo2 master && + git merge --allow-unrelated-histories FETCH_HEAD ) ' +test_expect_success 'custom merge does not lock index' ' + git reset --hard anchor && + write_script sleep-an-hour.sh <<-\EOF && + sleep 3600 & + echo $! >sleep.pid + EOF + + test_write_lines >.gitattributes \ + "* merge=ours" "text merge=sleep-an-hour" && + test_config merge.ours.driver true && + test_config merge.sleep-an-hour.driver ./sleep-an-hour.sh && + + # We are testing that the custom merge driver does not block + # index.lock on Windows due to an inherited file handle. + # To ensure that the backgrounded process ran sufficiently + # long (and has been started in the first place), we do not + # ignore the result of the kill command. + # By packaging the command in test_when_finished, we get both + # the correctness check and the clean-up. + test_when_finished "kill \$(cat sleep.pid)" && + git merge master +' + test_done |