log: fix indentation for --graph --show-signature
[gitweb.git] / t / t7001-mv.sh
index d432f42bcbd509b0dae46848d2745eba26fc6872..3bfdfed1f7774edb8a87864bdb6a021dc6a185ed 100755 (executable)
@@ -70,6 +70,35 @@ test_expect_success \
 rm -f idontexist untracked1 untracked2 \
      path0/idontexist path0/untracked1 path0/untracked2 \
      .git/index.lock
+rmdir path1
+
+test_expect_success \
+    'moving to absent target with trailing slash' \
+    'test_must_fail git mv path0/COPYING no-such-dir/ &&
+     test_must_fail git mv path0/COPYING no-such-dir// &&
+     git mv path0/ no-such-dir/ &&
+     test_path_is_dir no-such-dir'
+
+test_expect_success \
+    'clean up' \
+    'git reset --hard'
+
+test_expect_success \
+    'moving to existing untracked target with trailing slash' \
+    'mkdir path1 &&
+     git mv path0/ path1/ &&
+     test_path_is_dir path1/path0/'
+
+test_expect_success \
+    'moving to existing tracked target with trailing slash' \
+    'mkdir path2 &&
+     >path2/file && git add path2/file &&
+     git mv path1/path0/ path2/ &&
+     test_path_is_dir path2/path0/'
+
+test_expect_success \
+    'clean up' \
+    'git reset --hard'
 
 test_expect_success \
     'adding another file' \
@@ -293,6 +322,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 &&