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

Re: Change in .gitignore handling: intended or bug?

From
Duy Nguyen <pclouds@gmail.com>
Date
Mar 5, 2016, 00:43 UTC
Message-ID
<CACsJy8BZm9pFdR+Njst7qZ1UnHUL9XpigM5pW+CLEicOc7ra8g@mail.gmail.com>
In-Reply-To
<xmqq4mcm17b4.fsf@gitster.mtv.corp.google.com>
On Sat, Mar 5, 2016 at 12:28 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 24 quoted lines
> Duy Nguyen <pclouds@gmail.com> writes:
>
>> On Fri, Mar 4, 2016 at 6:56 PM, Kevin Daudt <me@ikke.info> wrote:
>>> Verified that it's different in 2.7.0, but 2.7.2 gives expected output.
>>
>> Thanks. 2.7.1 reverts the faulty commit from 2.7.0 that generated two
>> other regression reports before this one. I guess it's all good then
>> (except for the people still on 2.7.0)
>
> Are we good at 2.8.0-rc0, too?  Somehow I had an impression that we
> queued "another attempt to do it differently" or something.
>
>  ... goes and looks ...
>
>     $ rungit maint status -suall
>     ?? baz/quux/corge/wibble.txt
>     ?? baz/quux/grault.txt
>     ?? foo/bar.txt
>     $ rungit master status -suall
>     ?? baz/quux/corge/wibble.txt
>     ?? baz/quux/grault.txt
>     ?? baz/waldo.txt
>     ?? foo/bar.txt
>     ?? foo/garply.txt

If you swap a60ea8f and bac65a2 so that we can have tracing even without the problematic commit a60ea8f (dir.c: fix match_pathname() - 2016-02-15). Without a60ea8f I got

GIT_TRACE_EXCLUDE=1 ~/w/git/temp/git status -suall 2>&1 >/dev/null
|grep waldo
07:25:05.639445 dir.c:952               exclude: baz/waldo.txt vs * at
line 1 => yes
(meaning, baz/waldo.txt matches "*" rule and is decided to be excluded)
with a60ea8f
> /tmp/abc $ GIT_TRACE_EXCLUDE=1 ~/w/git/temp/git status -suall 2>&1 >/dev/null |grep waldo

07:25:24.425125 dir.c:952 exclude: baz/waldo.txt vs /baz at line 4 => no

the decision is not taken earlier from line "!/baz" and it's decided to be re-included. Which I would argue is the correct thing because you ask to re-include the whole directory "baz". It should behave this way because exclude rules without '!' behave this way.

Because positive any negative rules can be nested, by adding a rule to reinclude what's inside baz..

    *
    !/foo
    !/foo/bar.txt
    !/baz
    /baz/*
    !/baz/quux
    !/baz/quux/**/*
you'll get baz/waldo.txt excluded.

Yes it's a behavior change. I think the old behavior is unintended. But it's probably out there long enough that many .gitignore files may rely on it and by making it right, I break them. Whether to revert the series is up to you. Let me know if I should send the revert patch.

-- 
Duy
Previous: Junio C HamanoNext: Duy Nguyen
Message 9 of 28 in “Change in .gitignore handling: intended or bug?”
  1. Charles StrahanMar 4, 2016
  2. Duy NguyenMar 4, 2016
  3. Kevin DaudtMar 4, 2016
  4. Charles StrahanMar 4, 2016
  5. Kevin DaudtMar 4, 2016
  6. Duy NguyenMar 4, 2016
  7. Junio C HamanoMar 4, 2016
  8. Junio C HamanoMar 4, 2016
  9. Duy NguyenMar 5, 2016
  10. Duy NguyenMar 5, 2016
  11. Charles StrahanMar 5, 2016
  12. Junio C HamanoMar 5, 2016
  13. Junio C HamanoMar 7, 2016
  14. Junio C HamanoMar 8, 2016
  15. Duy NguyenMar 8, 2016
  16. Junio C HamanoMar 8, 2016
  17. Duy NguyenMar 9, 2016
  18. Junio C HamanoMar 9, 2016
  19. Junio C HamanoMar 9, 2016
  20. dir.c: fix dir re-inclusion rules with "NODIR" and "MUSTBEDIR"Nguyễn Thái Ngọc Duy, Mar 9, 2016
  21. Junio C HamanoMar 9, 2016
  22. Duy NguyenMar 10, 2016
  23. Duy NguyenMar 9, 2016
  24. Junio C HamanoMar 9, 2016
  25. Duy NguyenMar 10, 2016
  26. Junio C HamanoMar 10, 2016
  27. Junio C HamanoMar 10, 2016
  28. Duy NguyenMar 10, 2016

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.