diff options
author | René Scharfe <l.s.r@web.de> | 2014-03-22 18:15:58 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-03-24 15:13:10 -0700 |
commit | 3753bd1f69d3b17e0369390fb8960ae3b7855b70 (patch) | |
tree | 5f8f11d3b22aaec7b2e31de0b4fa434fa98ad818 | |
parent | pickaxe: merge diffcore_pickaxe_grep() and diffcore_pickaxe_count() into diff... (diff) | |
download | tgif-3753bd1f69d3b17e0369390fb8960ae3b7855b70.tar.xz |
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>
-rw-r--r-- | diffcore-pickaxe.c | 79 |
1 files changed, 38 insertions, 41 deletions
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c index cfc4262e4d..827a7d7e76 100644 --- a/diffcore-pickaxe.c +++ b/diffcore-pickaxe.c @@ -12,47 +12,6 @@ typedef int (*pickaxe_fn)(mmfile_t *one, mmfile_t *two, struct diff_options *o, regex_t *regexp, kwset_t kws); -static int pickaxe_match(struct diff_filepair *p, struct diff_options *o, - regex_t *regexp, kwset_t kws, pickaxe_fn fn); - -static void pickaxe(struct diff_queue_struct *q, struct diff_options *o, - regex_t *regexp, kwset_t kws, pickaxe_fn fn) -{ - int i; - struct diff_queue_struct outq; - - DIFF_QUEUE_CLEAR(&outq); - - if (o->pickaxe_opts & DIFF_PICKAXE_ALL) { - /* Showing the whole changeset if needle exists */ - for (i = 0; i < q->nr; i++) { - struct diff_filepair *p = q->queue[i]; - if (pickaxe_match(p, o, regexp, kws, fn)) - return; /* do not munge the queue */ - } - - /* - * Otherwise we will clear the whole queue by copying - * the empty outq at the end of this function, but - * first clear the current entries in the queue. - */ - for (i = 0; i < q->nr; i++) - diff_free_filepair(q->queue[i]); - } else { - /* Showing only the filepairs that has the needle */ - for (i = 0; i < q->nr; i++) { - struct diff_filepair *p = q->queue[i]; - if (pickaxe_match(p, o, regexp, kws, fn)) - diff_q(&outq, p); - else - diff_free_filepair(p); - } - } - - free(q->queue); - *q = outq; -} - struct diffgrep_cb { regex_t *regexp; int hit; @@ -204,6 +163,44 @@ static int pickaxe_match(struct diff_filepair *p, struct diff_options *o, return ret; } +static void pickaxe(struct diff_queue_struct *q, struct diff_options *o, + regex_t *regexp, kwset_t kws, pickaxe_fn fn) +{ + int i; + struct diff_queue_struct outq; + + DIFF_QUEUE_CLEAR(&outq); + + if (o->pickaxe_opts & DIFF_PICKAXE_ALL) { + /* Showing the whole changeset if needle exists */ + for (i = 0; i < q->nr; i++) { + struct diff_filepair *p = q->queue[i]; + if (pickaxe_match(p, o, regexp, kws, fn)) + return; /* do not munge the queue */ + } + + /* + * Otherwise we will clear the whole queue by copying + * the empty outq at the end of this function, but + * first clear the current entries in the queue. + */ + for (i = 0; i < q->nr; i++) + diff_free_filepair(q->queue[i]); + } else { + /* Showing only the filepairs that has the needle */ + for (i = 0; i < q->nr; i++) { + struct diff_filepair *p = q->queue[i]; + if (pickaxe_match(p, o, regexp, kws, fn)) + diff_q(&outq, p); + else + diff_free_filepair(p); + } + } + + free(q->queue); + *q = outq; +} + void diffcore_pickaxe(struct diff_options *o) { const char *needle = o->pickaxe; |