bisect.c: make show_list() build again

This function only compiles when DEBUG_BISECT is 1, which is often not the case. As a result there are two commits [1] [2] that break it but the breakages went unnoticed because the code did not compile by default. Update the function and include the new header file to make this function build again. In order to stop this from happening again, the function is now compiled unconditionally but exits early unless DEBUG_BISECT is non-zero. A smart compiler generates no extra code (not even a function call). But even if it does not, this function does not seem to be in a hot path that the extra cost becomes a big problem. [1] bb408ac95d (bisect.c: use commit-slab for commit weight instead of commit->util - 2018-05-19) [2] cbd53a2193 (object-store: move object access functions to object-store.h - 2018-05-15) Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Sep 2, 2018 at 09:42 UTC b0eb92bbc297348a47cc25bdd9d32ab338289359
1 file changed +5 -5
bisect.c
+5 -5
@@ -13,6 +13,7 @@
13 #include "sha1-array.h"
14 #include "argv-array.h"
15 #include "commit-slab.h"
16 +#include "object-store.h"
17
18 static struct oid_array good_revs;
19 static struct oid_array skipped_revs;
@@ -120,14 +121,14 @@ static inline int halfway(struct commit_list *p, int nr)
121 }
122 }
123
123 -#if !DEBUG_BISECT
124 -#define show_list(a,b,c,d) do { ; } while (0)
125 -#else
124 static void show_list(const char *debug, int counted, int nr,
125 struct commit_list *list)
126 {
127 struct commit_list *p;
128
129 + if (!DEBUG_BISECT)
130 + return;
131 +
132 fprintf(stderr, "%s (%d/%d)\n", debug, counted, nr);
133
134 for (p = list; p; p = p->next) {
@@ -145,7 +146,7 @@ static void show_list(const char *debug, int counted, int nr,
146 (flags & TREESAME) ? ' ' : 'T',
147 (flags & UNINTERESTING) ? 'U' : ' ',
148 (flags & COUNTED) ? 'C' : ' ');
148 - if (commit->util)
149 + if (*commit_weight_at(&commit_weight, p->item))
150 fprintf(stderr, "%3d", weight(p));
151 else
152 fprintf(stderr, "---");
@@ -160,7 +161,6 @@ static void show_list(const char *debug, int counted, int nr,
161 fprintf(stderr, "\n");
162 }
163 }
163 -#endif /* DEBUG_BISECT */
164
165 static struct commit_list *best_bisection(struct commit_list *list, int nr)
166 {