From: Junio C Hamano Date: Fri, 1 Feb 2013 20:39:24 +0000 (-0800) Subject: Merge branch 'nd/fetch-depth-is-broken' X-Git-Tag: v1.8.2-rc0~72 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/2532d891a4aab003a5ce19f04509fd8549754485?ds=inline;hp=-c Merge branch 'nd/fetch-depth-is-broken' "git fetch --depth" was broken in at least three ways. The resulting history was deeper than specified by one commit, it was unclear how to wipe the shallowness of the repository with the command, and documentation was misleading. * nd/fetch-depth-is-broken: fetch: elaborate --depth action upload-pack: fix off-by-one depth calculation in shallow clone fetch: add --unshallow for turning shallow repo into complete one --- 2532d891a4aab003a5ce19f04509fd8549754485 diff --combined commit.h index c16c8a7534,0adfce96e4..95b8350a5b --- a/commit.h +++ b/commit.h @@@ -86,11 -86,9 +86,11 @@@ struct pretty_print_context enum date_mode date_mode; unsigned date_mode_explicit:1; int need_8bit_cte; - int show_notes; + char *notes_message; struct reflog_walk_info *reflog_info; const char *output_encoding; + struct string_list *mailmap; + int color; }; struct userformat_want { @@@ -101,6 -99,8 +101,6 @@@ extern int has_non_ascii(const char *te struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */ extern char *logmsg_reencode(const struct commit *commit, const char *output_encoding); -extern char *reencode_commit_message(const struct commit *commit, - const char **encoding_p); extern void get_commit_format(const char *arg, struct rev_info *); extern const char *format_subject(struct strbuf *sb, const char *msg, const char *line_separator); @@@ -163,6 -163,9 +163,9 @@@ extern struct commit_list *get_merge_ba extern struct commit_list *get_merge_bases_many(struct commit *one, int n, struct commit **twos, int cleanup); extern struct commit_list *get_octopus_merge_bases(struct commit_list *in); + /* largest postive number a signed 32-bit integer can contain */ + #define INFINITE_DEPTH 0x7fffffff + extern int register_shallow(const unsigned char *sha1); extern int unregister_shallow(const unsigned char *sha1); extern int for_each_commit_graft(each_commit_graft_fn, void *); @@@ -222,8 -225,4 +225,8 @@@ struct commit *get_merge_parent(const c extern int parse_signed_commit(const unsigned char *sha1, struct strbuf *message, struct strbuf *signature); +extern void print_commit_list(struct commit_list *list, + const char *format_cur, + const char *format_last); + #endif /* COMMIT_H */ diff --combined upload-pack.c index 95d83135ae,8740002817..7c05b15e68 --- a/upload-pack.c +++ b/upload-pack.c @@@ -603,8 -603,6 +603,8 @@@ static void receive_needs(void object = parse_object(sha1); if (!object) die("did not find object for %s", line); + if (object->type != OBJ_COMMIT) + die("invalid shallow object %s", sha1_to_hex(sha1)); object->flags |= CLIENT_SHALLOW; add_object_array(object, NULL, &shallows); continue; @@@ -672,10 -670,17 +672,17 @@@ if (depth == 0 && shallows.nr == 0) return; if (depth > 0) { - struct commit_list *result, *backup; + struct commit_list *result = NULL, *backup = NULL; int i; - backup = result = get_shallow_commits(&want_obj, depth, - SHALLOW, NOT_SHALLOW); + if (depth == INFINITE_DEPTH) + for (i = 0; i < shallows.nr; i++) { + struct object *object = shallows.objects[i].item; + object->flags |= NOT_SHALLOW; + } + else + backup = result = + get_shallow_commits(&want_obj, depth, + SHALLOW, NOT_SHALLOW); while (result) { struct object *object = &result->item->object; if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) { @@@ -729,7 -734,12 +736,7 @@@ static int send_ref(const char *refname " include-tag multi_ack_detailed"; struct object *o = lookup_unknown_object(sha1); const char *refname_nons = strip_namespace(refname); - - if (o->type == OBJ_NONE) { - o->type = sha1_object_info(sha1, NULL); - if (o->type < 0) - die("git upload-pack: cannot find object %s:", sha1_to_hex(sha1)); - } + unsigned char peeled[20]; if (capabilities) packet_write(1, "%s %s%c%s%s agent=%s\n", @@@ -744,8 -754,11 +751,8 @@@ o->flags |= OUR_REF; nr_our_refs++; } - if (o->type == OBJ_TAG) { - o = deref_tag_noverify(o); - if (o) - packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname_nons); - } + if (!peel_ref(refname, peeled)) + packet_write(1, "%s %s^{}\n", sha1_to_hex(peeled), refname_nons); return 0; }