From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Avery Pennarun <apenwarr@gmail.com>,
SungHyun Nam <goweol@gmail.com>,
git@vger.kernel.org
Subject: Re: 'git add' regression in git-1.7?
Date: Fri, 19 Feb 2010 03:24:45 -0500 [thread overview]
Message-ID: <20100219082445.GB13691@coredump.intra.peff.net> (raw)
In-Reply-To: <20100219060249.GD22645@coredump.intra.peff.net>
On Fri, Feb 19, 2010 at 01:02:49AM -0500, Jeff King wrote:
> But this is a little disturbing still:
>
> $ git init
> $ mkdir dir
> $ touch dir/sub
> $ touch root
> $ echo dir >.gitignore
> $ echo root >>.gitignore
>
> $ git add root
> The following paths are ignored by one of your .gitignore files:
> root
> Use -f if you really want to add them.
> fatal: no files added
> $ echo $?
> 128
>
> $ git add dir
> The following paths are ignored by one of your .gitignore files:
> dir
> Use -f if you really want to add them.
> fatal: no files added
> $ echo $?
> 128
>
> $ git add dir/sub
> $ echo $?
> 0
>
> but we didn't actually add the file.
Junio,
This seems to be caused by dir.c:treat_one_path. In the first few lines:
int exclude = excluded(dir, path, &dtype);
if (exclude && (dir->flags & DIR_COLLECT_IGNORED)
&& in_pathspec(path, *len, simplify))
dir_add_ignored(dir, path, *len);
we see that the prefix "dir" is excluded, but it is not in our pathspec
("dir/sub"), so we do not add it to the ignored list.
This is related to your recent 48ffef9 (ls-files: fix overeager pathspec
optimization, 2010-01-08), as before then we actually didn't consider
"dir/sub" to be ignored at all. The in_pathspec check did not originate
there; it's from my e96980e (builtin-add: simplify (and increase
accuracy of) exclude handling, 2007-06-12). But it is definitely still
necessary.
I'm not sure of the right way to fix this. We can drop further down into
the directory hierarchy when doing COLLECT_IGNORED and look for actual
files, but that may have a negative performance impact. Perhaps we can
go further only if we are a prefix of a pathspec. Or maybe there is some
way to be more clever.
I dunno. I'm out of ideas for the evening, and since you looked at this
not too long ago, I thought you might have some insight.
-Peff
next prev parent reply other threads:[~2010-02-19 8:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-19 4:30 'git add' regression in git-1.7? SungHyun Nam
2010-02-19 4:42 ` Avery Pennarun
2010-02-19 5:04 ` SungHyun Nam
2010-02-19 5:15 ` Avery Pennarun
2010-02-19 5:34 ` Jeff King
2010-02-19 6:02 ` Jeff King
2010-02-19 8:24 ` Jeff King [this message]
2010-03-01 2:00 ` Junio C Hamano
2010-03-01 3:25 ` [PATCH] add: fail "git add ignored-dir/file" without -f Junio C Hamano
2010-03-01 8:26 ` [PATCH 1/3] t0050: mark non-working test as such Junio C Hamano
2010-03-09 22:37 ` 'git add' regression in git-1.7? Jeff King
2010-03-09 23:09 ` Jeff King
2010-03-10 7:06 ` Junio C Hamano
2010-03-11 7:15 ` Jeff King
2010-03-14 6:34 ` Junio C Hamano
2010-03-14 20:44 ` Jeff King
2010-03-15 2:02 ` Junio C Hamano
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=20100219082445.GB13691@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=apenwarr@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=goweol@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.
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).