Re: [PATCH v2 6/7] add: warn when pathspec only matches SKIP_WORKTREE entries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 4, 2021 at 1:03 PM Junio C Hamano <gitster@xxxxxxxxx> wrote:
>
> Elijah Newren <newren@xxxxxxxxx> writes:
>
> > I think it's kind of lame that git-add won't provide a warning for
> > ignored files when the match is via glob/pattern; if git-add didn't
> > end up adding anything, but an ignored file was matched, I think a
> > warning is appropriate.
>
> I am not so sure.  When I have this in my exclude list:
>
>         tmp-*
>
> and have this file in the working tree:
>
>         tmp-000.txt
>
> I am not sure if I want to see any such warning when I did
>
>         $ git add "*.txt"
>
> After all, I said that I never would want to worry about anything
> that begins with "tmp-".  It would be a totally different issue if I
> did
>
>         $ git add tmp-000.txt
>
> as I am contermanding my previous wish and saying that I care about
> this particular file, even if its name begins with "tmp-".
>
> So far, the flow of logic is simple, clear and straight-forward.
>
> BUT.
>
> What makes the whole thing tricky is that people don't do
>
>         $ git add "*.txt"
>
> The instead do
>
>         $ git add *.txt
>
> and "git add" cannot tell if the tmp-000.txt it sees is what the
> user meant, or what the shell expanded.
>
> If there were no shell glob expansion, then "warn only if a
> glob/pattern did not match any" would have been an attractive
> option, especially when we had another file in the working tree,
> say, hello.txt, next to the tmp-000.txt.  Then
>
>         $ git add "*.txt"
>
> would add only hello.txt, and we won't see a warning about
> tmp-000.txt.  But end-users will use shell expansion, i.e.
>
>         $ git add *.txt
>
> (1) warning against tmp-000.txt because the command line named it
>     explicitly (from "git add"'s point of view, but never from the
>     user's point of view) would be a disaster.  I think that is why
>     your suggestion was "if git-add did not add anything then warn".
>     but ...
>
> (2) not warning, because the command line named hello.txt as well,
>     i.e. "git add" added something, would make it inconsistent.
>     Whether there is another file whose name ends with .txt, what
>     the user typed (i.e. *.txt) to the command line is the same, and
>     the exclude pattern (i.e. tmp-*) is the same, but the presence
>     of an unrelated hello.txt affects if a warning is given for
>     tmp-000.txt.
>
> So, I dunno.

Fair enough.  All the more reason to leave it out of Matheus' patch
series, then.  :-)



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux