Subject: Re: [PATCH V3] check-ignore: Add option to ignore index contents

From: Junio C Hamano <[email-masked]>
Date: Thu, 05 Sep 2013 15:27:36 -0700

Dave Williams <[email-masked]> writes:

> check-ignore currently shows how .gitignore rules would treat untracked
> paths. Tracked paths do not generate useful output.  This prevents
> debugging of why a path became tracked unexpectedly unless that path is
> first removed from the index with `git rm --cached <path>`.
>
> This option (-i, --no-index) simply by-passes the check for the path
> being in the index and hence allows tracked paths to be checked too.

Now the long option name is "--no-index", it makes me wonder if "-i"
is a good synonym for it, and the longer I stare at it, the more
certain I become convinced that it is a bad choice.

Do we even need a short-and-sweet one-letter option for this?  I'd
prefer starting with only the long option.

I came up with a squashable tweak to remove "-i" on top of this
patch; will tentatively queue this patch with it to 'pu'.

> In particlar Junio queried my approach in
> builtin/git-check-ignores.c that bypassed the functions that check
> a path is in the index as well as avoiding reading the index in
> the first place.

Thanks.

I think this version is cleaner without those "if (!no_index)" used
for special casing in the codeflow.  An empty index is a valid
state, in which the in-core index starts when any git program
begins.  Not reading the index should be the only thing necessary to
mimick the state in which nothing has been added to the index, and
if that is not the case, we have found a bug in the existing code.

> Regarding the test script I have tidied up the variables containing the
> separate option switches so they dont contain leading spaces, instead I
> have added spaces as needed when formatting the command line.  This
> not only improves my patch but also the existing code which was a little
> inconsistent in this respect.

Yeah, that's very much appreciated.

> Finally I have rebased from the latest commmit on master to pick up
> unrelated recent changes made to builtin/check-ignores.c and updated my
> code to be consistent with this.
>
> Hopefully I have put these patch notes in the right place now! Let me
> know if not.
>
> Dave

Nicely done.