pack-objects: only repack or loosen objects residing in "local" packs
[gitweb.git] / sha1_file.c
index ac4375d298eb12602e35337f378fd22278695f7d..7ead56cc3ef8e96e2ddda1dc77cc83cb6946e7fc 100644 (file)
@@ -1856,26 +1856,8 @@ off_t find_pack_entry_one(const unsigned char *sha1,
        return 0;
 }
 
-int matches_pack_name(struct packed_git *p, const char *name)
-{
-       const char *last_c, *c;
-
-       if (!strcmp(p->pack_name, name))
-               return 1;
-
-       for (c = p->pack_name, last_c = c; *c;)
-               if (*c == '/')
-                       last_c = ++c;
-               else
-                       ++c;
-       if (!strcmp(last_c, name))
-               return 1;
-
-       return 0;
-}
-
 static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
-                        const char **ignore_packed)
+                        int kept_pack_only)
 {
        static struct packed_git *last_found = (void *)1;
        struct packed_git *p;
@@ -1887,15 +1869,8 @@ static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
        p = (last_found == (void *)1) ? packed_git : last_found;
 
        do {
-               if (ignore_packed) {
-                       const char **ig;
-                       for (ig = ignore_packed; *ig; ig++)
-                               if (matches_pack_name(p, *ig))
-                                       break;
-                       if (*ig)
-                               goto next;
-               }
-
+               if (kept_pack_only && !p->pack_keep)
+                       goto next;
                if (p->num_bad_objects) {
                        unsigned i;
                        for (i = 0; i < p->num_bad_objects; i++)
@@ -1937,13 +1912,12 @@ static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
 
 static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
 {
-       return find_pack_ent(sha1, e, NULL);
+       return find_pack_ent(sha1, e, 0);
 }
 
-static int find_kept_pack_entry(const unsigned char *sha1, struct pack_entry *e,
-                               const char **ignore_packed)
+static int find_kept_pack_entry(const unsigned char *sha1, struct pack_entry *e)
 {
-       return find_pack_ent(sha1, e, ignore_packed);
+       return find_pack_ent(sha1, e, 1);
 }
 
 struct packed_git *find_sha1_pack(const unsigned char *sha1,
@@ -2413,10 +2387,10 @@ int has_sha1_pack(const unsigned char *sha1)
        return find_pack_entry(sha1, &e);
 }
 
-int has_sha1_kept_pack(const unsigned char *sha1, const char **ignore_packed)
+int has_sha1_kept_pack(const unsigned char *sha1)
 {
        struct pack_entry e;
-       return find_kept_pack_entry(sha1, &e, ignore_packed);
+       return find_kept_pack_entry(sha1, &e);
 }
 
 int has_sha1_file(const unsigned char *sha1)