diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-09-17 22:53:47 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-09-17 22:53:47 +0200 |
commit | c2407322b6f248955d8ce8d1d453f2dc1b03e618 (patch) | |
tree | bb7e887651dc1023ebc3ab432fd7b678ed8549e0 /entry.c | |
parent | Merge branch 'mk/http-backend-content-length' (diff) | |
parent | clone: report duplicate entries on case-insensitive filesystems (diff) | |
download | git-c2407322b6f248955d8ce8d1d453f2dc1b03e618.tar.xz git-c2407322b6f248955d8ce8d1d453f2dc1b03e618.zip |
Merge branch 'nd/clone-case-smashing-warning'
Running "git clone" against a project that contain two files with
pathnames that differ only in cases on a case insensitive
filesystem would result in one of the files lost because the
underlying filesystem is incapable of holding both at the same
time. An attempt is made to detect such a case and warn.
* nd/clone-case-smashing-warning:
clone: report duplicate entries on case-insensitive filesystems
Diffstat (limited to 'entry.c')
-rw-r--r-- | entry.c | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -399,6 +399,34 @@ static int check_path(const char *path, int len, struct stat *st, int skiplen) return lstat(path, st); } +static void mark_colliding_entries(const struct checkout *state, + struct cache_entry *ce, struct stat *st) +{ + int i, trust_ino = check_stat; + +#if defined(GIT_WINDOWS_NATIVE) + trust_ino = 0; +#endif + + ce->ce_flags |= CE_MATCHED; + + for (i = 0; i < state->istate->cache_nr; i++) { + struct cache_entry *dup = state->istate->cache[i]; + + if (dup == ce) + break; + + if (dup->ce_flags & (CE_MATCHED | CE_VALID | CE_SKIP_WORKTREE)) + continue; + + if ((trust_ino && dup->ce_stat_data.sd_ino == st->st_ino) || + (!trust_ino && !fspathcmp(ce->name, dup->name))) { + dup->ce_flags |= CE_MATCHED; + break; + } + } +} + /* * Write the contents from ce out to the working tree. * @@ -456,6 +484,9 @@ int checkout_entry(struct cache_entry *ce, return -1; } + if (state->clone) + mark_colliding_entries(state, ce, &st); + /* * We unlink the old file, to get the new one with the * right permissions (including umask, which is nasty |