remote-{ext,fd}: print usage message on invalid arguments
authorJeff King <peff@peff.net>
Tue, 30 May 2017 05:15:09 +0000 (01:15 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 30 May 2017 05:45:04 +0000 (14:45 +0900)
We just say "Expected two arguments" when we get a different
number of arguments, but we can be slightly friendlier.
People shouldn't generally be running remote helpers
themselves, but curious users might say "git remote-ext -h".

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/remote-ext.c
builtin/remote-fd.c
index 11b48bfb41193387d53588c879ee50431f77b9cd..bfb21ba7d217bafaf3527af007cd4ac4658d36c5 100644 (file)
@@ -3,6 +3,9 @@
 #include "run-command.h"
 #include "pkt-line.h"
 
+static const char usage_msg[] =
+       "git remote-ext <remote> <url>";
+
 /*
  * URL syntax:
  *     'command [arg1 [arg2 [...]]]'   Invoke command with given arguments.
@@ -193,7 +196,7 @@ static int command_loop(const char *child)
 int cmd_remote_ext(int argc, const char **argv, const char *prefix)
 {
        if (argc != 3)
-               die("Expected two arguments");
+               usage(usage_msg);
 
        return command_loop(argv[2]);
 }
index 08d7121b6d118042a45086d2902769d282c062f8..91dfe07e06a1b9603dfd7a0d04f4b7866841d63f 100644 (file)
@@ -1,6 +1,9 @@
 #include "builtin.h"
 #include "transport.h"
 
+static const char usage_msg[] =
+       "git remote-fd <remote> <url>";
+
 /*
  * URL syntax:
  *     'fd::<inoutfd>[/<anything>]'            Read/write socket pair
@@ -57,7 +60,7 @@ int cmd_remote_fd(int argc, const char **argv, const char *prefix)
        char *end;
 
        if (argc != 3)
-               die("Expected two arguments");
+               usage(usage_msg);
 
        input_fd = (int)strtoul(argv[2], &end, 10);