From: Jason Cooper <git@lakedaemon.net>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>,
"lhf635@163.com" <lhf635@163.com>, git <git@vger.kernel.org>
Subject: Re: the opposite of .gitignore, whitelist
Date: Fri, 26 Oct 2018 15:27:54 +0000 [thread overview]
Message-ID: <20181026152754.GF24185@io.lakedaemon.net> (raw)
In-Reply-To: <20181026133453.GE24185@io.lakedaemon.net>
On Fri, Oct 26, 2018 at 01:34:53PM +0000, Jason Cooper wrote:
> On Fri, Oct 26, 2018 at 02:39:26PM +0200, Ævar Arnfjörð Bjarmason wrote:
...
> > I thought this was a bug:
> >
> > (
> > rm -rf /tmp/git &&
> > git init /tmp/git &&
> > cd /tmp/git >/dev/null &&
> > echo '*' >.gitignore &&
> > echo '!*.txt' >>.gitignore &&
> > echo '!.gitignore' >>.gitignore &&
> > touch foo.png foo.txt &&
> > mkdir dir &&
> > touch dir/bar.png dir/bar.txt &&
> > git add *.txt &&
> > git add */*.txt;
> > git status --short
> > )
> >
> > But it's a limitation, gitignore(5) says:
> >
> > It is not possible to re-include a file if a parent directory of
> > that file is excluded. Git doesn’t list excluded directories for
> > performance reasons, so any patterns on contained files have no
> > effect, no matter where they are defined.
>
> Bingo. This is the exact problem I encountered.
(
rm -rf /tmp/git &&
git init /tmp/git &&
cd /tmp/git >/dev/null &&
echo '*' >.gitignore &&
echo '!dir/' >>.gitignore &&
echo '!*.txt' >>.gitignore &&
echo '!.gitignore' >>.gitignore &&
touch foo.png foo.txt &&
mkdir dir &&
echo '*' >dir/.gitignore &&
echo '!*.txt' >>dir/.gitignore &&
echo '!.gitignore' >>dir/.gitignore &&
touch dir/bar.png dir/bar.txt &&
git add *.txt &&
git add */*.txt;
git status --short
)
Well, this wfm...
Ugly, but doable.
thx,
Jason.
prev parent reply other threads:[~2018-10-26 15:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-25 2:39 the opposite of .gitignore, whitelist lhf635
2018-10-25 5:37 ` Junio C Hamano
2018-10-25 14:38 ` Jason Cooper
2018-10-26 9:36 ` Jeff King
2018-10-26 11:31 ` Mischa POSLAWSKY
2018-10-26 11:53 ` Jeff King
2018-10-26 12:39 ` Ævar Arnfjörð Bjarmason
2018-10-26 13:28 ` Rafael Ascensão
2018-10-26 13:34 ` Jason Cooper
2018-10-26 15:27 ` Jason Cooper [this message]
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=20181026152754.GF24185@io.lakedaemon.net \
--to=git@lakedaemon.net \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=lhf635@163.com \
--cc=peff@peff.net \
/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).