зеркало из https://github.com/microsoft/git.git
Merge branch 'sb/mv-submodule-fix'
"git mv old new" did not adjust the path for a submodule that lives as a subdirectory inside old/ directory correctly. * sb/mv-submodule-fix: mv: allow moving nested submodules
This commit is contained in:
Коммит
9cb50a3ca6
21
builtin/mv.c
21
builtin/mv.c
|
@ -252,15 +252,18 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
|
||||||
int pos;
|
int pos;
|
||||||
if (show_only || verbose)
|
if (show_only || verbose)
|
||||||
printf(_("Renaming %s to %s\n"), src, dst);
|
printf(_("Renaming %s to %s\n"), src, dst);
|
||||||
if (!show_only && mode != INDEX) {
|
if (show_only)
|
||||||
if (rename(src, dst) < 0 && !ignore_errors)
|
continue;
|
||||||
die_errno(_("renaming '%s' failed"), src);
|
if (mode != INDEX && rename(src, dst) < 0) {
|
||||||
if (submodule_gitfile[i]) {
|
if (ignore_errors)
|
||||||
if (submodule_gitfile[i] != SUBMODULE_WITH_GITDIR)
|
continue;
|
||||||
connect_work_tree_and_git_dir(dst, submodule_gitfile[i]);
|
die_errno(_("renaming '%s' failed"), src);
|
||||||
if (!update_path_in_gitmodules(src, dst))
|
}
|
||||||
gitmodules_modified = 1;
|
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)
|
if (mode == WORKING_DIRECTORY)
|
||||||
|
|
|
@ -292,6 +292,9 @@ test_expect_success 'setup submodule' '
|
||||||
echo content >file &&
|
echo content >file &&
|
||||||
git add file &&
|
git add file &&
|
||||||
git commit -m "added sub and file" &&
|
git commit -m "added sub and file" &&
|
||||||
|
mkdir -p deep/directory/hierachy &&
|
||||||
|
git submodule add ./. deep/directory/hierachy/sub &&
|
||||||
|
git commit -m "added another submodule" &&
|
||||||
git branch submodule
|
git branch submodule
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -475,4 +478,17 @@ test_expect_success 'mv -k does not accidentally destroy submodules' '
|
||||||
git checkout .
|
git checkout .
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'moving a submodule in nested directories' '
|
||||||
|
(
|
||||||
|
cd deep &&
|
||||||
|
git mv directory ../ &&
|
||||||
|
# git status would fail if the update of linking git dir to
|
||||||
|
# work dir of the submodule failed.
|
||||||
|
git status &&
|
||||||
|
git config -f ../.gitmodules submodule.deep/directory/hierachy/sub.path >../actual &&
|
||||||
|
echo "directory/hierachy/sub" >../expect
|
||||||
|
) &&
|
||||||
|
test_cmp actual expect
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Загрузка…
Ссылка в новой задаче