Git development
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Boyd Stephen Smith Jr." <bss@iguanasuicide.net>,
	"Santi Béjar" <santi@agolina.net>,
	"Thomas Rast" <trast@student.ethz.ch>,
	git@vger.kernel.org, "Teemu Likonen" <tlikonen@iki.fi>
Subject: Re: [PATCH] diff: Support diff.color-words config option
Date: Tue, 20 Jan 2009 18:28:14 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.1.00.0901201819490.5159@intel-tinevez-2-302> (raw)
In-Reply-To: <7vskndkip9.fsf@gitster.siamese.dyndns.org>

Hi,

On Tue, 20 Jan 2009, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> >> @@ -92,6 +93,8 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
> >>  	}
> >>  	if (!strcmp(var, "diff.external"))
> >>  		return git_config_string(&external_diff_cmd_cfg, var, value);
> >> +	if (!strcmp(var, "diff.color-words"))
> >
> > I'd call it diff.wordregex, because that's what it is.
> 
> If we want to add a new word-oriented option to diff that is not about 
> coloring the word differences, is it safe and sane to reuse the same 
> definition?  That is, "git diff --color-words" would be affected when 
> diff.wordregex is set to some value, so does any new word-oriented 
> operation we will add, and the single regex configured would be used as 
> the default value to define how a word would look like.
> 
> I think it makes sense; I do not think of a case offhand where you would 
> want to define what a word is for the purpose of coloring diffs in one 
> way, and would want to use a different definition for another 
> word-oriented operation.

Why not cross that bridge when we're there?  Should we ever feel the need 
for different word regexes, we would just introduce color.wordregex.

