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

Re: Git 2.7.0 gitignore behaviour regression

From
Duy Nguyen <pclouds@gmail.com>
Date
Jan 6, 2016, 09:42 UTC
Message-ID
<CACsJy8AQ9s4VkFn+TNJLD55xJc40+-54BTYbC4Os71uSkL1QSA@mail.gmail.com>
In-Reply-To
<20160105150602.GA4130@sigill.intra.peff.net>
On Tue, Jan 5, 2016 at 10:06 PM, Jeff King <peff@peff.net> wrote:
Show 36 quoted lines
> On Tue, Jan 05, 2016 at 02:40:16PM +0000, Mike McQuaid wrote:
>
>> Homebrew has a series of convoluted .gitignore rules due to our
>> special/weird use-case of wanting to ignore everything in a working
>> directory except a select few files/directories. We experienced a bug
>> with our .gitignore file for users using Git 2.7.0. This may well be a
>> valid WONTFIX or intentional behaviour change but I wanted to flag it
>> in case it wasn’t.
>>
>> Here’s a minimal test case:
>>
>> - Create an empty git repository in a directory with `git init`
>> - Create a directory named ‘a' containing a file named ‘b' with `mkdir a && touch a/b`
>> - Create a ‘gitignore’ file with the following contents:
>> ```
>> */
>> /a
>> !/a/*
>> ```
>> - Run `git status --short`.
>>
>> The output with Git 2.6.4 is:
>> ```
>> ?? .gitignore
>> ```
>>
>> The output with Git 2.7.0 is:
>> ```
>> ?? .gitignore
>> ?? a/
>> ```
>
> Thanks for giving a clear example. This bisects to Duy's 57534ee (dir.c:
> don't exclude whole dir prematurely if neg pattern may match,
> 2015-09-21). AFAICT (and I don't recall looking over this patch
> previously), what you are seeing is the intended effect of the patch.

Yeah.. I think it's the only relevant commit in 2.7.0 cycle anyway. These patterns "/a" followed by "!/a/*" were wrecking my head. But I finally decided 2.7 output makes more sense. You asked to un-ignore everything inside 'a' so we can't treat 'a' as (entirely) ignored and hide it away.

> I'm sympathetic that in making that use-case work, we might have
> regressed another one, but it's hard to tell from the small example. Can
> you elaborate on your use case? Why are you both ignoring and unignoring
> everything in the directory?

Also how bad this affects you (widely-used 'wrong' behavior can become 'right', and my change a regression as a result)

-- 
Duy
Previous: Jeff KingNext: Mike McQuaid
Message 3 of 13 in “Git 2.7.0 gitignore behaviour regression”
  1. Mike McQuaidJan 5, 2016
  2. Jeff KingJan 5, 2016
  3. Duy NguyenJan 6, 2016
  4. Mike McQuaidJan 6, 2016
  5. Duy NguyenJan 6, 2016
  6. Junio C HamanoJan 6, 2016
  7. Jeff KingJan 7, 2016
  8. Duy NguyenJan 7, 2016
  9. Carlos Martín NietoJan 8, 2016
  10. brian m. carlsonJan 7, 2016
  11. Duy NguyenJan 8, 2016
  12. brian m. carlsonJan 8, 2016
  13. Duy NguyenJan 8, 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.