]> git.ipfire.org Git - thirdparty/git.git/blame - http-fetch.c
config: remove git_config_iter
[thirdparty/git.git] / http-fetch.c
CommitLineData
30ae764b 1#include "cache.h"
f01d7496 2#include "exec_cmd.h"
888692b7 3#include "http.h"
30ae764b
DB
4#include "walker.h"
5
616f86d7
JN
6static const char http_fetch_usage[] = "git http-fetch "
7"[-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin] commit-id url";
8
3f2e2297 9int cmd_main(int argc, const char **argv)
30ae764b
DB
10{
11 struct walker *walker;
12 int commits_on_stdin = 0;
13 int commits;
14 const char **write_ref = NULL;
15 char **commit_id;
6f5185bd 16 char *url = NULL;
30ae764b
DB
17 int arg = 1;
18 int rc = 0;
19 int get_tree = 0;
20 int get_history = 0;
21 int get_all = 0;
22 int get_verbosely = 0;
23 int get_recover = 0;
24
30ae764b
DB
25 while (arg < argc && argv[arg][0] == '-') {
26 if (argv[arg][1] == 't') {
27 get_tree = 1;
28 } else if (argv[arg][1] == 'c') {
29 get_history = 1;
30 } else if (argv[arg][1] == 'a') {
31 get_all = 1;
32 get_tree = 1;
33 get_history = 1;
34 } else if (argv[arg][1] == 'v') {
35 get_verbosely = 1;
36 } else if (argv[arg][1] == 'w') {
37 write_ref = &argv[arg + 1];
38 arg++;
616f86d7
JN
39 } else if (argv[arg][1] == 'h') {
40 usage(http_fetch_usage);
30ae764b
DB
41 } else if (!strcmp(argv[arg], "--recover")) {
42 get_recover = 1;
43 } else if (!strcmp(argv[arg], "--stdin")) {
44 commits_on_stdin = 1;
45 }
46 arg++;
47 }
616f86d7
JN
48 if (argc != arg + 2 - commits_on_stdin)
49 usage(http_fetch_usage);
30ae764b
DB
50 if (commits_on_stdin) {
51 commits = walker_targets_stdin(&commit_id, &write_ref);
52 } else {
53 commit_id = (char **) &argv[arg++];
54 commits = 1;
55 }
6f5185bd 56
a6c786fc
BW
57 if (get_all == 0)
58 warning("http-fetch: use without -a is deprecated.\n"
59 "In a future release, -a will become the default.");
60
6f5185bd
TRC
61 if (argv[arg])
62 str_end_url_with_slash(argv[arg], &url);
616f86d7 63
13ee1384 64 setup_git_directory();
616f86d7
JN
65
66 git_config(git_default_config, NULL);
67
a4ddbc33 68 http_init(NULL, url, 0);
888692b7 69 walker = get_http_walker(url);
30ae764b
DB
70 walker->get_tree = get_tree;
71 walker->get_history = get_history;
72 walker->get_all = get_all;
73 walker->get_verbosely = get_verbosely;
74 walker->get_recover = get_recover;
75
76 rc = walker_fetch(walker, commits, commit_id, write_ref, url);
77
78 if (commits_on_stdin)
79 walker_targets_free(commits, commit_id, write_ref);
80
81 if (walker->corrupt_object_found) {
82 fprintf(stderr,
83"Some loose object were found to be corrupt, but they might be just\n"
84"a false '404 Not Found' error message sent with incorrect HTTP\n"
05207a28 85"status code. Suggest running 'git fsck'.\n");
30ae764b
DB
86 }
87
88 walker_free(walker);
888692b7 89 http_cleanup();
30ae764b 90
6f5185bd 91 free(url);
3057ded0 92
30ae764b
DB
93 return rc;
94}