From: Junio C Hamano Date: Tue, 6 Mar 2018 22:54:00 +0000 (-0800) Subject: Merge branch 'sm/mv-dry-run-update' X-Git-Tag: v2.17.0-rc0~49 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/a4ae2e5a1c45890f5eeccb2d1989a15c07f99e3d?hp=-c Merge branch 'sm/mv-dry-run-update' Code clean-up. * sm/mv-dry-run-update: mv: remove unneeded 'if (!show_only)' t7001: add test case for --dry-run --- a4ae2e5a1c45890f5eeccb2d1989a15c07f99e3d diff --combined builtin/mv.c index cf3684d907,9662804d23..8ce6a2ddd4 --- a/builtin/mv.c +++ b/builtin/mv.c @@@ -81,7 -81,7 +81,7 @@@ static void prepare_move_submodule(cons struct strbuf submodule_dotgit = STRBUF_INIT; if (!S_ISGITLINK(active_cache[first]->ce_mode)) die(_("Directory %s is in index and no submodule?"), src); - if (!is_staging_gitmodules_ok()) + if (!is_staging_gitmodules_ok(&the_index)) die(_("Please stage your changes to .gitmodules or stash them to proceed")); strbuf_addf(&submodule_dotgit, "%s/.git", src); *submodule_gitfile = read_gitfile(submodule_dotgit.buf); @@@ -131,6 -131,7 +131,6 @@@ int cmd_mv(int argc, const char **argv struct stat st; struct string_list src_for_dst = STRING_LIST_INIT_NODUP; - gitmodules_config(); git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, builtin_mv_options, @@@ -286,12 -287,11 +286,11 @@@ pos = cache_name_pos(src, strlen(src)); assert(pos >= 0); - if (!show_only) - rename_cache_entry_at(pos, dst); + rename_cache_entry_at(pos, dst); } if (gitmodules_modified) - stage_updated_gitmodules(); + stage_updated_gitmodules(&the_index); if (active_cache_changed && write_locked_index(&the_index, &lock_file, COMMIT_LOCK)) diff --combined t/t7001-mv.sh index 6e5031f56f,1744ed4607..d4e6485a26 --- a/t/t7001-mv.sh +++ b/t/t7001-mv.sh @@@ -38,6 -38,12 +38,12 @@@ test_expect_success 'git diff-tree -r -M --name-status HEAD^ HEAD | \ grep "^R100..*path1/COPYING..*path0/COPYING"' + test_expect_success \ + 'mv --dry-run does not move file' \ + 'git mv -n path0/COPYING MOVED && + test -f path0/COPYING && + test ! -f MOVED' + test_expect_success \ 'checking -k on non-existing file' \ 'git mv -k idontexist path0' @@@ -452,7 -458,7 +458,7 @@@ test_expect_success 'checking out a com 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_i18ngrep "^warning: unable to rmdir '\''sub2'\'':" actual && git status -s sub2 >actual && echo "?? sub2/" >expected && test_cmp expected actual && @@@ -488,32 -494,7 +494,32 @@@ test_expect_success 'moving a submodul git config -f ../.gitmodules submodule.deep/directory/hierarchy/sub.path >../actual && echo "directory/hierarchy/sub" >../expect ) && - test_cmp actual expect + test_cmp expect actual +' + +test_expect_failure 'moving nested submodules' ' + git commit -am "cleanup commit" && + mkdir sub_nested_nested && + (cd sub_nested_nested && + touch nested_level2 && + git init && + git add . && + git commit -m "nested level 2" + ) && + mkdir sub_nested && + (cd sub_nested && + touch nested_level1 && + git init && + git add . && + git commit -m "nested level 1" + git submodule add ../sub_nested_nested && + git commit -m "add nested level 2" + ) && + git submodule add ./sub_nested nested_move && + git commit -m "add nested_move" && + git submodule update --init --recursive && + git mv nested_move sub_nested_moved && + git status ' test_done