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

From: SZEDER Gábor <[email-masked]>
Date: Wed, 24 Apr 2019 13:25:50 +0200

On Wed, Apr 24, 2019 at 10:03:37AM +0900, Junio C Hamano wrote:
> SZEDER Gábor <[email-masked]> writes:
> 
> > I remember being rather puzzled by 'git ls-files' listing the same
> > file more than once depending on its --options when I was working on
> > the git-aware path completion parts of our completion script.
> 
> Yup, I recall a thread we recently had where we wondered why we see
> two entries reported when we ask for 'modified' and 'deleted' at the
> same time.
> 
> 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

There are other combination of options that need similar treatment,
e.g. '--cached --modified', '--cached --deleted', and I vaguely
remember a combination involving '--killed' as well.

On second thought, however, I'm not sure that such a '--dedup' option
would be all that useful in the above cases.  If the users have to
adjust their 'git ls-files' invocation by specifying '--dedup' to
avoid the same paths listed multiple times, then they might just as
well remove the redundant options.  After all, a deleted file is
inherently modified, and a modified file is inherently cached...

>  * When neither -s nor -u is given, do not show the same path more
>    than once, even the ones with multiple stages.
>