summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-08-04 07:52:37 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-08-05 06:31:23 (GMT)
commit725b06050a083474e240a2436121e0a80bb9f175 (patch)
tree3831874f7cce9b6307bcf3816525f66973878eba /dir.c
parent806d13b1ccdbdde4bbdfb96902791c4b7ed125f6 (diff)
downloadgit-725b06050a083474e240a2436121e0a80bb9f175.zip
git-725b06050a083474e240a2436121e0a80bb9f175.tar.gz
git-725b06050a083474e240a2436121e0a80bb9f175.tar.bz2
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>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/dir.c b/dir.c
index 29d1d5b..ae7046f 100644
--- a/dir.c
+++ b/dir.c
@@ -727,8 +727,12 @@ static void free_simplify(struct path_simplify *simplify)
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);