assume parse_commit checks for NULL commit
The parse_commit function will check whether it was passed a NULL commit pointer, and if so, return an error. There is no need for callers to check this separately. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Oct 24, 2013 at 04:53 UTC
5e7d4d3e932432131d0f8f4195e0061ecf644865
5 files changed
+5
-7
builtin/branch.c
+1
-1
@@ -490,7 +490,7 @@ static void add_verbose_info(struct strbuf *out, struct ref_item *item,
490
const char *sub = _(" **** invalid ref ****");
491
struct commit *commit = item->commit;
492
493
- if (commit && !parse_commit(commit)) {
493
+ if (!parse_commit(commit)) {
494
pp_commit_easy(CMIT_FMT_ONELINE, commit, &subject);
495
sub = subject.buf;
496
}
builtin/commit.c
+2
-2
@@ -1311,7 +1311,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1,
1311
commit = lookup_commit(sha1);
1312
if (!commit)
1313
die(_("couldn't look up newly created commit"));
1314
- if (!commit || parse_commit(commit))
1314
+ if (parse_commit(commit))
1315
die(_("could not parse newly created commit"));
1316
1317
strbuf_addstr(&format, "format:%h] %s");
@@ -1503,7 +1503,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1503
current_head = NULL;
1504
else {
1505
current_head = lookup_commit_or_die(sha1, "HEAD");
1506
- if (!current_head || parse_commit(current_head))
1506
+ if (parse_commit(current_head))
1507
die(_("could not parse HEAD commit"));
1508
}
1509
argc = parse_and_validate_options(argc, argv, builtin_commit_options,
commit.c
+1
-1
@@ -79,7 +79,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)
79
if (get_sha1_committish(name, sha1))
80
return NULL;
81
commit = lookup_commit_reference(sha1);
82
- if (!commit || parse_commit(commit))
82
+ if (parse_commit(commit))
83
return NULL;
84
return commit;
85
}
notes-utils.c
+1
-1
@@ -18,7 +18,7 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,
18
unsigned char parent_sha1[20];
19
if (!read_ref(t->ref, parent_sha1)) {
20
struct commit *parent = lookup_commit(parent_sha1);
21
- if (!parent || parse_commit(parent))
21
+ if (parse_commit(parent))
22
die("Failed to find/parse commit %s", t->ref);
23
commit_list_insert(parent, &parents);
24
}
sha1_name.c
-2
@@ -582,8 +582,6 @@ static int get_parent(const char *name, int len,
582
if (ret)
583
return ret;
584
commit = lookup_commit_reference(sha1);
585
- if (!commit)
586
- return -1;
585
if (parse_commit(commit))
586
return -1;
587
if (!idx) {