@ -11,6 +11,18 @@ test_description='test cherry-pick and revert with conflicts
. ./test-lib.sh
. ./test-lib.sh
test_cmp_rev () {
git rev-parse --verify "$1" >expect.rev &&
git rev-parse --verify "$2" >actual.rev &&
test_cmp expect.rev actual.rev
}
pristine_detach () {
git checkout -f "$1^0" &&
git read-tree -u --reset HEAD &&
git clean -d -f -f -q -x
}
test_expect_success setup '
test_expect_success setup '
echo unrelated >unrelated &&
echo unrelated >unrelated &&
@ -23,13 +35,7 @@ test_expect_success setup '
'
'
test_expect_success 'failed cherry-pick does not advance HEAD' '
test_expect_success 'failed cherry-pick does not advance HEAD' '
pristine_detach initial &&
git checkout -f initial^0 &&
git read-tree -u --reset HEAD &&
git clean -d -f -f -q -x &&
git update-index --refresh &&
git diff-index --exit-code HEAD &&
head=$(git rev-parse HEAD) &&
head=$(git rev-parse HEAD) &&
test_must_fail git cherry-pick picked &&
test_must_fail git cherry-pick picked &&
@ -39,12 +45,7 @@ test_expect_success 'failed cherry-pick does not advance HEAD' '
'
'
test_expect_success 'advice from failed cherry-pick' "
test_expect_success 'advice from failed cherry-pick' "
git checkout -f initial^0 &&
pristine_detach initial &&
git read-tree -u --reset HEAD &&
git clean -d -f -f -q -x &&
git update-index --refresh &&
git diff-index --exit-code HEAD &&
picked=\$(git rev-parse --short picked) &&
picked=\$(git rev-parse --short picked) &&
cat <<-EOF >expected &&
cat <<-EOF >expected &&
@ -59,13 +60,7 @@ test_expect_success 'advice from failed cherry-pick' "
"
"
test_expect_success 'failed cherry-pick produces dirty index' '
test_expect_success 'failed cherry-pick produces dirty index' '
pristine_detach initial &&
git checkout -f initial^0 &&
git read-tree -u --reset HEAD &&
git clean -d -f -f -q -x &&
git update-index --refresh &&
git diff-index --exit-code HEAD &&
test_must_fail git cherry-pick picked &&
test_must_fail git cherry-pick picked &&
@ -74,9 +69,7 @@ test_expect_success 'failed cherry-pick produces dirty index' '
'
'
test_expect_success 'failed cherry-pick registers participants in index' '
test_expect_success 'failed cherry-pick registers participants in index' '
pristine_detach initial &&
git read-tree -u --reset HEAD &&
git clean -d -f -f -q -x &&
{
{
git checkout base -- foo &&
git checkout base -- foo &&
git ls-files --stage foo &&
git ls-files --stage foo &&
@ -90,10 +83,7 @@ test_expect_success 'failed cherry-pick registers participants in index' '
2 s/ 0 / 2 /
2 s/ 0 / 2 /
3 s/ 0 / 3 /
3 s/ 0 / 3 /
" < stages > expected &&
" < stages > expected &&
git checkout -f initial^0 &&
git read-tree -u --reset HEAD &&
git update-index --refresh &&
git diff-index --exit-code HEAD &&
test_must_fail git cherry-pick picked &&
test_must_fail git cherry-pick picked &&
git ls-files --stage --unmerged > actual &&
git ls-files --stage --unmerged > actual &&
@ -102,10 +92,7 @@ test_expect_success 'failed cherry-pick registers participants in index' '
'
'
test_expect_success 'failed cherry-pick describes conflict in work tree' '
test_expect_success 'failed cherry-pick describes conflict in work tree' '
pristine_detach initial &&
git checkout -f initial^0 &&
git read-tree -u --reset HEAD &&
git clean -d -f -f -q -x &&
cat <<-EOF > expected &&
cat <<-EOF > expected &&
<<<<<<< HEAD
<<<<<<< HEAD
a
a
@ -114,9 +101,6 @@ test_expect_success 'failed cherry-pick describes conflict in work tree' '
>>>>>>> objid picked
>>>>>>> objid picked
EOF
EOF
git update-index --refresh &&
git diff-index --exit-code HEAD &&
test_must_fail git cherry-pick picked &&
test_must_fail git cherry-pick picked &&
sed "s/[a-f0-9]*\.\.\./objid/" foo > actual &&
sed "s/[a-f0-9]*\.\.\./objid/" foo > actual &&
@ -124,11 +108,8 @@ test_expect_success 'failed cherry-pick describes conflict in work tree' '
'
'
test_expect_success 'diff3 -m style' '
test_expect_success 'diff3 -m style' '
pristine_detach initial &&
git config merge.conflictstyle diff3 &&
git config merge.conflictstyle diff3 &&
git checkout -f initial^0 &&
git read-tree -u --reset HEAD &&
git clean -d -f -f -q -x &&
cat <<-EOF > expected &&
cat <<-EOF > expected &&
<<<<<<< HEAD
<<<<<<< HEAD
a
a
@ -139,9 +120,6 @@ test_expect_success 'diff3 -m style' '
>>>>>>> objid picked
>>>>>>> objid picked
EOF
EOF
git update-index --refresh &&
git diff-index --exit-code HEAD &&
test_must_fail git cherry-pick picked &&
test_must_fail git cherry-pick picked &&
sed "s/[a-f0-9]*\.\.\./objid/" foo > actual &&
sed "s/[a-f0-9]*\.\.\./objid/" foo > actual &&
@ -149,10 +127,8 @@ test_expect_success 'diff3 -m style' '
'
'
test_expect_success 'revert also handles conflicts sanely' '
test_expect_success 'revert also handles conflicts sanely' '
git config --unset merge.conflictstyle &&
git config --unset merge.conflictstyle &&
git read-tree -u --reset HEAD &&
pristine_detach initial &&
git clean -d -f -f -q -x &&
cat <<-EOF > expected &&
cat <<-EOF > expected &&
<<<<<<< HEAD
<<<<<<< HEAD
a
a
@ -173,10 +149,7 @@ test_expect_success 'revert also handles conflicts sanely' '
2 s/ 0 / 2 /
2 s/ 0 / 2 /
3 s/ 0 / 3 /
3 s/ 0 / 3 /
" < stages > expected-stages &&
" < stages > expected-stages &&
git checkout -f initial^0 &&
git read-tree -u --reset HEAD &&
git update-index --refresh &&
git diff-index --exit-code HEAD &&
head=$(git rev-parse HEAD) &&
head=$(git rev-parse HEAD) &&
test_must_fail git revert picked &&
test_must_fail git revert picked &&
@ -192,10 +165,8 @@ test_expect_success 'revert also handles conflicts sanely' '
'
'
test_expect_success 'revert conflict, diff3 -m style' '
test_expect_success 'revert conflict, diff3 -m style' '
pristine_detach initial &&
git config merge.conflictstyle diff3 &&
git config merge.conflictstyle diff3 &&
git checkout -f initial^0 &&
git read-tree -u --reset HEAD &&
git clean -d -f -f -q -x &&
cat <<-EOF > expected &&
cat <<-EOF > expected &&
<<<<<<< HEAD
<<<<<<< HEAD
a
a
@ -206,9 +177,6 @@ test_expect_success 'revert conflict, diff3 -m style' '
>>>>>>> parent of objid picked
>>>>>>> parent of objid picked
EOF
EOF
git update-index --refresh &&
git diff-index --exit-code HEAD &&
test_must_fail git revert picked &&
test_must_fail git revert picked &&
sed "s/[a-f0-9]*\.\.\./objid/" foo > actual &&
sed "s/[a-f0-9]*\.\.\./objid/" foo > actual &&