X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-fetch-pack.c;h=273239af3be61736ee4ff484d628950c4de7311a;hb=2c47789d817aaf745a5ce5d5f79619c634cc8566;hp=29b38e4650cbd032ecfae02b334ce2b62ea1e622;hpb=ad416ed433fdcf838916a84177fe9e810be19eff;p=git.git diff --git a/builtin-fetch-pack.c b/builtin-fetch-pack.c index 29b38e465..273239af3 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. @@ -61,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 @@ -105,15 +117,15 @@ static const unsigned char* get_rev(void) while (commit == NULL) { unsigned int mark; - struct commit_list *parents = NULL; + struct commit_list *parents; if (rev_list == NULL || non_common_revs == 0) return NULL; commit = rev_list->item; - if (!(commit->object.parsed)) - if (!parse_commit(commit)) - parents = commit->parents; + if (!commit->object.parsed) + parse_commit(commit); + parents = commit->parents; commit->object.flags |= POPPED; if (!(commit->object.flags & COMMON)) @@ -153,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; @@ -176,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)); @@ -292,7 +309,8 @@ done: } flushes--; } - return retval; + /* it is no error to fetch into a completely empty repo */ + return count ? retval : 0; } static struct commit_list *complete; @@ -502,7 +520,8 @@ static int get_pack(int xd[2], char **pack_lockfile) if (read_pack_header(demux.out, &header)) die("protocol error: bad pack header"); - snprintf(hdr_arg, sizeof(hdr_arg), "--pack_header=%u,%u", + snprintf(hdr_arg, sizeof(hdr_arg), + "--pack_header=%"PRIu32",%"PRIu32, ntohl(header.hdr_version), ntohl(header.hdr_entries)); if (ntohl(header.hdr_entries) < unpack_limit) do_keep = 0; @@ -618,7 +637,7 @@ static int remove_duplicates(int nr_heads, char **heads) return dst; } -static int fetch_pack_config(const char *var, const char *value) +static int fetch_pack_config(const char *var, const char *value, void *cb) { if (strcmp(var, "fetch.unpacklimit") == 0) { fetch_unpack_limit = git_config_int(var, value); @@ -630,7 +649,7 @@ static int fetch_pack_config(const char *var, const char *value) return 0; } - return git_default_config(var, value); + return git_default_config(var, value, cb); } static struct lock_file lock; @@ -640,7 +659,7 @@ static void fetch_pack_setup(void) static int did_setup; if (did_setup) return; - git_config(fetch_pack_config); + git_config(fetch_pack_config, NULL); if (0 <= transfer_unpack_limit) unpack_limit = transfer_unpack_limit; else if (0 <= fetch_unpack_limit) @@ -683,6 +702,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; @@ -799,5 +822,6 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args, } } + reprepare_packed_git(); return ref_cpy; }