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

Re: [RFC/PATCH] gitweb: Add committags support

From
Junio C Hamano <junkio@cox.net>
Date
Sep 23, 2006, 19:58 UTC
Message-ID
<7veju2s6bi.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060923121134.GM13132@pasky.or.cz>
Petr Baudis <pasky@suse.cz> writes:
Show 11 quoted lines
> Also, there is a fundamental limitation for the multi-word patterns that
> they won't work if the line wraps at that point in the log message. This
> will likely be a problem especially for the msgids, because those are
> very long and are very likely to cause a linewrap immediately before.
>
> By the way, I don't think taking just 40-digits sha1s is very useful,
> since that's insanely long and besides the linewrap issue, a lot of
> people just shorten that to some 8 to 12 digits now - I'd use {8-40}
> instead (the enforced minimum is 4 in the Git autocompletion code but we
> shouldn't encourage people to write so ambiguous sha1s to persistent
> records).

True. Without looking at Jakub's code under discussion, off the top of my head, I wonder if we can do something like this:

 (1) take the whole commit log message, not line by line, into a
     Perl variable, say $log.  Note that this is _before_ HTML
     escaping.
 (2) each enabled tag-marking sub are expected to take a list of
     string or ref as its parameter.  The first one in the chain
     takes a single parameter which is ($log).  You call all the
     enabled ones, in some order, and feed the return value from
     the previous one as the input to the next one.
 (3) a tag-marking sub are expected to inspect the list it
     received as its input parameter, and build its return value
     by looking at each element in the list:
	(3-1) if the element is not a string, pass it down as-is
	in the output list.
	(3-2) if the element is a string, do the pattern match,
	and output one or more elements in the output list.
	Literal string you did not care about are placed as
	string for later taggers to be processed, the links you
	generate are placed as a ref to string.
    For example, commit_id tag-marker might look like this:
        sub tag_marker_commit_id {
                my @input = (@_);
                my @output;
                for (@input) {
                        if (!ref $_) {
                                push @output, $_;
                                next;
                        }
                        while ($_ ne '' && m/(.*?)\b([0-9a-fA-F]{6,})\b(.*)/s) {
                                my ($pre, $sha1, $post) = ($1, $2, $3);
                                if (!is_a_commit_id($sha1)) {
                                        push @output, "$pre$sha1";
                                }
                                else {
					my $subst =
                                          href(action => 'commit', hash => $2);
                                        push @output, $1;
                                        push @output, \$subst;
                                }
                                $_ = $post;
                        }
                }
                return @output;
        }
 (4) when you finished calling the chain, you would have a list
     of string and ref.  You html quote the strings and pass
     the ref's (which are supposed to be already HTML) as is,
     and concatenate the result:
	sub markup_all {
        	my ($log) = @_;
                my @current = $log;
                for my $tag_marker (@tag_markers) {
			@current = $tag_marker->(@current);
		}
                return join('',
                	map {
                        	(ref $_) ? $$_ : esc_html($_)
			} @current);
	}
Hmm?
     
Previous: Jakub NarebskiNext: Jakub Narebski
Message 11 of 17 in “gitweb: Add committags support”
  1. gitweb: Add committags supportJakub Narebski, Sep 21, 2006
  2. Jakub NarebskiSep 22, 2006
  3. Petr BaudisSep 23, 2006
  4. Jakub NarebskiSep 23, 2006
  5. Petr BaudisSep 23, 2006
  6. Jakub NarebskiSep 23, 2006
  7. Petr BaudisSep 23, 2006
  8. Jakub NarebskiSep 25, 2006
  9. Petr BaudisSep 25, 2006
  10. Jakub NarebskiSep 26, 2006
  11. Junio C HamanoSep 23, 2006
  12. Jakub NarebskiSep 23, 2006
  13. Junio C HamanoSep 23, 2006
  14. Jakub NarebskiSep 24, 2006
  15. Junio C HamanoSep 24, 2006
  16. Jakub NarebskiSep 24, 2006
  17. Junio C HamanoSep 24, 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.