X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-fetch-pack.c;h=c97a42739d23ac7ed90ae207e5a3770c388e66a7;hb=170e095a9cfe31617162e8a9b5063b8bc38af82b;hp=5ea48ca7dbc22785f4e4f3c35f3dc48ee18f0d8a;hpb=cb99be7c7d2afc71106ffaf400c769c8e72f1bb2;p=git.git diff --git a/builtin-fetch-pack.c b/builtin-fetch-pack.c index 5ea48ca7d..c97a42739 100644 --- a/builtin-fetch-pack.c +++ b/builtin-fetch-pack.c @@ -18,7 +18,7 @@ static struct fetch_pack_args args = { }; static const char fetch_pack_usage[] = -"git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=] [--depth=] [--no-progress] [-v] [:] [...]"; +"git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--include-tag] [--upload-pack=] [--depth=] [--no-progress] [-v] [:] [...]"; #define COMPLETE (1U << 0) #define COMMON (1U << 1) @@ -26,6 +26,8 @@ static const char fetch_pack_usage[] = #define SEEN (1U << 3) #define POPPED (1U << 4) +static int marked; + /* * After sending this many "have"s if we do not get any new ACK , we * give up traversing our history. @@ -41,7 +43,8 @@ static void rev_list_push(struct commit *commit, int mark) commit->object.flags |= mark; if (!(commit->object.parsed)) - parse_commit(commit); + if (parse_commit(commit)) + return; insert_by_date(commit, &rev_list); @@ -60,6 +63,16 @@ static int rev_list_insert_ref(const char *path, const unsigned char *sha1, int return 0; } +static int clear_marks(const char *path, const unsigned char *sha1, int flag, void *cb_data) +{ + struct object *o = deref_tag(parse_object(sha1), path, 0); + + if (o && o->type == OBJ_COMMIT) + clear_commit_marks((struct commit *)o, + COMMON | COMMON_REF | SEEN | POPPED); + return 0; +} + /* This function marks a rev and its ancestors as common. In some cases, it is desirable to mark only the ancestors (for example @@ -83,7 +96,8 @@ static void mark_common(struct commit *commit, if (!ancestors_only && !(o->flags & POPPED)) non_common_revs--; if (!o->parsed && !dont_parse) - parse_commit(commit); + if (parse_commit(commit)) + return; for (parents = commit->parents; parents; @@ -103,20 +117,20 @@ static const unsigned char* get_rev(void) while (commit == NULL) { unsigned int mark; - struct commit_list* parents; + struct commit_list *parents; if (rev_list == NULL || non_common_revs == 0) return NULL; commit = rev_list->item; - if (!(commit->object.parsed)) + if (!commit->object.parsed) parse_commit(commit); + parents = commit->parents; + commit->object.flags |= POPPED; if (!(commit->object.flags & COMMON)) non_common_revs--; - parents = commit->parents; - if (commit->object.flags & COMMON) { /* do not send "have", and ignore ancestors */ commit = NULL; @@ -151,6 +165,10 @@ static int find_common(int fd[2], unsigned char *result_sha1, unsigned in_vain = 0; int got_continue = 0; + if (marked) + for_each_ref(clear_marks, NULL); + marked = 1; + for_each_ref(rev_list_insert_ref, NULL); fetching = 0; @@ -174,13 +192,14 @@ static int find_common(int fd[2], unsigned char *result_sha1, } if (!fetching) - packet_write(fd[1], "want %s%s%s%s%s%s%s\n", + packet_write(fd[1], "want %s%s%s%s%s%s%s%s\n", sha1_to_hex(remote), (multi_ack ? " multi_ack" : ""), (use_sideband == 2 ? " side-band-64k" : ""), (use_sideband == 1 ? " side-band" : ""), (args.use_thin_pack ? " thin-pack" : ""), (args.no_progress ? " no-progress" : ""), + (args.include_tag ? " include-tag" : ""), " ofs-delta"); else packet_write(fd[1], "want %s\n", sha1_to_hex(remote)); @@ -212,7 +231,8 @@ static int find_common(int fd[2], unsigned char *result_sha1, if (!lookup_object(sha1)) die("object not found: %s", line); /* make sure that it is parsed as shallow */ - parse_object(sha1); + if (!parse_object(sha1)) + die("error in object: %s", line); if (unregister_shallow(sha1)) die("no shallow found: %s", line); continue; @@ -386,7 +406,6 @@ static int everything_local(struct ref **refs, int nr_match, char **match) int retval; unsigned long cutoff = 0; - track_object_refs = 0; save_commit_buffer = 0; for (ref = *refs; ref; ref = ref->next) { @@ -681,6 +700,10 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) args.use_thin_pack = 1; continue; } + if (!strcmp("--include-tag", arg)) { + args.include_tag = 1; + continue; + } if (!strcmp("--all", arg)) { args.fetch_all = 1; continue;