aboutsummaryrefslogtreecommitdiff
path: root/builtin/index-pack.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-06-03 15:32:14 -0700
committerJunio C Hamano <gitster@pobox.com>2011-06-05 22:45:36 -0700
commit4f8ec74efa9fc69aa3b0bd52affe31ca09f2fdd3 (patch)
treee9216d4f3ed55b8827a2f5b554e05778270d3c05 /builtin/index-pack.c
parent3c9fc074c220d5d1d2173c84cc6ae57d750e2a2c (diff)
downloadgit-4f8ec74efa9fc69aa3b0bd52affe31ca09f2fdd3.tar.gz
git-4f8ec74efa9fc69aa3b0bd52affe31ca09f2fdd3.tar.xz
index-pack: a miniscule refactor
Introduce a helper function that takes the type of an object and tell if it is a delta, as we seem to use this check in many places. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/index-pack.c')
-rw-r--r--builtin/index-pack.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 513fbbc55..0216af76a 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -498,12 +498,17 @@ static void sha1_object(const void *data, unsigned long size,
}
}
+static int is_delta_type(enum object_type type)
+{
+ return (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA);
+}
+
static void *get_base_data(struct base_data *c)
{
if (!c->data) {
struct object_entry *obj = c->obj;
- if (obj->type == OBJ_REF_DELTA || obj->type == OBJ_OFS_DELTA) {
+ if (is_delta_type(obj->type)) {
void *base = get_base_data(c->base);
void *raw = get_data_from_pack(obj);
c->data = patch_delta(
@@ -629,7 +634,7 @@ static void parse_pack_objects(unsigned char *sha1)
struct object_entry *obj = &objects[i];
void *data = unpack_raw_entry(obj, &delta->base);
obj->real_type = obj->type;
- if (obj->type == OBJ_REF_DELTA || obj->type == OBJ_OFS_DELTA) {
+ if (is_delta_type(obj->type)) {
nr_deltas++;
delta->obj_no = i;
delta++;
@@ -676,7 +681,7 @@ static void parse_pack_objects(unsigned char *sha1)
struct object_entry *obj = &objects[i];
struct base_data base_obj;
- if (obj->type == OBJ_REF_DELTA || obj->type == OBJ_OFS_DELTA)
+ if (is_delta_type(obj->type))
continue;
base_obj.obj = obj;
base_obj.data = NULL;