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

Re: [PATCH/RFC] Makefile: dedup list of files obtained from ls-files

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 23, 2019, 01:18 UTC
Message-ID
<xmqq8sw17c3q.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<d869060a-a731-ff1d-3131-a146078fcf88@ramsayjones.plus.com>
Ramsay Jones <ramsay@ramsayjones.plus.com> writes:
Show 9 quoted lines
>> FWIW, after reading your commit message my thoughts immediately turned
>> to "why can't ls-files have a mode that outputs each just once", but
>> then ended up at the same place as your patch: it's not that hard to
>> just de-dup the output.
>
> My immediate thought was "that is simply a bug, no?" :-D
>
> I haven't used 'git ls-files' that much, so it's no great surprise
> that I had not noticed it odd behaviour!

Yup, the real issue is that ls-files uses exactly the same code for tagged output, output with stage numbers and just plain list of paths, so as we saw in the motivating use case for this patch, unmerged paths give us one source of duplication when we are asking for list of paths without stages.

It also considers, IIRC, deletion is merely one of the forms of modifications, so asking it to list modified paths and deleted paths at the same time would give you another source of duplication.

Perhaps not-so-low-hanging fruit miniproject would be to teach "ls-files" a new "--dedup" option that does two things:

 * When -m and -d are asked at the same time, ignore '-d', because
   '-d' will give duplicates for subsets of what '-m' would show
   anyway; and
 * When neither -s nor -u is given, do not show the same path more
   than once, even the ones with multiple stages.

Perhaps it is safe to leave a #leftoverbits mark for the above, now that two people in addition to I noticed that the behaviour is less than ideal.

Previous: Ramsay JonesNext: SZEDER Gábor
Message 6 of 11 in “Makefile: dedup list of files obtained from ls-files”
  1. Makefile: dedup list of files obtained from ls-filesJunio C Hamano, Apr 21, 2019
  2. Eric SunshineApr 22, 2019
  3. Junio C HamanoApr 22, 2019
  4. Jeff KingApr 22, 2019
  5. Ramsay JonesApr 22, 2019
  6. Junio C HamanoApr 23, 2019
  7. SZEDER GáborApr 23, 2019
  8. Junio C HamanoApr 24, 2019
  9. SZEDER GáborApr 24, 2019
  10. Eric SunshineApr 24, 2019
  11. Junio C HamanoApr 25, 2019

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.