X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=entry.c;h=06d24f14c6ba9401637aebfb11659ae747796c06;hb=9f3d54d193d9edcf443c9dd62789af5e8e47635c;hp=f276cf3b88ea40cb4e6d03c623ce27cb0204c63e;hpb=daf85d97f8ae4ba462e55c79b1520342028f24d7;p=git.git diff --git a/entry.c b/entry.c index f276cf3b8..06d24f14c 100644 --- a/entry.c +++ b/entry.c @@ -177,11 +177,15 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout /* * This is like 'lstat()', except it refuses to follow symlinks - * in the path. + * in the path, after skipping "skiplen". */ -int check_path(const char *path, int len, struct stat *st) +int check_path(const char *path, int len, struct stat *st, int skiplen) { - if (has_symlink_leading_path(path, len)) { + const char *slash = path + len; + + while (path < slash && *slash != '/') + slash--; + if (!has_dirs_only_path(path, slash - path, skiplen)) { errno = ENOENT; return -1; } @@ -201,7 +205,7 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *t strcpy(path + len, ce->name); len += ce_namelen(ce); - if (!check_path(path, len, &st)) { + if (!check_path(path, len, &st, state->base_dir_len)) { unsigned changed = ce_match_stat(ce, &st, CE_MATCH_IGNORE_VALID); if (!changed) return 0;