Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
diff: factor out match_filter()
author
Junio C Hamano
<gitster@pobox.com>
Wed, 17 Jul 2013 22:09:34 +0000
(15:09 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 17 Jul 2013 22:09:34 +0000
(15:09 -0700)
diffcore_apply_filter() checks if a filepair matches the filter
given with the "--diff-filter" option for each input filepairs with
a fairly complex expression in two places.
Create a helper function and call it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
949226f
)
diff --git
a/diff.c
b/diff.c
index 41c64f2b28176f1c3a48e421e779931c7cb51fc2..0220c19525f45f40eb6e940ac5454d996967e498 100644
(file)
--- a/
diff.c
+++ b/
diff.c
@@
-4509,6
+4509,17
@@
void diff_flush(struct diff_options *options)
}
}
}
}
+static int match_filter(const struct diff_options *options, const struct diff_filepair *p)
+{
+ return (((p->status == DIFF_STATUS_MODIFIED) &&
+ ((p->score &&
+ strchr(options->filter, DIFF_STATUS_FILTER_BROKEN)) ||
+ (!p->score &&
+ strchr(options->filter, DIFF_STATUS_MODIFIED)))) ||
+ ((p->status != DIFF_STATUS_MODIFIED) &&
+ strchr(options->filter, p->status)));
+}
+
static void diffcore_apply_filter(struct diff_options *options)
{
int i;
static void diffcore_apply_filter(struct diff_options *options)
{
int i;
@@
-4524,14
+4535,7
@@
static void diffcore_apply_filter(struct diff_options *options)
if (strchr(filter, DIFF_STATUS_FILTER_AON)) {
int found;
for (i = found = 0; !found && i < q->nr; i++) {
if (strchr(filter, DIFF_STATUS_FILTER_AON)) {
int found;
for (i = found = 0; !found && i < q->nr; i++) {
- struct diff_filepair *p = q->queue[i];
- if (((p->status == DIFF_STATUS_MODIFIED) &&
- ((p->score &&
- strchr(filter, DIFF_STATUS_FILTER_BROKEN)) ||
- (!p->score &&
- strchr(filter, DIFF_STATUS_MODIFIED)))) ||
- ((p->status != DIFF_STATUS_MODIFIED) &&
- strchr(filter, p->status)))
+ if (match_filter(options, q->queue[i]))
found++;
}
if (found)
found++;
}
if (found)
@@
-4549,14
+4553,7
@@
static void diffcore_apply_filter(struct diff_options *options)
/* Only the matching ones */
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
/* Only the matching ones */
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
-
- if (((p->status == DIFF_STATUS_MODIFIED) &&
- ((p->score &&
- strchr(filter, DIFF_STATUS_FILTER_BROKEN)) ||
- (!p->score &&
- strchr(filter, DIFF_STATUS_MODIFIED)))) ||
- ((p->status != DIFF_STATUS_MODIFIED) &&
- strchr(filter, p->status)))
+ if (match_filter(options, p))
diff_q(&outq, p);
else
diff_free_filepair(p);
diff_q(&outq, p);
else
diff_free_filepair(p);