Thread (1 message) 1 message, 1 author, 2021-01-10

Re: [PATCH v2] fixup! mergetool: add automerge configuration

From: Junio C Hamano <hidden>
Date: 2021-01-10 01:53:27
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Junio C Hamano [off-list ref] writes:
I was hoping that we can avoid repetition that can cause bugs with
something like
...
Here is a cleaned-up version that would apply cleanly on top of
yours.

I suspect that it would make it even easier to follow the logic if
the two sed "-e" expressions are swapped for the $LOCAL one.  

It would clarify that we remove $C0 (separator before ours) and
$C1..$C3 (ancestor's and theirs, including the separators) to get
the local version.

The other two are already described in the correct order.

Thanks.

 git-mergetool.sh | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 9029a79431..ed152a4187 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -243,16 +243,14 @@ auto_merge () {
 	git merge-file --diff3 --marker-size=7 -q -p "$LOCAL" "$BASE" "$REMOTE" >"$DIFF3"
 	if test -s "$DIFF3"
 	then
-		cr=$(printf '\r')
-		sed -e '/^<<<<<<< /,/^||||||| /d' \
-			-e "/^=======$cr\{0,1\}$/,/^>>>>>>> /d" \
-			"$DIFF3" >"$BASE"
-		sed -e '/^||||||| /,/^>>>>>>> /d' \
-			-e '/^<<<<<<< /d' \
-			"$DIFF3" >"$LOCAL"
-		sed -e "/^<<<<<<< /,/^=======$cr\{0,1\}$/d" \
-			-e '/^>>>>>>> /d' \
-			"$DIFF3" >"$REMOTE"
+		C0="^<<<<<<< "
+		C1="^||||||| "
+		C2="^=======$(printf '\015')\{0,1\}$"
+		C3="^>>>>>>> "
+
+		sed -e "/$C0/,/$C1/d" -e "/$C2/,/$C3/d" "$DIFF3" >"$BASE"
+		sed -e "/$C1/,/$C3/d" -e "/$C0/d" "$DIFF3" >"$LOCAL"
+		sed -e "/$C0/,/$C2/d" -e "/$C3/d" "$DIFF3" >"$REMOTE"
 	fi
 	rm -- "$DIFF3"
 }
-- 
2.30.0-307-g37795e20d9
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help