1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
#! /bin/sh
set -ex
BASE="$(dirname "$(cd $(dirname "$0") && pwd)")"
. "$BASE/t/test-lib.sh"
GIT_IMERGE="git-imerge"
EXPECTED_TREE=ffa191c987a8d3f597376744a95439fa1b4a55c5
test_conflict () {
local conflict=$1
TMP="$BASE/t/tmp/conflicted-$conflict"
DESCRIPTION="git-imerge test repository with conflict at $conflict"
# Set up a test repo with two branches, `c` and `d`, that each have a
# commit making incompatible changes to the same file `conflict.txt`:
init_test_repo "$TMP" "$DESCRIPTION"
cd "$TMP"
modify c.txt 0
modify d.txt 0
modify conflict.txt "original version"
commit -m 'm⇒0'
git checkout -b c master --
for i in $(seq 9)
do
modify c.txt $i
# Is this the commit that should conflict?
case $conflict in
$i-*) modify conflict.txt "c version" ;;
esac
commit -m "c⇒$i"
done
git checkout -b d master --
for i in $(seq 6)
do
modify d.txt $i
# Is this the commit that should conflict?
case $conflict in
*-$i) modify conflict.txt "d version" ;;
esac
commit -m "d⇒$i"
done
git checkout c
"$GIT_IMERGE" init --name=c-d d
"$GIT_IMERGE" list
"$GIT_IMERGE" diagram --commits --frontier --html=imerge0.html
"$GIT_IMERGE" autofill 2>&1 | tee autofill.out
if grep -q Traceback autofill.out
then
exit 1
fi
if ! grep -q "suggest manual merge of $conflict" autofill.out
then
echo "conflict not detected"
exit 1
fi
"$GIT_IMERGE" diagram --commits --frontier --html=imerge1.html
"$GIT_IMERGE" continue --edit
echo 'merged version' >conflict.txt
git add conflict.txt
"$GIT_IMERGE" continue --no-edit
"$GIT_IMERGE" diagram --commits --frontier --html=imerge2.html
GIT_EDITOR=cat "$GIT_IMERGE" simplify --goal=merge --branch=c-d-merge
check_tree c-d-merge $EXPECTED_TREE
"$GIT_IMERGE" simplify --goal=rebase --branch=c-d-rebase
check_tree c-d-rebase $EXPECTED_TREE
"$GIT_IMERGE" simplify --goal=rebase-with-history --branch=c-d-rebase-with-history
check_tree c-d-rebase-with-history $EXPECTED_TREE
"$GIT_IMERGE" simplify --goal=border --branch=c-d-border
check_tree c-d-border $EXPECTED_TREE
"$GIT_IMERGE" simplify --goal=border-with-history --branch=c-d-border-with-history
check_tree c-d-border-with-history $EXPECTED_TREE
"$GIT_IMERGE" simplify --goal=border-with-history2 --branch=c-d-border-with-history2
check_tree c-d-border-with-history2 $EXPECTED_TREE
"$GIT_IMERGE" remove
git checkout c
"$GIT_IMERGE" start --goal=full --first-parent --name=c-d d 2>&1 | tee start.out
if grep -q Traceback start.out
then
exit 1
fi
if ! grep -q "suggest manual merge of $conflict" autofill.out
then
echo "conflict not detected"
exit 1
fi
"$GIT_IMERGE" diagram --commits --frontier --html=imerge3.html
echo 'merged version' >conflict.txt
git add conflict.txt
GIT_EDITOR=cat git commit
"$GIT_IMERGE" continue --edit
"$GIT_IMERGE" diagram --commits --frontier --html=imerge4.html
"$GIT_IMERGE" finish --branch=c-d-full
check_tree c-d-full $EXPECTED_TREE
}
# Run tests with conflicts at various locations...
# A generic location:
test_conflict 4-3
# The four corners:
test_conflict 1-1
test_conflict 9-1
test_conflict 1-6
test_conflict 9-6
# Along each of the edges:
test_conflict 1-2
test_conflict 9-5
test_conflict 5-1
test_conflict 6-6
|