git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jan 9, 2021, 21:59 UTC
Message-ID
<X/onP6vFAHH8SUBo@camp.crustytoothpaste.net>
In-Reply-To
<20210109214922.33972-1-davvid@gmail.com>
On 2021-01-09 at 21:49:22, David Aguilar wrote:
Show 5 quoted lines
> 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.

Show 23 quoted lines
> 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
Previous: David AguilarNext: David Aguilar
Message 2 of 24 in “fixup! mergetool: add automerge configuration”
  1. fixup! mergetool: add automerge configurationDavid Aguilar, Jan 9, 2021
  2. brian m. carlsonJan 9, 2021
  3. fixup! mergetool: add automerge configurationDavid Aguilar, Jan 9, 2021
  4. Seth HouseJan 9, 2021
  5. Junio C HamanoJan 10, 2021
  6. Re* [PATCH v2] fixup! mergetool: add automerge configurationJunio C Hamano, Jan 10, 2021
  7. Seth HouseJan 10, 2021
  8. Junio C HamanoJan 10, 2021
  9. Seth HouseJan 16, 2021
  10. automerge implementation ideas for WindowsSeth House, Jan 20, 2021
  11. Junio C HamanoJan 21, 2021
  12. Seth HouseJan 22, 2021
  13. Junio C HamanoJan 22, 2021
  14. brian m. carlsonJan 22, 2021
  15. Johannes SchindelinJan 22, 2021
  16. brian m. carlsonJan 22, 2021
  17. Johannes SchindelinJan 26, 2021
  18. Seth HouseJan 26, 2021
  19. Junio C HamanoJan 26, 2021
  20. Seth HouseJan 27, 2021
  21. Junio C HamanoJan 29, 2021
  22. Junio C HamanoJan 9, 2021
  23. Junio C HamanoJan 10, 2021
  24. Junio C HamanoJan 9, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.