# Copyright (C) 2009 Free Software Foundation, Inc. # # Copying and distribution of this file, with or without modification, # in any medium, are permitted without royalty provided the copyright # notice and this notice are preserved. # Test the --merge option . $srcdir/test-lib.sh require_cat require_diff use_local_patch use_tmpdir # ============================================================== if ! patch --merge /dev/null ; then echo "Merge support DISABLED; skipping this test" exit fi # ============================================================== x2() { body=`seq 1 $1` shift echo "$body" > a sed= while test $# -gt 0 -a "$1" != -- ; do sed="$sed -e $1" shift done echo "$body" | sed$sed -e b > b shift sed= while test $# -gt 0 ; do sed="$sed -e $1" shift done echo "$body" | sed$sed -e b > c output=`diff -u a b | patch $ARGS -f c` status=$? echo "$output" | sed -e '/^\(\|patching file c\)$/d' cat c test $status == 0 || echo "Status: $status" } x() { ARGS="$ARGS --merge" x2 "$@" echo ARGS="$ARGS --merge=diff3" x2 "$@" } unset ARGS # ============================================================== check 'x 3' <>>>>>> 3 Status: 1 Hunk #1 NOT MERGED at 2-8. 1 <<<<<<< 2c ||||||| 2 ======= 2b >>>>>>> 3 Status: 1 EOF check 'x 3 2d -- 2d' <>>>>>> 4 Status: 1 Hunk #1 NOT MERGED at 2-9. 1 <<<<<<< 2 ||||||| 2 3 ======= 3 >>>>>>> 4 Status: 1 EOF check 'x 4 3d -- 2d' <>>>>>> 4 Status: 1 Hunk #1 NOT MERGED at 2-9. 1 <<<<<<< 3 ||||||| 2 3 ======= 2 >>>>>>> 4 Status: 1 EOF # ============================================================== check 'x 3 3ib -- 2d' <>>>>>> 3 Status: 1 Hunk #1 NOT MERGED at 2-8. 1 <<<<<<< ||||||| 2 ======= 2 b >>>>>>> 3 Status: 1 EOF check 'x 3 2d -- 3ib' <>>>>>> 3 Status: 1 Hunk #1 NOT MERGED at 2-8. 1 <<<<<<< 2 b ||||||| 2 ======= >>>>>>> 3 Status: 1 EOF # ============================================================== # (Note that the output here differs from the diff3 output: # patch does not have enough information to know that the "c" # on the last line is part of the conflict. check 'x 1 1cb -- 1cc' <>>>>>> c Status: 1 Hunk #1 NOT MERGED at 1-6. <<<<<<< ||||||| 1 ======= b >>>>>>> c Status: 1 EOF check 'x 4 2ca 3cb -- 2ca 3cc' <>>>>>> 4 Status: 1 Hunk #1 NOT MERGED at 2-11. 1 <<<<<<< a c ||||||| 2 3 ======= a b >>>>>>> 4 Status: 1 EOF check 'x 6 3c3b 4c4b -- 3c3c 4c4c' <>>>>>> 5 6 Status: 1 Hunk #1 NOT MERGED at 3-12. 1 2 <<<<<<< 3c 4c ||||||| 3 4 ======= 3b 4b >>>>>>> 5 6 Status: 1 EOF check 'x 4 2cb 3ca -- 2cc 3ca' <>>>>>> a 4 Status: 1 Hunk #1 NOT MERGED at 2-11. 1 <<<<<<< c a ||||||| 2 3 ======= b a >>>>>>> 4 Status: 1 EOF check 'x 3 2ib 3ib -- 2ic' <>>>>>> 2 b 3 Status: 1 Hunk #1 NOT MERGED at 2-7, merged at 9. 1 <<<<<<< c ||||||| ======= b >>>>>>> 2 b 3 Status: 1 EOF check 'x 3 2ib 3ib 3ib -- 2ic' <>>>>>> 2 b b 3 Status: 1 Hunk #1 NOT MERGED at 2-7, merged at 9-10. 1 <<<<<<< c ||||||| ======= b >>>>>>> 2 b b 3 Status: 1 EOF check 'x 9 4ca 5cb 6ca -- 4ca 5cc 6ca' <>>>>>> a 7 8 9 Status: 1 Hunk #1 NOT MERGED at 4-16. 1 2 3 <<<<<<< a c a ||||||| 4 5 6 ======= a b a >>>>>>> 7 8 9 Status: 1 EOF check 'x 3 2ib 3ib -- 1i0' <>>>>>> 5 Status: 1 Hunk #1 NOT MERGED at 2-11. 1 <<<<<<< 2 3c 4 ||||||| 2 3 4 ======= >>>>>>> 5 Status: 1 EOF check 'x 5 3c3c -- 2,4d' <>>>>>> 5 Status: 1 Hunk #1 NOT MERGED at 2-11. 1 <<<<<<< ||||||| 2 3 4 ======= 2 3c 4 >>>>>>> 5 Status: 1 EOF # ============================================================== check 'x 3 1,2d -- 2ic' <>>>>>> 3 Status: 1 Hunk #1 NOT MERGED at 1-9. <<<<<<< 1 c 2 ||||||| 1 2 ======= >>>>>>> 3 Status: 1 EOF check 'x 3 2ic -- 1,2d' <>>>>>> 3 Status: 1 Hunk #1 NOT MERGED at 1-9. <<<<<<< ||||||| 1 2 ======= 1 c 2 >>>>>>> 3 Status: 1 EOF