{"thread":{"id":"23459","subject":"[PATCH v4 1/3] diff: add --word-diff option that generalizes --color-words","startedAt":"2010-04-14T15:59:05Z","lastAt":"2010-04-19T01:08:19Z","messageCount":11,"participants":["Thomas Rast","Junio C Hamano","Jens Lehmann","Paul Mackerras"],"isPatch":true,"patchVersion":4,"patchTotal":3},"messages":[{"id":"139489","messageId":"cover.1271260308.git.trast@student.ethz.ch","threadId":"23459","inReplyTo":"7v8w8sljjr.fsf@alter.siamese.dyndns.org","subject":"[PATCH v4 0/3] git-diff --word-diff/gitk --color-words","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-04-14T15:59:05Z","receivedAt":"2010-04-14T15:59:05Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"This merely addresses Junio's comments on 1/3 of the last round, since\nI haven't heard anything about the gitk patches.\n\n\nThomas Rast (3):\n  diff: add --word-diff option that generalizes --color-words\n  gitk: do not parse \"  >\" context as submodule change\n  gitk: add the equivalent of diff --color-words\n"},{"id":"139488","messageId":"9a2b460ea5db47154623386638e883f749c4ee35.1271260308.git.trast@student.ethz.ch","threadId":"23459","inReplyTo":"cover.1271260308.git.trast@student.ethz.ch","subject":"[PATCH v4 1/3] diff: add --word-diff option that generalizes --color-words","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-04-14T15:59:06Z","receivedAt":"2010-04-14T15:59:06Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"This teaches the --color-words engine a more general interface that\nsupports two new modes:\n\n* --word-diff=plain, inspired by the 'wdiff' utility (most similar to\n  'wdiff -n <old> <new>'): uses delimiters [-removed-] and {+added+}\n\n* --word-diff=porcelain, which generates an ad-hoc machine readable\n  format:\n  - each diff unit is prefixed by [-+ ] and terminated by newline as\n    in unified diff\n  - newlines in the input are output as a line consisting only of a\n    tilde '~'\n\nBoth of these formats still support color if it is enabled, using it\nto highlight the differences.  --color-words becomes a synonym for\n--word-diff=color, which is the color-only format.  Also adds some\ncompatibility/convenience options.\n\nThanks to Junio C Hamano and Miles Bader for good ideas.\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n Documentation/diff-options.txt  |   40 ++++++++++-\n Documentation/gitattributes.txt |    2 +-\n color.c                         |   28 --------\n color.h                         |    1 -\n diff.c                          |  139 +++++++++++++++++++++++++++++++++-----\n diff.h                          |   10 +++-\n t/t4034-diff-words.sh           |  122 ++++++++++++++++++++++++++++++++++\n 7 files changed, 288 insertions(+), 54 deletions(-)\n\ndiff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\nindex 60e922e..a616ca5 100644\n--- a/Documentation/diff-options.txt\n+++ b/Documentation/diff-options.txt\n@@ -126,11 +126,39 @@ any of those replacements occurred.\n \tgives the default to color output.\n \tSame as `--color=never`.\n \n---color-words[=<regex>]::\n-\tShow colored word diff, i.e., color words which have changed.\n-\tBy default, words are separated by whitespace.\n+--word-diff[=<mode>]::\n+\tShow a word diff, using the <mode> to delimit changed words.\n+\tBy default, words are delimited by whitespace; see\n+\t`--word-diff-regex` below.  The <mode> defaults to 'plain', and\n+\tmust be one of:\n++\n+--\n+color::\n+\tHighlight changed words using only colors.  Implies `--color`.\n+plain::\n+\tShow words as `[-removed-]` and `{+added+}`.  Makes no\n+\tattempts to escape the delimiters if they appear in the input,\n+\tso the output may be ambiguous.\n+porcelain::\n+\tUse a special line-based format intended for script\n+\tconsumption.  Added/removed/unchanged runs are printed in the\n+\tusual unified diff format, starting with a `+`/`-`/` `\n+\tcharacter at the beginning of the line and extending to the\n+\tend of the line.  Newlines in the input are represented by a\n+\ttilde `~` on a line of its own.\n+none::\n+\tDisable word diff again.\n+--\n++\n+Note that despite the name of the first mode, color is used to\n+highlight the changed parts in all modes if enabled.\n+\n+--word-diff-regex=<regex>::\n+\tUse <regex> to decide what a word is, instead of considering\n+\truns of non-whitespace to be a word.  Also implies\n+\t`--word-diff` unless it was already enabled.\n +\n-When a <regex> is specified, every non-overlapping match of the\n+Every non-overlapping match of the\n <regex> is considered a word.  Anything between these matches is\n considered whitespace and ignored(!) for the purposes of finding\n differences.  You may want to append `|[^[:space:]]` to your regular\n@@ -142,6 +170,10 @@ The regex can also be set via a diff driver or configuration option, see\n linkgit:gitattributes[1] or linkgit:git-config[1].  Giving it explicitly\n overrides any diff driver or configuration setting.  Diff drivers\n override configuration settings.\n+\n+--color-words[=<regex>]::\n+\tEquivalent to `--word-diff=color` plus (if a regex was\n+\tspecified) `--word-diff-regex=<regex>`.\n endif::git-format-patch[]\n \n --no-renames::\ndiff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt\nindex a8500d1..0523a57 100644\n--- a/Documentation/gitattributes.txt\n+++ b/Documentation/gitattributes.txt\n@@ -360,7 +360,7 @@ patterns are available:\n Customizing word diff\n ^^^^^^^^^^^^^^^^^^^^^\n \n-You can customize the rules that `git diff --color-words` uses to\n+You can customize the rules that `git diff --word-diff` uses to\n split words in a line, by specifying an appropriate regular expression\n in the \"diff.*.wordRegex\" configuration variable.  For example, in TeX\n a backslash followed by a sequence of letters forms a command, but\ndiff --git a/color.c b/color.c\nindex bcf4e2c..1b00554 100644\n--- a/color.c\n+++ b/color.c\n@@ -211,31 +211,3 @@ int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...)\n \tva_end(args);\n \treturn r;\n }\n-\n-/*\n- * This function splits the buffer by newlines and colors the lines individually.\n- *\n- * Returns 0 on success.\n- */\n-int color_fwrite_lines(FILE *fp, const char *color,\n-\t\tsize_t count, const char *buf)\n-{\n-\tif (!*color)\n-\t\treturn fwrite(buf, count, 1, fp) != 1;\n-\twhile (count) {\n-\t\tchar *p = memchr(buf, '\\n', count);\n-\t\tif (p != buf && (fputs(color, fp) < 0 ||\n-\t\t\t\tfwrite(buf, p ? p - buf : count, 1, fp) != 1 ||\n-\t\t\t\tfputs(GIT_COLOR_RESET, fp) < 0))\n-\t\t\treturn -1;\n-\t\tif (!p)\n-\t\t\treturn 0;\n-\t\tif (fputc('\\n', fp) < 0)\n-\t\t\treturn -1;\n-\t\tcount -= p + 1 - buf;\n-\t\tbuf = p + 1;\n-\t}\n-\treturn 0;\n-}\n-\n-\ndiff --git a/color.h b/color.h\nindex 5c264b0..03ca064 100644\n--- a/color.h\n+++ b/color.h\n@@ -61,6 +61,5 @@\n int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);\n __attribute__((format (printf, 3, 4)))\n int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);\n-int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf);\n \n #endif /* COLOR_H */\ndiff --git a/diff.c b/diff.c\nindex 7effdac..f587b83 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -560,16 +560,68 @@ static void diff_words_append(char *line, unsigned long len,\n \tbuffer->text.ptr[buffer->text.size] = '\\0';\n }\n \n+struct diff_words_style_elem\n+{\n+\tconst char *prefix;\n+\tconst char *suffix;\n+\tconst char *color; /* NULL; filled in by the setup code if\n+\t\t\t    * color is enabled */\n+};\n+\n+struct diff_words_style\n+{\n+\tenum diff_words_type type;\n+\tstruct diff_words_style_elem new, old, ctx;\n+\tconst char *newline;\n+};\n+\n+struct diff_words_style diff_words_styles[] = {\n+\t{ DIFF_WORDS_PORCELAIN, {\"+\", \"\\n\"}, {\"-\", \"\\n\"}, {\" \", \"\\n\"}, \"~\\n\" },\n+\t{ DIFF_WORDS_PLAIN, {\"{+\", \"+}\"}, {\"[-\", \"-]\"}, {\"\", \"\"}, \"\\n\" },\n+\t{ DIFF_WORDS_COLOR, {\"\", \"\"}, {\"\", \"\"}, {\"\", \"\"}, \"\\n\" }\n+};\n+\n struct diff_words_data {\n \tstruct diff_words_buffer minus, plus;\n \tconst char *current_plus;\n \tFILE *file;\n \tregex_t *word_regex;\n+\tenum diff_words_type type;\n+\tstruct diff_words_style *style;\n };\n \n+static int fn_out_diff_words_write_helper(FILE *fp,\n+\t\t\t\t\t  struct diff_words_style_elem *st_el,\n+\t\t\t\t\t  const char *newline,\n+\t\t\t\t\t  size_t count, const char *buf)\n+{\n+\twhile (count) {\n+\t\tchar *p = memchr(buf, '\\n', count);\n+\t\tif (p != buf) {\n+\t\t\tif (st_el->color && fputs(st_el->color, fp) < 0)\n+\t\t\t\treturn -1;\n+\t\t\tif (fputs(st_el->prefix, fp) < 0 ||\n+\t\t\t    fwrite(buf, p ? p - buf : count, 1, fp) != 1 ||\n+\t\t\t    fputs(st_el->suffix, fp) < 0)\n+\t\t\t\treturn -1;\n+\t\t\tif (st_el->color && *st_el->color\n+\t\t\t    && fputs(GIT_COLOR_RESET, fp) < 0)\n+\t\t\t\treturn -1;\n+\t\t}\n+\t\tif (!p)\n+\t\t\treturn 0;\n+\t\tif (fputs(newline, fp) < 0)\n+\t\t\treturn -1;\n+\t\tcount -= p + 1 - buf;\n+\t\tbuf = p + 1;\n+\t}\n+\treturn 0;\n+}\n+\n static void fn_out_diff_words_aux(void *priv, char *line, unsigned long len)\n {\n \tstruct diff_words_data *diff_words = priv;\n+\tstruct diff_words_style *style = diff_words->style;\n \tint minus_first, minus_len, plus_first, plus_len;\n \tconst char *minus_begin, *minus_end, *plus_begin, *plus_end;\n \n@@ -593,16 +645,17 @@ static void fn_out_diff_words_aux(void *priv, char *line, unsigned long len)\n \t\tplus_begin = plus_end = diff_words->plus.orig[plus_first].end;\n \n \tif (diff_words->current_plus != plus_begin)\n-\t\tfwrite(diff_words->current_plus,\n-\t\t\t\tplus_begin - diff_words->current_plus, 1,\n-\t\t\t\tdiff_words->file);\n+\t\tfn_out_diff_words_write_helper(diff_words->file,\n+\t\t\t\t&style->ctx, style->newline,\n+\t\t\t\tplus_begin - diff_words->current_plus,\n+\t\t\t\tdiff_words->current_plus);\n \tif (minus_begin != minus_end)\n-\t\tcolor_fwrite_lines(diff_words->file,\n-\t\t\t\tdiff_get_color(1, DIFF_FILE_OLD),\n+\t\tfn_out_diff_words_write_helper(diff_words->file,\n+\t\t\t\t&style->old, style->newline,\n \t\t\t\tminus_end - minus_begin, minus_begin);\n \tif (plus_begin != plus_end)\n-\t\tcolor_fwrite_lines(diff_words->file,\n-\t\t\t\tdiff_get_color(1, DIFF_FILE_NEW),\n+\t\tfn_out_diff_words_write_helper(diff_words->file,\n+\t\t\t\t&style->new, style->newline,\n \t\t\t\tplus_end - plus_begin, plus_begin);\n \n \tdiff_words->current_plus = plus_end;\n@@ -685,11 +738,12 @@ static void diff_words_show(struct diff_words_data *diff_words)\n \txdemitconf_t xecfg;\n \txdemitcb_t ecb;\n \tmmfile_t minus, plus;\n+\tstruct diff_words_style *style = diff_words->style;\n \n \t/* special case: only removal */\n \tif (!diff_words->plus.text.size) {\n-\t\tcolor_fwrite_lines(diff_words->file,\n-\t\t\tdiff_get_color(1, DIFF_FILE_OLD),\n+\t\tfn_out_diff_words_write_helper(diff_words->file,\n+\t\t\t&style->old, style->newline,\n \t\t\tdiff_words->minus.text.size, diff_words->minus.text.ptr);\n \t\tdiff_words->minus.text.size = 0;\n \t\treturn;\n@@ -710,10 +764,10 @@ static void diff_words_show(struct diff_words_data *diff_words)\n \tfree(plus.ptr);\n \tif (diff_words->current_plus != diff_words->plus.text.ptr +\n \t\t\tdiff_words->plus.text.size)\n-\t\tfwrite(diff_words->current_plus,\n+\t\tfn_out_diff_words_write_helper(diff_words->file,\n+\t\t\t&style->ctx, style->newline,\n \t\t\tdiff_words->plus.text.ptr + diff_words->plus.text.size\n-\t\t\t- diff_words->current_plus, 1,\n-\t\t\tdiff_words->file);\n+\t\t\t- diff_words->current_plus, diff_words->current_plus);\n \tdiff_words->minus.text.size = diff_words->plus.text.size = 0;\n }\n \n@@ -825,6 +879,9 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n \n \tif (len < 1) {\n \t\temit_line(ecbdata->file, reset, reset, line, len);\n+\t\tif (ecbdata->diff_words\n+\t\t    && ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN)\n+\t\t\tfputs(\"~\\n\", ecbdata->file);\n \t\treturn;\n \t}\n \n@@ -839,9 +896,13 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)\n \t\t\treturn;\n \t\t}\n \t\tdiff_words_flush(ecbdata);\n-\t\tline++;\n-\t\tlen--;\n-\t\temit_line(ecbdata->file, plain, reset, line, len);\n+\t\tif (ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN) {\n+\t\t\temit_line(ecbdata->file, plain, reset, line, len);\n+\t\t\tfputs(\"~\\n\", ecbdata->file);\n+\t\t} else {\n+\t\t\t/* don't print the prefix character */\n+\t\t\temit_line(ecbdata->file, plain, reset, line+1, len-1);\n+\t\t}\n \t\treturn;\n \t}\n \n@@ -1739,10 +1800,13 @@ static void builtin_diff(const char *name_a,\n \t\t\txecfg.ctxlen = strtoul(diffopts + 10, NULL, 10);\n \t\telse if (!prefixcmp(diffopts, \"-u\"))\n \t\t\txecfg.ctxlen = strtoul(diffopts + 2, NULL, 10);\n-\t\tif (DIFF_OPT_TST(o, COLOR_DIFF_WORDS)) {\n+\t\tif (o->word_diff) {\n+\t\t\tint i;\n+\n \t\t\tecbdata.diff_words =\n \t\t\t\txcalloc(1, sizeof(struct diff_words_data));\n \t\t\tecbdata.diff_words->file = o->file;\n+\t\t\tecbdata.diff_words->type = o->word_diff;\n \t\t\tif (!o->word_regex)\n \t\t\t\to->word_regex = userdiff_word_regex(one);\n \t\t\tif (!o->word_regex)\n@@ -1758,10 +1822,23 @@ static void builtin_diff(const char *name_a,\n \t\t\t\t\tdie (\"Invalid regular expression: %s\",\n \t\t\t\t\t\t\to->word_regex);\n \t\t\t}\n+\t\t\tfor (i = 0; i < ARRAY_SIZE(diff_words_styles); i++) {\n+\t\t\t\tif (o->word_diff == diff_words_styles[i].type) {\n+\t\t\t\t\tecbdata.diff_words->style =\n+\t\t\t\t\t\t&diff_words_styles[i];\n+\t\t\t\t\tbreak;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\tif (DIFF_OPT_TST(o, COLOR_DIFF)) {\n+\t\t\t\tstruct diff_words_style *st = ecbdata.diff_words->style;\n+\t\t\t\tst->old.color = diff_get_color_opt(o, DIFF_FILE_OLD);\n+\t\t\t\tst->new.color = diff_get_color_opt(o, DIFF_FILE_NEW);\n+\t\t\t\tst->ctx.color = diff_get_color_opt(o, DIFF_PLAIN);\n+\t\t\t}\n \t\t}\n \t\txdi_diff_outf(&mf1, &mf2, fn_out_consume, &ecbdata,\n \t\t\t      &xpp, &xecfg, &ecb);\n-\t\tif (DIFF_OPT_TST(o, COLOR_DIFF_WORDS))\n+\t\tif (o->word_diff)\n \t\t\tfree_diff_words_data(&ecbdata);\n \t\tif (textconv_one)\n \t\t\tfree(mf1.ptr);\n@@ -2830,13 +2907,37 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\tDIFF_OPT_CLR(options, COLOR_DIFF);\n \telse if (!strcmp(arg, \"--color-words\")) {\n \t\tDIFF_OPT_SET(options, COLOR_DIFF);\n-\t\tDIFF_OPT_SET(options, COLOR_DIFF_WORDS);\n+\t\toptions->word_diff = DIFF_WORDS_COLOR;\n \t}\n \telse if (!prefixcmp(arg, \"--color-words=\")) {\n \t\tDIFF_OPT_SET(options, COLOR_DIFF);\n-\t\tDIFF_OPT_SET(options, COLOR_DIFF_WORDS);\n+\t\toptions->word_diff = DIFF_WORDS_COLOR;\n \t\toptions->word_regex = arg + 14;\n \t}\n+\telse if (!strcmp(arg, \"--word-diff\")) {\n+\t\tif (options->word_diff == DIFF_WORDS_NONE)\n+\t\t\toptions->word_diff = DIFF_WORDS_PLAIN;\n+\t}\n+\telse if (!prefixcmp(arg, \"--word-diff=\")) {\n+\t\tconst char *type = arg + 12;\n+\t\tif (!strcmp(type, \"plain\"))\n+\t\t\toptions->word_diff = DIFF_WORDS_PLAIN;\n+\t\telse if (!strcmp(type, \"color\")) {\n+\t\t\tDIFF_OPT_SET(options, COLOR_DIFF);\n+\t\t\toptions->word_diff = DIFF_WORDS_COLOR;\n+\t\t}\n+\t\telse if (!strcmp(type, \"porcelain\"))\n+\t\t\toptions->word_diff = DIFF_WORDS_PORCELAIN;\n+\t\telse if (!strcmp(type, \"none\"))\n+\t\t\toptions->word_diff = DIFF_WORDS_NONE;\n+\t\telse\n+\t\t\tdie(\"bad --word-diff argument: %s\", type);\n+\t}\n+\telse if (!prefixcmp(arg, \"--word-diff-regex=\")) {\n+\t\tif (options->word_diff == DIFF_WORDS_NONE)\n+\t\t\toptions->word_diff = DIFF_WORDS_PLAIN;\n+\t\toptions->word_regex = arg + 18;\n+\t}\n \telse if (!strcmp(arg, \"--exit-code\"))\n \t\tDIFF_OPT_SET(options, EXIT_WITH_STATUS);\n \telse if (!strcmp(arg, \"--quiet\"))\ndiff --git a/diff.h b/diff.h\nindex 6a71013..9ace08c 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -54,7 +54,7 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,\n #define DIFF_OPT_FIND_COPIES_HARDER  (1 <<  6)\n #define DIFF_OPT_FOLLOW_RENAMES      (1 <<  7)\n #define DIFF_OPT_COLOR_DIFF          (1 <<  8)\n-#define DIFF_OPT_COLOR_DIFF_WORDS    (1 <<  9)\n+/* (1 <<  9) unused */\n #define DIFF_OPT_HAS_CHANGES         (1 << 10)\n #define DIFF_OPT_QUICK               (1 << 11)\n #define DIFF_OPT_NO_INDEX            (1 << 12)\n@@ -79,6 +79,13 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,\n #define DIFF_XDL_SET(opts, flag)    ((opts)->xdl_opts |= XDF_##flag)\n #define DIFF_XDL_CLR(opts, flag)    ((opts)->xdl_opts &= ~XDF_##flag)\n \n+enum diff_words_type {\n+\tDIFF_WORDS_NONE = 0,\n+\tDIFF_WORDS_PORCELAIN,\n+\tDIFF_WORDS_PLAIN,\n+\tDIFF_WORDS_COLOR\n+};\n+\n struct diff_options {\n \tconst char *filter;\n \tconst char *orderfile;\n@@ -108,6 +115,7 @@ struct diff_options {\n \tint stat_width;\n \tint stat_name_width;\n \tconst char *word_regex;\n+\tenum diff_words_type word_diff;\n \n \t/* this is set by diffcore for DIFF_FORMAT_PATCH */\n \tint found_changes;\ndiff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh\nindex 2e2e103..6f7548c 100755\n--- a/t/t4034-diff-words.sh\n+++ b/t/t4034-diff-words.sh\n@@ -55,6 +55,93 @@ test_expect_success 'word diff with runs of whitespace' '\n \n '\n \n+test_expect_success '--word-diff=color' '\n+\n+\tword_diff --word-diff=color\n+\n+'\n+\n+test_expect_success '--color --word-diff=color' '\n+\n+\tword_diff --color --word-diff=color\n+\n+'\n+\n+sed 's/#.*$//' > expect <<EOF\n+diff --git a/pre b/post\n+index 330b04f..5ed8eff 100644\n+--- a/pre\n++++ b/post\n+@@ -1,3 +1,7 @@\n+-h(4)\n++h(4),hh[44]\n+~\n+ # significant space\n+~\n+ a = b + c\n+~\n+~\n++aa = a\n+~\n+~\n++aeff = aeff * ( aaa )\n+~\n+EOF\n+\n+test_expect_success '--word-diff=porcelain' '\n+\n+\tword_diff --word-diff=porcelain\n+\n+'\n+\n+cat > expect <<EOF\n+diff --git a/pre b/post\n+index 330b04f..5ed8eff 100644\n+--- a/pre\n++++ b/post\n+@@ -1,3 +1,7 @@\n+[-h(4)-]{+h(4),hh[44]+}\n+\n+a = b + c\n+\n+{+aa = a+}\n+\n+{+aeff = aeff * ( aaa )+}\n+EOF\n+\n+test_expect_success '--word-diff=plain' '\n+\n+\tword_diff --word-diff=plain\n+\n+'\n+\n+test_expect_success '--word-diff=plain --no-color' '\n+\n+\tword_diff --word-diff=plain --no-color\n+\n+'\n+\n+cat > expect <<EOF\n+<WHITE>diff --git a/pre b/post<RESET>\n+<WHITE>index 330b04f..5ed8eff 100644<RESET>\n+<WHITE>--- a/pre<RESET>\n+<WHITE>+++ b/post<RESET>\n+<CYAN>@@ -1,3 +1,7 @@<RESET>\n+<RED>[-h(4)-]<RESET><GREEN>{+h(4),hh[44]+}<RESET>\n+\n+a = b + c<RESET>\n+\n+<GREEN>{+aa = a+}<RESET>\n+\n+<GREEN>{+aeff = aeff * ( aaa )+}<RESET>\n+EOF\n+\n+test_expect_success '--word-diff=plain --color' '\n+\n+\tword_diff --word-diff=plain --color\n+\n+'\n+\n cat > expect <<\\EOF\n <WHITE>diff --git a/pre b/post<RESET>\n <WHITE>index 330b04f..5ed8eff 100644<RESET>\n@@ -143,6 +230,25 @@ test_expect_success 'command-line overrides config' '\n \tword_diff --color-words=\"[a-z]+\"\n '\n \n+cat > expect <<\\EOF\n+<WHITE>diff --git a/pre b/post<RESET>\n+<WHITE>index 330b04f..5ed8eff 100644<RESET>\n+<WHITE>--- a/pre<RESET>\n+<WHITE>+++ b/post<RESET>\n+<CYAN>@@ -1,3 +1,7 @@<RESET>\n+h(4),<GREEN>{+hh+}<RESET>[44]\n+\n+a = b + c<RESET>\n+\n+<GREEN>{+aa = a+}<RESET>\n+\n+<GREEN>{+aeff = aeff * ( aaa+}<RESET> )\n+EOF\n+\n+test_expect_success 'command-line overrides config: --word-diff-regex' '\n+\tword_diff --color --word-diff-regex=\"[a-z]+\"\n+'\n+\n cp expect.non-whitespace-is-word expect\n \n test_expect_success '.gitattributes override config' '\n@@ -209,4 +315,20 @@ test_expect_success 'test when words are only removed at the end' '\n \n '\n \n+cat > expect <<\\EOF\n+diff --git a/pre b/post\n+index 289cb9d..2d06f37 100644\n+--- a/pre\n++++ b/post\n+@@ -1 +1 @@\n+-(:\n++(\n+EOF\n+\n+test_expect_success '--word-diff=none' '\n+\n+\tword_diff --word-diff=plain --word-diff=none\n+\n+'\n+\n test_done\n-- \n1.7.1.rc1.260.g41ab89\n"},{"id":"139491","messageId":"5531510bfb94997f729a894a0b5a3158177a9add.1271260308.git.trast@student.ethz.ch","threadId":"23459","inReplyTo":"cover.1271260308.git.trast@student.ethz.ch","subject":"[PATCH v4 2/3] gitk: do not parse \" >\" context as submodule change","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-04-14T15:59:07Z","receivedAt":"2010-04-14T15:59:07Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Since 5c838d2 (gitk: Use the --submodule option for displaying diffs\nwhen available, 2009-10-28) gitk erroneously matches \"  >\" and \"  <\"\nat the beginning of a line in the submodule code even if we're in the\ndiff text section and the lines should be treated as context.\n\nFix by (ab)using the $diffinhdr variable also in the 'Submodule...'\ncase, and move the \"  >\"/\"  <\" specific code inside the $diffinhdr\ntest.  The existing code will set $diffinhdr to 0 when it hits a\n\"+++\", so that it is always 0 when we can hit a context line.\n---\n gitk |   16 ++++++++++------\n 1 files changed, 10 insertions(+), 6 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 1f36a3e..7b8799e 100755\n--- a/gitk\n+++ b/gitk\n@@ -7688,12 +7688,8 @@ proc getblobdiffline {bdf ids} {\n \t    lappend ctext_file_lines $fname\n \t    makediffhdr $fname $ids\n \t    $ctext insert end \"\\n$line\\n\" filesep\n-\t} elseif {![string compare -length 3 \"  >\" $line]} {\n-\t    set line [encoding convertfrom $diffencoding $line]\n-\t    $ctext insert end \"$line\\n\" dresult\n-\t} elseif {![string compare -length 3 \"  <\" $line]} {\n-\t    set line [encoding convertfrom $diffencoding $line]\n-\t    $ctext insert end \"$line\\n\" d0\n+\t    # pretend we're in a file header to correctly parse \"  [><]\"\n+\t    set diffinhdr 1\n \t} elseif {$diffinhdr} {\n \t    if {![string compare -length 12 \"rename from \" $line]} {\n \t\tset fname [string range $line [expr 6 + [string first \" from \" $line] ] end]\n@@ -7712,6 +7708,14 @@ proc getblobdiffline {bdf ids} {\n \t\t    set fname [lindex $fname 0]\n \t\t}\n \t\tmakediffhdr $fname $ids\n+\t    } elseif {![string compare -length 3 \"  >\" $line]} {\n+\t\tset line [encoding convertfrom $diffencoding $line]\n+\t\t$ctext insert end \"$line\\n\" dresult\n+\t\tcontinue\n+\t    } elseif {![string compare -length 3 \"  <\" $line]} {\n+\t\tset line [encoding convertfrom $diffencoding $line]\n+\t\t$ctext insert end \"$line\\n\" d0\n+\t\tcontinue\n \t    } elseif {[string compare -length 3 $line \"---\"] == 0} {\n \t\t# do nothing\n \t\tcontinue\n-- \n1.7.1.rc1.260.g41ab89\n"},{"id":"139490","messageId":"bc720738f918f0523842b3839b7e611c453b5241.1271260308.git.trast@student.ethz.ch","threadId":"23459","inReplyTo":"cover.1271260308.git.trast@student.ethz.ch","subject":"[PATCH v4 3/3] gitk: add the equivalent of diff --color-words","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-04-14T15:59:08Z","receivedAt":"2010-04-14T15:59:08Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Use the newly added 'diff --word-diff=porcelain' to teach gitk a\ncolor-words mode, with two different modes analogous to the\n--word-diff=plain and --word-diff=color settings.  These are selected\nby a dropdown box.\n\nAs an extra twist, automatically enable this word-diff support when\nthe user mentions a word-diff related option on the command line.\nThese options were previously ignored because they would break diff\nparsing.\n\nBoth of these features are only enabled if we have a version of git\nthat supports --word-diff=porcelain, tentatively set to 1.7.2.\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n gitk |   64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---\n 1 files changed, 61 insertions(+), 3 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 7b8799e..f2a1eb7 100755\n--- a/gitk\n+++ b/gitk\n@@ -131,6 +131,7 @@ proc unmerged_files {files} {\n \n proc parseviewargs {n arglist} {\n     global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs env\n+    global worddiff git_version\n \n     set vdatemode($n) 0\n     set vmergeonly($n) 0\n@@ -168,7 +169,7 @@ proc parseviewargs {n arglist} {\n \t\tlappend diffargs $arg\n \t    }\n \t    \"--raw\" - \"--patch-with-raw\" - \"--patch-with-stat\" -\n-\t    \"--name-only\" - \"--name-status\" - \"--color\" - \"--color-words\" -\n+\t    \"--name-only\" - \"--name-status\" - \"--color\" -\n \t    \"--log-size\" - \"--pretty=*\" - \"--decorate\" - \"--abbrev-commit\" -\n \t    \"--cc\" - \"-z\" - \"--header\" - \"--parents\" - \"--boundary\" -\n \t    \"--no-color\" - \"-g\" - \"--walk-reflogs\" - \"--no-walk\" -\n@@ -177,6 +178,18 @@ proc parseviewargs {n arglist} {\n \t\t# These cause our parsing of git log's output to fail, or else\n \t\t# they're options we want to set ourselves, so ignore them.\n \t    }\n+\t    \"--color-words*\" - \"--word-diff=color\" {\n+\t\t# These trigger a word diff in the console interface,\n+\t\t# so help the user by enabling our own support\n+\t\tif {[package vcompare $git_version \"1.7.2\"] >= 0} {\n+\t\t    set worddiff [mc \"Color words\"]\n+\t\t}\n+\t    }\n+\t    \"--word-diff*\" {\n+\t\tif {[package vcompare $git_version \"1.7.2\"] >= 0} {\n+\t\t    set worddiff [mc \"Markup words\"]\n+\t\t}\n+\t    }\n \t    \"--stat=*\" - \"--numstat\" - \"--shortstat\" - \"--summary\" -\n \t    \"--check\" - \"--exit-code\" - \"--quiet\" - \"--topo-order\" -\n \t    \"--full-history\" - \"--dense\" - \"--sparse\" -\n@@ -1967,6 +1980,8 @@ proc makewindow {} {\n     global fprogitem fprogcoord lastprogupdate progupdatepending\n     global rprogitem rprogcoord rownumsel numcommits\n     global have_tk85 use_ttk NS\n+    global git_version\n+    global worddiff\n \n     # The \"mc\" arguments here are purely so that xgettext\n     # sees the following string as needing to be translated\n@@ -2240,6 +2255,15 @@ proc makewindow {} {\n     ${NS}::checkbutton .bleft.mid.ignspace -text [mc \"Ignore space change\"] \\\n \t-command changeignorespace -variable ignorespace\n     pack .bleft.mid.ignspace -side left -padx 5\n+\n+    set worddiff [mc \"Line diff\"]\n+    if {[package vcompare $git_version \"1.7.2\"] >= 0} {\n+\tmakedroplist .bleft.mid.worddiff worddiff [mc \"Line diff\"] \\\n+\t    [mc \"Markup words\"] [mc \"Color words\"]\n+\ttrace add variable worddiff write changeworddiff\n+\tpack .bleft.mid.worddiff -side left -padx 5\n+    }\n+\n     set ctext .bleft.bottom.ctext\n     text $ctext -background $bgcolor -foreground $fgcolor \\\n \t-state disabled -font textfont \\\n@@ -7494,11 +7518,16 @@ proc changeignorespace {} {\n     reselectline\n }\n \n+proc changeworddiff {name ix op} {\n+    reselectline\n+}\n+\n proc getblobdiffs {ids} {\n     global blobdifffd diffids env\n     global diffinhdr treediffs\n     global diffcontext\n     global ignorespace\n+    global worddiff\n     global limitdiffs vfilelimit curview\n     global diffencoding targetline diffnparents\n     global git_version\n@@ -7515,6 +7544,9 @@ proc getblobdiffs {ids} {\n     if {$ignorespace} {\n \tappend cmd \" -w\"\n     }\n+    if {$worddiff ne [mc \"Line diff\"]} {\n+\tappend cmd \" --word-diff=porcelain\"\n+    }\n     if {$limitdiffs && $vfilelimit($curview) ne {}} {\n \tset cmd [concat $cmd -- $vfilelimit($curview)]\n     }\n@@ -7599,6 +7631,7 @@ proc getblobdiffline {bdf ids} {\n     global ctext_file_names ctext_file_lines\n     global diffinhdr treediffs mergemax diffnparents\n     global diffencoding jump_to_here targetline diffline\n+    global worddiff\n \n     set nr 0\n     $ctext conf -state normal\n@@ -7731,15 +7764,28 @@ proc getblobdiffline {bdf ids} {\n \t    # parse the prefix - one ' ', '-' or '+' for each parent\n \t    set prefix [string range $line 0 [expr {$diffnparents - 1}]]\n \t    set tag [expr {$diffnparents > 1? \"m\": \"d\"}]\n+\t    set dowords [expr {$worddiff ne [mc \"Line diff\"] && $diffnparents == 1}]\n+\t    set words_pre_markup \"\"\n+\t    set words_post_markup \"\"\n \t    if {[string trim $prefix \" -+\"] eq {}} {\n \t\t# prefix only has \" \", \"-\" and \"+\" in it: normal diff line\n \t\tset num [string first \"-\" $prefix]\n+\t\tif {$dowords} {\n+\t\t    set line [string range $line 1 end]\n+\t\t}\n \t\tif {$num >= 0} {\n \t\t    # removed line, first parent with line is $num\n \t\t    if {$num >= $mergemax} {\n \t\t\tset num \"max\"\n \t\t    }\n-\t\t    $ctext insert end \"$line\\n\" $tag$num\n+\t\t    if {$dowords && $worddiff eq [mc \"Markup words\"]} {\n+\t\t\t$ctext insert end \"\\[-$line-\\]\" $tag$num\n+\t\t    } else {\n+\t\t\t$ctext insert end \"$line\" $tag$num\n+\t\t    }\n+\t\t    if {!$dowords} {\n+\t\t\t$ctext insert end \"\\n\" $tag$num\n+\t\t    }\n \t\t} else {\n \t\t    set tags {}\n \t\t    if {[string first \"+\" $prefix] >= 0} {\n@@ -7754,6 +7800,8 @@ proc getblobdiffline {bdf ids} {\n \t\t\t\tlappend tags m$num\n \t\t\t    }\n \t\t\t}\n+\t\t\tset words_pre_markup \"{+\"\n+\t\t\tset words_post_markup \"+}\"\n \t\t    }\n \t\t    if {$targetline ne {}} {\n \t\t\tif {$diffline == $targetline} {\n@@ -7763,8 +7811,17 @@ proc getblobdiffline {bdf ids} {\n \t\t\t    incr diffline\n \t\t\t}\n \t\t    }\n-\t\t    $ctext insert end \"$line\\n\" $tags\n+\t\t    if {$dowords && $worddiff eq [mc \"Markup words\"]} {\n+\t\t\t$ctext insert end \"$words_pre_markup$line$words_post_markup\" $tags\n+\t\t    } else {\n+\t\t\t$ctext insert end \"$line\" $tags\n+\t\t    }\n+\t\t    if {!$dowords} {\n+\t\t\t$ctext insert end \"\\n\" $tags\n+\t\t    }\n \t\t}\n+\t    } elseif {$dowords && $prefix eq \"~\"} {\n+\t\t$ctext insert end \"\\n\" {}\n \t    } else {\n \t\t# \"\\ No newline at end of file\",\n \t\t# or something else we don't recognize\n@@ -11383,6 +11440,7 @@ if {[tk windowingsystem] eq \"win32\"} {\n set diffcolors {red \"#00a000\" blue}\n set diffcontext 3\n set ignorespace 0\n+set worddiff \"\"\n set markbgcolor \"#e0e0ff\"\n \n set circlecolors {white blue gray blue blue}\n-- \n1.7.1.rc1.260.g41ab89\n"},{"id":"139521","messageId":"7vpr21ohj8.fsf@alter.siamese.dyndns.org","threadId":"23459","inReplyTo":"9a2b460ea5db47154623386638e883f749c4ee35.1271260308.git.trast@student.ethz.ch","subject":"Re: [PATCH v4 1/3] diff: add --word-diff option that generalizes --color-words","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-14T21:23:07Z","receivedAt":"2010-04-14T21:23:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Looks good; I'll queue this one and hopefully Paul can give feedback to\nthe gitk patches.\n\nThanks.\n"},{"id":"139621","messageId":"4BC76FA2.3030204@web.de","threadId":"23459","inReplyTo":"5531510bfb94997f729a894a0b5a3158177a9add.1271260308.git.trast@student.ethz.ch","subject":"Re: [PATCH v4 2/3] gitk: do not parse \" >\" context as submodule change","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2010-04-15T19:57:22Z","receivedAt":"2010-04-15T19:57:22Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 14.04.2010 17:59, schrieb Thomas Rast:\n> Since 5c838d2 (gitk: Use the --submodule option for displaying diffs\n> when available, 2009-10-28) gitk erroneously matches \"  >\" and \"  <\"\n> at the beginning of a line in the submodule code even if we're in the\n> diff text section and the lines should be treated as context.\n> \n> Fix by (ab)using the $diffinhdr variable also in the 'Submodule...'\n> case, and move the \"  >\"/\"  <\" specific code inside the $diffinhdr\n> test.  The existing code will set $diffinhdr to 0 when it hits a\n> \"+++\", so that it is always 0 when we can hit a context line.\n\nThanks for fixing this issue I accidentally introduced!\n\nIn that said patch I unfortunately also managed to screw up the\nsubmodule name detection when it was not followed just by commits\n(but e.g. by \"contains untracked content\"). I did already send a\npatch to address this issue, but here is a rebased version on top\nof your patch series just in case:\n\n--------------------8<--------------------\nFrom: Jens Lehmann <Jens.Lehmann@web.de>\nDate: Thu, 15 Apr 2010 21:53:12 +0200\nSubject: [PATCH] Teach gitk to display dirty submodules correctly\n\nSince 1.7.1 \"git diff --submodule\" prints out extra lines when the\nsubmodule contains untracked or modified files. Show all those lines for\none submodule under the same header.\n\nAlso e.g. for newly added or removed submodules the submodule name\ncontained trailing garbage because the extraction of the name was not\ndone right. Now it scans either for the first hex number followed by a\n\"..\" or the string \"contains \".\n\nSigned-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n---\n gitk-git/gitk |   27 +++++++++++++++++++--------\n 1 files changed, 19 insertions(+), 8 deletions(-)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex f2a1eb7..93d25ec 100644\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -7530,7 +7530,7 @@ proc getblobdiffs {ids} {\n     global worddiff\n     global limitdiffs vfilelimit curview\n     global diffencoding targetline diffnparents\n-    global git_version\n+    global git_version currdiffsubmod\n\n     set textconv {}\n     if {[package vcompare $git_version \"1.6.1\"] >= 0} {\n@@ -7560,6 +7560,7 @@ proc getblobdiffs {ids} {\n     set diffencoding [get_path_encoding {}]\n     fconfigure $bdf -blocking 0 -encoding binary -eofchar {}\n     set blobdifffd($ids) $bdf\n+    set currdiffsubmod \"\"\n     filerun $bdf [list getblobdiffline $bdf $diffids]\n }\n\n@@ -7631,7 +7632,7 @@ proc getblobdiffline {bdf ids} {\n     global ctext_file_names ctext_file_lines\n     global diffinhdr treediffs mergemax diffnparents\n     global diffencoding jump_to_here targetline diffline\n-    global worddiff\n+    global worddiff currdiffsubmod\n\n     set nr 0\n     $ctext conf -state normal\n@@ -7712,15 +7713,24 @@ proc getblobdiffline {bdf ids} {\n\n \t} elseif {![string compare -length 10 \"Submodule \" $line]} {\n \t    # start of a new submodule\n-\t    if {[string compare [$ctext get \"end - 4c\" end] \"\\n \\n\\n\"]} {\n+\t    if {[regexp -indices \"\\[0-9a-f\\]+\\\\.\\\\.\" $line nameend]} {\n+\t\tset fname [string range $line 10 [expr [lindex $nameend 0] - 2]]\n+\t    } else {\n+\t\tset fname [string range $line 10 [expr [string first \"contains \" $line] - 2]]\n+\t    }\n+\t    if {$currdiffsubmod != $fname} {\n \t\t$ctext insert end \"\\n\";     # Add newline after commit message\n \t    }\n \t    set curdiffstart [$ctext index \"end - 1c\"]\n \t    lappend ctext_file_names \"\"\n-\t    set fname [string range $line 10 [expr [string last \" \" $line] - 1]]\n-\t    lappend ctext_file_lines $fname\n-\t    makediffhdr $fname $ids\n-\t    $ctext insert end \"\\n$line\\n\" filesep\n+\t    if {$currdiffsubmod != $fname} {\n+\t\tlappend ctext_file_lines $fname\n+\t\tmakediffhdr $fname $ids\n+\t\tset currdiffsubmod $fname\n+\t\t$ctext insert end \"\\n$line\\n\" filesep\n+\t    } else {\n+\t\t$ctext insert end \"$line\\n\" filesep\n+\t    }\n \t    # pretend we're in a file header to correctly parse \"  [><]\"\n \t    set diffinhdr 1\n \t} elseif {$diffinhdr} {\n@@ -8588,7 +8598,7 @@ proc do_cmp_commits {a b} {\n }\n\n proc diffcommits {a b} {\n-    global diffcontext diffids blobdifffd diffinhdr\n+    global diffcontext diffids blobdifffd diffinhdr currdiffsubmod\n\n     set tmpdir [gitknewtmpdir]\n     set fna [file join $tmpdir \"commit-[string range $a 0 7]\"]\n@@ -8609,6 +8619,7 @@ proc diffcommits {a b} {\n     set diffids [list commits $a $b]\n     set blobdifffd($diffids) $fd\n     set diffinhdr 0\n+    set currdiffsubmod \"\"\n     filerun $fd [list getblobdiffline $fd $diffids]\n }\n\n-- \n1.7.1.rc1.252.gff9f\n"},{"id":"139718","messageId":"20100417063320.GA6681@brick.ozlabs.ibm.com","threadId":"23459","inReplyTo":"5531510bfb94997f729a894a0b5a3158177a9add.1271260308.git.trast@student.ethz.ch","subject":"Re: [PATCH v4 2/3] gitk: do not parse \" >\" context as submodule change","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2010-04-17T06:33:20Z","receivedAt":"2010-04-17T06:33:20Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"On Wed, Apr 14, 2010 at 05:59:07PM +0200, Thomas Rast wrote:\n\n> Since 5c838d2 (gitk: Use the --submodule option for displaying diffs\n> when available, 2009-10-28) gitk erroneously matches \"  >\" and \"  <\"\n> at the beginning of a line in the submodule code even if we're in the\n> diff text section and the lines should be treated as context.\n> \n> Fix by (ab)using the $diffinhdr variable also in the 'Submodule...'\n> case, and move the \"  >\"/\"  <\" specific code inside the $diffinhdr\n> test.  The existing code will set $diffinhdr to 0 when it hits a\n> \"+++\", so that it is always 0 when we can hit a context line.\n\nLooks good, but there's no Signed-off-by?\n\nPaul.\n"},{"id":"139719","messageId":"20100417063557.GB6681@brick.ozlabs.ibm.com","threadId":"23459","inReplyTo":"bc720738f918f0523842b3839b7e611c453b5241.1271260308.git.trast@student.ethz.ch","subject":"Re: [PATCH v4 3/3] gitk: add the equivalent of diff --color-words","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2010-04-17T06:35:57Z","receivedAt":"2010-04-17T06:35:57Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"On Wed, Apr 14, 2010 at 05:59:08PM +0200, Thomas Rast wrote:\n\n> Use the newly added 'diff --word-diff=porcelain' to teach gitk a\n> color-words mode, with two different modes analogous to the\n> --word-diff=plain and --word-diff=color settings.  These are selected\n> by a dropdown box.\n> \n> As an extra twist, automatically enable this word-diff support when\n> the user mentions a word-diff related option on the command line.\n> These options were previously ignored because they would break diff\n> parsing.\n> \n> Both of these features are only enabled if we have a version of git\n> that supports --word-diff=porcelain, tentatively set to 1.7.2.\n> \n> Signed-off-by: Thomas Rast <trast@student.ethz.ch>\n\nLooks fine.  The only nit I can see is that a \"--word-diffoobar\"\noption would get treated as \"--word-diff=plain\" rather than giving an\nerror or being passed as-is to git log.\n\nWhen does this need to go in, i.e. when is the git patch likely to go\nin?\n\nPaul.\n"},{"id":"139720","messageId":"7vhbna601d.fsf@alter.siamese.dyndns.org","threadId":"23459","inReplyTo":"20100417063557.GB6681@brick.ozlabs.ibm.com","subject":"Re: [PATCH v4 3/3] gitk: add the equivalent of diff --color-words","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-17T06:55:10Z","receivedAt":"2010-04-17T06:55:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Paul Mackerras <paulus@samba.org> writes:\n\n> When does this need to go in, i.e. when is the git patch likely to go\n> in?\n\nI am expecting that this will be in soon after the current 1.7.1 cycle,\nsometime around early-to-mid May timeframe.\n"},{"id":"139743","messageId":"201004171420.55737.trast@student.ethz.ch","threadId":"23459","inReplyTo":"20100417063320.GA6681@brick.ozlabs.ibm.com","subject":"Re: [PATCH v4 2/3] gitk: do not parse \" >\" context as submodule change","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-04-17T12:20:55Z","receivedAt":"2010-04-17T12:20:55Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Paul Mackerras wrote:\n> On Wed, Apr 14, 2010 at 05:59:07PM +0200, Thomas Rast wrote:\n> \n> > Since 5c838d2 (gitk: Use the --submodule option for displaying diffs\n> > when available, 2009-10-28) gitk erroneously matches \"  >\" and \"  <\"\n> > at the beginning of a line in the submodule code even if we're in the\n> > diff text section and the lines should be treated as context.\n> > \n> > Fix by (ab)using the $diffinhdr variable also in the 'Submodule...'\n> > case, and move the \"  >\"/\"  <\" specific code inside the $diffinhdr\n> > test.  The existing code will set $diffinhdr to 0 when it hits a\n> > \"+++\", so that it is always 0 when we can hit a context line.\n> \n> Looks good, but there's no Signed-off-by?\n\nWhoops, sorry:\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"139862","messageId":"20100419010819.GA4386@brick.ozlabs.ibm.com","threadId":"23459","inReplyTo":"201004171420.55737.trast@student.ethz.ch","subject":"Re: [PATCH v4 2/3] gitk: do not parse \" >\" context as submodule change","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2010-04-19T01:08:19Z","receivedAt":"2010-04-19T01:08:19Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"On Sat, Apr 17, 2010 at 02:20:55PM +0200, Thomas Rast wrote:\n\n> Whoops, sorry:\n> \n> Signed-off-by: Thomas Rast <trast@student.ethz.ch>\n\nThanks, but now that I have applied Jens Lehmann's patch that also\ntouches this area, your patch doesn't apply.  Could you rebase it and\nsend it again?\n\nThanks,\nPaul.\n"}]}