summaryrefslogtreecommitdiff
path: root/fsck.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-07-09 18:33:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-07-09 18:33:28 (GMT)
commite91ae32a01ffe294b8510c1d8cd7138493a0712f (patch)
tree461b9dacf6c1e8adf5f59251af093dc7c407091f /fsck.c
parent72c779457cd72928e36f2bc43c3ff7f3ae7b77c3 (diff)
parent67a31f612830e79fe768ac886ed9ef7eadd8fb10 (diff)
downloadgit-e91ae32a01ffe294b8510c1d8cd7138493a0712f.zip
git-e91ae32a01ffe294b8510c1d8cd7138493a0712f.tar.gz
git-e91ae32a01ffe294b8510c1d8cd7138493a0712f.tar.bz2
Merge branch 'jk/skip-prefix'
* jk/skip-prefix: http-push: refactor parsing of remote object names imap-send: use skip_prefix instead of using magic numbers use skip_prefix to avoid repeated calculations git: avoid magic number with skip_prefix fetch-pack: refactor parsing in get_ack fast-import: refactor parsing of spaces stat_opt: check extra strlen call daemon: use skip_prefix to avoid magic numbers fast-import: use skip_prefix for parsing input use skip_prefix to avoid repeating strings use skip_prefix to avoid magic numbers transport-helper: avoid reading past end-of-string fast-import: fix read of uninitialized argv memory apply: use skip_prefix instead of raw addition refactor skip_prefix to return a boolean avoid using skip_prefix as a boolean daemon: mark some strings as const parse_diff_color_slot: drop ofs parameter
Diffstat (limited to 'fsck.c')
-rw-r--r--fsck.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/fsck.c b/fsck.c
index a7233c8..a4e8593 100644
--- a/fsck.c
+++ b/fsck.c
@@ -279,20 +279,17 @@ static int fsck_ident(const char **ident, struct object *obj, fsck_error error_f
static int fsck_commit_buffer(struct commit *commit, const char *buffer,
fsck_error error_func)
{
- const char *tmp;
unsigned char tree_sha1[20], sha1[20];
struct commit_graft *graft;
int parents = 0;
int err;
- buffer = skip_prefix(buffer, "tree ");
- if (!buffer)
+ if (!skip_prefix(buffer, "tree ", &buffer))
return error_func(&commit->object, FSCK_ERROR, "invalid format - expected 'tree' line");
if (get_sha1_hex(buffer, tree_sha1) || buffer[40] != '\n')
return error_func(&commit->object, FSCK_ERROR, "invalid 'tree' line format - bad sha1");
buffer += 41;
- while ((tmp = skip_prefix(buffer, "parent "))) {
- buffer = tmp;
+ while (skip_prefix(buffer, "parent ", &buffer)) {
if (get_sha1_hex(buffer, sha1) || buffer[40] != '\n')
return error_func(&commit->object, FSCK_ERROR, "invalid 'parent' line format - bad sha1");
buffer += 41;
@@ -319,14 +316,12 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,
if (p || parents)
return error_func(&commit->object, FSCK_ERROR, "parent objects missing");
}
- buffer = skip_prefix(buffer, "author ");
- if (!buffer)
+ if (!skip_prefix(buffer, "author ", &buffer))
return error_func(&commit->object, FSCK_ERROR, "invalid format - expected 'author' line");
err = fsck_ident(&buffer, &commit->object, error_func);
if (err)
return err;
- buffer = skip_prefix(buffer, "committer ");
- if (!buffer)
+ if (!skip_prefix(buffer, "committer ", &buffer))
return error_func(&commit->object, FSCK_ERROR, "invalid format - expected 'committer' line");
err = fsck_ident(&buffer, &commit->object, error_func);
if (err)