diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-08-25 14:47:56 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-08-25 14:47:56 -0700 |
commit | 3613339eaf3638f7a22ee55f914308f8bab5f2cf (patch) | |
tree | 1721427f802507e63211f24db2dc41ad36184e43 | |
parent | Merge branch 'jl/submodule-summary-diff-files' (diff) | |
parent | check_path(): allow symlinked directories to checkout-index --prefix (diff) | |
download | tgif-3613339eaf3638f7a22ee55f914308f8bab5f2cf.tar.xz |
Merge branch 'jc/maint-checkout-index-to-prefix'
* jc/maint-checkout-index-to-prefix:
check_path(): allow symlinked directories to checkout-index --prefix
-rw-r--r-- | cache.h | 2 | ||||
-rw-r--r-- | entry.c | 12 | ||||
-rwxr-xr-x | t/t2000-checkout-cache-clash.sh | 9 |
3 files changed, 18 insertions, 5 deletions
@@ -469,7 +469,7 @@ extern int index_path(unsigned char *sha1, const char *path, struct stat *st, in extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st); /* "careful lstat()" */ -extern int check_path(const char *path, int len, struct stat *st); +extern int check_path(const char *path, int len, struct stat *st, int skiplen); #define REFRESH_REALLY 0x0001 /* ignore_valid */ #define REFRESH_UNMERGED 0x0002 /* allow unmerged */ @@ -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; diff --git a/t/t2000-checkout-cache-clash.sh b/t/t2000-checkout-cache-clash.sh index f7e1a735ec..de3edb5d57 100755 --- a/t/t2000-checkout-cache-clash.sh +++ b/t/t2000-checkout-cache-clash.sh @@ -48,4 +48,13 @@ test_expect_success \ 'git checkout-index conflicting paths.' \ 'test -f path0 && test -d path1 && test -f path1/file1' +test_expect_success SYMLINKS 'checkout-index -f twice with --prefix' ' + mkdir -p tar/get && + ln -s tar/get there && + echo first && + git checkout-index -a -f --prefix=there/ && + echo second && + git checkout-index -a -f --prefix=there/ +' + test_done |