git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Re* [PATCH v2] fixup! mergetool: add automerge configuration
@ 2021-01-22  9:08 Seth House
  0 siblings, 0 replies; 13+ messages in thread
From: Seth House @ 2021-01-22  9:08 UTC (permalink / raw)
  To: brian m. carlson; +Cc: Junio C Hamano, David Aguilar, Felipe Contreras, git

On Fri, Jan 22, 2021 at 02:50:17AM +0000, brian m. carlson wrote:
> Can you report this as a bug?  This behavior isn't compliant with POSIX
> and it makes it really hard for folks to write portable code

I finally tracked down what upstream project these packages come from.
I don't use Windows very often and the MSYS2, MinGW, msysgit, & Cygwin
project history and overlap is *complicated* to say the least.

It seems the Git-for-Windows userland comes from both MSYS2 and MinGW
[1]. sed and awk come from MSYS2 and the carriage return conversion is
indeed documented [2].

[1] https://github.com/git-for-windows/build-extra#msys2
[2] https://www.msys2.org/wiki/How-does-MSYS2-differ-from-Cygwin/#runtime

It looks like the auto-CR conversion is well-tread, and well-flamed,
territory. I'd prefer not to reignite that but I filed an issue to start
a discussion. That issue also details the history behind this behavior
for anyone interested:

https://github.com/msys2/MSYS2-packages/issues/2315


^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: [PATCH] fixup! mergetool: add automerge configuration
@ 2021-01-09 21:59 brian m. carlson
  2021-01-09 22:42 ` [PATCH v2] " David Aguilar
  0 siblings, 1 reply; 13+ messages in thread
From: brian m. carlson @ 2021-01-09 21:59 UTC (permalink / raw)
  To: David Aguilar; +Cc: Junio C Hamano, Seth House, Felipe Contreras, git

[-- Attachment #1: Type: text/plain, Size: 1711 bytes --]

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.

> 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.
> 
> 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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-01-29  0:42 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22  9:08 Re* [PATCH v2] fixup! mergetool: add automerge configuration Seth House
  -- strict thread matches above, loose matches on Subject: below --
2021-01-09 21:59 [PATCH] " 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-22  2:50               ` 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

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).