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

Re: [PATCHv4] diff.c: emit moved lines with a different color

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 7, 2016, 18:52 UTC
Message-ID
<xmqqvay7lezg.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<87a1ddbf-2499-d5b4-55c4-aeed2b72acce@ramsayjones.plus.com>
Ramsay Jones <ramsay@ramsayjones.plus.com> writes:
Show 15 quoted lines
>> +static int diff_line_moved_entry_cmp(const struct diff_line_moved_entry *a,
>> +				     const struct diff_line_moved_entry *b,
>> +				     const void *unused)
>> +{
>> +	return strcmp(a->line, b->line) &&
>> +	       a->hash_prev_line == b->hash_prev_line;
>
> I doubt it would make much difference, but my knee-jerk reaction to
> this was to suggest swapping the order of the expression, thus:
>
> 	return a->hash_prev_line == b->hash_prev_line &&
> 		strcmp(a->line, b->line);
>
> ... but perhaps it doesn't read quite so well, and probably wouldn't affect
> performance much (except in strange edge cases), so it may not be worth it.

It would make very much sense to do so, as the final version will be a lot more involved than a mere strcmp() to make "git diff -w" to also work as expected with this new feature.

Previous: Ramsay JonesNext: Jakub Narębski
Message 3 of 6 in “[PATCHv4] diff.c: emit moved lines with a different color”
  1. Stefan BellerSep 6, 2016
  2. Ramsay JonesSep 6, 2016
  3. Junio C HamanoSep 7, 2016
  4. Jakub NarębskiSep 6, 2016
  5. Stefan BellerSep 6, 2016
  6. Jakub NarębskiSep 6, 2016

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.