remote-{ext,fd}: print usage message on invalid arguments

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>

Jeff King committed May 30, 2017 at 01:15 UTC bb246590a1b648ac23f6a22d1d9e119129ba2f03
2 files changed +8 -2
builtin/remote-ext.c
+4 -1
@@ -3,6 +3,9 @@
3 #include "run-command.h"
4 #include "pkt-line.h"
5
6 +static const char usage_msg[] =
7 + "git remote-ext <remote> <url>";
8 +
9 /*
10 * URL syntax:
11 * 'command [arg1 [arg2 [...]]]' Invoke command with given arguments.
@@ -193,7 +196,7 @@ static int command_loop(const char *child)
196 int cmd_remote_ext(int argc, const char **argv, const char *prefix)
197 {
198 if (argc != 3)
196 - die("Expected two arguments");
199 + usage(usage_msg);
200
201 return command_loop(argv[2]);
202 }
builtin/remote-fd.c
+4 -1
@@ -1,6 +1,9 @@
1 #include "builtin.h"
2 #include "transport.h"
3
4 +static const char usage_msg[] =
5 + "git remote-fd <remote> <url>";
6 +
7 /*
8 * URL syntax:
9 * 'fd::<inoutfd>[/<anything>]' Read/write socket pair
@@ -57,7 +60,7 @@ int cmd_remote_fd(int argc, const char **argv, const char *prefix)
60 char *end;
61
62 if (argc != 3)
60 - die("Expected two arguments");
63 + usage(usage_msg);
64
65 input_fd = (int)strtoul(argv[2], &end, 10);
66