diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-11-20 23:44:52 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-11-20 23:44:52 -0800 |
commit | 750054cd3f1298bc9e113a47eaa6346923e08c19 (patch) | |
tree | 2a1f04ed14b6a705723c2832939d50b302252625 /http-fetch.c | |
parent | 1b8dbdb41e503f6829be4e1d8ada4c8eabbc49bd (diff) | |
parent | d74bb308fa9e49e0a5b9a0792e6079bbc0c8aea8 (diff) | |
download | git-750054cd3f1298bc9e113a47eaa6346923e08c19.tar.gz |
Merge branch 'jn/help-everywhere'
* jn/help-everywhere: (23 commits)
diff --no-index: make the usage string less scary
merge-{recursive,subtree}: use usagef() to print usage
Introduce usagef() that takes a printf-style format
Let 'git <command> -h' show usage without a git dir
Show usage string for 'git http-push -h'
Let 'git http-fetch -h' show usage outside any git repository
Show usage string for 'git stripspace -h'
Show usage string for 'git unpack-file -h'
Show usage string for 'git show-index -h'
Show usage string for 'git rev-parse -h'
Show usage string for 'git merge-one-file -h'
Show usage string for 'git mailsplit -h'
Show usage string for 'git imap-send -h'
Show usage string for 'git get-tar-commit-id -h'
Show usage string for 'git fast-import -h'
Show usage string for 'git check-ref-format -h'
http-fetch: add missing initialization of argv0_path
Show usage string for 'git show-ref -h'
Show usage string for 'git merge-ours -h'
Show usage string for 'git commit-tree -h'
...
Conflicts:
imap-send.c
Diffstat (limited to 'http-fetch.c')
-rw-r--r-- | http-fetch.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/http-fetch.c b/http-fetch.c index e8f44babd9..ffd0ad7e29 100644 --- a/http-fetch.c +++ b/http-fetch.c @@ -1,6 +1,10 @@ #include "cache.h" +#include "exec_cmd.h" #include "walker.h" +static const char http_fetch_usage[] = "git http-fetch " +"[-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin] commit-id url"; + int main(int argc, const char **argv) { const char *prefix; @@ -19,9 +23,7 @@ int main(int argc, const char **argv) int get_verbosely = 0; int get_recover = 0; - prefix = setup_git_directory(); - - git_config(git_default_config, NULL); + git_extract_argv0_path(argv[0]); while (arg < argc && argv[arg][0] == '-') { if (argv[arg][1] == 't') { @@ -37,6 +39,8 @@ int main(int argc, const char **argv) } else if (argv[arg][1] == 'w') { write_ref = &argv[arg + 1]; arg++; + } else if (argv[arg][1] == 'h') { + usage(http_fetch_usage); } else if (!strcmp(argv[arg], "--recover")) { get_recover = 1; } else if (!strcmp(argv[arg], "--stdin")) { @@ -44,10 +48,8 @@ int main(int argc, const char **argv) } arg++; } - if (argc < arg + 2 - commits_on_stdin) { - usage("git http-fetch [-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin] commit-id url"); - return 1; - } + if (argc != arg + 2 - commits_on_stdin) + usage(http_fetch_usage); if (commits_on_stdin) { commits = walker_targets_stdin(&commit_id, &write_ref); } else { @@ -55,6 +57,11 @@ int main(int argc, const char **argv) commits = 1; } url = argv[arg]; + + prefix = setup_git_directory(); + + git_config(git_default_config, NULL); + if (url && url[strlen(url)-1] != '/') { rewritten_url = xmalloc(strlen(url)+2); strcpy(rewritten_url, url); |