Re: 'git add' regression in git-1.7?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]