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

Re: [PATCH] xdiff: Show function names in hunk headers.

From
Junio C Hamano <junkio@cox.net>
Date
Mar 29, 2006, 00:21 UTC
Message-ID
<7v4q1ihzio.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<slrne2ik1i.s3g.mdw@metalzone.distorted.org.uk>
Mark Wooding <mdw@distorted.org.uk> writes:
Show 10 quoted lines
> Junio C Hamano <junkio@cox.net> wrote:
>
>> GNU diff -p does "^[[:alpha:]$_]"; personally I think any line
>> that does not begin with a whitespace is good enough.
>...
> The second suggestion is slightly refined, but a little more
> complicated.  We ask for a line which starts /either/ with two
> non-whitespace characters, or with an alphanumeric.  Why?  Because text
> documents have a tendency to have headings of the form `7 Heading!' and
> I want to catch them.
Asciidoc?
        . enumerated one
          this is one item
        . enumerated two
          this is another item
> I think I like option 2 best, as a nice compromise between stupidity and
> actually working.  Opinions, anyone?

It's just a heuristic, so there are only two things we could sensibly do. Either we keep it absolutely stupid to save our code and sanity, or we give full configurability via -F regexp to the end users.

I suspect feeping creaturism would eventually push us to go the latter route, but for now I'd vote for doing exactly the same as what default GNU does, by looking at the first letter without using regexps. When we add regexps later, the users can customize the pattern to match the languages they use, and we might end up having to have a set of (file-suffix -> default regexp) mappings, with full end user configurability via .git/config -- gaaah but true X-<.

	[diff]
        	functionline = "^\w" for .c
                functionline = "^(?i)\s*(?:function|procedure)" for .f77
                functionline = "^\(defun " for .el
                ...
Previous: Mark WoodingNext: Mark Wooding
Message 6 of 8 in “xdiff: Show function names in hunk headers.”
  1. xdiff: Show function names in hunk headers.Mark Wooding, Mar 28, 2006
  2. Junio C HamanoMar 28, 2006
  3. Junio C HamanoMar 28, 2006
  4. Mark WoodingMar 28, 2006
  5. Mark WoodingMar 28, 2006
  6. Junio C HamanoMar 29, 2006
  7. Mark WoodingMar 29, 2006
  8. Andreas EricssonMar 28, 2006

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.