Skip to content

Commit 3753bd1

Browse files
rscharfegitster
authored andcommitted
pickaxe: move pickaxe() after pickaxe_match()
pickaxe() calls pickaxe_match(); moving the definition of the former after the latter allows us to do without an explicit function declaration. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 63b52af commit 3753bd1

File tree

1 file changed

+38
-41
lines changed

1 file changed

+38
-41
lines changed

diffcore-pickaxe.c

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,6 @@ typedef int (*pickaxe_fn)(mmfile_t *one, mmfile_t *two,
1212
struct diff_options *o,
1313
regex_t *regexp, kwset_t kws);
1414

15-
static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,
16-
regex_t *regexp, kwset_t kws, pickaxe_fn fn);
17-
18-
static void pickaxe(struct diff_queue_struct *q, struct diff_options *o,
19-
regex_t *regexp, kwset_t kws, pickaxe_fn fn)
20-
{
21-
int i;
22-
struct diff_queue_struct outq;
23-
24-
DIFF_QUEUE_CLEAR(&outq);
25-
26-
if (o->pickaxe_opts & DIFF_PICKAXE_ALL) {
27-
/* Showing the whole changeset if needle exists */
28-
for (i = 0; i < q->nr; i++) {
29-
struct diff_filepair *p = q->queue[i];
30-
if (pickaxe_match(p, o, regexp, kws, fn))
31-
return; /* do not munge the queue */
32-
}
33-
34-
/*
35-
* Otherwise we will clear the whole queue by copying
36-
* the empty outq at the end of this function, but
37-
* first clear the current entries in the queue.
38-
*/
39-
for (i = 0; i < q->nr; i++)
40-
diff_free_filepair(q->queue[i]);
41-
} else {
42-
/* Showing only the filepairs that has the needle */
43-
for (i = 0; i < q->nr; i++) {
44-
struct diff_filepair *p = q->queue[i];
45-
if (pickaxe_match(p, o, regexp, kws, fn))
46-
diff_q(&outq, p);
47-
else
48-
diff_free_filepair(p);
49-
}
50-
}
51-
52-
free(q->queue);
53-
*q = outq;
54-
}
55-
5615
struct diffgrep_cb {
5716
regex_t *regexp;
5817
int hit;
@@ -204,6 +163,44 @@ static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,
204163
return ret;
205164
}
206165

166+
static void pickaxe(struct diff_queue_struct *q, struct diff_options *o,
167+
regex_t *regexp, kwset_t kws, pickaxe_fn fn)
168+
{
169+
int i;
170+
struct diff_queue_struct outq;
171+
172+
DIFF_QUEUE_CLEAR(&outq);
173+
174+
if (o->pickaxe_opts & DIFF_PICKAXE_ALL) {
175+
/* Showing the whole changeset if needle exists */
176+
for (i = 0; i < q->nr; i++) {
177+
struct diff_filepair *p = q->queue[i];
178+
if (pickaxe_match(p, o, regexp, kws, fn))
179+
return; /* do not munge the queue */
180+
}
181+
182+
/*
183+
* Otherwise we will clear the whole queue by copying
184+
* the empty outq at the end of this function, but
185+
* first clear the current entries in the queue.
186+
*/
187+
for (i = 0; i < q->nr; i++)
188+
diff_free_filepair(q->queue[i]);
189+
} else {
190+
/* Showing only the filepairs that has the needle */
191+
for (i = 0; i < q->nr; i++) {
192+
struct diff_filepair *p = q->queue[i];
193+
if (pickaxe_match(p, o, regexp, kws, fn))
194+
diff_q(&outq, p);
195+
else
196+
diff_free_filepair(p);
197+
}
198+
}
199+
200+
free(q->queue);
201+
*q = outq;
202+
}
203+
207204
void diffcore_pickaxe(struct diff_options *o)
208205
{
209206
const char *needle = o->pickaxe;

0 commit comments

Comments
 (0)