aboutsummaryrefslogtreecommitdiffstats
path: root/entry.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-08-10 22:15:41 -0700
committerJunio C Hamano <gitster@pobox.com>2009-08-10 22:15:41 -0700
commit6eedee514eb39f2b097cd572b47946cef6ea88e6 (patch)
treec8dbaa255d1cc0a7ced714afa3b6f3c303ee4ce3 /entry.c
parent67f272c2f21a3d5a372b113b91836455d45257a7 (diff)
parentb6b0737d02e3bb9b3015ec66f5b6454d5b83d57b (diff)
downloadgit-6eedee514eb39f2b097cd572b47946cef6ea88e6.tar.gz
Merge branch 'jp/symlink-dirs'
* jp/symlink-dirs: t6035-merge-dir-to-symlink depends on SYMLINKS prerequisite git-checkout: be careful about untracked symlinks lstat_cache: guard against full match of length of 'name' parameter Demonstrate bugs when a directory is replaced with a symlink
Diffstat (limited to 'entry.c')
-rw-r--r--entry.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/entry.c b/entry.c
index d3e86c722a..f276cf3b88 100644
--- a/entry.c
+++ b/entry.c
@@ -175,6 +175,19 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout
return 0;
}
+/*
+ * This is like 'lstat()', except it refuses to follow symlinks
+ * in the path.
+ */
+int check_path(const char *path, int len, struct stat *st)
+{
+ if (has_symlink_leading_path(path, len)) {
+ errno = ENOENT;
+ return -1;
+ }
+ return lstat(path, st);
+}
+
int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath)
{
static char path[PATH_MAX + 1];
@@ -188,7 +201,7 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *t
strcpy(path + len, ce->name);
len += ce_namelen(ce);
- if (!lstat(path, &st)) {
+ if (!check_path(path, len, &st)) {
unsigned changed = ce_match_stat(ce, &st, CE_MATCH_IGNORE_VALID);
if (!changed)
return 0;