path: root/t/
diff options
authorJens Lehmann <>2013-10-13 11:52:05 (GMT)
committerJonathan Nieder <>2013-10-14 05:35:19 (GMT)
commit04c1ee576accad4d0a04f168b86992aba0a6727d (patch)
tree919b6501b0fc1d63389dbd3faee1739884acde60 /t/
parentc5f424fd014488bd8a92b97f52bfe47823bc2128 (diff)
mv: Fix spurious warning when moving a file in presence of submodules
In commit 0656781fa "git mv" learned to update the submodule path in the .gitmodules file when moving a submodule in the work tree. But since that commit update_path_in_gitmodules() gets called no matter if we moved a submodule or a regular file, which is wrong and leads to a bogus warning when moving a regular file in a repo containing a .gitmodules file: warning: Could not find section in .gitmodules where path=<filename> Fix that by only calling update_path_in_gitmodules() when moving a submodule. To achieve that, we introduce the special SUBMODULE_WITH_GITDIR define to distinguish the cases where we also have to connect work tree and git directory from those where we only need to update the .gitmodules setting. A test for submodules using a .git directory together with a .gitmodules file has been added to t7001. Even though newer git versions will always use a gitfile when cloning submodules, repositories cloned with older git versions will still use this layout. Reported-by: Matthieu Moy <> Signed-off-by: Jens Lehmann <> Signed-off-by: Jonathan Nieder <>
Diffstat (limited to 't/')
1 files changed, 26 insertions, 0 deletions
diff --git a/t/ b/t/
index d432f42..b90e985 100755
--- a/t/
+++ b/t/
@@ -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 &&