Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2021-12-09 13:30:04 +0300
committerJunio C Hamano <gitster@pobox.com>2021-12-10 00:24:06 +0300
commitff046a0066f55cb730ced3f8eb54d508dcd3a4c7 (patch)
tree7024a1f0de38e00f93b8b6987377c7e007e45ee3 /diff.c
parent08fba1076faf0b2c0bfeda628c84ac15efd27cfb (diff)
diff --color-moved: unify moved block growth functions
After the last two commits pmb_advance_or_null() and pmb_advance_or_null_multi_match() differ only in the comparison they perform. Lets simplify the code by combining them into a single function. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c41
1 files changed, 12 insertions, 29 deletions
diff --git a/diff.c b/diff.c
index 22e0edac17..51f092e724 100644
--- a/diff.c
+++ b/diff.c
@@ -1002,36 +1002,23 @@ static void pmb_advance_or_null(struct diff_options *o,
unsigned flags = o->color_moved_ws_handling & XDF_WHITESPACE_FLAGS;
for (i = 0; i < pmb_nr; i++) {
+ int match;
struct moved_entry *prev = pmb[i].match;
struct moved_entry *cur = (prev && prev->next_line) ?
prev->next_line : NULL;
- if (cur && xdiff_compare_lines(cur->es->line, cur->es->len,
- l->line, l->len,
- flags)) {
- pmb[i].match = cur;
- } else {
- pmb[i].match = NULL;
- }
- }
-}
-static void pmb_advance_or_null_multi_match(struct diff_options *o,
- struct emitted_diff_symbol *l,
- struct moved_block *pmb,
- int pmb_nr)
-{
- int i;
-
- for (i = 0; i < pmb_nr; i++) {
- struct moved_entry *prev = pmb[i].match;
- struct moved_entry *cur = (prev && prev->next_line) ?
- prev->next_line : NULL;
- if (cur && !cmp_in_block_with_wsd(cur, l, &pmb[i])) {
- /* Advance to the next line */
+ if (o->color_moved_ws_handling &
+ COLOR_MOVED_WS_ALLOW_INDENTATION_CHANGE)
+ match = cur &&
+ !cmp_in_block_with_wsd(cur, l, &pmb[i]);
+ else
+ match = cur &&
+ xdiff_compare_lines(cur->es->line, cur->es->len,
+ l->line, l->len, flags);
+ if (match)
pmb[i].match = cur;
- } else {
+ else
moved_block_clear(&pmb[i]);
- }
}
}
@@ -1194,11 +1181,7 @@ static void mark_color_as_moved(struct diff_options *o,
continue;
}
- if (o->color_moved_ws_handling &
- COLOR_MOVED_WS_ALLOW_INDENTATION_CHANGE)
- pmb_advance_or_null_multi_match(o, l, pmb, pmb_nr);
- else
- pmb_advance_or_null(o, l, pmb, pmb_nr);
+ pmb_advance_or_null(o, l, pmb, pmb_nr);
pmb_nr = shrink_potential_moved_blocks(pmb, pmb_nr);