зеркало из https://github.com/microsoft/git.git
Merge branch 'jl/submodule-mv'
Moving a regular file in a repository with a .gitmodules file was producing a warning 'Could not find section in .gitmodules where path=<filename>'. * jl/submodule-mv: mv: Fix spurious warning when moving a file in presence of submodules
This commit is contained in:
Коммит
9dd860c856
13
builtin/mv.c
13
builtin/mv.c
|
@ -55,6 +55,7 @@ static const char *add_slash(const char *path)
|
|||
}
|
||||
|
||||
static struct lock_file lock_file;
|
||||
#define SUBMODULE_WITH_GITDIR ((const char *)1)
|
||||
|
||||
int cmd_mv(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
|
@ -132,6 +133,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
|
|||
submodule_gitfile[i] = read_gitfile(submodule_dotgit.buf);
|
||||
if (submodule_gitfile[i])
|
||||
submodule_gitfile[i] = xstrdup(submodule_gitfile[i]);
|
||||
else
|
||||
submodule_gitfile[i] = SUBMODULE_WITH_GITDIR;
|
||||
strbuf_release(&submodule_dotgit);
|
||||
} else {
|
||||
const char *src_w_slash = add_slash(src);
|
||||
|
@ -230,10 +233,12 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
|
|||
if (!show_only && mode != INDEX) {
|
||||
if (rename(src, dst) < 0 && !ignore_errors)
|
||||
die_errno (_("renaming '%s' failed"), src);
|
||||
if (submodule_gitfile[i])
|
||||
connect_work_tree_and_git_dir(dst, submodule_gitfile[i]);
|
||||
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)
|
||||
|
|
|
@ -293,6 +293,32 @@ test_expect_success 'git mv moves a submodule with a .git directory and no .gitm
|
|||
git diff-files --quiet
|
||||
'
|
||||
|
||||
test_expect_success 'git mv moves a submodule with a .git directory and .gitmodules' '
|
||||
rm -rf mod &&
|
||||
git reset --hard &&
|
||||
git submodule update &&
|
||||
entry="$(git ls-files --stage sub | cut -f 1)" &&
|
||||
(
|
||||
cd sub &&
|
||||
rm -f .git &&
|
||||
cp -a ../.git/modules/sub .git &&
|
||||
GIT_WORK_TREE=. git config --unset core.worktree
|
||||
) &&
|
||||
mkdir mod &&
|
||||
git mv sub mod/sub &&
|
||||
! test -e sub &&
|
||||
[ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] &&
|
||||
(
|
||||
cd mod/sub &&
|
||||
git status
|
||||
) &&
|
||||
echo mod/sub >expected &&
|
||||
git config -f .gitmodules submodule.sub.path >actual &&
|
||||
test_cmp expected actual &&
|
||||
git update-index --refresh &&
|
||||
git diff-files --quiet
|
||||
'
|
||||
|
||||
test_expect_success 'git mv moves a submodule with gitfile' '
|
||||
rm -rf mod/sub &&
|
||||
git reset --hard &&
|
||||
|
|
Загрузка…
Ссылка в новой задаче