diff --color-moved-ws: fix false positives
[gitweb.git] / diff.c
diff --git a/diff.c b/diff.c
index e38d1ecaf45d1b79eeab093ba86e34fe3bbd931a..8c0778ddb797eda0b66f7392e3071d593e173868 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -304,7 +304,9 @@ static int parse_color_moved_ws(const char *arg)
                strbuf_addstr(&sb, i->string);
                strbuf_trim(&sb);
 
-               if (!strcmp(sb.buf, "ignore-space-change"))
+               if (!strcmp(sb.buf, "no"))
+                       ret = 0;
+               else if (!strcmp(sb.buf, "ignore-space-change"))
                        ret |= XDF_IGNORE_WHITESPACE_CHANGE;
                else if (!strcmp(sb.buf, "ignore-space-at-eol"))
                        ret |= XDF_IGNORE_WHITESPACE_AT_EOL;
@@ -320,7 +322,7 @@ static int parse_color_moved_ws(const char *arg)
 
        if ((ret & COLOR_MOVED_WS_ALLOW_INDENTATION_CHANGE) &&
            (ret & XDF_WHITESPACE_FLAGS))
-               die(_("color-moved-ws: allow-indentation-change cannot be combined with other white space modes"));
+               die(_("color-moved-ws: allow-indentation-change cannot be combined with other whitespace modes"));
 
        string_list_clear(&l, 0);
 
@@ -1104,10 +1106,10 @@ static void mark_color_as_moved(struct diff_options *o,
                        continue;
                }
 
-               l->flags |= DIFF_SYMBOL_MOVED_LINE;
-
-               if (o->color_moved == COLOR_MOVED_PLAIN)
+               if (o->color_moved == COLOR_MOVED_PLAIN) {
+                       l->flags |= DIFF_SYMBOL_MOVED_LINE;
                        continue;
+               }
 
                if (o->color_moved_ws_handling &
                    COLOR_MOVED_WS_ALLOW_INDENTATION_CHANGE)
@@ -1141,10 +1143,13 @@ static void mark_color_as_moved(struct diff_options *o,
                        block_length = 0;
                }
 
-               block_length++;
+               if (pmb_nr) {
+                       block_length++;
 
-               if (flipped_block && o->color_moved != COLOR_MOVED_BLOCKS)
-                       l->flags |= DIFF_SYMBOL_MOVED_LINE_ALT;
+                       l->flags |= DIFF_SYMBOL_MOVED_LINE;
+                       if (flipped_block && o->color_moved != COLOR_MOVED_BLOCKS)
+                               l->flags |= DIFF_SYMBOL_MOVED_LINE_ALT;
+               }
        }
        adjust_last_block(o, n, block_length);
 
@@ -3228,7 +3233,7 @@ static void emit_binary_diff_body(struct diff_options *o,
        }
 
        if (delta && delta_size < deflate_size) {
-               char *s = xstrfmt("%lu", orig_size);
+               char *s = xstrfmt("%"PRIuMAX , (uintmax_t)orig_size);
                emit_diff_symbol(o, DIFF_SYMBOL_BINARY_DIFF_HEADER_DELTA,
                                 s, strlen(s), 0);
                free(s);
@@ -5036,6 +5041,8 @@ int diff_opt_parse(struct diff_options *options,
                if (cm < 0)
                        die("bad --color-moved argument: %s", arg);
                options->color_moved = cm;
+       } else if (!strcmp(arg, "--no-color-moved-ws")) {
+               options->color_moved_ws_handling = 0;
        } else if (skip_prefix(arg, "--color-moved-ws=", &arg)) {
                options->color_moved_ws_handling = parse_color_moved_ws(arg);
        } else if (skip_to_optional_arg_default(arg, "--color-words", &options->word_regex, NULL)) {