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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 10, 2021, 01:52 UTC
Message-ID
<xmqqeeitd0dh.fsf@gitster.c.googlers.com>
In-Reply-To
<xmqqbldxem24.fsf@gitster.c.googlers.com>
Junio C Hamano <gitster@pobox.com> 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
Previous: Junio C HamanoNext: Junio C Hamano
Message 23 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.