git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Charles Strahan <charles@cstrahan.com>
To: Kevin Daudt <me@ikke.info>
Cc: git@vger.kernel.org
Subject: Re: Change in .gitignore handling: intended or bug?
Date: Fri, 04 Mar 2016 01:12:37 -0500	[thread overview]
Message-ID: <1457071957.2027843.539286050.10CF8D0A@webmail.messagingengine.com> (raw)
In-Reply-To: <20160304055117.GB26609@ikke.info>

I'm on 2.7.0.

Here's a quick sanity check:

├── baz
│   ├── quux
│   │   ├── corge
│   │   │   └── wibble.txt
│   │   └── grault.txt
│   └── waldo.txt
└── foo
    ├── bar.txt
    └── garply.txt

$ git --version
git version 2.7.0

$ git status -sb -uall
## Initial commit on master
?? baz/quux/corge/wibble.txt
?? baz/quux/grault.txt
?? baz/waldo.txt
?? foo/bar.txt
?? foo/garply.txt


For the lazy (such as myself), this will set up an identical tree:

mkdir -p foo
mkdir -p baz/quux/corge
touch foo/bar.txt
touch foo/garply.txt
touch baz/waldo.txt
touch baz/quux/grault.txt
touch baz/quux/corge/wibble.txt
cat <<"EOF" > .gitignore
*
!/foo
!/foo/bar.txt
!/baz
!/baz/quux
!/baz/quux/**/*
EOF


I just checked https://git-scm.com/docs/gitignore and the example at the
bottom
suggests that this behavior may be expected:

    $ cat .gitignore
    # exclude everything except directory foo/bar
    /*
    !/foo
    /foo/*
    !/foo/bar

Note the /foo/*, explicitly ignoring the entries below /foo.

This wasn't always the case, though, so I'd love to hear if it was
intentional
(or if I've lost my mind, which is quite possible).

-Charles



On Fri, Mar 4, 2016, at 12:51 AM, Kevin Daudt wrote:
> On Thu, Mar 03, 2016 at 09:11:56PM -0500, Charles Strahan wrote:
> > Hello,
> > 
> > I've found a change in the way .gitignore works, and I'm not sure if
> > it's a bug
> > or intended.
> > 
> > Previously, one could use the following .gitignore:
> > 
> >     *
> >     !/foo
> >     !/foo/bar.txt
> >     !/baz
> >     !/baz/quux
> >     !/baz/quux/**/*
> > 
> > And these files would be seen by git:
> > 
> >     foo/bar.txt
> >     baz/quux/grault.txt
> >     baz/quux/corge/wibble.txt
> > 
> > And these files would be ignored:
> > 
> >     foo/garply.txt
> >     baz/waldo.txt
> > 
> > At some point (between git 2.6.0 and 2.7.0, I think), the behavior
> > changed such
> > that _none_ of the files above would be ignored. Previously, git would
> > treat
> > !/foo as an indication that it should not prune /foo, but that
> > _wouldn't_ be
> > sufficient to un-ignore the contents thereof. Now, it seems the new
> > scheme
> > treats !/foo as functionally equivalent to !/foo followed by !/foo/**/*
> > in the
> > old scheme.
> > 
> > I manage my home directory by making it a git repo, and using
> > ~/.gitignore to
> > selectively permit certain files or subdirectories to be seen by git.
> > The recent
> > change in behavior has resulted in sensitive directories like ~/.gpg
> > being
> > un-ignored. For reference, I've appended my .gitignore to the end of
> > this email.
> > 
> > So, is this behavior intended, or is this a bug? If the former, is there
> > an
> > announcement explaining this change?
> > 
> > -Charles
> > 
> > [snip]
> > --
> > To unsubscribe from this list: send the line "unsubscribe git" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> Works as intended for me:
> 
> ├── baz
> │   ├── quux
> │   │   ├── corge
> │   │   │   └── wibble.txt
> │   │   └── grault.txt
> │   └── waldo.txt
> └── foo
>     ├── bar.txt
>     └── garply.txt
> 
> $ git status -s -uall
> ?? baz/quux/corge/wibble.txt
> ?? baz/quux/grault.txt
> ?? foo/bar.txt
> 
> garply.txt and waldo.txt are ignore, but the rest is still tracked.
> 
> I'm on 2.7.2.

  reply	other threads:[~2016-03-04  6:12 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-04  2:11 Change in .gitignore handling: intended or bug? Charles Strahan
2016-03-04  3:09 ` Duy Nguyen
2016-03-04  5:51 ` Kevin Daudt
2016-03-04  6:12   ` Charles Strahan [this message]
2016-03-04 11:56     ` Kevin Daudt
2016-03-04 12:36       ` Duy Nguyen
2016-03-04 17:28         ` Junio C Hamano
2016-03-04 19:12           ` Junio C Hamano
2016-03-05  0:43           ` Duy Nguyen
2016-03-05  0:50             ` Duy Nguyen
2016-03-05  1:00               ` Charles Strahan
2016-03-05  1:35                 ` Junio C Hamano
2016-03-07 21:11             ` Junio C Hamano
2016-03-08  6:14               ` Junio C Hamano
2016-03-08 10:19                 ` Duy Nguyen
2016-03-08 18:10                   ` Junio C Hamano
2016-03-09  0:18                     ` Duy Nguyen
2016-03-09  0:32                       ` Junio C Hamano
2016-03-09  0:45                         ` Junio C Hamano
2016-03-09 11:08                           ` [PATCH] dir.c: fix dir re-inclusion rules with "NODIR" and "MUSTBEDIR" Nguyễn Thái Ngọc Duy
2016-03-09 17:55                             ` Junio C Hamano
2016-03-10  0:39                               ` Duy Nguyen
2016-03-09  9:48                     ` Change in .gitignore handling: intended or bug? Duy Nguyen
2016-03-09 18:02                       ` Junio C Hamano
2016-03-10  0:26                         ` Duy Nguyen
2016-03-10  0:37                           ` Junio C Hamano
2016-03-10  0:59                             ` Junio C Hamano
2016-03-10 10:56                               ` Duy Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1457071957.2027843.539286050.10CF8D0A@webmail.messagingengine.com \
    --to=charles@cstrahan.com \
    --cc=git@vger.kernel.org \
    --cc=me@ikke.info \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).