git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1bis/2] Diff patterns for POSIX shells

From
Jeff King <peff@peff.net>
Date
Aug 3, 2011, 09:32 UTC
Message-ID
<20110803093252.GA16351@sigill.intra.peff.net>
In-Reply-To
<1312349176-20984-1-git-send-email-giuseppe.bilotta@gmail.com>
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
Previous: Giuseppe BilottaNext: Giuseppe Bilotta
Message 6 of 9 in “Minor userdiff stuff”
  1. 0/2 Minor userdiff stuffGiuseppe Bilotta, Aug 1, 2011
  2. 1/2 Diff patterns for POSIX shellsGiuseppe Bilotta, Aug 1, 2011
  3. Junio C HamanoAug 2, 2011
  4. Giuseppe BilottaAug 2, 2011
  5. Diff patterns for POSIX shellsGiuseppe Bilotta, Aug 3, 2011
  6. Jeff KingAug 3, 2011
  7. Giuseppe BilottaAug 3, 2011
  8. Junio C HamanoAug 3, 2011
  9. 2/2 Use specific diff rules for repo filesGiuseppe Bilotta, Aug 1, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.