git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: しらいしななこ <nanako3@bluebottle.com>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	git@vger.kernel.org
Subject: Re: [PATCH] Per-path attribute based hunk header selection.
Date: Sat, 7 Jul 2007 13:17:11 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0707071317060.4093@racer.site> (raw)
In-Reply-To: <7vabu88qem.fsf@assigned-by-dhcp.cox.net>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2527 bytes --]

Hi,

On Sat, 7 Jul 2007, Junio C Hamano wrote:

> しらいしななこ  <nanako3@bluebottle.com> writes:
> 
> > I would love to see "diff=tex" attribute to work on my manuscripts, 
> > [...]
> > It does not work well, however.  It shows only part of lines.
> >
> > 	@@ -8,7 +8,8 @@ \section{
> > 	@@ -224,7 +225,7 @@ sub
> > 	@@ -240,7 +241,7 @@ subsub
> >
> > I have no idea what am I doing wrong (truthfully, I do not know what I 
> > am doing, period).

Those are regular expressions. Read more about them here:

	http://en.wikipedia.org/wiki/Regular_expression

> > +	if (!strcmp(ident, "tex"))
> > +		return "^\\\\\\(sub\\)*section{";

It is always easier, and will never require C skills, to put this into the 
config. With Junio's current version:

	echo '*.tex funcname=tex' >> .gitattributes
	echo '[funcname] tex = ^\(\\\(sub\)*section{.*\)' >> .git/config

The problem is of course that the backslashes have to be escaped _both_ in 
C and in regexps.

You could write that much simpler, though:

	\\[a-z]*section.*

It would work the same, in practice, because if something like 
\supercoolsection is defined, you are likely wanting to match that, too.

> Johannes, it strikes me that it is very odd having to add ".*$" at the 
> end and to surround the whole thing in a parentheses. Shouldn't the 
> ff_regexp() grabber simply pick the whole line? After all, that is what 
> GNU "diff -p -F RE" does.

Yes, but then you can forget about your hierarchical idea.

Or maybe not, since I am still awaiting a sane syntax for that, which 
would probably have to solve just one more problem.

Here is a patch for the rest of the line thing:

diff --git a/xdiff-interface.c b/xdiff-interface.c
index be866d1..9503dfb 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -156,7 +156,7 @@ static long ff_regexp(const char *line, long len,
 	}
 	i = pmatch[1].rm_so >= 0 ? 1 : 0;
 	line += pmatch[i].rm_so;
-	result = pmatch[i].rm_eo - pmatch[i].rm_so;
+	result = (int)len - pmatch[i].rm_so;
 	if (result > buffer_size)
 		result = buffer_size;
 	else

> Also this makes me realize that not all contents in the world are not 
> programming language source files, and "funcname" is a misnomer.  For 
> this one, however, we _can_ blame GNU diff, as they call this 
> --show-function-line option ;-)

Okay.

How about sorting out the other technical issues first 
(diff.<type>.funcname instead of funcname.<type>), leaving the names 
alone, and then rename the remaining references of funcname to hunkheader?

Ciao,
Dscho

  reply	other threads:[~2007-07-07 12:24 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-04 18:06 [PATCH 2/2] diff: add custom regular expressions for function names Johannes Schindelin
2007-07-04 18:41 ` Linus Torvalds
2007-07-04 18:45   ` Johannes Schindelin
2007-07-04 20:44   ` Junio C Hamano
2007-07-04 21:20     ` Johannes Schindelin
2007-07-05  5:00     ` Junio C Hamano
2007-07-05  5:02       ` [PATCH 1/2] Future-proof source for changes in xdemitconf_t Junio C Hamano
2007-07-05 11:01         ` Johannes Schindelin
2007-07-05  5:02       ` [PATCH 2/2] WIP per-path attribute based hunk header selection Junio C Hamano
2007-07-05 11:25         ` Johannes Schindelin
2007-07-05 16:43           ` Junio C Hamano
2007-07-06  8:37           ` [PATCH 1/3] Introduce diff_filespec_is_binary() Junio C Hamano
2007-07-06 12:20             ` Johannes Schindelin
2007-07-06  8:39           ` [PATCH] Per-path attribute based hunk header selection Junio C Hamano
2007-07-06 12:38             ` Johannes Schindelin
2007-07-06 17:59             ` Linus Torvalds
2007-07-07  2:00               ` Junio C Hamano
2007-07-07 10:08                 ` しらいしななこ
2007-07-07 10:22                   ` Junio C Hamano
2007-07-07 12:17                     ` Johannes Schindelin [this message]
2007-07-07 20:36                       ` Junio C Hamano
2007-07-08  7:23                       ` Junio C Hamano
2007-07-08 11:58                         ` Johannes Schindelin
2007-07-09  3:22                 ` Nicolas Pitre
2007-07-09  5:05                   ` Junio C Hamano
2007-07-09 11:40                     ` Johannes Schindelin
2007-07-07 10:12               ` [PATCH] Fix configuration syntax to specify customized hunk header patterns Junio C Hamano
2007-07-05  8:24       ` [PATCH 2/2] diff: add custom regular expressions for function names Florian Weimer
2007-07-05 11:44       ` Johannes Schindelin

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=Pine.LNX.4.64.0707071317060.4093@racer.site \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=nanako3@bluebottle.com \
    --cc=torvalds@linux-foundation.org \
    /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).