{"thread":{"id":"3540","subject":"[PATCH] git-mv: fix moves into a subdir from outside","startedAt":"2006-03-03T16:23:32Z","lastAt":"2006-03-03T16:23:32Z","messageCount":1,"participants":["Josef Weidendorfer"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"17119","messageId":"200603031723.32905.Josef.Weidendorfer@gmx.de","threadId":"3540","inReplyTo":null,"subject":"[PATCH] git-mv: fix moves into a subdir from outside","fromName":"Josef Weidendorfer","fromEmail":"josef.weidendorfer@gmx.de","sentAt":"2006-03-03T16:23:32Z","receivedAt":"2006-03-03T16:23:32Z","isPatch":true,"sender":{"key":"josef.weidendorfer@gmx.de","avatar":null},"body":"git-mv needs to be run from the base directory so that\nthe check if a file is under revision also covers files\noutside of a subdirectory. Previously, e.g. in the git repo,\n\n  cd Documentation; git-mv ../README .\n\nproduced the error\n\n  Error: '../README' not under version control\n\nThe test is extended for this case; it previously only tested\none direction.\n\nSigned-off-by: Josef Weidendorfer <Josef.Weidendorfer@gmx.de>\n\n---\n\n git-mv.perl   |    8 ++++++++\n t/t7001-mv.sh |   18 ++++++++++++++++--\n 2 files changed, 24 insertions(+), 2 deletions(-)\n\n08d21abe95064934ea559b88801415e09b19f628\ndiff --git a/git-mv.perl b/git-mv.perl\nindex f3e859a..0a63860 100755\n--- a/git-mv.perl\n+++ b/git-mv.perl\n@@ -62,9 +62,17 @@ else {\n     $dstDir = \"\";\n }\n \n+my $subdir_prefix = `git rev-parse --show-prefix`;\n+chomp($subdir_prefix);\n+\n+# run in git base directory, so that git-ls-files lists all revisioned files\n+chdir \"$GIT_DIR/..\";\n+\n # normalize paths, needed to compare against versioned files and update-index\n # also, this is nicer to end-users by doing \".//a/./b/.//./c\" ==> \"a/b/c\"\n for (@srcArgs, @dstArgs) {\n+    # prepend git prefix as we run from base directory\n+    $_ = $subdir_prefix.$_;\n     s|^\\./||;\n     s|/\\./|/| while (m|/\\./|);\n     s|//+|/|g;\ndiff --git a/t/t7001-mv.sh b/t/t7001-mv.sh\nindex 43d74c5..811a479 100755\n--- a/t/t7001-mv.sh\n+++ b/t/t7001-mv.sh\n@@ -11,17 +11,31 @@ test_expect_success \\\n      git-commit -m add -a'\n \n test_expect_success \\\n-    'moving the file' \\\n+    'moving the file out of subdirectory' \\\n     'cd path0 && git-mv COPYING ../path1/COPYING'\n \n # in path0 currently\n test_expect_success \\\n     'commiting the change' \\\n-    'cd .. && git-commit -m move -a'\n+    'cd .. && git-commit -m move-out -a'\n \n test_expect_success \\\n     'checking the commit' \\\n     'git-diff-tree -r -M --name-status  HEAD^ HEAD | \\\n     grep -E \"^R100.+path0/COPYING.+path1/COPYING\"'\n \n+test_expect_success \\\n+    'moving the file back into subdirectory' \\\n+    'cd path0 && git-mv ../path1/COPYING COPYING'\n+\n+# in path0 currently\n+test_expect_success \\\n+    'commiting the change' \\\n+    'cd .. && git-commit -m move-in -a'\n+\n+test_expect_success \\\n+    'checking the commit' \\\n+    'git-diff-tree -r -M --name-status  HEAD^ HEAD | \\\n+    grep -E \"^R100.+path1/COPYING.+path0/COPYING\"'\n+\n test_done\n-- \n1.2.0.g719b\n"}]}