sha1-array: convert internal storage for struct sha1_array to object_id
Make the internal storage for struct sha1_array use an array of struct object_id internally. Update the users of this struct which inspect its internals. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
f9b11147e0
commit
ee3051bd23
26
shallow.c
26
shallow.c
@ -273,7 +273,7 @@ static int write_shallow_commits_1(struct strbuf *out, int use_pack_protocol,
|
||||
if (!extra)
|
||||
return data.count;
|
||||
for (i = 0; i < extra->nr; i++) {
|
||||
strbuf_addstr(out, sha1_to_hex(extra->sha1[i]));
|
||||
strbuf_addstr(out, oid_to_hex(extra->oid + i));
|
||||
strbuf_addch(out, '\n');
|
||||
data.count++;
|
||||
}
|
||||
@ -396,9 +396,9 @@ void prepare_shallow_info(struct shallow_info *info, struct sha1_array *sa)
|
||||
ALLOC_ARRAY(info->ours, sa->nr);
|
||||
ALLOC_ARRAY(info->theirs, sa->nr);
|
||||
for (i = 0; i < sa->nr; i++) {
|
||||
if (has_sha1_file(sa->sha1[i])) {
|
||||
if (has_object_file(sa->oid + i)) {
|
||||
struct commit_graft *graft;
|
||||
graft = lookup_commit_graft(sa->sha1[i]);
|
||||
graft = lookup_commit_graft(sa->oid[i].hash);
|
||||
if (graft && graft->nr_parent < 0)
|
||||
continue;
|
||||
info->ours[info->nr_ours++] = i;
|
||||
@ -417,13 +417,13 @@ void clear_shallow_info(struct shallow_info *info)
|
||||
|
||||
void remove_nonexistent_theirs_shallow(struct shallow_info *info)
|
||||
{
|
||||
unsigned char (*sha1)[20] = info->shallow->sha1;
|
||||
struct object_id *oid = info->shallow->oid;
|
||||
int i, dst;
|
||||
trace_printf_key(&trace_shallow, "shallow: remove_nonexistent_theirs_shallow\n");
|
||||
for (i = dst = 0; i < info->nr_theirs; i++) {
|
||||
if (i != dst)
|
||||
info->theirs[dst] = info->theirs[i];
|
||||
if (has_sha1_file(sha1[info->theirs[i]]))
|
||||
if (has_object_file(oid + info->theirs[i]))
|
||||
dst++;
|
||||
}
|
||||
info->nr_theirs = dst;
|
||||
@ -559,7 +559,7 @@ static void post_assign_shallow(struct shallow_info *info,
|
||||
void assign_shallow_commits_to_refs(struct shallow_info *info,
|
||||
uint32_t **used, int *ref_status)
|
||||
{
|
||||
unsigned char (*sha1)[20] = info->shallow->sha1;
|
||||
struct object_id *oid = info->shallow->oid;
|
||||
struct sha1_array *ref = info->ref;
|
||||
unsigned int i, nr;
|
||||
int *shallow, nr_shallow = 0;
|
||||
@ -599,18 +599,18 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
|
||||
|
||||
/* Mark potential bottoms so we won't go out of bound */
|
||||
for (i = 0; i < nr_shallow; i++) {
|
||||
struct commit *c = lookup_commit(sha1[shallow[i]]);
|
||||
struct commit *c = lookup_commit(oid[shallow[i]].hash);
|
||||
c->object.flags |= BOTTOM;
|
||||
}
|
||||
|
||||
for (i = 0; i < ref->nr; i++)
|
||||
paint_down(&pi, ref->sha1[i], i);
|
||||
paint_down(&pi, ref->oid[i].hash, i);
|
||||
|
||||
if (used) {
|
||||
int bitmap_size = ((pi.nr_bits + 31) / 32) * sizeof(uint32_t);
|
||||
memset(used, 0, sizeof(*used) * info->shallow->nr);
|
||||
for (i = 0; i < nr_shallow; i++) {
|
||||
const struct commit *c = lookup_commit(sha1[shallow[i]]);
|
||||
const struct commit *c = lookup_commit(oid[shallow[i]].hash);
|
||||
uint32_t **map = ref_bitmap_at(&pi.ref_bitmap, c);
|
||||
if (*map)
|
||||
used[shallow[i]] = xmemdupz(*map, bitmap_size);
|
||||
@ -664,7 +664,7 @@ static void post_assign_shallow(struct shallow_info *info,
|
||||
struct ref_bitmap *ref_bitmap,
|
||||
int *ref_status)
|
||||
{
|
||||
unsigned char (*sha1)[20] = info->shallow->sha1;
|
||||
struct object_id *oid = info->shallow->oid;
|
||||
struct commit *c;
|
||||
uint32_t **bitmap;
|
||||
int dst, i, j;
|
||||
@ -679,7 +679,7 @@ static void post_assign_shallow(struct shallow_info *info,
|
||||
for (i = dst = 0; i < info->nr_theirs; i++) {
|
||||
if (i != dst)
|
||||
info->theirs[dst] = info->theirs[i];
|
||||
c = lookup_commit(sha1[info->theirs[i]]);
|
||||
c = lookup_commit(oid[info->theirs[i]].hash);
|
||||
bitmap = ref_bitmap_at(ref_bitmap, c);
|
||||
if (!*bitmap)
|
||||
continue;
|
||||
@ -700,7 +700,7 @@ static void post_assign_shallow(struct shallow_info *info,
|
||||
for (i = dst = 0; i < info->nr_ours; i++) {
|
||||
if (i != dst)
|
||||
info->ours[dst] = info->ours[i];
|
||||
c = lookup_commit(sha1[info->ours[i]]);
|
||||
c = lookup_commit(oid[info->ours[i]].hash);
|
||||
bitmap = ref_bitmap_at(ref_bitmap, c);
|
||||
if (!*bitmap)
|
||||
continue;
|
||||
@ -722,7 +722,7 @@ static void post_assign_shallow(struct shallow_info *info,
|
||||
int delayed_reachability_test(struct shallow_info *si, int c)
|
||||
{
|
||||
if (si->need_reachability_test[c]) {
|
||||
struct commit *commit = lookup_commit(si->shallow->sha1[c]);
|
||||
struct commit *commit = lookup_commit(si->shallow->oid[c].hash);
|
||||
|
||||
if (!si->commits) {
|
||||
struct commit_array ca;
|
||||
|
Reference in New Issue
Block a user