summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2013-10-24 08:53:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-10-24 22:43:50 (GMT)
commit5e7d4d3e932432131d0f8f4195e0061ecf644865 (patch)
tree69826f91be44e4096551bc75e884f0f1db7d8db5
parent0064053bd76ba385e1b5d51b6175bc17bc507804 (diff)
downloadgit-5e7d4d3e932432131d0f8f4195e0061ecf644865.zip
git-5e7d4d3e932432131d0f8f4195e0061ecf644865.tar.gz
git-5e7d4d3e932432131d0f8f4195e0061ecf644865.tar.bz2
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>
-rw-r--r--builtin/branch.c2
-rw-r--r--builtin/commit.c4
-rw-r--r--commit.c2
-rw-r--r--notes-utils.c2
-rw-r--r--sha1_name.c2
5 files changed, 5 insertions, 7 deletions
diff --git a/builtin/branch.c b/builtin/branch.c
index 0836890..8db095f 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -490,7 +490,7 @@ static void add_verbose_info(struct strbuf *out, struct ref_item *item,
const char *sub = _(" **** invalid ref ****");
struct commit *commit = item->commit;
- if (commit && !parse_commit(commit)) {
+ if (!parse_commit(commit)) {
pp_commit_easy(CMIT_FMT_ONELINE, commit, &subject);
sub = subject.buf;
}
diff --git a/builtin/commit.c b/builtin/commit.c
index 10acc53..89f65f2 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1311,7 +1311,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1,
commit = lookup_commit(sha1);
if (!commit)
die(_("couldn't look up newly created commit"));
- if (!commit || parse_commit(commit))
+ if (parse_commit(commit))
die(_("could not parse newly created commit"));
strbuf_addstr(&format, "format:%h] %s");
@@ -1503,7 +1503,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
current_head = NULL;
else {
current_head = lookup_commit_or_die(sha1, "HEAD");
- if (!current_head || parse_commit(current_head))
+ if (parse_commit(current_head))
die(_("could not parse HEAD commit"));
}
argc = parse_and_validate_options(argc, argv, builtin_commit_options,
diff --git a/commit.c b/commit.c
index 26c1d54..8535e5c 100644
--- a/commit.c
+++ b/commit.c
@@ -79,7 +79,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)
if (get_sha1_committish(name, sha1))
return NULL;
commit = lookup_commit_reference(sha1);
- if (!commit || parse_commit(commit))
+ if (parse_commit(commit))
return NULL;
return commit;
}
diff --git a/notes-utils.c b/notes-utils.c
index 9107c37..7bb3473 100644
--- a/notes-utils.c
+++ b/notes-utils.c
@@ -18,7 +18,7 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,
unsigned char parent_sha1[20];
if (!read_ref(t->ref, parent_sha1)) {
struct commit *parent = lookup_commit(parent_sha1);
- if (!parent || parse_commit(parent))
+ if (parse_commit(parent))
die("Failed to find/parse commit %s", t->ref);
commit_list_insert(parent, &parents);
}
diff --git a/sha1_name.c b/sha1_name.c
index 65ad066..729ab14 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -582,8 +582,6 @@ static int get_parent(const char *name, int len,
if (ret)
return ret;
commit = lookup_commit_reference(sha1);
- if (!commit)
- return -1;
if (parse_commit(commit))
return -1;
if (!idx) {