> >> @@ -1550,6 +1553,8 @@ static void builtin_diff(const char *name_a,
> >>  				o->word_regex = userdiff_word_regex(one);
> >>  			if (!o->word_regex)
> >>  				o->word_regex = userdiff_word_regex(two);
> >> +			if (!o->word_regex)
> >> +				o->word_regex = diff_color_words_cfg;
> >
> > IMHO this is the wrong order.  config should not override attributes, 
> > which are by definition more specific.
> 
> Isn't it merely giving a fallback value when attributes does not give one?

Yep.  Boyd (or Stephen, as he wants to be called, making it hard to guess 
from his email address, but that's all part of the fun, in't it?) already 
realized that I was up too late and got the order wrong myself.

> By the way, wouldn't it make sense to optimize the precontext of that 
> hunk by doing _something_ like:
> 
> 	if (!o->word_regex && strcmp(one->path, two->path))
>         	o->word_regex = userdiff_word_regex(two);
> 
> "Something like" comes from special cases like /dev/null for new/deleted
> files, etc.

You mean to avoid the cost of initializing the regex in case one and the 
same file is diffed against itself?  But that would be better handled 
before calling builtin_diff(), don't you think?

I do not know off-hand if diffcore_std() handles that already, so that the 
diff_flush() ... builtin_diff() cascade is not even called.

But you raise a valid concern: the regular expression is initialized every 
time we look at a file.  We probably should have a member 
word_regex_compiled in diff_options, then, and only initialize it the 
first time.

Ciao,
Dscho "who does not have the time to work on Git right now"

  reply	other threads:[~2009-01-20 17:29 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-11 19:58 [PATCH 0/4] refactor the --color-words to make it more hackable Johannes Schindelin
2009-01-11 19:59 ` [PATCH 1/4] Add color_fwrite(), a function coloring each line individually Johannes Schindelin
2009-01-11 22:43   ` Junio C Hamano
2009-01-11 23:49     ` Johannes Schindelin
2009-01-11 23:49       ` [PATCH v2 " Johannes Schindelin
2009-01-12  1:27         ` Jakub Narebski
2009-01-11 19:59 ` [PATCH 2/4] color-words: refactor word splitting and use ALLOC_GROW() Johannes Schindelin
2009-01-11 19:59 ` [PATCH 3/4] color-words: refactor to allow for 0-character word boundaries Johannes Schindelin
2009-01-11 23:08   ` Junio C Hamano
2009-01-11 23:38     ` Johannes Schindelin
2009-01-12  8:47   ` Thomas Rast
2009-01-12  9:36     ` Junio C Hamano
2009-01-14 17:49       ` [PATCH take 3 0/4] color-words improvements Johannes Schindelin
2009-01-14 17:50         ` [PATCH 1/4] Add color_fwrite_lines(), a function coloring each line individually Johannes Schindelin
2009-01-14 17:50         ` [PATCH 2/4] color-words: refactor word splitting and use ALLOC_GROW() Johannes Schindelin
2009-01-14 17:51         ` [PATCH 3/4] color-words: change algorithm to allow for 0-character word boundaries Johannes Schindelin
2009-01-14 18:08           ` Johannes Schindelin
2009-01-14 17:51         ` [PATCH 4/4] color-words: take an optional regular expression describing words Johannes Schindelin
2009-01-14 19:55           ` Thomas Rast
2009-01-14 18:54         ` [PATCH take 3 0/4] color-words improvements Teemu Likonen
2009-01-14 18:57           ` Teemu Likonen
2009-01-14 19:28             ` Johannes Schindelin
2009-01-14 19:32               ` Johannes Schindelin
2009-01-14 19:58           ` Thomas Rast
2009-01-14 22:06             ` Johannes Schindelin
2009-01-14 22:11               ` Thomas Rast
2009-01-14 22:24               ` Boyd Stephen Smith Jr.
2009-01-15  4:56               ` Teemu Likonen
2009-01-15 12:41                 ` Johannes Schindelin
2009-01-15 13:03                   ` Teemu Likonen
2009-01-15 13:27                     ` Thomas Rast
2009-01-15 18:15                   ` Junio C Hamano
2009-01-15 19:25                     ` Johannes Schindelin
2009-01-16  0:10                       ` Santi Béjar
2009-01-16  1:37                         ` Junio C Hamano
2009-01-16  1:42                         ` Boyd Stephen Smith Jr.
2009-01-16  1:55                         ` Johannes Schindelin
2009-01-16  9:02                           ` Santi Béjar
2009-01-16 11:57                             ` Johannes Schindelin
2009-01-16 12:01                             ` Santi Béjar
2009-01-16 12:40                               ` Johannes Schindelin
2009-01-16 19:04                               ` Thomas Rast
2009-01-16 21:09                                 ` Johannes Schindelin
2009-01-17 16:29                                   ` [PATCH v4 0/7] customizable --color-words Thomas Rast
2009-01-17 16:29                                     ` [PATCH v4 1/7] Add color_fwrite_lines(), a function coloring each line individually Thomas Rast
2009-01-17 16:29                                       ` [PATCH v4 2/7] color-words: refactor word splitting and use ALLOC_GROW() Thomas Rast
2009-01-17 16:29                                         ` [PATCH v4 3/7] color-words: change algorithm to allow for 0-character word boundaries Thomas Rast
2009-01-17 16:29                                           ` [PATCH v4 4/7] color-words: take an optional regular expression describing words Thomas Rast
2009-01-17 16:29                                             ` [PATCH v4 5/7] color-words: enable REG_NEWLINE to help user Thomas Rast
2009-01-17 16:29                                               ` [PATCH v4 6/7] color-words: expand docs with precise semantics Thomas Rast
2009-01-17 16:29                                                 ` [PATCH v4 7/7] color-words: make regex configurable via attributes Thomas Rast
2009-01-18 15:05                                     ` [PATCH v4 0/7] customizable --color-words Santi Béjar
2009-01-18 15:29                                       ` Santi Béjar
2009-01-19 22:47                                     ` Santi Béjar
2009-01-19 23:35                                       ` Johannes Schindelin
2009-01-20  2:17                                         ` [PATCH] Add tests for diff.color-words configuration option Boyd Stephen Smith Jr.
2009-01-20  3:45                                           ` [PATCH] diff: Support diff.color-words config option Boyd Stephen Smith Jr.
2009-01-20  6:59                                             ` Junio C Hamano
2009-01-20 17:42                                               ` Markus Heidelberg
2009-01-20 17:58                                                 ` Boyd Stephen Smith Jr.
2009-01-20 21:08                                                 ` Johannes Schindelin
2009-01-21 10:27                                                   ` Junio C Hamano
2009-01-21 19:37                                                   ` Markus Heidelberg
2009-01-20 10:02                                             ` Johannes Schindelin
2009-01-20 16:52                                               ` Boyd Stephen Smith Jr.
2009-01-20 17:14                                                 ` Johannes Schindelin
2009-01-20 17:09                                               ` Junio C Hamano
2009-01-20 17:28                                                 ` Johannes Schindelin [this message]
2009-01-20 20:27                                                   ` Junio C Hamano
2009-01-20 21:02                                                     ` Johannes Schindelin
2009-01-21  3:46                                               ` [PATCH] color-words: " Boyd Stephen Smith Jr.
2009-01-21  4:59                                                 ` [PATCH] Change the spelling of "wordregex" Boyd Stephen Smith Jr.
2009-01-21  8:26                                                   ` Johannes Schindelin
2009-01-21  9:22                                                     ` Thomas Rast
2009-01-21 15:33                                                     ` Boyd Stephen Smith Jr.
2009-01-21  8:25                                                 ` [PATCH] color-words: Support diff.color-words config option Johannes Schindelin
2009-01-21 16:09                                                   ` Boyd Stephen Smith Jr.
2009-01-21 10:27                                                 ` [PATCH] color-words: Support diff.wordregex " Junio C Hamano
2009-01-20 14:38                                             ` [PATCH] diff: Support diff.color-words " Jakub Narebski
2009-01-20  9:58                                           ` [PATCH] Add tests for diff.color-words configuration option Johannes Schindelin
2009-01-20 16:34                                             ` Boyd Stephen Smith Jr.
2009-01-20 16:54                                               ` Johannes Schindelin
2009-01-16 16:11                             ` [PATCH take 3 0/4] color-words improvements Boyd Stephen Smith Jr.
2009-01-14 19:46         ` [PATCH] color-words: make regex configurable via attributes Thomas Rast
2009-01-14 20:12           ` Johannes Schindelin
2009-01-14 20:17             ` Thomas Rast
2009-01-14 20:44             ` [PATCH replacement for take 3 3/4] color-words: change algorithm to allow for 0-character word boundaries Johannes Schindelin
2009-01-14 20:46               ` [PATCH replacement for take 3 4/4] color-words: take an optional regular expression describing words Johannes Schindelin
2009-01-15  0:32                 ` Thomas Rast
2009-01-15  1:12                   ` Johannes Schindelin
2009-01-15  1:36                     ` Johannes Schindelin
2009-01-15  8:30                       ` Thomas Rast
2009-01-15 10:40                         ` Thomas Rast
2009-01-15 12:54                           ` Johannes Schindelin
2009-01-14 22:26             ` [PATCH 1/4] color-words: fix quoting in t4034 Thomas Rast
2009-01-14 22:41               ` Johannes Schindelin
2009-01-14 22:26             ` [PATCH 2/4] color-words: enable REG_NEWLINE to help user Thomas Rast
2009-01-14 22:26             ` [PATCH 3/4] color-words: expand docs with precise semantics Thomas Rast
2009-01-14 22:26             ` [PATCH 4/4] color-words: make regex configurable via attributes Thomas Rast
2009-01-15  1:33               ` Johannes Schindelin
2009-01-15  1:43                 ` Johannes Schindelin
2009-01-14 20:04         ` [PATCH take 3 0/4] color-words improvements Thomas Rast
2009-01-14 21:07           ` Johannes Schindelin
2009-01-14 22:37             ` Thomas Rast
2009-01-11 20:00 ` [PATCH 4/4] color-words: take an optional regular expression describing words Johannes Schindelin
2009-01-11 21:53 ` [PATCH 0/4] refactor the --color-words to make it more hackable Thomas Rast
2009-01-11 23:02   ` Johannes Schindelin
2009-01-12  6:25     ` Thomas Rast
2009-01-14 13:00 ` Santi Béjar

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=alpine.DEB.1.00.0901201819490.5159@intel-tinevez-2-302 \
    --to=johannes.schindelin@gmx.de \
    --cc=bss@iguanasuicide.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=santi@agolina.net \
    --cc=tlikonen@iki.fi \
    --cc=trast@student.ethz.ch \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox