add: refuse to add working tree items beyond symlinks

This is the same fix for the issue of adding "sym/path" when "sym" is a
symblic link that points at a directory "dir" with "path" in it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2008-08-04 00:52:37 -07:00
parent 806d13b1cc
commit 725b06050a
3 changed files with 22 additions and 3 deletions

View File

@ -153,6 +153,16 @@ static const char **validate_pathspec(int argc, const char **argv, const char *p
{
const char **pathspec = get_pathspec(prefix, argv);
if (pathspec) {
const char **p;
for (p = pathspec; *p; p++) {
if (has_symlink_leading_path(strlen(*p), *p)) {
int len = prefix ? strlen(prefix) : 0;
die("'%s' is beyond a symbolic link", *p + len);
}
}
}
return pathspec;
}
@ -278,7 +288,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
fprintf(stderr, "Maybe you wanted to say 'git add .'?\n");
return 0;
}
pathspec = get_pathspec(prefix, argv);
pathspec = validate_pathspec(argc, argv, prefix);
/*
* If we are adding new files, we need to scan the working