From: Junio C Hamano <gitster@pobox.com>
To: David Aguilar <davvid@gmail.com>
Cc: Seth House <seth@eseth.com>,
Felipe Contreras <felipe.contreras@gmail.com>,
"brian m. carlson" <sandals@crustytoothpaste.net>,
git@vger.kernel.org
Subject: Re: [PATCH v2] fixup! mergetool: add automerge configuration
Date: Sat, 09 Jan 2021 15:18:43 -0800 [thread overview]
Message-ID: <xmqqbldxem24.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20210109224236.50363-1-davvid@gmail.com> (David Aguilar's message of "Sat, 9 Jan 2021 14:42:36 -0800")
David Aguilar <davvid@gmail.com> writes:
> "\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 <sandals@crustytoothpaste.net>
> Signed-off-by: David Aguilar <davvid@gmail.com>
> ---
> 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"
> }
I was hoping that we can avoid repetition that can cause bugs with
something like
diff --git i/git-mergetool.sh w/git-mergetool.sh
index a44afd3822..e07dabbf72 100755
--- i/git-mergetool.sh
+++ w/git-mergetool.sh
@@ -243,9 +243,13 @@ 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"
+ C0="^<<<<<<< "
+ C1="^||||||| "
+ C2="^=======$(printf '\015')*\$"
+ 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"
}
next prev parent reply other threads:[~2021-01-09 23:19 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-09 21:49 [PATCH] fixup! mergetool: add automerge configuration David Aguilar
2021-01-09 21:59 ` brian m. carlson
2021-01-09 22:42 ` [PATCH v2] " David Aguilar
2021-01-09 22:54 ` Seth House
2021-01-10 1:17 ` Junio C Hamano
2021-01-10 6:40 ` Re* " Junio C Hamano
2021-01-10 7:29 ` Seth House
2021-01-10 11:24 ` Junio C Hamano
2021-01-16 4:24 ` Seth House
2021-01-20 23:24 ` automerge implementation ideas for Windows Seth House
2021-01-21 22:50 ` Junio C Hamano
2021-01-22 1:09 ` Seth House
2021-01-22 2:26 ` Junio C Hamano
2021-01-22 2:50 ` Re* [PATCH v2] fixup! mergetool: add automerge configuration brian m. carlson
2021-01-22 16:29 ` Johannes Schindelin
2021-01-22 23:25 ` brian m. carlson
2021-01-26 14:32 ` Johannes Schindelin
2021-01-26 18:06 ` Seth House
2021-01-26 20:10 ` Junio C Hamano
2021-01-27 3:37 ` Seth House
2021-01-29 0:41 ` Junio C Hamano
2021-01-09 23:18 ` Junio C Hamano [this message]
2021-01-10 1:52 ` Junio C Hamano
2021-01-09 23:21 ` [PATCH] " Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqbldxem24.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=davvid@gmail.com \
--cc=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=sandals@crustytoothpaste.net \
--cc=seth@eseth.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).