From: Junio C Hamano <gitster@pobox.com>
To: Peter Krefting <peter@softwolves.pp.se>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v3] import-tars: Allow per-tar author and commit message.
Date: Thu, 27 Aug 2009 18:38:54 -0700 [thread overview]
Message-ID: <7vskfcd8ep.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <alpine.DEB.2.00.0908270741170.6459@perkele.intern.softwolves.pp.se> (Peter Krefting's message of "Thu\, 27 Aug 2009 07\:42\:57 +0100 \(CET\)")
Peter Krefting <peter@softwolves.pp.se> 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@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;
}
next prev parent reply other threads:[~2009-08-28 1:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-26 19:26 [PATCH v3] import-tars: Allow per-tar author and commit message Peter Krefting
2009-08-27 4:57 ` Junio C Hamano
2009-08-27 6:42 ` Peter Krefting
2009-08-28 1:38 ` Junio C Hamano [this message]
2009-08-28 18:56 ` Peter Krefting
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vskfcd8ep.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=peter@softwolves.pp.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox