From db9410990ee41f2b253763621c0023c782ec86e2 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 30 Aug 2008 07:46:55 -0700 Subject: checkout -f: allow ignoring unmerged paths when checking out of the index Earlier we made "git checkout $pathspec" to atomically refuse the operation of $pathspec matched any path with unmerged stages. This patch allows: $ git checkout -f a b c to ignore, instead of error out on, such unmerged paths. The fix to prevent checkout of an unmerged path from random stages is still there. Signed-off-by: Junio C Hamano --- t/t7201-co.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 't') diff --git a/t/t7201-co.sh b/t/t7201-co.sh index 83a366f1e..88692f987 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -359,4 +359,27 @@ test_expect_success 'checkout an unmerged path should fail' ' test_cmp 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 && + echo "none of the above" >sample && + echo ourside >expect && + cat sample >fild && + cat sample >file && + cat sample >filf && + git checkout -f fild file filf && + test_cmp expect fild && + test_cmp expect filf && + test_cmp sample file +' + test_done -- cgit v1.2.1 From 38901a48375952ab6c02f22bddfa19ac2bec2c36 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 30 Aug 2008 07:48:18 -0700 Subject: checkout --ours/--theirs: allow checking out one side of a conflicting merge This lets you to check out 'our' (or 'their') version of an unmerged path out of the index while resolving conflicts. Signed-off-by: Junio C Hamano --- t/t7201-co.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 't') diff --git a/t/t7201-co.sh b/t/t7201-co.sh index 88692f987..c7ae14118 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -382,4 +382,29 @@ test_expect_success 'checkout with an unmerged path can be ignored' ' test_cmp sample file ' +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 && + echo "none of the above" >sample && + echo ourside >expect && + cat sample >fild && + cat sample >file && + cat sample >filf && + git checkout --ours . && + test_cmp expect fild && + test_cmp expect filf && + test_cmp expect file && + git checkout --theirs file && + test ztheirside = "z$(cat file)" +' + test_done -- cgit v1.2.1 From e0af48e49682ea3345f932f6b9e7fa7c5e5e611a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 28 Aug 2008 01:10:04 -0700 Subject: xdiff-merge: optionally show conflicts in "diff3 -m" style When showing conflicting merges, we traditionally followed RCS's merge output format. The output shows: <<<<<<< postimage from one side; ======= postimage of the other side; and >>>>>>> Some poeple find it easier to be able to understand what is going on when they can view the common ancestor's version, which is used by "diff3 -m", which shows: <<<<<<< postimage from one side; ||||||| shared preimage; ======= postimage of the other side; and >>>>>>> This is an initial step to bring that as an optional feature to git. Only "git merge-file" has been converted, with "--diff3" option. Signed-off-by: Junio C Hamano --- t/t6023-merge-file.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 't') diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh index f674c48ca..20786ce79 100755 --- a/t/t6023-merge-file.sh +++ b/t/t6023-merge-file.sh @@ -161,4 +161,41 @@ test_expect_success 'ZEALOUS_ALNUM' ' ' +cat >expect <<\EOF +Dominus regit me, +<<<<<<< new8.txt +et nihil mihi deerit; + + + + +In loco pascuae ibi me collocavit; +super aquam refectionis educavit me. +||||||| +et nihil mihi deerit. +In loco pascuae ibi me collocavit, +super aquam refectionis educavit me; +======= +et nihil mihi deerit, + + + + +In loco pascuae ibi me collocavit -- +super aquam refectionis educavit me, +>>>>>>> new9.txt +animam meam convertit, +deduxit me super semitas jusitiae, +propter nomen suum. +Nam et si ambulavero in medio umbrae mortis, +non timebo mala, quoniam TU mecum es: +virga tua et baculus tuus ipsa me consolata sunt. +EOF + +test_expect_success '"diff3 -m" style output' ' + test_must_fail git merge-file -p --diff3 \ + new8.txt new5.txt new9.txt >actual && + test_cmp expect actual +' + test_done -- cgit v1.2.1 From b541248467fa47979a34e3f1c5bbe3308fbdc4d1 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 29 Aug 2008 10:49:56 -0700 Subject: merge.conflictstyle: choose between "merge" and "diff3 -m" styles This teaches "git merge-file" to honor merge.conflictstyle configuration variable, whose value can be "merge" (default) or "diff3". Signed-off-by: Junio C Hamano --- t/t6023-merge-file.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 't') diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh index 20786ce79..b76bca888 100755 --- a/t/t6023-merge-file.sh +++ b/t/t6023-merge-file.sh @@ -192,10 +192,17 @@ non timebo mala, quoniam TU mecum es: virga tua et baculus tuus ipsa me consolata sunt. EOF -test_expect_success '"diff3 -m" style output' ' +test_expect_success '"diff3 -m" style output (1)' ' test_must_fail git merge-file -p --diff3 \ new8.txt new5.txt new9.txt >actual && test_cmp expect actual ' +test_expect_success '"diff3 -m" style output (2)' ' + git config merge.conflictstyle diff3 && + test_must_fail git merge-file -p \ + new8.txt new5.txt new9.txt >actual && + test_cmp expect actual +' + test_done -- cgit v1.2.1 From 0cf8581e330e7140c9f5c94a53d441187c0f8ff9 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 30 Aug 2008 07:52:24 -0700 Subject: checkout -m: recreate merge when checking out of unmerged index This teaches git-checkout to recreate a merge out of unmerged index entries while resolving conflicts. With this patch, checking out an unmerged path from the index now have the following possibilities: * Without any option, an attempt to checkout an unmerged path will atomically fail (i.e. no other cleanly-merged paths are checked out either); * With "-f", other cleanly-merged paths are checked out, and unmerged paths are ignored; * With "--ours" or "--theirs, the contents from the specified stage is checked out; * With "-m" (we should add "--merge" as synonym), the 3-way merge is recreated from the staged object names and checked out. Signed-off-by: Junio C Hamano --- t/t7201-co.sh | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 't') diff --git a/t/t7201-co.sh b/t/t7201-co.sh index c7ae14118..1d4ff6e8d 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -407,4 +407,67 @@ test_expect_success 'checkout unmerged stage' ' test ztheirside = "z$(cat file)" ' +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 && + echo "none of the above" >sample && + echo ourside >expect && + cat sample >fild && + cat sample >file && + cat sample >filf && + git checkout -m -- 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 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 && + echo "none of the above" >sample && + echo ourside >expect && + cat sample >fild && + cat sample >file && + cat sample >filf && + git checkout -m -- 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 -- cgit v1.2.1 From eac5a401512181cd315a1031af2b8a25430e335a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 31 Aug 2008 19:32:40 -0700 Subject: checkout --conflict=