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 <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Mar 22, 2014 at 18:15 UTC
3753bd1f69d3b17e0369390fb8960ae3b7855b70
1 file changed
+38
-41
diffcore-pickaxe.c
+38
-41
@@ -12,47 +12,6 @@ typedef int (*pickaxe_fn)(mmfile_t *one, mmfile_t *two,
12
struct diff_options *o,
13
regex_t *regexp, kwset_t kws);
14
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
-
15
struct diffgrep_cb {
16
regex_t *regexp;
17
int hit;
@@ -204,6 +163,44 @@ static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,
163
return ret;
164
}
165
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
+
204
void diffcore_pickaxe(struct diff_options *o)
205
{
206
const char *needle = o->pickaxe;