6 static const char http_fetch_usage
[] = "git http-fetch "
7 "[-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin] commit-id url";
9 int main(int argc
, const char **argv
)
12 struct walker
*walker
;
13 int commits_on_stdin
= 0;
15 const char **write_ref
= NULL
;
18 char *rewritten_url
= NULL
;
24 int get_verbosely
= 0;
27 git_extract_argv0_path(argv
[0]);
29 while (arg
< argc
&& argv
[arg
][0] == '-') {
30 if (argv
[arg
][1] == 't') {
32 } else if (argv
[arg
][1] == 'c') {
34 } else if (argv
[arg
][1] == 'a') {
38 } else if (argv
[arg
][1] == 'v') {
40 } else if (argv
[arg
][1] == 'w') {
41 write_ref
= &argv
[arg
+ 1];
43 } else if (argv
[arg
][1] == 'h') {
44 usage(http_fetch_usage
);
45 } else if (!strcmp(argv
[arg
], "--recover")) {
47 } else if (!strcmp(argv
[arg
], "--stdin")) {
52 if (argc
!= arg
+ 2 - commits_on_stdin
)
53 usage(http_fetch_usage
);
54 if (commits_on_stdin
) {
55 commits
= walker_targets_stdin(&commit_id
, &write_ref
);
57 commit_id
= (char **) &argv
[arg
++];
62 prefix
= setup_git_directory();
64 git_config(git_default_config
, NULL
);
66 if (url
&& url
[strlen(url
)-1] != '/') {
67 rewritten_url
= xmalloc(strlen(url
)+2);
68 strcpy(rewritten_url
, url
);
69 strcat(rewritten_url
, "/");
74 walker
= get_http_walker(url
);
75 walker
->get_tree
= get_tree
;
76 walker
->get_history
= get_history
;
77 walker
->get_all
= get_all
;
78 walker
->get_verbosely
= get_verbosely
;
79 walker
->get_recover
= get_recover
;
81 rc
= walker_fetch(walker
, commits
, commit_id
, write_ref
, url
);
84 walker_targets_free(commits
, commit_id
, write_ref
);
86 if (walker
->corrupt_object_found
) {
88 "Some loose object were found to be corrupt, but they might be just\n"
89 "a false '404 Not Found' error message sent with incorrect HTTP\n"
90 "status code. Suggest running 'git fsck'.\n");