git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: Junio C Hamano <gitster@pobox.com>,
	git@vger.kernel.org, Brandon Casey <drafnel@gmail.com>
Subject: Re: [PATCH] attr: map builtin userdiff drivers to well-known extensions
Date: Fri, 16 Dec 2011 14:21:04 -0500	[thread overview]
Message-ID: <20111216192104.GA19924@sigill.intra.peff.net> (raw)
In-Reply-To: <4EEB4F13.2010402@viscovery.net>

On Fri, Dec 16, 2011 at 03:00:51PM +0100, Johannes Sixt wrote:

> Am 12/16/2011 12:00, schrieb Jeff King:
> >  static const char *builtin_attr[] = {
> ...
> > +	"*.c diff=cpp",
> > +	"*.cc diff=cpp",
> > +	"*.cxx diff=cpp",
> > +	"*.cpp diff=cpp",
> > +	"*.h diff=cpp",
> > +	"*.hpp diff=cpp",
> 
> Please don't do this. It would be a serious regression for C++ coders, and
> some C coders as well. The built-in hunk header patterns are severly
> broken and don't work well with C++ code. I know for sure that the
> following are not recognized:
> 
> - template declarations, e.g. template<class T> func(T x);
> - constructor definitionss, e.g. MyClass::MyClass()
> - functions that return references, e.g. const string& func()
> - function definitions along the GNU coding style, e.g.
> 
>      void
>      the_func ()

Hmm. I think it's a legitimate criticism to say "hunk-header detection
is a broken feature because our heuristics aren't good enough, and we
shouldn't start using it by default because people will complain because
it sucks too much".

At the same time, I think we have seen people complaining that the
regular dumb funcname detection is not good enough[1], and that using
language-specific funcnames, while not 100% perfect, produces better
results on the whole.

So I think rather than saying "this doesn't always work", it's important
to ask "on the whole, does this tend to produce better results than
without, and when we are wrong, how bad is it?"

I'm not clear from what you wrote on whether you were saying it is
simply sub-optimal, or whether on balance it is way worse than the
default funcname matching.

And if it is bad on balance, is the right solution to avoid exposing
people to it, or is it to make our patterns better? I.e., is it fixable,
or is it simply too hard a problem to get right in the general case, and
we shouldn't turn it on by default?

> I am currently using this pattern (but I'm sure it can be optimized) with
> an appropriate xcpp attribute:
> 
> [diff "xcpp"]
>         xfuncname = "!^[
> \\t]*[a-zA-Z_][a-zA-Z_0-9]*[^()]*:[[:space:]]*$\n^[a-zA-Z_][a-zA-Z_0-9]*.*"

So, I'm confused. If you are using this, surely you have "*.c diff=xcpp"
in your attributes file, and my patch has no effect for you, as it is
lower precedence than user-supplied gitattributes? Also, if you called
it diff.cpp.xfuncname, then wouldn't my patch still be useful, as your
complaint is not "my *.c files are not actually C language" but "the C
language driver sucks" (but you be remedying that by providing your own
config).

-Peff

  parent reply	other threads:[~2011-12-16 19:21 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-16 11:00 [PATCH] attr: map builtin userdiff drivers to well-known extensions Jeff King
2011-12-16 14:00 ` Johannes Sixt
2011-12-16 17:01   ` Junio C Hamano
2011-12-16 19:21   ` Jeff King [this message]
2011-12-16 19:30     ` Jeff King
2011-12-16 19:33     ` Junio C Hamano
2011-12-17  1:17       ` Jeff King
2011-12-16 22:05     ` Johannes Sixt
2011-12-17  1:21       ` Jeff King
2011-12-17  3:38         ` Jonathan Nieder
2011-12-19 15:49           ` [PATCHv2 1/2] " Jeff King
2011-12-19 18:07             ` Jonathan Nieder
2011-12-19 18:55               ` Jeff King
2011-12-22  1:47             ` Ævar Arnfjörð Bjarmason
2011-12-19 15:57           ` [PATCHv2 2/2] attr: drop C/C++ default extension mapping Jeff King
2011-12-19 18:10             ` Jonathan Nieder
2011-12-19 20:51               ` Thomas Rast
2011-12-19 20:52         ` [PATCH] t4018: introduce test cases for the internal hunk header patterns Brandon Casey
2011-12-19 21:53           ` [PATCH] t4018: add a few more test cases for cpp hunk header matching Brandon Casey
2011-12-19 22:37           ` [PATCH] t4018: introduce test cases for the internal hunk header patterns Junio C Hamano
2011-12-19 22:57             ` Brandon Casey
2011-12-19 23:17               ` Junio C Hamano
2011-12-20  2:42                 ` [PATCH v2] " Brandon Casey
2011-12-20  8:25                   ` Jakub Narebski
2011-12-20 15:58                     ` Brandon Casey
2011-12-20  9:13                   ` Thomas Rast
2011-12-20 19:52                   ` Johannes Sixt
2011-12-20 20:08             ` [PATCH] " Junio C Hamano
2011-12-16 17:51 ` [PATCH] attr: map builtin userdiff drivers to well-known extensions Mark Levedahl
2011-12-16 19:28   ` Jeff King
2011-12-16 19:26 ` Philip Oakley
2011-12-16 19:32   ` Jeff King
2011-12-22  0:05     ` Philip Oakley
2011-12-23  5:47       ` Jeff King
2011-12-16 19:38   ` 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=20111216192104.GA19924@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=drafnel@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j.sixt@viscovery.net \
    /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;
as well as URLs for NNTP newsgroup(s).