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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> 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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux