From cc41cd2e60da8224dcd04f23d837853cff5d4eda Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 27 Jul 2006 20:58:53 +0200 Subject: Remove -d from *-fetch usage strings This is a really ancient remnant of the short era of delta objects stored directly in the object database. Signed-off-by: Petr Baudis Signed-off-by: Junio C Hamano --- http-fetch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'http-fetch.c') diff --git a/http-fetch.c b/http-fetch.c index 12493fbed2..dc286b79f6 100644 --- a/http-fetch.c +++ b/http-fetch.c @@ -1245,7 +1245,7 @@ int main(int argc, char **argv) arg++; } if (argc < arg + 2) { - usage("git-http-fetch [-c] [-t] [-a] [-d] [-v] [--recover] [-w ref] commit-id url"); + usage("git-http-fetch [-c] [-t] [-a] [-v] [--recover] [-w ref] commit-id url"); return 1; } commit_id = argv[arg]; -- cgit v1.2.1 From c6b69bdbc1b0b914aa0d1e59a29305fce82d6f06 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 27 Jul 2006 23:56:14 +0200 Subject: Make pull() take some implicit data as explicit arguments Currently it's a bit weird that pull() takes a single argument describing the commit but takes the write_ref from a global variable. This makes it take that as a parameter as well, which might be nicer for the libification in the future, but especially it will make for nicer code when we implement pull()ing multiple commits at once. Signed-off-by: Petr Baudis Signed-off-by: Junio C Hamano --- http-fetch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'http-fetch.c') diff --git a/http-fetch.c b/http-fetch.c index dc286b79f6..963d439f82 100644 --- a/http-fetch.c +++ b/http-fetch.c @@ -1216,6 +1216,7 @@ int fetch_ref(char *ref, unsigned char *sha1) int main(int argc, char **argv) { + const char *write_ref = NULL; char *commit_id; char *url; char *path; @@ -1250,7 +1251,6 @@ int main(int argc, char **argv) } commit_id = argv[arg]; url = argv[arg + 1]; - write_ref_log_details = url; http_init(); @@ -1268,7 +1268,7 @@ int main(int argc, char **argv) alt->path_len = strlen(path); } - if (pull(commit_id)) + if (pull(commit_id, write_ref, url)) rc = 1; http_cleanup(); -- cgit v1.2.1 From 4211e4d10cd98b1aeed97bdb6cdebb9411956bb5 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 27 Jul 2006 23:56:17 +0200 Subject: Make pull() support fetching multiple targets at once pull() now takes an array of arguments instead of just one of each kind. Currently, no users use the new capability, but that'll change. Signed-off-by: Petr Baudis Signed-off-by: Junio C Hamano --- http-fetch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'http-fetch.c') diff --git a/http-fetch.c b/http-fetch.c index 963d439f82..bc67db1add 100644 --- a/http-fetch.c +++ b/http-fetch.c @@ -1268,7 +1268,7 @@ int main(int argc, char **argv) alt->path_len = strlen(path); } - if (pull(commit_id, write_ref, url)) + if (pull(1, &commit_id, &write_ref, url)) rc = 1; http_cleanup(); -- cgit v1.2.1 From 8e29f6a07e321a24f1d4f579817f5a8a43cdac05 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 27 Jul 2006 23:56:22 +0200 Subject: Teach git-http-fetch the --stdin switch Speeds up things quite a lot when fetching tags with Cogito. Signed-off-by: Petr Baudis Signed-off-by: Junio C Hamano --- http-fetch.c | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'http-fetch.c') diff --git a/http-fetch.c b/http-fetch.c index bc67db1add..1aad39b4d8 100644 --- a/http-fetch.c +++ b/http-fetch.c @@ -36,6 +36,8 @@ enum XML_Status { #define PREV_BUF_SIZE 4096 #define RANGE_HEADER_SIZE 30 +static int commits_on_stdin = 0; + static int got_alternates = -1; static int corrupt_object_found = 0; @@ -43,7 +45,7 @@ static struct curl_slist *no_pragma_header; struct alt_base { - char *base; + const char *base; int path_len; int got_indices; struct packed_git *packs; @@ -81,7 +83,7 @@ struct object_request }; struct alternates_request { - char *base; + const char *base; char *url; struct buffer *buffer; struct active_request_slot *slot; @@ -142,7 +144,7 @@ static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb, return size; } -static void fetch_alternates(char *base); +static void fetch_alternates(const char *base); static void process_object_response(void *callback_data); @@ -507,7 +509,7 @@ static void process_alternates_response(void *callback_data) (struct alternates_request *)callback_data; struct active_request_slot *slot = alt_req->slot; struct alt_base *tail = alt; - char *base = alt_req->base; + const char *base = alt_req->base; static const char null_byte = '\0'; char *data; int i = 0; @@ -612,7 +614,7 @@ static void process_alternates_response(void *callback_data) got_alternates = 1; } -static void fetch_alternates(char *base) +static void fetch_alternates(const char *base) { struct buffer buffer; char *url; @@ -1185,7 +1187,7 @@ int fetch_ref(char *ref, unsigned char *sha1) char *url; char hex[42]; struct buffer buffer; - char *base = alt->base; + const char *base = alt->base; struct active_request_slot *slot; struct slot_results results; buffer.size = 41; @@ -1214,11 +1216,12 @@ int fetch_ref(char *ref, unsigned char *sha1) return 0; } -int main(int argc, char **argv) +int main(int argc, const char **argv) { - const char *write_ref = NULL; - char *commit_id; - char *url; + int commits; + const char **write_ref = NULL; + char **commit_id; + const char *url; char *path; int arg = 1; int rc = 0; @@ -1238,19 +1241,26 @@ int main(int argc, char **argv) } else if (argv[arg][1] == 'v') { get_verbosely = 1; } else if (argv[arg][1] == 'w') { - write_ref = argv[arg + 1]; + write_ref = &argv[arg + 1]; arg++; } else if (!strcmp(argv[arg], "--recover")) { get_recover = 1; + } else if (!strcmp(argv[arg], "--stdin")) { + commits_on_stdin = 1; } arg++; } - if (argc < arg + 2) { - usage("git-http-fetch [-c] [-t] [-a] [-v] [--recover] [-w ref] commit-id url"); + if (argc < arg + 2 - commits_on_stdin) { + usage("git-http-fetch [-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin] commit-id url"); return 1; } - commit_id = argv[arg]; - url = argv[arg + 1]; + if (commits_on_stdin) { + commits = pull_targets_stdin(&commit_id, &write_ref); + } else { + commit_id = (char **) &argv[arg++]; + commits = 1; + } + url = argv[arg]; http_init(); @@ -1268,13 +1278,16 @@ int main(int argc, char **argv) alt->path_len = strlen(path); } - if (pull(1, &commit_id, &write_ref, url)) + if (pull(commits, commit_id, write_ref, url)) rc = 1; http_cleanup(); curl_slist_free_all(no_pragma_header); + if (commits_on_stdin) + pull_targets_free(commits, commit_id, write_ref); + if (corrupt_object_found) { fprintf(stderr, "Some loose object were found to be corrupt, but they might be just\n" -- cgit v1.2.1