refs.c: remove the_repo from read_ref_at()
[gitweb.git] / builtin / pack-objects.c
index bd67491c1633602a7fab3c48e86bde4421f92c4e..a154fc29f6b7841c2417ca302b631437e7376baa 100644 (file)
@@ -33,6 +33,7 @@
 #include "object-store.h"
 #include "dir.h"
 #include "midx.h"
+#include "trace2.h"
 
 #define IN_PACK(obj) oe_in_pack(&to_pack, obj)
 #define SIZE(obj) oe_size(&to_pack, obj)
@@ -1643,7 +1644,7 @@ static void check_object(struct object_entry *entry)
 
                /*
                 * No choice but to fall back to the recursive delta walk
-                * with sha1_object_info() to find about the object type
+                * with oid_object_info() to find about the object type
                 * at this point...
                 */
                give_up:
@@ -1719,7 +1720,7 @@ static void drop_reused_delta(struct object_entry *entry)
        if (packed_object_info(the_repository, IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {
                /*
                 * We failed to get the info from this pack for some reason;
-                * fall back to sha1_object_info, which may find another copy.
+                * fall back to oid_object_info, which may find another copy.
                 * And if that fails, the error will be recorded in oe_type(entry)
                 * and dealt with in prepare_pack().
                 */
@@ -1902,10 +1903,10 @@ static int type_size_sort(const void *_a, const void *_b)
 {
        const struct object_entry *a = *(struct object_entry **)_a;
        const struct object_entry *b = *(struct object_entry **)_b;
-       enum object_type a_type = oe_type(a);
-       enum object_type b_type = oe_type(b);
-       unsigned long a_size = SIZE(a);
-       unsigned long b_size = SIZE(b);
+       const enum object_type a_type = oe_type(a);
+       const enum object_type b_type = oe_type(b);
+       const unsigned long a_size = SIZE(a);
+       const unsigned long b_size = SIZE(b);
 
        if (a_type > b_type)
                return -1;
@@ -1920,7 +1921,7 @@ static int type_size_sort(const void *_a, const void *_b)
        if (a->preferred_base < b->preferred_base)
                return 1;
        if (use_delta_islands) {
-               int island_cmp = island_delta_cmp(&a->idx.oid, &b->idx.oid);
+               const int island_cmp = island_delta_cmp(&a->idx.oid, &b->idx.oid);
                if (island_cmp)
                        return island_cmp;
        }
@@ -2167,7 +2168,7 @@ static unsigned int check_delta_limit(struct object_entry *me, unsigned int n)
        struct object_entry *child = DELTA_CHILD(me);
        unsigned int m = n;
        while (child) {
-               unsigned int c = check_delta_limit(child, n + 1);
+               const unsigned int c = check_delta_limit(child, n + 1);
                if (m < c)
                        m = c;
                child = DELTA_SIBLING(child);
@@ -2222,7 +2223,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,
                while (window_memory_limit &&
                       mem_usage > window_memory_limit &&
                       count > 1) {
-                       uint32_t tail = (idx + window - count) % window;
+                       const uint32_t tail = (idx + window - count) % window;
                        mem_usage -= free_unpacked(array + tail);
                        count--;
                }
@@ -3473,6 +3474,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                }
        }
 
+       trace2_region_enter("pack-objects", "enumerate-objects",
+                           the_repository);
        prepare_packing_data(the_repository, &to_pack);
 
        if (progress)
@@ -3487,12 +3490,23 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
        if (include_tag && nr_result)
                for_each_ref(add_ref_tag, NULL);
        stop_progress(&progress_state);
+       trace2_region_leave("pack-objects", "enumerate-objects",
+                           the_repository);
 
        if (non_empty && !nr_result)
                return 0;
-       if (nr_result)
+       if (nr_result) {
+               trace2_region_enter("pack-objects", "prepare-pack",
+                                   the_repository);
                prepare_pack(window, depth);
+               trace2_region_leave("pack-objects", "prepare-pack",
+                                   the_repository);
+       }
+
+       trace2_region_enter("pack-objects", "write-pack-file", the_repository);
        write_pack_file();
+       trace2_region_leave("pack-objects", "write-pack-file", the_repository);
+
        if (progress)
                fprintf_ln(stderr,
                           _("Total %"PRIu32" (delta %"PRIu32"),"