Skip to content

Commit 548d346

Browse files
jrngitster
authored andcommitted
Show usage string for 'git http-push -h'
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 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. Also delay finding a git directory until after option parsing, so "http-push -h" can be used outside any git repository. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Acked-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 616f86d commit 548d346

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

http-push.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,8 +1792,6 @@ int main(int argc, char **argv)
17921792

17931793
git_extract_argv0_path(argv[0]);
17941794

1795-
setup_git_directory();
1796-
17971795
repo = xcalloc(sizeof(*repo), 1);
17981796

17991797
argv++;
@@ -1827,6 +1825,8 @@ int main(int argc, char **argv)
18271825
force_delete = 1;
18281826
continue;
18291827
}
1828+
if (!strcmp(arg, "-h"))
1829+
usage(http_push_usage);
18301830
}
18311831
if (!repo->url) {
18321832
char *path = strstr(arg, "//");
@@ -1854,6 +1854,8 @@ int main(int argc, char **argv)
18541854
if (delete_branch && nr_refspec != 1)
18551855
die("You must specify only one branch name when deleting a remote branch");
18561856

1857+
setup_git_directory();
1858+
18571859
memset(remote_dir_exists, -1, 256);
18581860

18591861
/*

0 commit comments

Comments
 (0)