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