Skip to content

Commit b0eb92b

Browse files
pcloudsgitster
authored andcommitted
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] bb408ac (bisect.c: use commit-slab for commit weight instead of commit->util - 2018-05-19) [2] cbd53a2 (object-store: move object access functions to object-store.h - 2018-05-15) Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2f74393 commit b0eb92b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

bisect.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "sha1-array.h"
1414
#include "argv-array.h"
1515
#include "commit-slab.h"
16+
#include "object-store.h"
1617

1718
static struct oid_array good_revs;
1819
static struct oid_array skipped_revs;
@@ -120,14 +121,14 @@ static inline int halfway(struct commit_list *p, int nr)
120121
}
121122
}
122123

123-
#if !DEBUG_BISECT
124-
#define show_list(a,b,c,d) do { ; } while (0)
125-
#else
126124
static void show_list(const char *debug, int counted, int nr,
127125
struct commit_list *list)
128126
{
129127
struct commit_list *p;
130128

129+
if (!DEBUG_BISECT)
130+
return;
131+
131132
fprintf(stderr, "%s (%d/%d)\n", debug, counted, nr);
132133

133134
for (p = list; p; p = p->next) {
@@ -145,7 +146,7 @@ static void show_list(const char *debug, int counted, int nr,
145146
(flags & TREESAME) ? ' ' : 'T',
146147
(flags & UNINTERESTING) ? 'U' : ' ',
147148
(flags & COUNTED) ? 'C' : ' ');
148-
if (commit->util)
149+
if (*commit_weight_at(&commit_weight, p->item))
149150
fprintf(stderr, "%3d", weight(p));
150151
else
151152
fprintf(stderr, "---");
@@ -160,7 +161,6 @@ static void show_list(const char *debug, int counted, int nr,
160161
fprintf(stderr, "\n");
161162
}
162163
}
163-
#endif /* DEBUG_BISECT */
164164

165165
static struct commit_list *best_bisection(struct commit_list *list, int nr)
166166
{

0 commit comments

Comments
 (0)