# Copyright (C) 2009, 2011-2012 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_gnu_diff require_sed 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 while test $# -gt 0 && test "$1" != -- ; do echo "$1" shift done > a.sed echo "$body" | sed -f a.sed > b shift while test $# -gt 0 ; do echo "$1" shift done > b.sed echo "$body" | sed -f b.sed > c rm -f a.sed b.sed output=`diff -u a b | patch $ARGS -f c` status=$? echo "$output" | sed -e '/^$/d' -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 3i\\ b -- 2d' <>>>>>> 3 Status: 1 Hunk #1 NOT MERGED at 2-8. 1 <<<<<<< ||||||| 2 ======= 2 b >>>>>>> 3 Status: 1 EOF check 'x 3 2d -- 3i\\ b' <>>>>>> 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 1c\\ b -- 1c\\ c' <>>>>>> c Status: 1 Hunk #1 NOT MERGED at 1-6. <<<<<<< ||||||| 1 ======= b >>>>>>> c Status: 1 EOF check 'x 4 2c\\ a 3c\\ b -- 2c\\ a 3c\\ c' <>>>>>> 4 Status: 1 Hunk #1 NOT MERGED at 2-11. 1 <<<<<<< a c ||||||| 2 3 ======= a b >>>>>>> 4 Status: 1 EOF check 'x 6 3c\\ 3b 4c\\ 4b -- 3c\\ 3c 4c\\ 4c' <>>>>>> 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 2c\\ b 3c\\ a -- 2c\\ c 3c\\ a' <>>>>>> 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 2i\\ b 3i\\ b -- 2i\\ c' <>>>>>> 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 2i\\ b 3i\\ b 3i\\ b -- 2i\\ c' <>>>>>> 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 4c\\ a 5c\\ b 6c\\ a -- 4c\\ a 5c\\ c 6c\\ a' <>>>>>> 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 2i\\ b 3i\\ b -- 1i\\ 0' <>>>>>> 5 Status: 1 Hunk #1 NOT MERGED at 2-11. 1 <<<<<<< 2 3c 4 ||||||| 2 3 4 ======= >>>>>>> 5 Status: 1 EOF check 'x 5 3c\\ 3c -- 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 -- 2i\\ c' <>>>>>> 3 Status: 1 Hunk #1 NOT MERGED at 1-9. <<<<<<< 1 c 2 ||||||| 1 2 ======= >>>>>>> 3 Status: 1 EOF check 'x 3 2i\\ c -- 1,2d' <>>>>>> 3 Status: 1 Hunk #1 NOT MERGED at 1-9. <<<<<<< ||||||| 1 2 ======= 1 c 2 >>>>>>> 3 Status: 1 EOF