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

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

 



Greg Brockman <gdb@xxxxxxx> 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/
--
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]