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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Peter Krefting <peter@xxxxxxxxxxxxxxxx> writes:

> 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@xxxxxxxxxxxxxxxx>

	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;
	}
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]