Thread (7 messages) 7 messages, 3 authors, 2016-06-15

Re: [RFC/PATCH] git-add: Don't exclude explicitly-specified tracked files

From: Matthieu Moy <hidden>
Date: 2016-06-15 22:49:18

Possibly related (same subject, not in this thread)

Greg Brockman [off-list ref] 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/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help