diff options
Diffstat (limited to 't/t7001-mv.sh')
| -rwxr-xr-x | t/t7001-mv.sh | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh index d72cef8826..879a6dce60 100755 --- a/t/t7001-mv.sh +++ b/t/t7001-mv.sh @@ -4,6 +4,10 @@ test_description='git mv in subdirs' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-diff-data.sh +index_at_path () { + git ls-files --format='%(objectmode) %(objectname) %(stage)' "$@" +} + test_expect_success 'mv -f refreshes updated index entry' ' echo test >bar && git add bar && @@ -170,6 +174,13 @@ test_expect_success 'do not move directory over existing directory' ' test_must_fail git mv path2 path0 ' +test_expect_success 'rename directory to non-existing directory' ' + mkdir dir-a && + >dir-a/f && + git add dir-a && + git mv dir-a non-existing-dir +' + test_expect_success 'move into "."' ' git mv path1/path2/ . ' @@ -187,7 +198,8 @@ test_expect_success "Michael Cassar's test case" ' git mv papers/unsorted/Thesis.pdf papers/all-papers/moo-blah.pdf && T=$(git write-tree) && - git ls-tree -r $T | verbose grep partA/outline.txt + git ls-tree -r $T >out && + grep partA/outline.txt out ' rm -fr papers partA path? @@ -260,12 +272,12 @@ test_expect_success 'git mv should not change sha1 of moved cache entry' ' git init && echo 1 >dirty && git add dirty && - entry="$(git ls-files --stage dirty | cut -f 1)" && + entry="$(index_at_path dirty)" && git mv dirty dirty2 && - test "$entry" = "$(git ls-files --stage dirty2 | cut -f 1)" && + test "$entry" = "$(index_at_path dirty2)" && echo 2 >dirty2 && git mv dirty2 dirty && - test "$entry" = "$(git ls-files --stage dirty | cut -f 1)" + test "$entry" = "$(index_at_path dirty)" ' rm -f dirty dirty2 @@ -284,7 +296,7 @@ test_expect_success 'git mv error on conflicted file' ' EOF test_must_fail git mv conflict newname 2>actual && - test_i18ngrep "conflicted" actual + test_grep "conflicted" actual ' test_expect_success 'git mv should overwrite symlink to a file' ' @@ -342,7 +354,7 @@ test_expect_success 'git mv cannot move a submodule in a file' ' ' test_expect_success 'git mv moves a submodule with a .git directory and no .gitmodules' ' - entry="$(git ls-files --stage sub | cut -f 1)" && + entry="$(index_at_path sub)" && git rm .gitmodules && ( cd sub && @@ -353,7 +365,7 @@ test_expect_success 'git mv moves a submodule with a .git directory and no .gitm mkdir mod && git mv sub mod/sub && test_path_is_missing sub && - test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" && + test "$entry" = "$(index_at_path mod/sub)" && git -C mod/sub status && git update-index --refresh && git diff-files --quiet @@ -363,7 +375,7 @@ test_expect_success 'git mv moves a submodule with a .git directory and .gitmodu rm -rf mod && git reset --hard && git submodule update && - entry="$(git ls-files --stage sub | cut -f 1)" && + entry="$(index_at_path sub)" && ( cd sub && rm -f .git && @@ -373,7 +385,7 @@ test_expect_success 'git mv moves a submodule with a .git directory and .gitmodu mkdir mod && git mv sub mod/sub && test_path_is_missing sub && - test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" && + test "$entry" = "$(index_at_path mod/sub)" && git -C mod/sub status && echo mod/sub >expected && git config -f .gitmodules submodule.sub.path >actual && @@ -386,11 +398,11 @@ test_expect_success 'git mv moves a submodule with gitfile' ' rm -rf mod && git reset --hard && git submodule update && - entry="$(git ls-files --stage sub | cut -f 1)" && + entry="$(index_at_path sub)" && mkdir mod && git -C mod mv ../sub/ . && test_path_is_missing sub && - test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" && + test "$entry" = "$(index_at_path mod/sub)" && git -C mod/sub status && echo mod/sub >expected && git config -f .gitmodules submodule.sub.path >actual && @@ -404,12 +416,12 @@ test_expect_success 'mv does not complain when no .gitmodules file is found' ' git reset --hard && git submodule update && git rm .gitmodules && - entry="$(git ls-files --stage sub | cut -f 1)" && + entry="$(index_at_path sub)" && mkdir mod && git mv sub mod/sub 2>actual.err && test_must_be_empty actual.err && test_path_is_missing sub && - test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" && + test "$entry" = "$(index_at_path mod/sub)" && git -C mod/sub status && git update-index --refresh && git diff-files --quiet @@ -420,7 +432,7 @@ test_expect_success 'mv will error out on a modified .gitmodules file unless sta git reset --hard && git submodule update && git config -f .gitmodules foo.bar true && - entry="$(git ls-files --stage sub | cut -f 1)" && + entry="$(index_at_path sub)" && mkdir mod && test_must_fail git mv sub mod/sub 2>actual.err && test_file_not_empty actual.err && @@ -430,7 +442,7 @@ test_expect_success 'mv will error out on a modified .gitmodules file unless sta git mv sub mod/sub 2>actual.err && test_must_be_empty actual.err && test_path_is_missing sub && - test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" && + test "$entry" = "$(index_at_path mod/sub)" && git -C mod/sub status && git update-index --refresh && git diff-files --quiet @@ -442,13 +454,13 @@ test_expect_success 'mv issues a warning when section is not found in .gitmodule git submodule update && git config -f .gitmodules --remove-section submodule.sub && git add .gitmodules && - entry="$(git ls-files --stage sub | cut -f 1)" && + entry="$(index_at_path sub)" && echo "warning: Could not find section in .gitmodules where path=sub" >expect.err && mkdir mod && git mv sub mod/sub 2>actual.err && test_cmp expect.err actual.err && test_path_is_missing sub && - test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" && + test "$entry" = "$(index_at_path mod/sub)" && git -C mod/sub status && git update-index --refresh && git diff-files --quiet @@ -470,7 +482,7 @@ test_expect_success 'checking out a commit before submodule moved needs manual u git mv sub sub2 && git commit -m "moved sub to sub2" && git checkout -q HEAD^ 2>actual && - test_i18ngrep "^warning: unable to rmdir '\''sub2'\'':" actual && + test_grep "^warning: unable to rmdir '\''sub2'\'':" actual && git status -s sub2 >actual && echo "?? sub2/" >expected && test_cmp expected actual && |
