@matheusbsbs / matheus-bagliano / commits / 5e6f85f6c1
Fork 0

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>

Josef Weidendorfer committed Mar 1, 2006 at 18:16 UTC 5e6f85f6c1d988d125dfcba16bb43a9a65f9eab3
1 file changed +10 -6
git-mv.perl
+10 -6
@@ -19,15 +19,15 @@ EOT
19 exit(1);
20 }
21
22 -my $GIT_DIR = `git rev-parse --git-dir`;
23 -exit 1 if $?; # rev-parse would have given "not a git dir" message.
24 -chomp($GIT_DIR);
25 -
22 our ($opt_n, $opt_f, $opt_h, $opt_k, $opt_v);
23 getopts("hnfkv") || usage;
24 usage() if $opt_h;
25 @ARGV >= 1 or usage;
26
27 +my $GIT_DIR = `git rev-parse --git-dir`;
28 +exit 1 if $?; # rev-parse would have given "not a git dir" message.
29 +chomp($GIT_DIR);
30 +
31 my (@srcArgs, @dstArgs, @srcs, @dsts);
32 my ($src, $dst, $base, $dstDir);
33
@@ -46,10 +46,14 @@ if (-d $ARGV[$argCount-1]) {
46 }
47 }
48 else {
49 - if ($argCount != 2) {
49 + if ($argCount < 2) {
50 + print "Error: need at least two arguments\n";
51 + exit(1);
52 + }
53 + if ($argCount > 2) {
54 print "Error: moving to directory '"
55 . $ARGV[$argCount-1]
52 - . "' not possible; not exisiting\n";
56 + . "' not possible; not existing\n";
57 exit(1);
58 }
59 @srcArgs = ($ARGV[0]);