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

Re: Improving merge of tricky conflicts

From
Jeff King <peff@peff.net>
Date
Jul 24, 2020, 19:48 UTC
Message-ID
<20200724194840.GA4013174@coredump.intra.peff.net>
In-Reply-To
<xmqqk0ytn208.fsf@gitster.c.googlers.com>
On Thu, Jul 23, 2020 at 06:19:19PM -0700, Junio C Hamano wrote:
> Unfortunately, there is no ">>>>>>>" shown with this code, as $_
> seems to get clobbered before the sub returns, so ...

Ah yeah, thanks for pointing it out (as you might guess I was mainly looking at the diff output to see if it was broken ;) ).

Your suggested fix is probably what I'd do (I really wish perl localized $_ automatically when entering new blocks, but I suspect they would never do so because of compatibility).

Show 7 quoted lines
> >   my $pre = File::Temp->new;
> >   print $pre @$pre_data;
> 
> I am debating myself if I want to see the base version between these
> two extra diffs.  Perhaps there is no need, as either one of these
> two extra diffs should be sufficient to see what was in the base
> version.

Yeah, I didn't give too much thought to the output, but was afraid of making it too long and hard to read. In addition to whether to show the base, I also wondered whether we could omit the "---/+++" header for each diff. It's mostly boilerplate, and the signal of "hey, this is the diff between 'base' and 'ours'" could be done on the "|||||||" line (which also could potentially use a different character to be more distinct).

I was also tempted to remove the hunk header since the line numbers are fairly useless. But it is possible for the diff to have multiple hunks, and you'd still want to show that.

My big challenge now will be remembering to try to use this next time I run into a conflict that could be helped by it. :)

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 25 in “Improving merge of tricky conflicts”
  1. B. SteblerJul 21, 2020
  2. Johannes SixtJul 22, 2020
  3. Jeff KingJul 22, 2020
  4. Junio C HamanoJul 22, 2020
  5. Jeff KingJul 23, 2020
  6. Junio C HamanoJul 24, 2020
  7. Jeff KingJul 24, 2020
  8. Junio C HamanoJul 24, 2020
  9. Martin von ZweigbergkJan 16, 2021
  10. Jeff KingJan 21, 2021
  11. Martin von ZweigbergkJan 21, 2021
  12. Jeff KingJan 21, 2021
  13. Sergey OrganovJul 22, 2020
  14. Junio C HamanoJul 22, 2020
  15. Sergey OrganovJul 22, 2020
  16. Jeff KingJul 23, 2020
  17. Sergey OrganovJul 23, 2020
  18. Junio C HamanoJul 23, 2020
  19. Jacob KellerJul 24, 2020
  20. Junio C HamanoJul 24, 2020
  21. Sergey OrganovJul 24, 2020
  22. Junio C HamanoJul 24, 2020
  23. Sergey OrganovJul 24, 2020
  24. Junio C HamanoJul 24, 2020
  25. Bono SteblerJul 22, 2020

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.