@matheusbsbs / matheus-bagliano / commits / f1f0a2be9f
Fork 0

Be more careful tangling object chains while marking commits.

Also Johannes noticed we use parse_object to look up if we know that object already -- we should just ask the in-core object registry with lookup_object() for that. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Oct 19, 2005 at 21:55 UTC f1f0a2be9fe6e6734d900381de189c56e023be7e
1 file changed +10 -4
fetch-pack.c
+10 -4
@@ -35,9 +35,12 @@ static int find_common(int fd[2], unsigned char *result_sha1,
35 * local ref), we tell them we have it but do not have to
36 * tell them about its ancestors, which they already know
37 * about.
38 + *
39 + * We use lookup_object here because we are only
40 + * interested in the case we *know* the object is
41 + * reachable and we have already scanned it.
42 */
39 - if (has_sha1_file(remote) &&
40 - ((o = parse_object(remote)) != NULL) &&
43 + if (((o = lookup_object(remote)) != NULL) &&
44 (o->flags & COMPLETE)) {
45 struct commit_list *p;
46 struct commit *commit =
@@ -120,10 +123,13 @@ static int mark_complete(const char *path, const unsigned char *sha1)
123 struct object *o = parse_object(sha1);
124
125 while (o && o->type == tag_type) {
126 + struct tag *t = (struct tag *) o;
127 + if (!t->tagged)
128 + break; /* broken repository */
129 o->flags |= COMPLETE;
124 - o = parse_object(((struct tag *)o)->tagged->sha1);
130 + o = parse_object(t->tagged->sha1);
131 }
126 - if (o->type == commit_type) {
132 + if (o && o->type == commit_type) {
133 struct commit *commit = (struct commit *)o;
134 commit->object.flags |= COMPLETE;
135 insert_by_date(commit, &complete);