aboutsummaryrefslogtreecommitdiff
path: root/git-mv.perl
diff options
context:
space:
mode:
authorJosef Weidendorfer <Josef.Weidendorfer@gmx.de>2006-03-01 18:16:36 +0100
committerJunio C Hamano <junkio@cox.net>2006-03-01 12:13:44 -0800
commit5e6f85f6c1d988d125dfcba16bb43a9a65f9eab3 (patch)
tree198ccbfae47015906570eadffdc02e9839d6ed17 /git-mv.perl
parent573464319f70bd54a7c48cfd7bed6a0f6f331f42 (diff)
downloadgit-5e6f85f6c1d988d125dfcba16bb43a9a65f9eab3.tar.gz
git-5e6f85f6c1d988d125dfcba16bb43a9a65f9eab3.tar.xz
git-mv: Allow -h without repo & fix error message
This fixes "git-mv -h" to output the usage without the need to be in a git repository. Additionally: - fix confusing error message when only one arg was given - fix typo in error message 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-xgit-mv.perl16
1 files changed, 10 insertions, 6 deletions
diff --git a/git-mv.perl b/git-mv.perl
index 2ea852c91..8cd95c472 100755
--- a/git-mv.perl
+++ b/git-mv.perl
@@ -19,15 +19,15 @@ EOT
exit(1);
}
-my $GIT_DIR = `git rev-parse --git-dir`;
-exit 1 if $?; # rev-parse would have given "not a git dir" message.
-chomp($GIT_DIR);
-
our ($opt_n, $opt_f, $opt_h, $opt_k, $opt_v);
getopts("hnfkv") || usage;
usage() if $opt_h;
@ARGV >= 1 or usage;
+my $GIT_DIR = `git rev-parse --git-dir`;
+exit 1 if $?; # rev-parse would have given "not a git dir" message.
+chomp($GIT_DIR);
+
my (@srcArgs, @dstArgs, @srcs, @dsts);
my ($src, $dst, $base, $dstDir);
@@ -46,10 +46,14 @@ if (-d $ARGV[$argCount-1]) {
}
}
else {
- if ($argCount != 2) {
+ if ($argCount < 2) {
+ print "Error: need at least two arguments\n";
+ exit(1);
+ }
+ if ($argCount > 2) {
print "Error: moving to directory '"
. $ARGV[$argCount-1]
- . "' not possible; not exisiting\n";
+ . "' not possible; not existing\n";
exit(1);
}
@srcArgs = ($ARGV[0]);