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 /unpack-trees.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 'unpack-trees.c')
-rw-r--r-- | unpack-trees.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/unpack-trees.c b/unpack-trees.c index f25089b878..cfa88bb6ec 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -336,6 +336,46 @@ static struct progress *get_progress(struct unpack_trees_options *o) return start_delayed_progress(_("Checking out files"), total); } +static void setup_collided_checkout_detection(struct checkout *state, + struct index_state *index) +{ + int i; + + state->clone = 1; + for (i = 0; i < index->cache_nr; i++) + index->cache[i]->ce_flags &= ~CE_MATCHED; +} + +static void report_collided_checkout(struct index_state *index) +{ + struct string_list list = STRING_LIST_INIT_NODUP; + int i; + + for (i = 0; i < index->cache_nr; i++) { + struct cache_entry *ce = index->cache[i]; + + if (!(ce->ce_flags & CE_MATCHED)) + continue; + + string_list_append(&list, ce->name); + ce->ce_flags &= ~CE_MATCHED; + } + + list.cmp = fspathcmp; + string_list_sort(&list); + + if (list.nr) { + warning(_("the following paths have collided (e.g. case-sensitive paths\n" + "on a case-insensitive filesystem) and only one from the same\n" + "colliding group is in the working tree:\n")); + + for (i = 0; i < list.nr; i++) + fprintf(stderr, " '%s'\n", list.items[i].string); + } + + string_list_clear(&list, 0); +} + static int check_updates(struct unpack_trees_options *o) { unsigned cnt = 0; @@ -350,6 +390,9 @@ static int check_updates(struct unpack_trees_options *o) state.refresh_cache = 1; state.istate = index; + if (o->clone) + setup_collided_checkout_detection(&state, index); + progress = get_progress(o); if (o->update) @@ -414,6 +457,10 @@ static int check_updates(struct unpack_trees_options *o) errs |= finish_delayed_checkout(&state); if (o->update) git_attr_set_direction(GIT_ATTR_CHECKIN); + + if (o->clone) + report_collided_checkout(index); + return errs != 0; } |