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

Re: [PATCH v3] import-tars: Allow per-tar author and commit message.

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 28, 2009, 01:38 UTC
Message-ID
<7vskfcd8ep.fsf@alter.siamese.dyndns.org>
In-Reply-To
<alpine.DEB.2.00.0908270741170.6459@perkele.intern.softwolves.pp.se>
Peter Krefting <peter@softwolves.pp.se> writes:
Show 9 quoted lines
> Junio C Hamano:
>
>> Do you really want to slurp Committer:/Author: lines from _anywhere_
>> in the file?  Wouldn't it make more sense to vaguely emulate e-mail
>> message format with headers, empty-line and then body that is free
>> form?
>
> I just tried not to overdo it, and keep the parsing code as simple as
> possible. I wasn't trying to implement an RFC 5322 compliant parser...
It is not about overdoing, but about not glossly underdoing.

Don't you at least want to avoid misparsing a msg file that looks like this?

	Author: Peter Krefting <peter@softwolves.pp.se>
	import-tars: Allow per-tar author and commit message
        This version updates the import-tars program so that another
	file next to the archive can be read for the log message and
        other meta information.  A line that begins with Committer: or
        Author: is used as long as it consists of name and <email>
	to override the corresponding metainformation.  Remaining lines
	are used as the commit log message.

And I do not think you need a complex parser. Stop paying attention to a line that begins with Author:/Committer:, once you see a line that does not match the pattern; and you would be Ok.

IOW, something like...
	my $reading_metainfo = 1;
        my $squashing_empty = 0;
	while (<>) {
        	if ($reading_metainfo) {
			if (/^Committer:.../) {
                        	...
				next;
			} elsif (/^Author:.../) {
                        	...
				next;
			} else {
                        	$reading_metainfo = 0;
			}
                }
                if (/^$/) {
			$squashing_empty = 1;
                        next;
		}
                if ($squashing_empty && $commit_msg ne '') {
                	$commit_msg .= "\n";
		}
                $commit_msg .= $_;
                $squashing_empty = 0;
	}
Previous: Peter KreftingNext: Peter Krefting
Message 4 of 5 in “import-tars: Allow per-tar author and commit message.”
  1. import-tars: Allow per-tar author and commit message.Peter Krefting, Aug 26, 2009
  2. Junio C HamanoAug 27, 2009
  3. Peter KreftingAug 27, 2009
  4. Junio C HamanoAug 28, 2009
  5. Peter KreftingAug 28, 2009

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.