Re: [RFC/PATCH] git-add: Don't exclude explicitly-specified tracked files
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Aug 12, 2010, 08:30 UTC
- Message-ID
- <vpqsk2kjks7.fsf@bauges.imag.fr>
- In-Reply-To
- <1281510236-8103-1-git-send-email-gdb@mit.edu>
Greg Brockman <gdb@MIT.EDU> writes:
> Currently, 'git add' will complain about excluded files, even if they > are already tracked:
This is not exactly true:
$ echo '*.pdf' > .gitignore; touch foo.pdf; git add -f foo.pdf $ echo content >> foo.pdf; git add foo.pdf
Here, the second "git add" didn't need the -f flag.
So, your problem is not about already-tracked exclude files, but it is about already-tracked files in an excluded directory.
> This commit changes 'git add' to disregard excludes for tracked files > whose paths are explicitly specified on the command-line.
I don't think you need this to solve the problem, and as Junio said, that would make "git add dir/*" add all the ignored files, which would make -f essentially useless.
After a quick look at the code, the issue seems close to (dir.c):
struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len)
{
if (!cache_name_is_other(pathname, len))
return NULL;ALLOC_GROW(dir->ignored, dir->ignored_nr+1, dir->ignored_alloc); return dir->ignored[dir->ignored_nr++] = dir_entry_new(pathname, len); }
I guess the "if (!cache_name_is_other(pathname, len))" test is the one allowing the behavior I got above, but here, in the case of "git add dir/file" with "dir" being ignored, "pathname" is just "dir", not "dir/file", hence your problem.
-- Matthieu Moy http://www-verimag.imag.fr/~moy/