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:
authorStefan Beller <sbeller@google.com>2017-06-30 23:53:08 +0300
committerJunio C Hamano <gitster@pobox.com>2017-06-30 23:59:42 +0300
commit176841f0c9b470b008c95eb50b7bb9424321d540 (patch)
treea20f44a2ca31e686ff27ff91221df20226fc9998 /diff.c
parent2e2d5ac184de8facde4e14cec8b4e2a154480ed8 (diff)
diff.c: color moved lines differently, plain mode
Add the 'plain' mode for move detection of code. This omits the checking for adjacent blocks, so it is not as useful. If you have a lot of the same blocks moved in the same patch, the 'Zebra' would end up slow as it is O(n^2) (n is number of same blocks). So this may be useful there and is generally easy to add. Instead be very literal at the move detection, do not skip over short blocks here. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/diff.c b/diff.c
index 084ecc5678..79ea592388 100644
--- a/diff.c
+++ b/diff.c
@@ -256,12 +256,14 @@ static int parse_color_moved(const char *arg)
if (!strcmp(arg, "no"))
return COLOR_MOVED_NO;
+ else if (!strcmp(arg, "plain"))
+ return COLOR_MOVED_PLAIN;
else if (!strcmp(arg, "zebra"))
return COLOR_MOVED_ZEBRA;
else if (!strcmp(arg, "default"))
return COLOR_MOVED_DEFAULT;
else
- return error(_("color moved setting must be one of 'no', 'default', 'zebra'"));
+ return error(_("color moved setting must be one of 'no', 'default', 'zebra', 'plain'"));
}
int git_diff_ui_config(const char *var, const char *value, void *cb)
@@ -879,7 +881,8 @@ static void mark_color_as_moved(struct diff_options *o,
}
if (!match) {
- if (block_length < COLOR_MOVED_MIN_BLOCK_LENGTH) {
+ if (block_length < COLOR_MOVED_MIN_BLOCK_LENGTH &&
+ o->color_moved != COLOR_MOVED_PLAIN) {
for (i = 0; i < block_length + 1; i++) {
l = &o->emitted_symbols->buf[n - i];
l->flags &= ~DIFF_SYMBOL_MOVED_LINE;
@@ -893,6 +896,9 @@ static void mark_color_as_moved(struct diff_options *o,
l->flags |= DIFF_SYMBOL_MOVED_LINE;
block_length++;
+ if (o->color_moved == COLOR_MOVED_PLAIN)
+ continue;
+
/* Check any potential block runs, advance each or nullify */
for (i = 0; i < pmb_nr; i++) {
struct moved_entry *p = pmb[i];