diff options
-rw-r--r-- | fsck-objects.c | 7 | ||||
-rw-r--r-- | name-rev.c | 13 | ||||
-rw-r--r-- | object.c | 15 | ||||
-rw-r--r-- | object.h | 5 |
4 files changed, 27 insertions, 13 deletions
diff --git a/fsck-objects.c b/fsck-objects.c index 769bb2a6a7..ef54a8a411 100644 --- a/fsck-objects.c +++ b/fsck-objects.c @@ -60,12 +60,13 @@ static int objwarning(struct object *obj, const char *err, ...) static void check_connectivity(void) { - int i; + int i, max; /* Look up all the requirements, warn about missing objects.. */ - for (i = 0; i < obj_allocs; i++) { + max = get_max_object_index(); + for (i = 0; i < max; i++) { const struct object_refs *refs; - struct object *obj = objs[i]; + struct object *obj = get_indexed_object(i); if (!obj) continue; diff --git a/name-rev.c b/name-rev.c index 3a5ac35d16..6a23f2d8a2 100644 --- a/name-rev.c +++ b/name-rev.c @@ -234,12 +234,15 @@ int main(int argc, char **argv) fwrite(p_start, p - p_start, 1, stdout); } } else if (all) { - int i; + int i, max; - for (i = 0; i < obj_allocs; i++) - if (objs[i]) - printf("%s %s\n", sha1_to_hex(objs[i]->sha1), - get_rev_name(objs[i])); + max = get_max_object_index(); + for (i = 0; i < max; i++) { + struct object * obj = get_indexed_object(i); + if (!obj) + continue; + printf("%s %s\n", sha1_to_hex(obj->sha1), get_rev_name(obj)); + } } else { int i; for (i = 0; i < revs.nr; i++) @@ -5,9 +5,18 @@ #include "commit.h" #include "tag.h" -struct object **objs; -static int nr_objs; -int obj_allocs; +static struct object **objs; +static int nr_objs, obj_allocs; + +unsigned int get_max_object_index(void) +{ + return obj_allocs; +} + +struct object *get_indexed_object(unsigned int idx) +{ + return objs[idx]; +} const char *type_names[] = { "none", "blob", "tree", "commit", "bad" @@ -40,10 +40,11 @@ struct object { }; extern int track_object_refs; -extern int obj_allocs; -extern struct object **objs; extern const char *type_names[]; +extern unsigned int get_max_object_index(void); +extern struct object *get_indexed_object(unsigned int); + static inline const char *typename(unsigned int type) { return type_names[type > TYPE_TAG ? TYPE_BAD : type]; |