summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 806d13b)
raw | patch | inline | side by side (parent: 806d13b)
author | Junio C Hamano <gitster@pobox.com> | |
Mon, 4 Aug 2008 07:52:37 +0000 (00:52 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 5 Aug 2008 06:31:23 +0000 (23:31 -0700) |
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>
symblic link that points at a directory "dir" with "path" in it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-add.c | patch | blob | history | |
dir.c | patch | blob | history | |
t/t0055-beyond-symlinks.sh | patch | blob | history |
diff --git a/builtin-add.c b/builtin-add.c
index fc3f96eaefff91e4e85adb92162716939f0ecd72..81b64d7b9d69f06fff70870e8a55fc4ad506133e 100644 (file)
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -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;
}
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
index 29d1d5ba31def46ba8b55905dc60773cc6cc167e..ae7046fd034ab828aa7e867ad9cbaa553d5edc0d 100644 (file)
--- a/dir.c
+++ b/dir.c
int read_directory(struct dir_struct *dir, const char *path, const char *base, int baselen, const char **pathspec)
{
- struct path_simplify *simplify = create_simplify(pathspec);
+ struct path_simplify *simplify;
+ if (has_symlink_leading_path(strlen(path), path))
+ return dir->nr;
+
+ simplify = create_simplify(pathspec);
read_directory_recursive(dir, path, base, baselen, 0, simplify);
free_simplify(simplify);
qsort(dir->entries, dir->nr, sizeof(struct dir_entry *), cmp_name);
index eb11dd7821cfab0162751d2684aa7098f851e322..b29c37a5a4de42239474c4fdf87c86c6f27b6ade 100755 (executable)
#!/bin/sh
-test_description='update-index refuses to add beyond symlinks'
+test_description='update-index and add refuse to add beyond symlinks'
. ./test-lib.sh
! ( git ls-files | grep c/d )
'
+test_expect_success 'add beyond symlinks' '
+ test_must_fail git add c/d &&
+ ! ( git ls-files | grep c/d )
+'
+
test_done