summaryrefslogtreecommitdiff
path: root/shallow.c
diff options
context:
space:
mode:
Diffstat (limited to 'shallow.c')
-rw-r--r--shallow.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/shallow.c b/shallow.c
index f9370961f9..54359d5490 100644
--- a/shallow.c
+++ b/shallow.c
@@ -27,13 +27,13 @@ void set_alternate_shallow_file(const char *path, int override)
alternate_shallow_file = xstrdup_or_null(path);
}
-int register_shallow(const unsigned char *sha1)
+int register_shallow(const struct object_id *oid)
{
struct commit_graft *graft =
xmalloc(sizeof(struct commit_graft));
- struct commit *commit = lookup_commit(sha1);
+ struct commit *commit = lookup_commit(oid);
- hashcpy(graft->oid.hash, sha1);
+ oidcpy(&graft->oid, oid);
graft->nr_parent = -1;
if (commit && commit->object.parsed)
commit->parents = NULL;
@@ -65,10 +65,10 @@ int is_repository_shallow(void)
is_shallow = 1;
while (fgets(buf, sizeof(buf), fp)) {
- unsigned char sha1[20];
- if (get_sha1_hex(buf, sha1))
+ struct object_id oid;
+ if (get_oid_hex(buf, &oid))
die("bad shallow line: %s", buf);
- register_shallow(sha1);
+ register_shallow(&oid);
}
fclose(fp);
return is_shallow;
@@ -241,7 +241,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
if (graft->nr_parent != -1)
return 0;
if (data->flags & SEEN_ONLY) {
- struct commit *c = lookup_commit(graft->oid.hash);
+ struct commit *c = lookup_commit(&graft->oid);
if (!c || !(c->object.flags & SEEN)) {
if (data->flags & VERBOSE)
printf("Removing %s from .git/shallow\n",
@@ -443,7 +443,7 @@ struct paint_info {
static uint32_t *paint_alloc(struct paint_info *info)
{
- unsigned nr = (info->nr_bits + 31) / 32;
+ unsigned nr = DIV_ROUND_UP(info->nr_bits, 32);
unsigned size = nr * sizeof(uint32_t);
void *p;
if (!info->pool_count || size > info->end - info->free) {
@@ -466,14 +466,14 @@ static uint32_t *paint_alloc(struct paint_info *info)
* UNINTERESTING or BOTTOM is hit. Set the id-th bit in ref_bitmap for
* all walked commits.
*/
-static void paint_down(struct paint_info *info, const unsigned char *sha1,
+static void paint_down(struct paint_info *info, const struct object_id *oid,
unsigned int id)
{
unsigned int i, nr;
struct commit_list *head = NULL;
- int bitmap_nr = (info->nr_bits + 31) / 32;
+ int bitmap_nr = DIV_ROUND_UP(info->nr_bits, 32);
size_t bitmap_size = st_mult(sizeof(uint32_t), bitmap_nr);
- struct commit *c = lookup_commit_reference_gently(sha1, 1);
+ struct commit *c = lookup_commit_reference_gently(oid, 1);
uint32_t *tmp; /* to be freed before return */
uint32_t *bitmap;
@@ -535,7 +535,7 @@ static void paint_down(struct paint_info *info, const unsigned char *sha1,
static int mark_uninteresting(const char *refname, const struct object_id *oid,
int flags, void *cb_data)
{
- struct commit *commit = lookup_commit_reference_gently(oid->hash, 1);
+ struct commit *commit = lookup_commit_reference_gently(oid, 1);
if (!commit)
return 0;
commit->object.flags |= UNINTERESTING;
@@ -603,18 +603,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(oid[shallow[i]].hash);
+ struct commit *c = lookup_commit(&oid[shallow[i]]);
c->object.flags |= BOTTOM;
}
for (i = 0; i < ref->nr; i++)
- paint_down(&pi, ref->oid[i].hash, i);
+ paint_down(&pi, ref->oid + i, i);
if (used) {
- int bitmap_size = ((pi.nr_bits + 31) / 32) * sizeof(uint32_t);
+ int bitmap_size = DIV_ROUND_UP(pi.nr_bits, 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(oid[shallow[i]].hash);
+ const struct commit *c = lookup_commit(&oid[shallow[i]]);
uint32_t **map = ref_bitmap_at(&pi.ref_bitmap, c);
if (*map)
used[shallow[i]] = xmemdupz(*map, bitmap_size);
@@ -645,7 +645,7 @@ static int add_ref(const char *refname, const struct object_id *oid,
{
struct commit_array *ca = cb_data;
ALLOC_GROW(ca->commits, ca->nr + 1, ca->alloc);
- ca->commits[ca->nr] = lookup_commit_reference_gently(oid->hash, 1);
+ ca->commits[ca->nr] = lookup_commit_reference_gently(oid, 1);
if (ca->commits[ca->nr])
ca->nr++;
return 0;
@@ -672,7 +672,7 @@ static void post_assign_shallow(struct shallow_info *info,
struct commit *c;
uint32_t **bitmap;
int dst, i, j;
- int bitmap_nr = (info->ref->nr + 31) / 32;
+ int bitmap_nr = DIV_ROUND_UP(info->ref->nr, 32);
struct commit_array ca;
trace_printf_key(&trace_shallow, "shallow: post_assign_shallow\n");
@@ -683,7 +683,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(oid[info->theirs[i]].hash);
+ c = lookup_commit(&oid[info->theirs[i]]);
bitmap = ref_bitmap_at(ref_bitmap, c);
if (!*bitmap)
continue;
@@ -704,7 +704,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(oid[info->ours[i]].hash);
+ c = lookup_commit(&oid[info->ours[i]]);
bitmap = ref_bitmap_at(ref_bitmap, c);
if (!*bitmap)
continue;
@@ -726,7 +726,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->oid[c].hash);
+ struct commit *commit = lookup_commit(&si->shallow->oid[c]);
if (!si->commits) {
struct commit_array ca;