Message ID | 20181022215236.72238-1-sbeller@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Bug with "git mv" and submodules, and with "git submodule add something --force" | expand |
Stefan Beller <sbeller@google.com> writes: >> You would want to be able to remove a submodule and replace it with >> a directory, but you can probably do it in two steps, i.e. >> >> git reset --hard >> git rm --cached sha1collisiondetection >> echo Now a regular dir >sha1collisiondetection/READ.ME >> find sha1collisiondetection ! -type d -print0 | >> git update-index --add --stdin -z > > "Ignoring path sha1collisiondetection/.git" > > Nice! There actually is another possible outcome that anybody following along must be aware of and be careful about: not even .git directory exist there, i.e. it is possible that the submodule has never been init'ed. So, it is not that nice X-<.
diff --git a/builtin/mv.c b/builtin/mv.c index 80bb967a63..9ec4b2f0a3 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -172,7 +172,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) /* Checking */ for (i = 0; i < argc; i++) { const char *src = source[i], *dst = destination[i]; - int length, src_is_dir; + int length, src_is_dir, pos; const char *bad = NULL; if (show_only) @@ -243,6 +243,13 @@ int cmd_mv(int argc, const char **argv, const char *prefix) else string_list_insert(&src_for_dst, dst); + pos = cache_name_pos(dst, strlen(dst)); + if (pos < 0) { + pos = -(pos + 1); + if (!S_ISGITLINK(active_cache[pos]->ce_mode)) + bad = _("moving across submodule boundaries not supported"); + } + if (!bad) continue; if (!ignore_errors)