summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-11-01 07:38:26 -0700
committerJunio C Hamano <gitster@pobox.com>2013-11-01 07:38:27 -0700
commit9dd860c8562917dbbdd595d5f9997b6856dbeb0a (patch)
tree144744d5287fbea0e785e3148783a11571acb20e /builtin
parent42817b96b1b80b56fd5a4d5e0d6239524b1832a3 (diff)
parent04c1ee576accad4d0a04f168b86992aba0a6727d (diff)
downloadgit-9dd860c8562917dbbdd595d5f9997b6856dbeb0a.tar.gz
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
Diffstat (limited to 'builtin')
-rw-r--r--builtin/mv.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/builtin/mv.c b/builtin/mv.c
index aec79d1838..2e0e61b651 100644
--- a/builtin/mv.c
+++ b/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)