From: mkoegler@auto.tuwien.ac.at (Martin Koegler)
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] git-fsck: report missing author/commit line in a commit as an error
Date: Mon, 21 Jan 2008 08:00:49 +0100 [thread overview]
Message-ID: <20080121070049.GA18819@auto.tuwien.ac.at> (raw)
In-Reply-To: <alpine.LSU.1.00.0801201918260.5731@racer.site>
On Sun, Jan 20, 2008 at 07:20:54PM +0000, Johannes Schindelin wrote:
> Hi,
>
> On Sun, 20 Jan 2008, Martin Koegler wrote:
>
> > + if (!commit->date)
> > + return objerror(&commit->object, "invalid author/commiter line in %s",
>
> s/commiter/committer/
Thanks. Will change in next version.
> It makes me wonder, though, if that's correct. AFAICT it is the committer
> date, and the rest of the line _might_ be just fine.
>
> Why not be less intrusive and just change the printf() into a return
> objerror(), like the commit message suggests?
parse_commit_date returns zero, if
* the author line is missing
* the author line is not terminated with \n
* the committer line is missing
* the committer line does not contain >
* the > is not followed by a number bigger than zero
* the commiter line is not terminated with \n
So, in my option the message "bad commit date in %s" is incorrect/misleading.
fsck_commit could be further simplified:
// If tree is missing, parse_commit should return zero => fsck_commit would not be called
- if (memcmp(buffer, "tree ", 5))
- return objerror(&commit->object, "invalid format - expected 'tree' line");
// If sha1 is missing/incorrect, parse_commit should return zero => fsck_commit would not be called
- if (get_sha1_hex(buffer+5, tree_sha1) || buffer[45] != '\n')
- return objerror(&commit->object, "invalid 'tree' line format - bad sha1");
buffer += 46;
while (!memcmp(buffer, "parent ", 7)) {
// If sha1 is missing/incorrect, parse_commit should return zero => fsck_commit would not be called
- if (get_sha1_hex(buffer+7, sha1) || buffer[47] != '\n')
- return objerror(&commit->object, "invalid 'parent' line format - bad sha1");
buffer += 48;
}
if (memcmp(buffer, "author ", 7))
return objerror(&commit->object, "invalid format - expected 'author' line");
I'm not sure, if this 6 lines should be dropped too.
The memcmp(buffer, "author ", 7) check is already done by
(!commit->date), but I prefer to keep it, as further committer/author
line checks can be based on it.
mfg Martin Kögler
PS:
While writting this mail, I noticed that parse_object_buffer does not
check the return value of parse_XX_buffer. I'll send a patch, which
correct this.
prev parent reply other threads:[~2008-01-21 7:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-20 18:59 [PATCH] git-fsck: report missing author/commit line in a commit as an error Martin Koegler
2008-01-20 19:20 ` Johannes Schindelin
2008-01-21 7:00 ` Martin Koegler [this message]
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=20080121070049.GA18819@auto.tuwien.ac.at \
--to=mkoegler@auto.tuwien.ac.at \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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;
as well as URLs for NNTP newsgroup(s).