From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Stefan Beller <sbeller@google.com>
Subject: Re: What's cooking in git.git (Jun 2017, #06; Thu, 22)
Date: Fri, 23 Jun 2017 23:59:25 +0200 [thread overview]
Message-ID: <871sqajrgi.fsf@gmail.com> (raw)
In-Reply-To: <xmqqinjnhcr8.fsf@gitster.mtv.corp.google.com>
On Thu, Jun 22 2017, Junio C. Hamano jotted:
> * sb/diff-color-move (2017-06-21) 25 commits
> - diff: document the new --color-moved setting
> - diff.c: add dimming to moved line detection
> - diff.c: color moved lines differently, plain mode
> - diff.c: color moved lines differently
> - diff.c: buffer all output if asked to
> - diff.c: emit_diff_symbol learns about DIFF_SYMBOL_SUMMARY
> - diff.c: emit_diff_symbol learns about DIFF_SYMBOL_STAT_SEP
> - diff.c: convert word diffing to use emit_diff_symbol
> - diff.c: convert show_stats to use emit_diff_symbol
> - diff.c: convert emit_binary_diff_body to use emit_diff_symbol
> - submodule.c: migrate diff output to use emit_diff_symbol
> - diff.c: emit_diff_symbol learns DIFF_SYMBOL_REWRITE_DIFF
> - diff.c: emit_diff_symbol learns about DIFF_SYMBOL_BINARY_FILES
> - diff.c: emit_diff_symbol learns DIFF_SYMBOL_HEADER
> - diff.c: emit_diff_symbol learns DIFF_SYMBOL_FILEPAIR
> - diff.c: emit_diff_symbol learns DIFF_SYMBOL_CONTEXT_INCOMPLETE
> - diff.c: emit_diff_symbol learns DIFF_SYMBOL_WORDS{_PORCELAIN}
> - diff.c: migrate emit_line_checked to use emit_diff_symbol
> - diff.c: emit_diff_symbol learns DIFF_SYMBOL_NO_LF_EOF
> - diff.c: emit_diff_symbol learns DIFF_SYMBOL_CONTEXT_FRAGINFO
> - diff.c: emit_diff_symbol learns DIFF_SYMBOL_CONTEXT_MARKER
> - diff.c: introduce emit_diff_symbol
> - diff.c: factor out diff_flush_patch_all_file_pairs
> - diff.c: move line ending check into emit_hunk_header
> - diff.c: readability fix
>
> "git diff" has been taught to optionally paint new lines that are
> the same as deleted lines elsewhere differently from genuinely new
> lines.
>
> Is any more update coming?
I guess here's as good a place for feedback is any, this feature's
great, but I discovered some minor warts in it:
This is good:
$ ./git --exec-path=$PWD show --color-moved=crap
fatal: bad --color-moved argument: crap
This is bad:
$ ./git --exec-path=$PWD -c diff.colorMoved=crap show
fatal: unable to parse 'diff.colormoved' from command-line config
Fixed with:
diff --git a/diff.c b/diff.c
index 7cae4f1ddb..036dbc1c3c 100644
--- a/diff.c
+++ b/diff.c
@@ -278,7 +278,7 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
if (!strcmp(var, "diff.colormoved")) {
int cm = parse_color_moved(value);
if (cm < 0)
- return -1;
+ die("bad --color-moved argument: %s", value);
diff_color_moved_default = cm;
return 0;
}
But I'm not familiar enough with the code to say if just dying here, as
opposed to returning -1 is OK or not.
Also, I think something like this (very lighty tested) patch on top
makes sense:
diff --git a/diff.c b/diff.c
index 7cae4f1ddb..d195d304d3 100644
--- a/diff.c
+++ b/diff.c
@@ -257,6 +257,15 @@ int git_diff_heuristic_config(const char *var, const char *value, void *cb)
static int parse_color_moved(const char *arg)
{
+ int v = git_parse_maybe_bool(arg);
+
+ if (v != -1) {
+ if (v == 0)
+ return COLOR_MOVED_NO;
+ else if (v == 1)
+ return COLOR_MOVED_PLAIN;
+ }
+
if (!strcmp(arg, "no"))
return COLOR_MOVED_NO;
else if (!strcmp(arg, "plain"))
I don't want to set this to a specific value, just "true" and it should
pick whatever the default is (and that in the config yields a very bad
error message, hence the first patch).
If you don't want to have a default for whatever reason I think the docs
need to change:
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 1ab7bdfb49..4b6f8c6d5c 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1085,8 +1085,9 @@ This does not affect linkgit:git-format-patch[1] or the
command line with the `--color[=<when>]` option.
diff.colorMoved::
- If set moved lines in a diff are colored differently,
- for details see '--color-moved' in linkgit:git-diff[1].
+ If set to a valid `<mode>` moved lines in a diff are colored
+ differently, for details of valid modes see '--color-moved' in
+ linkgit:git-diff[1].
color.diff.<slot>::
Use customized color for diff colorization. `<slot>` specifies
Right now the lazy reader (i.e. me) just reads "if set...<blah blah>"
tries it out, and then gets a cryptic error. "If set" to me immediately
sounds like a bool variable (but then I read the diff docs and found
it's not). So with that bool parsing it could be changed to:
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 1ab7bdfb49..e62d926740 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1085,8 +1085,10 @@ This does not affect linkgit:git-format-patch[1] or the
command line with the `--color[=<when>]` option.
diff.colorMoved::
- If set moved lines in a diff are colored differently,
- for details see '--color-moved' in linkgit:git-diff[1].
+ If set to either a valid `<mode>` or a true value, moved lines
+ in a diff are colored differently, for details of valid modes
+ see '--color-moved' in linkgit:git-diff[1]. If simply set to
+ true the default color mode will be used.
color.diff.<slot>::
Use customized color for diff colorization. `<slot>` specifies
next prev parent reply other threads:[~2017-06-23 21:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-22 22:35 What's cooking in git.git (Jun 2017, #06; Thu, 22) Junio C Hamano
2017-06-22 22:58 ` Ævar Arnfjörð Bjarmason
2017-06-23 5:28 ` Junio C Hamano
2017-06-24 0:27 ` Junio C Hamano
2017-06-23 9:43 ` Lars Schneider
2017-06-23 21:59 ` Ævar Arnfjörð Bjarmason [this message]
2017-06-23 23:39 ` Stefan Beller
2017-06-24 0:37 ` Junio C Hamano
2017-06-24 1:01 ` Junio C Hamano
2017-06-27 2:58 ` Stefan Beller
2017-06-24 0:16 ` Stefan Beller
2017-06-24 0:33 ` Junio C Hamano
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=871sqajrgi.fsf@gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sbeller@google.com \
/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.