]> git.ipfire.org Git - thirdparty/git.git/commitdiff
treewide: use get_all_packs
authorDerrick Stolee <dstolee@microsoft.com>
Mon, 20 Aug 2018 16:52:04 +0000 (16:52 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Aug 2018 22:31:40 +0000 (15:31 -0700)
There are many places in the codebase that want to iterate over
all packfiles known to Git. The purposes are wide-ranging, and
those that can take advantage of the multi-pack-index already
do. So, use get_all_packs() instead of get_packed_git() to be
sure we are iterating over all packfiles.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/count-objects.c
builtin/fsck.c
builtin/gc.c
builtin/pack-objects.c
builtin/pack-redundant.c
fast-import.c
http-backend.c
pack-bitmap.c
pack-objects.c
packfile.c
server-info.c

index d51e2ce1ec016ab35f1781675ff70793f0b974d5..a7cad052c615807b819f32c999c161f0f905c1bc 100644 (file)
@@ -123,7 +123,7 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
                struct strbuf pack_buf = STRBUF_INIT;
                struct strbuf garbage_buf = STRBUF_INIT;
 
-               for (p = get_packed_git(the_repository); p; p = p->next) {
+               for (p = get_all_packs(the_repository); p; p = p->next) {
                        if (!p->pack_local)
                                continue;
                        if (open_pack_index(p))
index 250f5af1182ddc66ac0a729c1d39e94d8b19a878..63c8578cc16cd2f77f28d7c1b0515ce317f4e264 100644 (file)
@@ -740,7 +740,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
                        struct progress *progress = NULL;
 
                        if (show_progress) {
-                               for (p = get_packed_git(the_repository); p;
+                               for (p = get_all_packs(the_repository); p;
                                     p = p->next) {
                                        if (open_pack_index(p))
                                                continue;
@@ -749,7 +749,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 
                                progress = start_progress(_("Checking objects"), total);
                        }
-                       for (p = get_packed_git(the_repository); p;
+                       for (p = get_all_packs(the_repository); p;
                             p = p->next) {
                                /* verify gives error messages itself */
                                if (verify_pack(p, fsck_obj_buffer,
index 57069442b0dc1297366e29b1fbf0e6ee70377146..2b592260e9ad0de18e8eaae4df20cc6f886a4681 100644 (file)
@@ -183,7 +183,7 @@ static struct packed_git *find_base_packs(struct string_list *packs,
 {
        struct packed_git *p, *base = NULL;
 
-       for (p = get_packed_git(the_repository); p; p = p->next) {
+       for (p = get_all_packs(the_repository); p; p = p->next) {
                if (!p->pack_local)
                        continue;
                if (limit) {
@@ -208,7 +208,7 @@ static int too_many_packs(void)
        if (gc_auto_pack_limit <= 0)
                return 0;
 
-       for (cnt = 0, p = get_packed_git(the_repository); p; p = p->next) {
+       for (cnt = 0, p = get_all_packs(the_repository); p; p = p->next) {
                if (!p->pack_local)
                        continue;
                if (p->pack_keep)
index 0d80dee2ba1ad82fd21622f73dac86b6010da4b6..cf5cf45ac940565f0dcd65ed21e164ed98844873 100644 (file)
@@ -2809,7 +2809,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)
 
        memset(&in_pack, 0, sizeof(in_pack));
 
-       for (p = get_packed_git(the_repository); p; p = p->next) {
+       for (p = get_all_packs(the_repository); p; p = p->next) {
                struct object_id oid;
                struct object *o;
 
@@ -2873,7 +2873,7 @@ static int has_sha1_pack_kept_or_nonlocal(const struct object_id *oid)
        struct packed_git *p;
 
        p = (last_found != (void *)1) ? last_found :
-                                       get_packed_git(the_repository);
+                                       get_all_packs(the_repository);
 
        while (p) {
                if ((!p->pack_local || p->pack_keep ||
@@ -2883,7 +2883,7 @@ static int has_sha1_pack_kept_or_nonlocal(const struct object_id *oid)
                        return 1;
                }
                if (p == last_found)
-                       p = get_packed_git(the_repository);
+                       p = get_all_packs(the_repository);
                else
                        p = p->next;
                if (p == last_found)
@@ -2919,7 +2919,7 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
        uint32_t i;
        struct object_id oid;
 
-       for (p = get_packed_git(the_repository); p; p = p->next) {
+       for (p = get_all_packs(the_repository); p; p = p->next) {
                if (!p->pack_local || p->pack_keep || p->pack_keep_in_core)
                        continue;
 
@@ -3066,7 +3066,7 @@ static void add_extra_kept_packs(const struct string_list *names)
        if (!names->nr)
                return;
 
-       for (p = get_packed_git(the_repository); p; p = p->next) {
+       for (p = get_all_packs(the_repository); p; p = p->next) {
                const char *name = basename(p->pack_name);
                int i;
 
@@ -3339,7 +3339,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
        add_extra_kept_packs(&keep_pack_list);
        if (ignore_packed_keep_on_disk) {
                struct packed_git *p;
-               for (p = get_packed_git(the_repository); p; p = p->next)
+               for (p = get_all_packs(the_repository); p; p = p->next)
                        if (p->pack_local && p->pack_keep)
                                break;
                if (!p) /* no keep-able packs found */
@@ -3352,7 +3352,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                 * it also covers non-local objects
                 */
                struct packed_git *p;
-               for (p = get_packed_git(the_repository); p; p = p->next) {
+               for (p = get_all_packs(the_repository); p; p = p->next) {
                        if (!p->pack_local) {
                                have_non_local_packs = 1;
                                break;
index 0494dceff73d672ee430f1c5bd0ce9f8b70c83f6..cf9a9aabd4eb2e834c08f85240bcb3d0154c3320 100644 (file)
@@ -577,7 +577,7 @@ static struct pack_list * add_pack(struct packed_git *p)
 
 static struct pack_list * add_pack_file(const char *filename)
 {
-       struct packed_git *p = get_packed_git(the_repository);
+       struct packed_git *p = get_all_packs(the_repository);
 
        if (strlen(filename) < 40)
                die("Bad pack filename: %s", filename);
@@ -592,7 +592,7 @@ static struct pack_list * add_pack_file(const char *filename)
 
 static void load_all(void)
 {
-       struct packed_git *p = get_packed_git(the_repository);
+       struct packed_git *p = get_all_packs(the_repository);
 
        while (p) {
                add_pack(p);
index 89bb0c9db3de9b380aad53709d882cb04f7d054a..f8c3acd3b5577caa24c13402ea2b6f733e41aec5 100644 (file)
@@ -1068,7 +1068,7 @@ static int store_object(
                duplicate_count_by_type[type]++;
                return 1;
        } else if (find_sha1_pack(oid.hash,
-                                 get_packed_git(the_repository))) {
+                                 get_all_packs(the_repository))) {
                e->type = type;
                e->pack_id = MAX_PACK_ID;
                e->idx.offset = 1; /* just not zero! */
@@ -1266,7 +1266,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
                truncate_pack(&checkpoint);
 
        } else if (find_sha1_pack(oid.hash,
-                                 get_packed_git(the_repository))) {
+                                 get_all_packs(the_repository))) {
                e->type = OBJ_BLOB;
                e->pack_id = MAX_PACK_ID;
                e->idx.offset = 1; /* just not zero! */
index 88c38c834ba479447be8eb64f3bc5331cdb9ed49..809ba7d2c49eace9e2e9c4dae348c394dac28209 100644 (file)
@@ -595,13 +595,13 @@ static void get_info_packs(struct strbuf *hdr, char *arg)
        size_t cnt = 0;
 
        select_getanyfile(hdr);
-       for (p = get_packed_git(the_repository); p; p = p->next) {
+       for (p = get_all_packs(the_repository); p; p = p->next) {
                if (p->pack_local)
                        cnt++;
        }
 
        strbuf_grow(&buf, cnt * 53 + 2);
-       for (p = get_packed_git(the_repository); p; p = p->next) {
+       for (p = get_all_packs(the_repository); p; p = p->next) {
                if (p->pack_local)
                        strbuf_addf(&buf, "P %s\n", p->pack_name + objdirlen + 6);
        }
index f0a1937a1cc5fbb13fc705df8d193a43a0648198..4e50ab391fa0df9fc2d28a5bfdc31996635699b6 100644 (file)
@@ -335,7 +335,7 @@ static int open_pack_bitmap(struct bitmap_index *bitmap_git)
 
        assert(!bitmap_git->map && !bitmap_git->loaded);
 
-       for (p = get_packed_git(the_repository); p; p = p->next) {
+       for (p = get_all_packs(the_repository); p; p = p->next) {
                if (open_pack_bitmap_1(bitmap_git, p) == 0)
                        ret = 0;
        }
index 92708522e76b4565882177f899612d72a3f6d75a..832dcf7462797523fea8262db31077033c1a2910 100644 (file)
@@ -99,7 +99,7 @@ static void prepare_in_pack_by_idx(struct packing_data *pdata)
         * (i.e. in_pack_idx also zero) should return NULL.
         */
        mapping[cnt++] = NULL;
-       for (p = get_packed_git(the_repository); p; p = p->next, cnt++) {
+       for (p = get_all_packs(the_repository); p; p = p->next, cnt++) {
                if (cnt == nr) {
                        free(mapping);
                        return;
index adcf2e12a0749b0b6ac8529c866e263fc2d8bc54..cbef7033c3b8ea96e716dbe693bb40182cacdcf0 100644 (file)
@@ -2036,7 +2036,7 @@ int for_each_packed_object(each_packed_object_fn cb, void *data,
        int pack_errors = 0;
 
        prepare_packed_git(the_repository);
-       for (p = the_repository->objects->packed_git; p; p = p->next) {
+       for (p = get_all_packs(the_repository); p; p = p->next) {
                if ((flags & FOR_EACH_OBJECT_LOCAL_ONLY) && !p->pack_local)
                        continue;
                if ((flags & FOR_EACH_OBJECT_PROMISOR_ONLY) &&
index 41050c2449b1adaaeddda30529f9eb1d62981396..e2b2d6a27a40b1a3683dd99459c0fab0d45dc0c9 100644 (file)
@@ -199,7 +199,7 @@ static void init_pack_info(const char *infofile, int force)
        objdir = get_object_directory();
        objdirlen = strlen(objdir);
 
-       for (p = get_packed_git(the_repository); p; p = p->next) {
+       for (p = get_all_packs(the_repository); p; p = p->next) {
                /* we ignore things on alternate path since they are
                 * not available to the pullers in general.
                 */
@@ -209,7 +209,7 @@ static void init_pack_info(const char *infofile, int force)
        }
        num_pack = i;
        info = xcalloc(num_pack, sizeof(struct pack_info *));
-       for (i = 0, p = get_packed_git(the_repository); p; p = p->next) {
+       for (i = 0, p = get_all_packs(the_repository); p; p = p->next) {
                if (!p->pack_local)
                        continue;
                info[i] = xcalloc(1, sizeof(struct pack_info));