All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH] index-pack: remove real_type from struct object_entry
Date: Fri, 24 Feb 2012 09:42:00 +0700	[thread overview]
Message-ID: <1330051320-19043-1-git-send-email-pclouds@gmail.com> (raw)

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

             reply	other threads:[~2012-02-24  2:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-24  2:42 Nguyễn Thái Ngọc Duy [this message]
2012-02-24  6:08 ` [PATCH] index-pack: remove real_type from struct object_entry Nguyen Thai Ngoc Duy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1330051320-19043-1-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.