* [PATCH] index-pack: remove real_type from struct object_entry
@ 2012-02-24 2:42 Nguyễn Thái Ngọc Duy
2012-02-24 6:08 ` Nguyen Thai Ngoc Duy
0 siblings, 1 reply; 2+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-02-24 2:42 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
Since ce3f6dc (fix multiple issues in index-pack), real_type is
identical to type, there's no reason to keep it.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
I'm pretty sure I read it right (i.e. type == real_type), but I may
have overlooked something. Not so sure why real_type was introduced
in the first place..
builtin/index-pack.c | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index dd1c5c9..2db9a35 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -18,7 +18,6 @@ struct object_entry {
unsigned long size;
unsigned int hdr_size;
enum object_type type;
- enum object_type real_type;
unsigned delta_depth;
int base_object_no;
};
@@ -581,7 +580,6 @@ static void resolve_delta(struct object_entry *delta_obj,
{
void *base_data, *delta_data;
- delta_obj->real_type = base->obj->real_type;
delta_obj->delta_depth = base->obj->delta_depth + 1;
if (deepest_delta < delta_obj->delta_depth)
deepest_delta = delta_obj->delta_depth;
@@ -594,7 +592,7 @@ static void resolve_delta(struct object_entry *delta_obj,
free(delta_data);
if (!result->data)
bad_object(delta_obj->idx.offset, "failed to apply delta");
- sha1_object(result->data, result->size, delta_obj->real_type,
+ sha1_object(result->data, result->size, delta_obj->type,
delta_obj->idx.sha1);
nr_resolved_deltas++;
}
@@ -626,7 +624,7 @@ static struct base_data *find_unresolved_deltas_1(struct base_data *base,
struct object_entry *child = objects + deltas[base->ref_first].obj_no;
struct base_data *result = alloc_base_data();
- assert(child->real_type == OBJ_REF_DELTA);
+ assert(child->type == OBJ_REF_DELTA);
resolve_delta(child, base, result);
if (base->ref_first == base->ref_last && base->ofs_last == -1)
free_base_data(base);
@@ -639,7 +637,7 @@ static struct base_data *find_unresolved_deltas_1(struct base_data *base,
struct object_entry *child = objects + deltas[base->ofs_first].obj_no;
struct base_data *result = alloc_base_data();
- assert(child->real_type == OBJ_OFS_DELTA);
+ assert(child->type == OBJ_OFS_DELTA);
resolve_delta(child, base, result);
if (base->ofs_first == base->ofs_last)
free_base_data(base);
@@ -702,7 +700,6 @@ static void parse_pack_objects(unsigned char *sha1)
for (i = 0; i < nr_objects; i++) {
struct object_entry *obj = &objects[i];
void *data = unpack_raw_entry(obj, &delta->base);
- obj->real_type = obj->type;
if (is_delta_type(obj->type)) {
nr_deltas++;
delta->obj_no = i;
@@ -805,7 +802,6 @@ static struct object_entry *append_obj_to_pack(struct sha1file *f,
obj[0].size = size;
obj[0].hdr_size = n;
obj[0].type = type;
- obj[0].real_type = type;
obj[1].idx.offset = obj[0].idx.offset + n;
obj[1].idx.offset += write_compressed(f, buf, size);
obj[0].idx.crc32 = crc32_end(f);
@@ -838,7 +834,7 @@ static void fix_unresolved_deltas(struct sha1file *f, int nr_unresolved)
*/
sorted_by_pos = xmalloc(nr_unresolved * sizeof(*sorted_by_pos));
for (i = 0; i < nr_deltas; i++) {
- if (objects[deltas[i].obj_no].real_type != OBJ_REF_DELTA)
+ if (objects[deltas[i].obj_no].type != OBJ_REF_DELTA)
continue;
sorted_by_pos[n++] = &deltas[i];
}
@@ -849,7 +845,7 @@ static void fix_unresolved_deltas(struct sha1file *f, int nr_unresolved)
enum object_type type;
struct base_data *base_obj = alloc_base_data();
- if (objects[d->obj_no].real_type != OBJ_REF_DELTA)
+ if (objects[d->obj_no].type != OBJ_REF_DELTA)
continue;
base_obj->data = read_sha1_file(d->base.sha1, &type, &base_obj->size);
if (!base_obj->data)
@@ -1053,7 +1049,7 @@ static void show_pack_info(int stat_only)
continue;
printf("%s %-6s %lu %lu %"PRIuMAX,
sha1_to_hex(obj->idx.sha1),
- typename(obj->real_type), obj->size,
+ typename(obj->type), obj->size,
(unsigned long)(obj[1].idx.offset - obj->idx.offset),
(uintmax_t)obj->idx.offset);
if (is_delta_type(obj->type)) {
--
1.7.3.1.256.g2539c.dirty
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] index-pack: remove real_type from struct object_entry
2012-02-24 2:42 [PATCH] index-pack: remove real_type from struct object_entry Nguyễn Thái Ngọc Duy
@ 2012-02-24 6:08 ` Nguyen Thai Ngoc Duy
0 siblings, 0 replies; 2+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2012-02-24 6:08 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
2012/2/24 Nguyễn Thái Ngọc Duy <pclouds@gmail.com>:
> @@ -581,7 +580,6 @@ static void resolve_delta(struct object_entry *delta_obj,
> {
> void *base_data, *delta_data;
>
> - delta_obj->real_type = base->obj->real_type;
> delta_obj->delta_depth = base->obj->delta_depth + 1;
> if (deepest_delta < delta_obj->delta_depth)
> deepest_delta = delta_obj->delta_depth;
This is wrong. Sorry for the noise.
--
Duy
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-02-24 6:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-24 2:42 [PATCH] index-pack: remove real_type from struct object_entry Nguyễn Thái Ngọc Duy
2012-02-24 6:08 ` Nguyen Thai Ngoc Duy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).