From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Stefan Beller <sbeller@google.com>
Cc: "SZEDER Gábor" <szeder.dev@gmail.com>,
git@vger.kernel.org, jacob.keller@gmail.com,
jonathantanmy@google.com, simon@ruderich.org
Subject: Re: [PATCH v3 8/8] diff.c: add white space mode to move detection that allows indent changes
Date: Sat, 23 Jun 2018 18:52:33 +0200 [thread overview]
Message-ID: <20180623165233.23653-1-szeder.dev@gmail.com> (raw)
In-Reply-To: <20180622015725.219575-9-sbeller@google.com>
> diff --git a/diff.c b/diff.c
> index 040b46545e5..9e357111864 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -302,12 +302,18 @@ static int parse_color_moved_ws(const char *arg)
> 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"));
Note that this is a translated error message.
> diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
> index aad0870c8a1..13b20be591e 100755
> --- a/t/t4015-diff-whitespace.sh
> +++ b/t/t4015-diff-whitespace.sh
> @@ -1827,4 +1827,94 @@ test_expect_success 'only move detection ignores white spaces' '
> test_cmp expected actual
> '
>
> +test_expect_success 'compare whitespace delta across moved blocks' '
> +
> + git reset --hard &&
> + q_to_tab <<-\EOF >text.txt &&
> + QIndented
> + QText across
> + Qsome lines
> + QBut! <- this stands out
> + QAdjusting with
> + QQdifferent starting
> + Qwhite spaces
> + QAnother outlier
> + QQQIndented
> + QQQText across
> + QQQfive lines
> + QQQthat has similar lines
> + QQQto previous blocks, but with different indent
> + QQQYetQAnotherQoutlierQ
> + EOF
> +
> + git add text.txt &&
> + git commit -m "add text.txt" &&
> +
> + q_to_tab <<-\EOF >text.txt &&
> + QQIndented
> + QQText across
> + QQsome lines
> + QQQBut! <- this stands out
> + Adjusting with
> + Qdifferent starting
> + white spaces
> + AnotherQoutlier
> + QQIndented
> + QQText across
> + QQfive lines
> + QQthat has similar lines
> + QQto previous blocks, but with different indent
> + QQYetQAnotherQoutlier
> + EOF
> +
> + git diff --color --color-moved --color-moved-ws=allow-indentation-change |
> + grep -v "index" |
> + test_decode_color >actual &&
Please use an intermediate file for the output of 'git diff', because
running it upstream of a pipe hides its exit code.
> +
> + q_to_tab <<-\EOF >expected &&
> + <BOLD>diff --git a/text.txt b/text.txt<RESET>
> + <BOLD>--- a/text.txt<RESET>
> + <BOLD>+++ b/text.txt<RESET>
> + <CYAN>@@ -1,14 +1,14 @@<RESET>
> + <BOLD;MAGENTA>-QIndented<RESET>
> + <BOLD;MAGENTA>-QText across<RESET>
> + <BOLD;MAGENTA>-Qsome lines<RESET>
> + <RED>-QBut! <- this stands out<RESET>
> + <BOLD;MAGENTA>-QAdjusting with<RESET>
> + <BOLD;MAGENTA>-QQdifferent starting<RESET>
> + <BOLD;MAGENTA>-Qwhite spaces<RESET>
> + <RED>-QAnother outlier<RESET>
> + <BOLD;MAGENTA>-QQQIndented<RESET>
> + <BOLD;MAGENTA>-QQQText across<RESET>
> + <BOLD;MAGENTA>-QQQfive lines<RESET>
> + <BOLD;MAGENTA>-QQQthat has similar lines<RESET>
> + <BOLD;MAGENTA>-QQQto previous blocks, but with different indent<RESET>
> + <RED>-QQQYetQAnotherQoutlierQ<RESET>
> + <BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>Indented<RESET>
> + <BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>Text across<RESET>
> + <BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>some lines<RESET>
> + <GREEN>+<RESET>QQQ<GREEN>But! <- this stands out<RESET>
> + <BOLD;CYAN>+<RESET><BOLD;CYAN>Adjusting with<RESET>
> + <BOLD;CYAN>+<RESET>Q<BOLD;CYAN>different starting<RESET>
> + <BOLD;CYAN>+<RESET><BOLD;CYAN>white spaces<RESET>
> + <GREEN>+<RESET><GREEN>AnotherQoutlier<RESET>
> + <BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>Indented<RESET>
> + <BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>Text across<RESET>
> + <BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>five lines<RESET>
> + <BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>that has similar lines<RESET>
> + <BOLD;CYAN>+<RESET>QQ<BOLD;CYAN>to previous blocks, but with different indent<RESET>
> + <GREEN>+<RESET>QQ<GREEN>YetQAnotherQoutlier<RESET>
> + EOF
> +
> + test_cmp expected actual
> +'
> +
> +test_expect_success 'compare whitespace delta incompatible with other space options' '
> + test_must_fail git diff \
> + --color-moved-ws=allow-indentation-change,ignore-all-space \
> + 2>err &&
> + grep allow-indentation-change err
A translated error message should be checked with 'test_i18ngrep'.
next prev parent reply other threads:[~2018-06-23 16:52 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-22 1:57 [PATCH v3 0/8] Moved code detection: ignore space on uniform indentation Stefan Beller
2018-06-22 1:57 ` [PATCH v3 1/8] xdiff/xdiff.h: remove unused flags Stefan Beller
2018-06-22 1:57 ` [PATCH v3 2/8] xdiff/xdiffi.c: remove unneeded function declarations Stefan Beller
2018-06-22 1:57 ` [PATCH v3 3/8] diff.c: do not pass diff options as keydata to hashmap Stefan Beller
2018-06-22 1:57 ` [PATCH v3 4/8] diff.c: adjust hash function signature to match hashmap expectation Stefan Beller
2018-06-22 1:57 ` [PATCH v3 5/8] diff.c: add a blocks mode for moved code detection Stefan Beller
2018-06-22 1:57 ` [PATCH v3 6/8] diff.c: decouple white space treatment from move detection algorithm Stefan Beller
2018-06-22 1:57 ` [PATCH v3 7/8] diff.c: factor advance_or_nullify out of mark_color_as_moved Stefan Beller
2018-06-22 1:57 ` [PATCH v3 8/8] diff.c: add white space mode to move detection that allows indent changes Stefan Beller
2018-06-23 16:52 ` SZEDER Gábor [this message]
2018-06-22 22:37 ` [PATCH v3 0/8] Moved code detection: ignore space on uniform indentation Junio C Hamano
2018-06-29 0:19 ` [PATCH v4 0/9] " Stefan Beller
2018-06-29 0:19 ` [PATCH v4 1/9] xdiff/xdiff.h: remove unused flags Stefan Beller
2018-06-29 0:19 ` [PATCH v4 2/9] xdiff/xdiffi.c: remove unneeded function declarations Stefan Beller
2018-06-29 0:19 ` [PATCH v4 3/9] t4015: avoid git as a pipe input Stefan Beller
2018-06-29 0:19 ` [PATCH v4 4/9] diff.c: do not pass diff options as keydata to hashmap Stefan Beller
2018-06-29 0:19 ` [PATCH v4 5/9] diff.c: adjust hash function signature to match hashmap expectation Stefan Beller
2018-06-29 0:19 ` [PATCH v4 6/9] diff.c: add a blocks mode for moved code detection Stefan Beller
2018-07-02 17:18 ` Brandon Williams
2018-06-29 0:19 ` [PATCH v4 7/9] diff.c: decouple white space treatment from move detection algorithm Stefan Beller
2018-07-02 17:22 ` Brandon Williams
2018-06-29 0:19 ` [PATCH v4 8/9] diff.c: factor advance_or_nullify out of mark_color_as_moved Stefan Beller
2018-06-29 0:19 ` [PATCH v4 9/9] diff.c: add white space mode to move detection that allows indent changes Stefan Beller
2018-07-02 17:36 ` Brandon Williams
2018-07-02 18:59 ` Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180623165233.23653-1-szeder.dev@gmail.com \
--to=szeder.dev@gmail.com \
--cc=git@vger.kernel.org \
--cc=jacob.keller@gmail.com \
--cc=jonathantanmy@google.com \
--cc=sbeller@google.com \
--cc=simon@ruderich.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.