From: Jonathan Nieder Date: Sun, 08 Nov 2009 07:26:04 GMT Subject: [PATCH] Show usage string for 'git http-push -h' Message-ID: <20091108072604.GA21367@progeny.tock> In-Reply-To: <20091108071152.GA20741@progeny.tock> git http-push already knows how to dump usage if it is given no options, but it interprets '-h' as the URL to a remote repository: $ git http-push -h error: Cannot access URL -h/, return code 6 Dump usage on -h, instead. Humans wanting to pass the URL -h/ to curl for some reason can use 'git http-push -h/' explicitly. Scripts expecting to access an HTTP repository at URL '-h' will break, though. Cc: Tay Ray Chuan Signed-off-by: Jonathan Nieder --- Jonathan Nieder wrote: > Some commands > do not show usage with '-h' and have been left unchanged. Like this one. Full list of non-builtin commands in C like this: http-push, fast-import, imap-send, remote-curl, show-index. http-push.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/http-push.c b/http-push.c index 00e83dc..2e0782a 100644 --- a/http-push.c +++ b/http-push.c @@ -13,8 +13,8 @@ #include -static const char http_push_usage[] = -"git http-push [--all] [--dry-run] [--force] [--verbose] [...]\n"; +static const char http_push_usage[] = "git http-push " +"[-h] [--all] [--dry-run] [--force] [--verbose] [...]\n"; #ifndef XML_STATUS_OK enum XML_Status { @@ -1792,6 +1792,11 @@ int main(int argc, char **argv) git_extract_argv0_path(argv[0]); + if (argc == 2 && !strcmp(argv[1], "-h")) { + fprintf(stderr, "usage: %s\n", http_push_usage); + return 0; + } + setup_git_directory(); repo = xcalloc(sizeof(*repo), 1); -- 1.6.5.2