{"thread":{"id":"29717","subject":"[PATCH] index-pack: remove real_type from struct object_entry","startedAt":"2012-02-24T02:42:00Z","lastAt":"2012-02-24T06:08:46Z","messageCount":2,"participants":["Nguyễn Thái Ngọc Duy","Nguyen Thai Ngoc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"185311","messageId":"1330051320-19043-1-git-send-email-pclouds@gmail.com","threadId":"29717","inReplyTo":null,"subject":"[PATCH] index-pack: remove real_type from struct object_entry","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-02-24T02:42:00Z","receivedAt":"2012-02-24T02:42:00Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Since ce3f6dc (fix multiple issues in index-pack), real_type is\nidentical to type, there's no reason to keep it.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n I'm pretty sure I read it right (i.e. type == real_type), but I may\n have overlooked something. Not so sure why real_type was introduced\n in the first place..\n\n builtin/index-pack.c |   16 ++++++----------\n 1 files changed, 6 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex dd1c5c9..2db9a35 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -18,7 +18,6 @@ struct object_entry {\n \tunsigned long size;\n \tunsigned int hdr_size;\n \tenum object_type type;\n-\tenum object_type real_type;\n \tunsigned delta_depth;\n \tint base_object_no;\n };\n@@ -581,7 +580,6 @@ static void resolve_delta(struct object_entry *delta_obj,\n {\n \tvoid *base_data, *delta_data;\n \n-\tdelta_obj->real_type = base->obj->real_type;\n \tdelta_obj->delta_depth = base->obj->delta_depth + 1;\n \tif (deepest_delta < delta_obj->delta_depth)\n \t\tdeepest_delta = delta_obj->delta_depth;\n@@ -594,7 +592,7 @@ static void resolve_delta(struct object_entry *delta_obj,\n \tfree(delta_data);\n \tif (!result->data)\n \t\tbad_object(delta_obj->idx.offset, \"failed to apply delta\");\n-\tsha1_object(result->data, result->size, delta_obj->real_type,\n+\tsha1_object(result->data, result->size, delta_obj->type,\n \t\t    delta_obj->idx.sha1);\n \tnr_resolved_deltas++;\n }\n@@ -626,7 +624,7 @@ static struct base_data *find_unresolved_deltas_1(struct base_data *base,\n \t\tstruct object_entry *child = objects + deltas[base->ref_first].obj_no;\n \t\tstruct base_data *result = alloc_base_data();\n \n-\t\tassert(child->real_type == OBJ_REF_DELTA);\n+\t\tassert(child->type == OBJ_REF_DELTA);\n \t\tresolve_delta(child, base, result);\n \t\tif (base->ref_first == base->ref_last && base->ofs_last == -1)\n \t\t\tfree_base_data(base);\n@@ -639,7 +637,7 @@ static struct base_data *find_unresolved_deltas_1(struct base_data *base,\n \t\tstruct object_entry *child = objects + deltas[base->ofs_first].obj_no;\n \t\tstruct base_data *result = alloc_base_data();\n \n-\t\tassert(child->real_type == OBJ_OFS_DELTA);\n+\t\tassert(child->type == OBJ_OFS_DELTA);\n \t\tresolve_delta(child, base, result);\n \t\tif (base->ofs_first == base->ofs_last)\n \t\t\tfree_base_data(base);\n@@ -702,7 +700,6 @@ static void parse_pack_objects(unsigned char *sha1)\n \tfor (i = 0; i < nr_objects; i++) {\n \t\tstruct object_entry *obj = &objects[i];\n \t\tvoid *data = unpack_raw_entry(obj, &delta->base);\n-\t\tobj->real_type = obj->type;\n \t\tif (is_delta_type(obj->type)) {\n \t\t\tnr_deltas++;\n \t\t\tdelta->obj_no = i;\n@@ -805,7 +802,6 @@ static struct object_entry *append_obj_to_pack(struct sha1file *f,\n \tobj[0].size = size;\n \tobj[0].hdr_size = n;\n \tobj[0].type = type;\n-\tobj[0].real_type = type;\n \tobj[1].idx.offset = obj[0].idx.offset + n;\n \tobj[1].idx.offset += write_compressed(f, buf, size);\n \tobj[0].idx.crc32 = crc32_end(f);\n@@ -838,7 +834,7 @@ static void fix_unresolved_deltas(struct sha1file *f, int nr_unresolved)\n \t */\n \tsorted_by_pos = xmalloc(nr_unresolved * sizeof(*sorted_by_pos));\n \tfor (i = 0; i < nr_deltas; i++) {\n-\t\tif (objects[deltas[i].obj_no].real_type != OBJ_REF_DELTA)\n+\t\tif (objects[deltas[i].obj_no].type != OBJ_REF_DELTA)\n \t\t\tcontinue;\n \t\tsorted_by_pos[n++] = &deltas[i];\n \t}\n@@ -849,7 +845,7 @@ static void fix_unresolved_deltas(struct sha1file *f, int nr_unresolved)\n \t\tenum object_type type;\n \t\tstruct base_data *base_obj = alloc_base_data();\n \n-\t\tif (objects[d->obj_no].real_type != OBJ_REF_DELTA)\n+\t\tif (objects[d->obj_no].type != OBJ_REF_DELTA)\n \t\t\tcontinue;\n \t\tbase_obj->data = read_sha1_file(d->base.sha1, &type, &base_obj->size);\n \t\tif (!base_obj->data)\n@@ -1053,7 +1049,7 @@ static void show_pack_info(int stat_only)\n \t\t\tcontinue;\n \t\tprintf(\"%s %-6s %lu %lu %\"PRIuMAX,\n \t\t       sha1_to_hex(obj->idx.sha1),\n-\t\t       typename(obj->real_type), obj->size,\n+\t\t       typename(obj->type), obj->size,\n \t\t       (unsigned long)(obj[1].idx.offset - obj->idx.offset),\n \t\t       (uintmax_t)obj->idx.offset);\n \t\tif (is_delta_type(obj->type)) {\n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"185315","messageId":"CACsJy8DT7QyLHbUQft2zbOm9Nv94b9trakk+nEfu4zT_xdf1AA@mail.gmail.com","threadId":"29717","inReplyTo":"1330051320-19043-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] index-pack: remove real_type from struct object_entry","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-02-24T06:08:46Z","receivedAt":"2012-02-24T06:08:46Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2012/2/24 Nguyễn Thái Ngọc Duy <pclouds@gmail.com>:\n> @@ -581,7 +580,6 @@ static void resolve_delta(struct object_entry *delta_obj,\n>  {\n>        void *base_data, *delta_data;\n>\n> -       delta_obj->real_type = base->obj->real_type;\n>        delta_obj->delta_depth = base->obj->delta_depth + 1;\n>        if (deepest_delta < delta_obj->delta_depth)\n>                deepest_delta = delta_obj->delta_depth;\n\nThis is wrong. Sorry for the noise.\n-- \nDuy\n"}]}