All tests on the commit buffer in fsck_cmd are ready done by
parse_commit_buffer.
This patch rips out all redundant tests. It still leaves the check for
author, as this is can be used as starting point for validation the
author/committer information.
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
---
builtin-fsck.c | 13 ++++---------
1 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/builtin-fsck.c b/builtin-fsck.c
index cc7524b..ba785ec 100644
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
@@ -354,7 +354,7 @@ static int fsck_tree(struct tree *item)
static int fsck_commit(struct commit *commit)
{
char *buffer = commit->buffer;
- unsigned char tree_sha1[20], sha1[20];
+ unsigned char tree_sha1[20];
if (verbose)
fprintf(stderr, "Checking commit %s\n",
@@ -363,22 +363,17 @@ static int fsck_commit(struct commit *commit)
if (!commit->date)
return objerror(&commit->object, "invalid author/committer line");
- if (memcmp(buffer, "tree ", 5))
- return objerror(&commit->object, "invalid format - expected 'tree' line");
- if (get_sha1_hex(buffer+5, tree_sha1) || buffer[45] != '\n')
+ if (get_sha1_hex(buffer+5, tree_sha1))
return objerror(&commit->object, "invalid 'tree' line format - bad sha1");
buffer += 46;
- while (!memcmp(buffer, "parent ", 7)) {
- if (get_sha1_hex(buffer+7, sha1) || buffer[47] != '\n')
- return objerror(&commit->object, "invalid 'parent' line format - bad sha1");
+ while (!memcmp(buffer, "parent ", 7))
buffer += 48;
- }
if (memcmp(buffer, "author ", 7))
return objerror(&commit->object, "invalid format - expected 'author' line");
free(commit->buffer);
commit->buffer = NULL;
if (!commit->tree)
- return objerror(&commit->object, "could not load commit's tree %s", tree_sha1);
+ return objerror(&commit->object, "could not load commit's tree %s", sha1_to_hex(tree_sha1));
if (!commit->parents && show_root)
printf("root %s\n", sha1_to_hex(commit->object.sha1));
return 0;
--
1.5.4.g22bc
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html| Eric Paris | [RFC 0/5] [TALPA] Intro to a linux interface for on access scanning |
| Mark Fasheh | Re: -mm merge plans for 2.6.23 -- sys_fallocate |
| Linus Torvalds | Linux 2.6.21-rc4 |
| Linus Torvalds | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
git: | |
| David Miller | [GIT]: Networking |
| David Miller | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Gerrit Renker | [PATCH 15/37] dccp: Set per-connection CCIDs via socket options |
| Christoph Lameter | Network latency regressions from 2.6.22 to 2.6.29 |
