[PATCH] fixup! mergetool: add automerge configuration

Subsystems: the rest

STALE2040d

4 messages, 3 authors, 2021-01-09 · open the first message on its own page

[PATCH] fixup! mergetool: add automerge configuration

From: David Aguilar <hidden>
Date: 2021-01-09 21:50:12

The use of "\r\?" in sed is not portable to macOS and possibly
other unix flavors.

Replace "\r" with a substituted variable that contains "\r".
Replace "\?" with "\{0,1\}".

Signed-off-by: David Aguilar <redacted>
---
This is based on top of fc/mergetool-automerge and can be squashed in
(with the addition of my sign-off) if desired.

Let me know if you'd prefer a separate patch. I figured we'd want
a squash to preserve bisectability.

 git-mergetool.sh | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/git-mergetool.sh b/git-mergetool.sh
index a44afd3822..12c3e83aa7 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -243,9 +243,16 @@ auto_merge () {
 	git merge-file --diff3 --marker-size=7 -q -p "$LOCAL" "$BASE" "$REMOTE" >"$DIFF3"
 	if test -s "$DIFF3"
 	then
-		sed -e '/^<<<<<<< /,/^||||||| /d' -e '/^=======\r\?$/,/^>>>>>>> /d' "$DIFF3" >"$BASE"
-		sed -e '/^||||||| /,/^>>>>>>> /d' -e '/^<<<<<<< /d' "$DIFF3" >"$LOCAL"
-		sed -e '/^<<<<<<< /,/^=======\r\?$/d' -e '/^>>>>>>> /d' "$DIFF3" >"$REMOTE"
+		cr=$(printf '\x0d')
+		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"
 	fi
 	rm -- "$DIFF3"
 }
-- 
2.30.0.rc1.6.g2bc636d1d6

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

From: brian m. carlson <hidden>
Date: 2021-01-09 22:00:29

On 2021-01-09 at 21:49:22, David Aguilar wrote:
The use of "\r\?" in sed is not portable to macOS and possibly
other unix flavors.

Replace "\r" with a substituted variable that contains "\r".
Replace "\?" with "\{0,1\}".
Ah, yes, this is true.  The statement about "\r" is also true for Linux
with POSIXLY_CORRECT, IIRC.
quoted hunk
Signed-off-by: David Aguilar <redacted>
---
This is based on top of fc/mergetool-automerge and can be squashed in
(with the addition of my sign-off) if desired.

Let me know if you'd prefer a separate patch. I figured we'd want
a squash to preserve bisectability.

 git-mergetool.sh | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/git-mergetool.sh b/git-mergetool.sh
index a44afd3822..12c3e83aa7 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -243,9 +243,16 @@ auto_merge () {
 	git merge-file --diff3 --marker-size=7 -q -p "$LOCAL" "$BASE" "$REMOTE" >"$DIFF3"
 	if test -s "$DIFF3"
 	then
-		sed -e '/^<<<<<<< /,/^||||||| /d' -e '/^=======\r\?$/,/^>>>>>>> /d' "$DIFF3" >"$BASE"
-		sed -e '/^||||||| /,/^>>>>>>> /d' -e '/^<<<<<<< /d' "$DIFF3" >"$LOCAL"
-		sed -e '/^<<<<<<< /,/^=======\r\?$/d' -e '/^>>>>>>> /d' "$DIFF3" >"$REMOTE"
+		cr=$(printf '\x0d')
Unfortunately, printf is not specified by POSIX to take hex escapes, so
this, too is nonportable.  We are unfortunately allowed to use only
octal escapes (yuck).  However, we can write this:

  cr=$(printf '\r')

or

  cr=$(printf '\015')

I think the former is clearer, since that's what we were writing before.
-- 
brian m. carlson (he/him or they/them)
Houston, Texas, US

[PATCH v2] fixup! mergetool: add automerge configuration

From: David Aguilar <hidden>
Date: 2021-01-09 22:43:41

"\r\?" in sed is not portable to macOS and possibly others.
"\r" is not valid on Linux with POSIXLY_CORRECT.

Replace "\r" with a substituted variable that contains "\r".
Replace "\?" with "\{0,1\}".

Helped-by: brian m. carlson [off-list ref]
Signed-off-by: David Aguilar <redacted>
---
This is based on top of fc/mergetool-automerge and can be squashed in
(with the addition of my sign-off) if desired.

Changes since last time:
- printf '\r' instead of printf '\x0d'
- The commit message now mentions POSIXLY_CORRECT.

 git-mergetool.sh | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/git-mergetool.sh b/git-mergetool.sh
index a44afd3822..9029a79431 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -243,9 +243,16 @@ auto_merge () {
 	git merge-file --diff3 --marker-size=7 -q -p "$LOCAL" "$BASE" "$REMOTE" >"$DIFF3"
 	if test -s "$DIFF3"
 	then
-		sed -e '/^<<<<<<< /,/^||||||| /d' -e '/^=======\r\?$/,/^>>>>>>> /d' "$DIFF3" >"$BASE"
-		sed -e '/^||||||| /,/^>>>>>>> /d' -e '/^<<<<<<< /d' "$DIFF3" >"$LOCAL"
-		sed -e '/^<<<<<<< /,/^=======\r\?$/d' -e '/^>>>>>>> /d' "$DIFF3" >"$REMOTE"
+		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"
 	fi
 	rm -- "$DIFF3"
 }
-- 
2.30.0.rc1.6.g3f22546b2b.dirty

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

From: Seth House <hidden>
Date: 2021-01-09 22:58:08

On Sat, Jan 09, 2021 at 02:42:36PM -0800, David Aguilar wrote:
Replace "\r" with a substituted variable that contains "\r".
Replace "\?" with "\{0,1\}".
Nice. I was (very slowly) converging on that as the culprit. Thanks for
the elegant fix! I'm running the test suite on Windows and OSX (now that
they're set up locally) with this included and I'll send a v10 once
complete.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help