* [PATCH 0/2] Minor userdiff stuff @ 2011-08-01 10:37 Giuseppe Bilotta 2011-08-01 10:37 ` [PATCH 1/2] Diff patterns for POSIX shells Giuseppe Bilotta 2011-08-01 10:37 ` [PATCH 2/2] Use specific diff rules for repo files Giuseppe Bilotta 0 siblings, 2 replies; 9+ messages in thread From: Giuseppe Bilotta @ 2011-08-01 10:37 UTC (permalink / raw) To: git; +Cc: Giuseppe Bilotta The first commit introduces diff patterns for POSIX shells. The second defines diff types for C, Perl and shell scripts in git.git Giuseppe Bilotta (2): Diff patterns for POSIX shells Use specific diff rules for repo files .gitattributes | 5 +++-- userdiff.c | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) -- 1.7.6.451.gcb935.dirty ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] Diff patterns for POSIX shells 2011-08-01 10:37 [PATCH 0/2] Minor userdiff stuff Giuseppe Bilotta @ 2011-08-01 10:37 ` Giuseppe Bilotta 2011-08-02 17:51 ` Junio C Hamano 2011-08-01 10:37 ` [PATCH 2/2] Use specific diff rules for repo files Giuseppe Bilotta 1 sibling, 1 reply; 9+ messages in thread From: Giuseppe Bilotta @ 2011-08-01 10:37 UTC (permalink / raw) To: git; +Cc: Giuseppe Bilotta All diffs following a function definition will have that function name as chunck header, but this is the best we can do with the current userdiff capabilities. Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> --- userdiff.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/userdiff.c b/userdiff.c index 01d3a8b..70120c3 100644 --- a/userdiff.c +++ b/userdiff.c @@ -107,6 +107,9 @@ "(@|@@|\\$)?[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\?(\\\\C-)?(\\\\M-)?." "|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\.{1,3}|::|[!=]~"), +PATTERNS("shell", "^[ \t]*([a-zA-Z_0-9]+)[ \t]*\\(\\).*", + /* -- */ + "(--|\\$)?[a-zA-Z_0-9]+|&&|\\|\\|"), PATTERNS("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$", "[={}\"]|[^={}\" \t]+"), PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$", -- 1.7.6.451.gcb935.dirty ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] Diff patterns for POSIX shells 2011-08-01 10:37 ` [PATCH 1/2] Diff patterns for POSIX shells Giuseppe Bilotta @ 2011-08-02 17:51 ` Junio C Hamano 2011-08-02 18:52 ` Giuseppe Bilotta 2011-08-03 5:26 ` [PATCH 1bis/2] " Giuseppe Bilotta 0 siblings, 2 replies; 9+ messages in thread From: Junio C Hamano @ 2011-08-02 17:51 UTC (permalink / raw) To: Giuseppe Bilotta; +Cc: git Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes: > All diffs following a function definition will have that function name > as chunck header, but this is the best we can do with the current > userdiff capabilities. > > Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> > --- > userdiff.c | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/userdiff.c b/userdiff.c > index 01d3a8b..70120c3 100644 > --- a/userdiff.c > +++ b/userdiff.c > @@ -107,6 +107,9 @@ > "(@|@@|\\$)?[a-zA-Z_][a-zA-Z0-9_]*" > "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\?(\\\\C-)?(\\\\M-)?." > "|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\.{1,3}|::|[!=]~"), > +PATTERNS("shell", "^[ \t]*([a-zA-Z_0-9]+)[ \t]*\\(\\).*", > + /* -- */ > + "(--|\\$)?[a-zA-Z_0-9]+|&&|\\|\\|"), Hmm, what is this "double-dash -- might be present before a name" about? > PATTERNS("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$", > "[={}\"]|[^={}\" \t]+"), > PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$", ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] Diff patterns for POSIX shells 2011-08-02 17:51 ` Junio C Hamano @ 2011-08-02 18:52 ` Giuseppe Bilotta 2011-08-03 5:26 ` [PATCH 1bis/2] " Giuseppe Bilotta 1 sibling, 0 replies; 9+ messages in thread From: Giuseppe Bilotta @ 2011-08-02 18:52 UTC (permalink / raw) To: Junio C Hamano; +Cc: git On Tue, Aug 2, 2011 at 7:51 PM, Junio C Hamano <gitster@pobox.com> wrote: > Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes: > >> All diffs following a function definition will have that function name >> as chunck header, but this is the best we can do with the current >> userdiff capabilities. >> >> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> >> --- >> userdiff.c | 3 +++ >> 1 files changed, 3 insertions(+), 0 deletions(-) >> >> diff --git a/userdiff.c b/userdiff.c >> index 01d3a8b..70120c3 100644 >> --- a/userdiff.c >> +++ b/userdiff.c >> @@ -107,6 +107,9 @@ >> "(@|@@|\\$)?[a-zA-Z_][a-zA-Z0-9_]*" >> "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\?(\\\\C-)?(\\\\M-)?." >> "|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\.{1,3}|::|[!=]~"), >> +PATTERNS("shell", "^[ \t]*([a-zA-Z_0-9]+)[ \t]*\\(\\).*", >> + /* -- */ >> + "(--|\\$)?[a-zA-Z_0-9]+|&&|\\|\\|"), > > Hmm, what is this "double-dash -- might be present before a name" about? > Now that's a good question. I think it was a brainfart while testing the regexp; came across a case switch where the candidate were options, and somehow decided that it was better to include the --. I'll prepare a patch without this stupidity. -- Giuseppe "Oblomov" Bilotta ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1bis/2] Diff patterns for POSIX shells 2011-08-02 17:51 ` Junio C Hamano 2011-08-02 18:52 ` Giuseppe Bilotta @ 2011-08-03 5:26 ` Giuseppe Bilotta 2011-08-03 9:32 ` Jeff King 1 sibling, 1 reply; 9+ messages in thread From: Giuseppe Bilotta @ 2011-08-03 5:26 UTC (permalink / raw) To: git; +Cc: Junio C Hamano, Giuseppe Bilotta All diffs following a function definition will have that function name as chunck header, but this is the best we can do with the current userdiff capabilities. Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> --- userdiff.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/userdiff.c b/userdiff.c index 01d3a8b..94b1c47 100644 --- a/userdiff.c +++ b/userdiff.c @@ -107,6 +107,9 @@ "(@|@@|\\$)?[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\?(\\\\C-)?(\\\\M-)?." "|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\.{1,3}|::|[!=]~"), +PATTERNS("shell", "^[ \t]*([a-zA-Z_0-9]+)[ \t]*\\(\\).*", + /* -- */ + "\\$?[a-zA-Z_0-9]+|&&|\\|\\|"), PATTERNS("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$", "[={}\"]|[^={}\" \t]+"), PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$", -- 1.7.6.485.gd947c.dirty ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1bis/2] Diff patterns for POSIX shells 2011-08-03 5:26 ` [PATCH 1bis/2] " Giuseppe Bilotta @ 2011-08-03 9:32 ` Jeff King 2011-08-03 10:12 ` Giuseppe Bilotta 2011-08-03 18:53 ` Junio C Hamano 0 siblings, 2 replies; 9+ messages in thread From: Jeff King @ 2011-08-03 9:32 UTC (permalink / raw) To: Giuseppe Bilotta; +Cc: git, Junio C Hamano On Wed, Aug 03, 2011 at 07:26:16AM +0200, Giuseppe Bilotta wrote: > All diffs following a function definition will have that function name > as chunck header, but this is the best we can do with the current > userdiff capabilities. Curious as to how this would look in git.git, I tried "git log -p" before and after your patches, and diffed the result. I noticed two things: 1. Given a block of shell code like this: foo() { ... do something ... } test_expect_success 'test foo' ' ... the actual test ... ' if we add new code after the test, the old regex would print: @@ -1,2 +3,4 @@ test_expect_success 'test foo' ' and now we say: @@ -1,2 +3,4 @@ foo which seems more misleading. I know the function-matching code has no way to say "look for ^}, which signals end of function", so we can't be entirely accurate. But I wonder if the new heuristic (which seems to look for a name followed by parentheses) is actually any better than the old. 2. What would have printed before: @@ -1,2 +3,4 @@ foo() { now prints @@ -1,2 +3,4 @@ foo without the parentheses or brace. It looks like the similar C one keeps the parentheses, at least. I find that a bit more readable, as it is more clear that the line indicates a function, and not simply some top-level command. -Peff ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1bis/2] Diff patterns for POSIX shells 2011-08-03 9:32 ` Jeff King @ 2011-08-03 10:12 ` Giuseppe Bilotta 2011-08-03 18:53 ` Junio C Hamano 1 sibling, 0 replies; 9+ messages in thread From: Giuseppe Bilotta @ 2011-08-03 10:12 UTC (permalink / raw) To: Jeff King; +Cc: git, Junio C Hamano On Wed, Aug 3, 2011 at 11:32 AM, Jeff King <peff@peff.net> wrote: > On Wed, Aug 03, 2011 at 07:26:16AM +0200, Giuseppe Bilotta wrote: > >> All diffs following a function definition will have that function name >> as chunck header, but this is the best we can do with the current >> userdiff capabilities. > > Curious as to how this would look in git.git, I tried "git log -p" > before and after your patches, and diffed the result. I noticed two > things: > > 1. Given a block of shell code like this: > > foo() { > ... do something ... > } > > test_expect_success 'test foo' ' > ... the actual test ... > ' > > if we add new code after the test, the old regex would print: > > @@ -1,2 +3,4 @@ test_expect_success 'test foo' ' > > and now we say: > > @@ -1,2 +3,4 @@ foo > > which seems more misleading. I know the function-matching code has > no way to say "look for ^}, which signals end of function", so we > can't be entirely accurate. But I wonder if the new heuristic > (which seems to look for a name followed by parentheses) is > actually any better than the old. I'm not too satisfied with the solution either. I've been thinking about adding some important keywords such as for, while, if, until, case etc, but decided it would be too much overkill. And, it still woudln't work 'correctly' in a case such as this one you presented above. > 2. What would have printed before: > > @@ -1,2 +3,4 @@ foo() { > > now prints > > @@ -1,2 +3,4 @@ foo > > without the parentheses or brace. It looks like the similar C one > keeps the parentheses, at least. I find that a bit more readable, > as it is more clear that the line indicates a function, and not > simply some top-level command. Indeed. I'll change the regexp to include the parenthesis. -- Giuseppe "Oblomov" Bilotta ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1bis/2] Diff patterns for POSIX shells 2011-08-03 9:32 ` Jeff King 2011-08-03 10:12 ` Giuseppe Bilotta @ 2011-08-03 18:53 ` Junio C Hamano 1 sibling, 0 replies; 9+ messages in thread From: Junio C Hamano @ 2011-08-03 18:53 UTC (permalink / raw) To: Jeff King; +Cc: Giuseppe Bilotta, git, Junio C Hamano Jeff King <peff@peff.net> writes: > On Wed, Aug 03, 2011 at 07:26:16AM +0200, Giuseppe Bilotta wrote: > >> All diffs following a function definition will have that function name >> as chunck header, but this is the best we can do with the current >> userdiff capabilities. > > Curious as to how this would look in git.git, I tried "git log -p" > before and after your patches, and diffed the result. I noticed two > things: Hmm, sounds like a regression without much upside to me. Thanks for looking. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] Use specific diff rules for repo files 2011-08-01 10:37 [PATCH 0/2] Minor userdiff stuff Giuseppe Bilotta 2011-08-01 10:37 ` [PATCH 1/2] Diff patterns for POSIX shells Giuseppe Bilotta @ 2011-08-01 10:37 ` Giuseppe Bilotta 1 sibling, 0 replies; 9+ messages in thread From: Giuseppe Bilotta @ 2011-08-01 10:37 UTC (permalink / raw) To: git; +Cc: Giuseppe Bilotta Let's eat our own dogfood. (Also, this makes word diff much nicer on git's own repo.) Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> --- .gitattributes | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index 5e98806..16930e6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ * whitespace=!indent,trail,space -*.[ch] whitespace=indent,trail,space -*.sh whitespace=indent,trail,space +*.[ch] whitespace=indent,trail,space diff=cpp +*.sh whitespace=indent,trail,space diff=shell +*.perl diff=perl -- 1.7.6.451.gcb935.dirty ^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-08-03 18:53 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-08-01 10:37 [PATCH 0/2] Minor userdiff stuff Giuseppe Bilotta 2011-08-01 10:37 ` [PATCH 1/2] Diff patterns for POSIX shells Giuseppe Bilotta 2011-08-02 17:51 ` Junio C Hamano 2011-08-02 18:52 ` Giuseppe Bilotta 2011-08-03 5:26 ` [PATCH 1bis/2] " Giuseppe Bilotta 2011-08-03 9:32 ` Jeff King 2011-08-03 10:12 ` Giuseppe Bilotta 2011-08-03 18:53 ` Junio C Hamano 2011-08-01 10:37 ` [PATCH 2/2] Use specific diff rules for repo files Giuseppe Bilotta
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).