Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
builtin/index-pack: convert struct ref_delta_entry to object_id
author
brian m. carlson
<sandals@crustytoothpaste.net>
Mon, 12 Mar 2018 02:27:37 +0000
(
02:27
+0000)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 14 Mar 2018 16:23:48 +0000
(09:23 -0700)
Convert this struct to use a member of type object_id. Convert various
static functions as well.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/index-pack.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
e5ec981
)
diff --git
a/builtin/index-pack.c
b/builtin/index-pack.c
index 59878e70b8017e1a531f2976230419a57c210038..9744175e2314617a448a34370e3606c16209ef74 100644
(file)
--- a/
builtin/index-pack.c
+++ b/
builtin/index-pack.c
@@
-58,7
+58,7
@@
struct ofs_delta_entry {
};
struct ref_delta_entry {
};
struct ref_delta_entry {
-
unsigned char sha1[20]
;
+
struct object_id oid
;
int obj_no;
};
int obj_no;
};
@@
-671,18
+671,18
@@
static void find_ofs_delta_children(off_t offset,
*last_index = last;
}
*last_index = last;
}
-static int compare_ref_delta_bases(const
unsigned char *sha
1,
- const
unsigned char *sha
2,
+static int compare_ref_delta_bases(const
struct object_id *oid
1,
+ const
struct object_id *oid
2,
enum object_type type1,
enum object_type type2)
{
int cmp = type1 - type2;
if (cmp)
return cmp;
enum object_type type1,
enum object_type type2)
{
int cmp = type1 - type2;
if (cmp)
return cmp;
- return
hashcmp(sha1, sha
2);
+ return
oidcmp(oid1, oid
2);
}
}
-static int find_ref_delta(const
unsigned char *sha1
, enum object_type type)
+static int find_ref_delta(const
struct object_id *oid
, enum object_type type)
{
int first = 0, last = nr_ref_deltas;
{
int first = 0, last = nr_ref_deltas;
@@
-691,7
+691,7
@@
static int find_ref_delta(const unsigned char *sha1, enum object_type type)
struct ref_delta_entry *delta = &ref_deltas[next];
int cmp;
struct ref_delta_entry *delta = &ref_deltas[next];
int cmp;
- cmp = compare_ref_delta_bases(
sha1, delta->sha1
,
+ cmp = compare_ref_delta_bases(
oid, &delta->oid
,
type, objects[delta->obj_no].type);
if (!cmp)
return next;
type, objects[delta->obj_no].type);
if (!cmp)
return next;
@@
-704,11
+704,11
@@
static int find_ref_delta(const unsigned char *sha1, enum object_type type)
return -first-1;
}
return -first-1;
}
-static void find_ref_delta_children(const
unsigned char *sha1
,
+static void find_ref_delta_children(const
struct object_id *oid
,
int *first_index, int *last_index,
enum object_type type)
{
int *first_index, int *last_index,
enum object_type type)
{
- int first = find_ref_delta(
sha1
, type);
+ int first = find_ref_delta(
oid
, type);
int last = first;
int end = nr_ref_deltas - 1;
int last = first;
int end = nr_ref_deltas - 1;
@@
-717,9
+717,9
@@
static void find_ref_delta_children(const unsigned char *sha1,
*last_index = -1;
return;
}
*last_index = -1;
return;
}
- while (first > 0 && !
hashcmp(ref_deltas[first - 1].sha1, sha1
))
+ while (first > 0 && !
oidcmp(&ref_deltas[first - 1].oid, oid
))
--first;
--first;
- while (last < end && !
hashcmp(ref_deltas[last + 1].sha1, sha1
))
+ while (last < end && !
oidcmp(&ref_deltas[last + 1].oid, oid
))
++last;
*first_index = first;
*last_index = last;
++last;
*first_index = first;
*last_index = last;
@@
-991,7
+991,7
@@
static struct base_data *find_unresolved_deltas_1(struct base_data *base,
struct base_data *prev_base)
{
if (base->ref_last == -1 && base->ofs_last == -1) {
struct base_data *prev_base)
{
if (base->ref_last == -1 && base->ofs_last == -1) {
- find_ref_delta_children(
base->obj->idx.oid.hash
,
+ find_ref_delta_children(
&base->obj->idx.oid
,
&base->ref_first, &base->ref_last,
OBJ_REF_DELTA);
&base->ref_first, &base->ref_last,
OBJ_REF_DELTA);
@@
-1075,7
+1075,7
@@
static int compare_ref_delta_entry(const void *a, const void *b)
const struct ref_delta_entry *delta_a = a;
const struct ref_delta_entry *delta_b = b;
const struct ref_delta_entry *delta_a = a;
const struct ref_delta_entry *delta_b = b;
- return
hashcmp(delta_a->sha1, delta_b->sha1
);
+ return
oidcmp(&delta_a->oid, &delta_b->oid
);
}
static void resolve_base(struct object_entry *obj)
}
static void resolve_base(struct object_entry *obj)
@@
-1141,7
+1141,7
@@
static void parse_pack_objects(unsigned char *hash)
ofs_delta++;
} else if (obj->type == OBJ_REF_DELTA) {
ALLOC_GROW(ref_deltas, nr_ref_deltas + 1, ref_deltas_alloc);
ofs_delta++;
} else if (obj->type == OBJ_REF_DELTA) {
ALLOC_GROW(ref_deltas, nr_ref_deltas + 1, ref_deltas_alloc);
-
hashcpy(ref_deltas[nr_ref_deltas].sha1, ref_delta_oid.hash
);
+
oidcpy(&ref_deltas[nr_ref_deltas].oid, &ref_delta_oid
);
ref_deltas[nr_ref_deltas].obj_no = i;
nr_ref_deltas++;
} else if (!data) {
ref_deltas[nr_ref_deltas].obj_no = i;
nr_ref_deltas++;
} else if (!data) {
@@
-1373,14
+1373,14
@@
static void fix_unresolved_deltas(struct hashfile *f)
if (objects[d->obj_no].real_type != OBJ_REF_DELTA)
continue;
if (objects[d->obj_no].real_type != OBJ_REF_DELTA)
continue;
- base_obj->data = read_sha1_file(d->
sha1
, &type, &base_obj->size);
+ base_obj->data = read_sha1_file(d->
oid.hash
, &type, &base_obj->size);
if (!base_obj->data)
continue;
if (!base_obj->data)
continue;
- if (check_sha1_signature(d->
sha1
, base_obj->data,
+ if (check_sha1_signature(d->
oid.hash
, base_obj->data,
base_obj->size, type_name(type)))
base_obj->size, type_name(type)))
- die(_("local object %s is corrupt"),
sha1_to_hex(d->sha1
));
- base_obj->obj = append_obj_to_pack(f, d->
sha1
,
+ die(_("local object %s is corrupt"),
oid_to_hex(&d->oid
));
+ base_obj->obj = append_obj_to_pack(f, d->
oid.hash
,
base_obj->data, base_obj->size, type);
find_unresolved_deltas(base_obj);
display_progress(progress, nr_resolved_deltas);
base_obj->data, base_obj->size, type);
find_unresolved_deltas(base_obj);
display_progress(progress, nr_resolved_deltas);