summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2022-04-13 20:01:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-04-14 06:56:08 (GMT)
commitbf20fe4ca8c8d2ba2087c9c44b4ee09a1d1467ed (patch)
tree08636c2ac7c428086e6ad0324f4f7d7703e82e86 /commit.c
parent89f45cf4eb031f28b5dd028983734c4ddfa99439 (diff)
downloadgit-bf20fe4ca8c8d2ba2087c9c44b4ee09a1d1467ed.zip
git-bf20fe4ca8c8d2ba2087c9c44b4ee09a1d1467ed.tar.gz
git-bf20fe4ca8c8d2ba2087c9c44b4ee09a1d1467ed.tar.bz2
cocci: add and apply free_commit_list() rules
Add and apply coccinelle rules to remove "if (E)" before "free_commit_list(E)", the function can accept NULL, and further change cases where "E = NULL" followed to also be unconditionally. The code changes in this commit were entirely made by the coccinelle rule being added here, and applied with: make contrib/coccinelle/free.cocci.patch patch -p1 <contrib/coccinelle/free.cocci.patch The only manual intervention here is that the the relevant code in commit.c has been manually re-indented. Suggested-by: Phillip Wood <phillip.wood123@gmail.com> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/commit.c b/commit.c
index 98b2e55..0fee9b1 100644
--- a/commit.c
+++ b/commit.c
@@ -397,17 +397,14 @@ int parse_commit_buffer(struct repository *r, struct commit *item, const void *b
if (item->object.parsed)
return 0;
-
- if (item->parents) {
- /*
- * Presumably this is leftover from an earlier failed parse;
- * clear it out in preparation for us re-parsing (we'll hit the
- * same error, but that's good, since it lets our caller know
- * the result cannot be trusted.
- */
- free_commit_list(item->parents);
- item->parents = NULL;
- }
+ /*
+ * Presumably this is leftover from an earlier failed parse;
+ * clear it out in preparation for us re-parsing (we'll hit the
+ * same error, but that's good, since it lets our caller know
+ * the result cannot be trusted.
+ */
+ free_commit_list(item->parents);
+ item->parents = NULL;
tail += size;
if (tail <= bufptr + tree_entry_len + 1 || memcmp(bufptr, "tree ", 5) ||