git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-mv: Allow -h without repo & fix error message

From
JWJosef Weidendorfer <josef.weidendorfer@gmx.de>
Date
Mar 1, 2006, 17:16 UTC
Message-ID
<200603011816.36981.Josef.Weidendorfer@gmx.de>
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>
---
 git-mv.perl |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
2f1dc137362cfa84553340a8f1310bc784e5935b
diff --git a/git-mv.perl b/git-mv.perl
index 2ea852c..8cd95c4 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]);
-- 
1.2.0.g719b
Message 1 of 1 in “git-mv: Allow -h without repo & fix error message”
  1. git-mv: Allow -h without repo & fix error messageJosef Weidendorfer, Mar 1, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.