summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2016-04-19 18:32:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-04-19 18:54:50 (GMT)
commita127331cd812336235cb95b45b7e4c52c433be7f (patch)
tree81371dd5392e9b10904a4cfd668dad0e06ca996f /builtin
parente46579643d56162299b1756b70d418005351b256 (diff)
downloadgit-a127331cd812336235cb95b45b7e4c52c433be7f.zip
git-a127331cd812336235cb95b45b7e4c52c433be7f.tar.gz
git-a127331cd812336235cb95b45b7e4c52c433be7f.tar.bz2
mv: allow moving nested submodules
When directories are moved using `git mv` all files in the directory have been just moved, but no further action was taken on them. This was done by assigning the mode = WORKING_DIRECTORY to the files inside a moved directory. submodules however need to update their link to the git directory as well as updates to the .gitmodules file. By removing the condition of `mode != INDEX` (the remaining modes are BOTH and WORKING_DIRECTORY) for the required submodule actions, we perform these for submodules in a moved directory. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/mv.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/builtin/mv.c b/builtin/mv.c
index d1d4316..c789501 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -251,15 +251,18 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
int pos;
if (show_only || verbose)
printf(_("Renaming %s to %s\n"), src, dst);
- if (!show_only && mode != INDEX) {
- if (rename(src, dst) < 0 && !ignore_errors)
- die_errno(_("renaming '%s' failed"), src);
- if (submodule_gitfile[i]) {
- if (submodule_gitfile[i] != SUBMODULE_WITH_GITDIR)
- connect_work_tree_and_git_dir(dst, submodule_gitfile[i]);
- if (!update_path_in_gitmodules(src, dst))
- gitmodules_modified = 1;
- }
+ if (show_only)
+ continue;
+ if (mode != INDEX && rename(src, dst) < 0) {
+ if (ignore_errors)
+ continue;
+ die_errno(_("renaming '%s' failed"), src);
+ }
+ if (submodule_gitfile[i]) {
+ if (submodule_gitfile[i] != SUBMODULE_WITH_GITDIR)
+ connect_work_tree_and_git_dir(dst, submodule_gitfile[i]);
+ if (!update_path_in_gitmodules(src, dst))
+ gitmodules_modified = 1;
}
if (mode == WORKING_DIRECTORY)