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

Re: [PATCH 1/2] fast-export: deletion action first

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 25, 2017, 04:24 UTC
Message-ID
<xmqqfugxw1us.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170425032927.74btvfcexbdq4rmz@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> Perhaps we would want a test for the case you are fixing (to be sure it
> is not re-broken), as well as confirming that we have not re-broken the
> original case (it looks like 060df62 added a test, so we may be OK with
> that).
Good suggestion.
Show 17 quoted lines
>
>> +/*
>> + * Compares two diff types to order based on output priorities.
>> + */
>> +static int diff_type_cmp(const void *a_, const void *b_)
>> [...]
>> +	/*
>> +	 * Move Delete entries first so that an addition is always reported after
>> +	 */
>> +	cmp = (b->status == DIFF_STATUS_DELETED) - (a->status == DIFF_STATUS_DELETED);
>>  	if (cmp)
>>  		return cmp;
>>  	/*
>
> So we sort deletions first. And the bit that the context doesn't quite
> show here is that we then compare renames and push them to the end.
> Everything else will compare equal.

Wait--we also allow renames? Rename is like delete in the context of discussing d/f conflicts, in that it tells us that the source path will be missing in the end result. If you rename a file "d" to "e", then there is a room for you to create a directory "d" to store a file "d/f" in. Shouldn't it participate also in this "delete before add to avoid d/f conflict" logic?

> Is qsort() guaranteed to be stable? If not, then we'll get the majority
> of entries in a non-deterministic order. Should we fallback to strcmp()
> so that within a given class, the entries are sorted by name?

Again, very good point, especially with the existing comment in the comparison function that explains why renames are shown last.

Previous: Jeff KingNext: Jeff King
Message 4 of 9 in “fast-export: deletion action first”
  1. 1/2 fast-export: deletion action firstMiguel Torroja, Apr 25, 2017
  2. 2/2 fast-export: DIFF_STATUS_RENAMED instead of 'R'Miguel Torroja, Apr 25, 2017
  3. Jeff KingApr 25, 2017
  4. Junio C HamanoApr 25, 2017
  5. Jeff KingApr 25, 2017
  6. Junio C HamanoApr 25, 2017
  7. Jeff KingApr 25, 2017
  8. fast-export: deletion action firstMiguel Torroja, May 4, 2017
  9. miguel torrojaMay 4, 2017

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.