]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'es/diff-color-moved-fix'
authorJunio C Hamano <gitster@pobox.com>
Wed, 15 Aug 2018 22:08:22 +0000 (15:08 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Aug 2018 22:08:22 +0000 (15:08 -0700)
One of the "diff --color-moved" mode "dimmed_zebra" that was named
in an unusual way has been deprecated and replaced by
"dimmed-zebra".

* es/diff-color-moved-fix:
  diff: --color-moved: rename "dimmed_zebra" to "dimmed-zebra"

1  2 
Documentation/diff-options.txt
diff.c
t/t4015-diff-whitespace.sh

index f394608b42c268f0f187dafabe50b718fde2a8bf,cbc05e8a95a670319ae2b54f42fddc23acf670d3..0378cd574eb01069baba14221d511f580565c0eb
@@@ -276,47 -268,19 +276,48 @@@ plain:
        that are added somewhere else in the diff. This mode picks up any
        moved line, but it is not very useful in a review to determine
        if a block of code was moved without permutation.
 -zebra::
 +blocks::
        Blocks of moved text of at least 20 alphanumeric characters
        are detected greedily. The detected blocks are
 -      painted using either the 'color.diff.{old,new}Moved' color or
 +      painted using either the 'color.diff.{old,new}Moved' color.
 +      Adjacent blocks cannot be told apart.
 +zebra::
 +      Blocks of moved text are detected as in 'blocks' mode. The blocks
 +      are painted using either the 'color.diff.{old,new}Moved' color or
        'color.diff.{old,new}MovedAlternative'. The change between
        the two colors indicates that a new block was detected.
- dimmed_zebra::
+ dimmed-zebra::
        Similar to 'zebra', but additional dimming of uninteresting parts
        of moved code is performed. The bordering lines of two adjacent
        blocks are considered interesting, the rest is uninteresting.
+       `dimmed_zebra` is a deprecated synonym.
  --
  
 +--color-moved-ws=<modes>::
 +      This configures how white spaces are ignored when performing the
 +      move detection for `--color-moved`.
 +ifdef::git-diff[]
 +      It can be set by the `diff.colorMovedWS` configuration setting.
 +endif::git-diff[]
 +      These modes can be given as a comma separated list:
 ++
 +--
 +ignore-space-at-eol::
 +      Ignore changes in whitespace at EOL.
 +ignore-space-change::
 +      Ignore changes in amount of whitespace.  This ignores whitespace
 +      at line end, and considers all other sequences of one or
 +      more whitespace characters to be equivalent.
 +ignore-all-space::
 +      Ignore whitespace when comparing lines. This ignores differences
 +      even if one line has whitespace where the other line has none.
 +allow-indentation-change::
 +      Initially ignore any white spaces in the move detection, then
 +      group the moved code blocks only into a block if the change in
 +      whitespace is the same per line. This is incompatible with the
 +      other modes.
 +--
 +
  --word-diff[=<mode>]::
        Show a word diff, using the <mode> to delimit changed words.
        By default, words are delimited by whitespace; see
diff --cc diff.c
index 04d044bbb67b77a9992a499d4f7728bb85cfe94f,717100780d9a9ea37f3d619fc74594e023ac45f9..0746d59fe6d04287e0a4053b4bb0eeda5fd26778
--- 1/diff.c
--- 2/diff.c
+++ b/diff.c
@@@ -274,43 -280,7 +276,43 @@@ static int parse_color_moved(const cha
        else if (!strcmp(arg, "dimmed_zebra"))
                return COLOR_MOVED_ZEBRA_DIM;
        else
-               return error(_("color moved setting must be one of 'no', 'default', 'blocks', 'zebra', 'dimmed_zebra', 'plain'"));
 -              return error(_("color moved setting must be one of 'no', 'default', 'zebra', 'dimmed-zebra', 'plain'"));
++              return error(_("color moved setting must be one of 'no', 'default', 'blocks', 'zebra', 'dimmed-zebra', 'plain'"));
 +}
 +
 +static int parse_color_moved_ws(const char *arg)
 +{
 +      int ret = 0;
 +      struct string_list l = STRING_LIST_INIT_DUP;
 +      struct string_list_item *i;
 +
 +      string_list_split(&l, arg, ',', -1);
 +
 +      for_each_string_list_item(i, &l) {
 +              struct strbuf sb = STRBUF_INIT;
 +              strbuf_addstr(&sb, i->string);
 +              strbuf_trim(&sb);
 +
 +              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;
 +              else if (!strcmp(sb.buf, "ignore-all-space"))
 +                      ret |= XDF_IGNORE_WHITESPACE;
 +              else if (!strcmp(sb.buf, "allow-indentation-change"))
 +                      ret |= COLOR_MOVED_WS_ALLOW_INDENTATION_CHANGE;
 +              else
 +                      error(_("ignoring unknown color-moved-ws mode '%s'"), sb.buf);
 +
 +              strbuf_release(&sb);
 +      }
 +
 +      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"));
 +
 +      string_list_clear(&l, 0);
 +
 +      return ret;
  }
  
  int git_diff_ui_config(const char *var, const char *value, void *cb)
index 41facf7abf9bff5cc39419b41998836018257f79,8cdfa225ef6cecb8d44b56c90da5b7e6f0355175..e2dc1895ba3942954dfaba3c0af914494d2aa317
@@@ -1271,52 -1271,9 +1271,52 @@@ test_expect_success 'detect blocks of m
        test_config color.diff.newMovedDimmed "normal cyan" &&
        test_config color.diff.oldMovedAlternativeDimmed "normal blue" &&
        test_config color.diff.newMovedAlternativeDimmed "normal yellow" &&
 -      git diff HEAD --no-renames --color-moved=dimmed-zebra --color |
 -              grep -v "index" |
 -              test_decode_color >actual &&
 +      git diff HEAD --no-renames --color-moved=blocks --color >actual.raw &&
 +      grep -v "index" actual.raw | test_decode_color >actual &&
 +      cat <<-\EOF >expected &&
 +      <BOLD>diff --git a/lines.txt b/lines.txt<RESET>
 +      <BOLD>--- a/lines.txt<RESET>
 +      <BOLD>+++ b/lines.txt<RESET>
 +      <CYAN>@@ -1,16 +1,16 @@<RESET>
 +      <MAGENTA>-long line 1<RESET>
 +      <MAGENTA>-long line 2<RESET>
 +      <MAGENTA>-long line 3<RESET>
 +       line 4<RESET>
 +       line 5<RESET>
 +       line 6<RESET>
 +       line 7<RESET>
 +       line 8<RESET>
 +       line 9<RESET>
 +      <CYAN>+<RESET><CYAN>long line 1<RESET>
 +      <CYAN>+<RESET><CYAN>long line 2<RESET>
 +      <CYAN>+<RESET><CYAN>long line 3<RESET>
 +      <CYAN>+<RESET><CYAN>long line 14<RESET>
 +      <CYAN>+<RESET><CYAN>long line 15<RESET>
 +      <CYAN>+<RESET><CYAN>long line 16<RESET>
 +       line 10<RESET>
 +       line 11<RESET>
 +       line 12<RESET>
 +       line 13<RESET>
 +      <MAGENTA>-long line 14<RESET>
 +      <MAGENTA>-long line 15<RESET>
 +      <MAGENTA>-long line 16<RESET>
 +      EOF
 +      test_cmp expected actual
 +
 +'
 +
- test_expect_success 'detect permutations inside moved code -- dimmed_zebra' '
++test_expect_success 'detect permutations inside moved code -- dimmed-zebra' '
 +      # reuse setup from test before!
 +      test_config color.diff.oldMoved "magenta" &&
 +      test_config color.diff.newMoved "cyan" &&
 +      test_config color.diff.oldMovedAlternative "blue" &&
 +      test_config color.diff.newMovedAlternative "yellow" &&
 +      test_config color.diff.oldMovedDimmed "normal magenta" &&
 +      test_config color.diff.newMovedDimmed "normal cyan" &&
 +      test_config color.diff.oldMovedAlternativeDimmed "normal blue" &&
 +      test_config color.diff.newMovedAlternativeDimmed "normal yellow" &&
-       git diff HEAD --no-renames --color-moved=dimmed_zebra --color >actual.raw &&
++      git diff HEAD --no-renames --color-moved=dimmed-zebra --color >actual.raw &&
 +      grep -v "index" actual.raw | test_decode_color >actual &&
        cat <<-\EOF >expected &&
        <BOLD>diff --git a/lines.txt b/lines.txt<RESET>
        <BOLD>--- a/lines.txt<RESET>