[PATCH] Show usage string for 'git http-push -h'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <rctay89@xxxxxxxxx>
Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
---
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 <expat.h>
 
-static const char http_push_usage[] =
-"git http-push [--all] [--dry-run] [--force] [--verbose] <remote> [<head>...]\n";
+static const char http_push_usage[] = "git http-push "
+"[-h] [--all] [--dry-run] [--force] [--verbose] <remote> [<head>...]\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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]