test refs/heads/delete-me = "$(git symbolic-ref HEAD)" &&
test_must_fail git checkout --track -b track'
-test_expect_success 'checkout an unmerged path should fail' '
+setup_conflicting_index () {
rm -f .git/index &&
O=$(echo original | git hash-object -w --stdin) &&
A=$(echo ourside | git hash-object -w --stdin) &&
echo "100644 $A 2 file" &&
echo "100644 $B 3 file" &&
echo "100644 $A 0 filf"
- ) | git update-index --index-info &&
+ ) | git update-index --index-info
+}
+
+test_expect_success 'checkout an unmerged path should fail' '
+ setup_conflicting_index &&
echo "none of the above" >sample &&
cat sample >fild &&
cat sample >file &&
'
test_expect_success 'checkout with an unmerged path can be ignored' '
- rm -f .git/index &&
- O=$(echo original | git hash-object -w --stdin) &&
- A=$(echo ourside | git hash-object -w --stdin) &&
- B=$(echo theirside | git hash-object -w --stdin) &&
- (
- echo "100644 $A 0 fild" &&
- echo "100644 $O 1 file" &&
- echo "100644 $A 2 file" &&
- echo "100644 $B 3 file" &&
- echo "100644 $A 0 filf"
- ) | git update-index --index-info &&
+ setup_conflicting_index &&
echo "none of the above" >sample &&
echo ourside >expect &&
cat sample >fild &&
'
test_expect_success 'checkout unmerged stage' '
- rm -f .git/index &&
- O=$(echo original | git hash-object -w --stdin) &&
- A=$(echo ourside | git hash-object -w --stdin) &&
- B=$(echo theirside | git hash-object -w --stdin) &&
- (
- echo "100644 $A 0 fild" &&
- echo "100644 $O 1 file" &&
- echo "100644 $A 2 file" &&
- echo "100644 $B 3 file" &&
- echo "100644 $A 0 filf"
- ) | git update-index --index-info &&
+ setup_conflicting_index &&
echo "none of the above" >sample &&
echo ourside >expect &&
cat sample >fild &&
'
test_expect_success 'checkout with --merge' '
- rm -f .git/index &&
- O=$(echo original | git hash-object -w --stdin) &&
- A=$(echo ourside | git hash-object -w --stdin) &&
- B=$(echo theirside | git hash-object -w --stdin) &&
- (
- echo "100644 $A 0 fild" &&
- echo "100644 $O 1 file" &&
- echo "100644 $A 2 file" &&
- echo "100644 $B 3 file" &&
- echo "100644 $A 0 filf"
- ) | git update-index --index-info &&
+ setup_conflicting_index &&
echo "none of the above" >sample &&
echo ourside >expect &&
cat sample >fild &&
test_expect_success 'checkout with --merge, in diff3 -m style' '
git config merge.conflictstyle diff3 &&
- rm -f .git/index &&
- O=$(echo original | git hash-object -w --stdin) &&
- A=$(echo ourside | git hash-object -w --stdin) &&
- B=$(echo theirside | git hash-object -w --stdin) &&
- (
- echo "100644 $A 0 fild" &&
- echo "100644 $O 1 file" &&
- echo "100644 $A 2 file" &&
- echo "100644 $B 3 file" &&
- echo "100644 $A 0 filf"
- ) | git update-index --index-info &&
+ setup_conflicting_index &&
echo "none of the above" >sample &&
echo ourside >expect &&
cat sample >fild &&
test_cmp merged file
'
+test_expect_success 'checkout --conflict=merge, overriding config' '
+ git config merge.conflictstyle diff3 &&
+ setup_conflicting_index &&
+ echo "none of the above" >sample &&
+ echo ourside >expect &&
+ cat sample >fild &&
+ cat sample >file &&
+ cat sample >filf &&
+ git checkout --conflict=merge -- fild file filf &&
+ (
+ echo "<<<<<<< ours"
+ echo ourside
+ echo "======="
+ echo theirside
+ echo ">>>>>>> theirs"
+ ) >merged &&
+ test_cmp expect fild &&
+ test_cmp expect filf &&
+ test_cmp merged file
+'
+
+test_expect_success 'checkout --conflict=diff3' '
+ git config --unset merge.conflictstyle
+ setup_conflicting_index &&
+ echo "none of the above" >sample &&
+ echo ourside >expect &&
+ cat sample >fild &&
+ cat sample >file &&
+ cat sample >filf &&
+ git checkout --conflict=diff3 -- fild file filf &&
+ (
+ echo "<<<<<<< ours"
+ echo ourside
+ echo "|||||||"
+ echo original
+ echo "======="
+ echo theirside
+ echo ">>>>>>> theirs"
+ ) >merged &&
+ test_cmp expect fild &&
+ test_cmp expect filf &&
+ test_cmp merged file
+'
+
test_done