aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-08-31 19:32:40 -0700
committerJunio C Hamano <gitster@pobox.com>2008-08-31 20:09:21 -0700
commiteac5a401512181cd315a1031af2b8a25430e335a (patch)
tree246e7b22c653c94af9a0cd615281b92e39fda902 /t
parent0cf8581e330e7140c9f5c94a53d441187c0f8ff9 (diff)
downloadgit-eac5a401512181cd315a1031af2b8a25430e335a.tar.gz
git-eac5a401512181cd315a1031af2b8a25430e335a.tar.xz
checkout --conflict=<style>: recreate merge in a non-default style
This new option does essentially the same thing as -m option when checking unmerged paths out of the index, but it uses the specified style instead of configured merge.conflictstyle. Setting "merge.conflictstyle" to "diff3" is usually less useful than using the default "merge" style, because the latter allows a conflict that results by both sides changing the same region in a very similar way to get simplified substancially by reducing the common lines. However, when one side removed a group of lines (perhaps a function was moved to some other file) while the other side modified it, the default "merge" style does not give any clue as to why the hunk is left conflicting. You would need the original to understand what is going on. The recommended use would be not to set merge.conflictstyle variable so that you would usually use the default "merge" style conflict, and when the result in a path in a particular merge is too hard to understand, use "git checkout --conflict=diff3 $path" to check it out with the original to review what is going on. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t7201-co.sh100
1 files changed, 54 insertions, 46 deletions
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 1d4ff6e8d..ac49311cf 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -337,7 +337,7 @@ test_expect_success \
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) &&
@@ -348,7 +348,11 @@ test_expect_success 'checkout an unmerged path should fail' '
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 &&
@@ -360,17 +364,7 @@ test_expect_success 'checkout an unmerged path should fail' '
'
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 &&
@@ -383,17 +377,7 @@ test_expect_success 'checkout with an unmerged path can be ignored' '
'
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 &&
@@ -408,17 +392,7 @@ test_expect_success 'checkout unmerged stage' '
'
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 &&
@@ -439,17 +413,7 @@ test_expect_success 'checkout with --merge' '
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 &&
@@ -470,4 +434,48 @@ test_expect_success 'checkout with --merge, in diff3 -m style' '
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