diff options
author | Josef Weidendorfer <Josef.Weidendorfer@gmx.de> | 2006-03-03 17:23:32 +0100 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-03-03 11:28:28 -0800 |
commit | 90924d55c5fc4205b2d41821a3288d478aa661a0 (patch) | |
tree | 5e4623fdbbfd3d04665f2ace8d8dc1bbf77d4d7a /git-mv.perl | |
parent | 8e69b31e0da6e5a540a3ca2ca16d59f3411385bc (diff) | |
download | git-90924d55c5fc4205b2d41821a3288d478aa661a0.tar.gz git-90924d55c5fc4205b2d41821a3288d478aa661a0.tar.xz |
git-mv: fix moves into a subdir from outside
git-mv needs to be run from the base directory so that
the check if a file is under revision also covers files
outside of a subdirectory. Previously, e.g. in the git repo,
cd Documentation; git-mv ../README .
produced the error
Error: '../README' not under version control
The test is extended for this case; it previously only tested
one direction.
Signed-off-by: Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-mv.perl')
-rwxr-xr-x | git-mv.perl | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/git-mv.perl b/git-mv.perl index fe9c40e1b..75aa8feeb 100755 --- a/git-mv.perl +++ b/git-mv.perl @@ -62,9 +62,17 @@ else { $dstDir = ""; } +my $subdir_prefix = `git rev-parse --show-prefix`; +chomp($subdir_prefix); + +# run in git base directory, so that git-ls-files lists all revisioned files +chdir "$GIT_DIR/.."; + # normalize paths, needed to compare against versioned files and update-index # also, this is nicer to end-users by doing ".//a/./b/.//./c" ==> "a/b/c" for (@srcArgs, @dstArgs) { + # prepend git prefix as we run from base directory + $_ = $subdir_prefix.$_; s|^\./||; s|/\./|/| while (m|/\./|); s|//+|/|g; |