cat-file: move batch_options definition to top of file
[gitweb.git] / sha1_file.c
index 7e38148fe52959e1cb8435132c65491dba6850b0..d0b26a0565008af0b276d0faeeda7f24b6cd4803 100644 (file)
@@ -3566,14 +3566,19 @@ int for_each_packed_object(each_packed_object_fn cb, void *data, unsigned flags)
 {
        struct packed_git *p;
        int r = 0;
+       int pack_errors = 0;
 
        prepare_packed_git();
        for (p = packed_git; p; p = p->next) {
                if ((flags & FOR_EACH_OBJECT_LOCAL_ONLY) && !p->pack_local)
                        continue;
+               if (open_pack_index(p)) {
+                       pack_errors = 1;
+                       continue;
+               }
                r = for_each_object_in_pack(p, cb, data);
                if (r)
                        break;
        }
-       return r;
+       return r ? r : pack_errors;
 }