git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Phil Pennock <phil-gitml@phil.spodhuis.org>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: .gitignore sub-dir exclusions not overriding '*'
Date: Wed, 19 Nov 2014 23:41:36 +0000	[thread overview]
Message-ID: <20141119234136.GA53731@tower.spodhuis.org> (raw)
In-Reply-To: <CACsJy8BHvucnEAW065OXOe5NBQkxp7+8HJb7XCGYgOa=pkxLVA@mail.gmail.com>

On 2014-11-19 at 16:48 +0700, Duy Nguyen wrote:
> On Wed, Nov 19, 2014 at 10:40 AM, Phil Pennock
> <phil-gitml@phil.spodhuis.org> wrote:
> > Expected to work as .gitignore in top-level of repo:
> >
> >     *
> >     !**/*.asc
> >     !.gitignore
> >
> 
> gitignore man page has this "It is not possible to re-include a file
> if a parent directory of that file is excluded". In this case,
> directory "foo" is ignored by "*". Although it makes sense for this
> particular case to re-include something in foo because we can clearly
> see there are rules to re-include. It's on my todo list, but I don't
> know when it will be implemented.

Thanks for this and the patches and discussion which follow.

I didn't cover it in my report, but one of the scenarios I tried was to
explicitly re-include directories, to make them candidates again, and
either use directory-matching patterns in the top-level .gitignore or to
use per-directory .gitignore to handle those directories.

Looking fresh today, I see that I failed to compare baseline behaviour
without a .gitignore when using `git status` as a baseline for
comparison.  So a .gitignore like this:

    *
    !*/
    !*.asc

appeared to not work; even within the `foo/` sub-directory, `git status`
shows no candidates for inclusion.  But this is true even without a
.gitignore.  *sigh*

In fact, it looks like the simple three lines above work, without any
.gitignore in sub-directories.

The behaviour which confused me between this simplified test-case and
the original was that `git status` shows files in the top-level
directory which are untracked, and in untracked files sub-directories
where some other file in that directory is already tracked, but if no
file in the sub-directory is already tracked, then `git status` does not
report the files for inclusion, even if the cwd is inside that
directory.

I tied myself in knots trying to avoid adding unencrypted files to the
repo.

Thanks,
-Phil

  parent reply	other threads:[~2014-11-19 23:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-19  3:40 .gitignore sub-dir exclusions not overriding '*' Phil Pennock
2014-11-19  9:48 ` Duy Nguyen
2014-11-19 10:30   ` [PATCH] dir.c: allow re-include after a dir is excluded in some cases Nguyễn Thái Ngọc Duy
2014-11-19 18:48     ` Junio C Hamano
2014-11-20  0:27       ` Duy Nguyen
2014-11-19 23:41   ` Phil Pennock [this message]
2014-11-20  1:26     ` .gitignore sub-dir exclusions not overriding '*' 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20141119234136.GA53731@tower.spodhuis.org \
    --to=phil-gitml@phil.spodhuis.org \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).