diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-08-20 23:42:18 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-08-20 23:42:18 -0700 |
commit | 4a871de89680842ebd43429d5d972375fb765fda (patch) | |
tree | ea1904d11cfe9169d733f57c51cfc49b5f7330a4 /builtin-add.c | |
parent | 22c09307bf0dc9999920763d94c95086e3a55642 (diff) | |
parent | 725b06050a083474e240a2436121e0a80bb9f175 (diff) | |
download | git-4a871de89680842ebd43429d5d972375fb765fda.tar.gz |
Merge branch 'jc/add-stop-at-symlink'
* jc/add-stop-at-symlink:
add: refuse to add working tree items beyond symlinks
update-index: refuse to add working tree items beyond symlinks
Diffstat (limited to 'builtin-add.c')
-rw-r--r-- | builtin-add.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/builtin-add.c b/builtin-add.c index fc3f96eaef..81b64d7b9d 100644 --- 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; } @@ -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 |