5 static const char http_fetch_usage[] = "git http-fetch "
6 "[-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin] commit-id url";
8 int main(int argc, const char **argv)
11 struct walker *walker;
12 int commits_on_stdin = 0;
14 const char **write_ref = NULL;
17 char *rewritten_url = NULL;
23 int get_verbosely = 0;
26 git_extract_argv0_path(argv[0]);
28 while (arg < argc && argv[arg][0] == '-') {
29 if (argv[arg][1] == 't') {
31 } else if (argv[arg][1] == 'c') {
33 } else if (argv[arg][1] == 'a') {
37 } else if (argv[arg][1] == 'v') {
39 } else if (argv[arg][1] == 'w') {
40 write_ref = &argv[arg + 1];
42 } else if (argv[arg][1] == 'h') {
43 usage(http_fetch_usage);
44 } else if (!strcmp(argv[arg], "--recover")) {
46 } else if (!strcmp(argv[arg], "--stdin")) {
51 if (argc != arg + 2 - commits_on_stdin)
52 usage(http_fetch_usage);
53 if (commits_on_stdin) {
54 commits = walker_targets_stdin(&commit_id, &write_ref);
56 commit_id = (char **) &argv[arg++];
61 prefix = setup_git_directory();
63 git_config(git_default_config, NULL);
65 if (url && url[strlen(url)-1] != '/') {
66 rewritten_url = xmalloc(strlen(url)+2);
67 strcpy(rewritten_url, url);
68 strcat(rewritten_url, "/");
72 walker = get_http_walker(url, NULL);
73 walker->get_tree = get_tree;
74 walker->get_history = get_history;
75 walker->get_all = get_all;
76 walker->get_verbosely = get_verbosely;
77 walker->get_recover = get_recover;
79 rc = walker_fetch(walker, commits, commit_id, write_ref, url);
82 walker_targets_free(commits, commit_id, write_ref);
84 if (walker->corrupt_object_found) {
86 "Some loose object were found to be corrupt, but they might be just\n"
87 "a false '404 Not Found' error message sent with incorrect HTTP\n"
88 "status code. Suggest running 'git fsck'.\n");