path: root/t/
diff options
authorJens Lehmann <>2013-07-30 19:50:03 (GMT)
committerJunio C Hamano <>2013-07-30 20:52:53 (GMT)
commita88c915de9886fe17005a5daff4900ced0ea76ad (patch)
tree3a969c58914c856210aa9e4770c66d2e7959a316 /t/
parent11502468287fdd62a22c43766881d21ab4fcf31c (diff)
mv: move submodules using a gitfile
When moving a submodule which uses a gitfile to point to the git directory stored in .git/modules/<name> of the superproject two changes must be made to make the submodule work: the .git file and the core.worktree setting must be adjusted to point from work tree to git directory and back. Achieve that by remembering which submodule uses a gitfile by storing the result of read_gitfile() of each submodule. If that is not NULL the new function connect_work_tree_and_git_dir() is called after renaming the submodule's work tree which updates the two settings to the new values. Extend the man page to inform the user about that feature (and while at it change the description to not talk about a script anymore, as mv is a builtin for quite some time now). Signed-off-by: Jens Lehmann <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 19 insertions, 0 deletions
diff --git a/t/ b/t/
index 15c18b6..b99177f 100755
--- a/t/
+++ b/t/
@@ -293,4 +293,23 @@ 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 gitfile' '
+ rm -rf mod/sub &&
+ git reset --hard &&
+ git submodule update &&
+ entry="$(git ls-files --stage sub | cut -f 1)" &&
+ (
+ cd mod &&
+ git mv ../sub/ .
+ ) &&
+ ! test -e sub &&
+ [ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] &&
+ (
+ cd mod/sub &&
+ git status
+ ) &&
+ git update-index --refresh &&
+ git diff-files --quiet