diff options
| author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2022-04-13 22:01:34 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2022-04-13 23:56:08 -0700 |
| commit | bf20fe4ca8c8d2ba2087c9c44b4ee09a1d1467ed (patch) | |
| tree | 08636c2ac7c428086e6ad0324f4f7d7703e82e86 /revision.c | |
| parent | format-patch: don't leak "extra_headers" or "ref_message_ids" (diff) | |
| download | git-bf20fe4ca8c8d2ba2087c9c44b4ee09a1d1467ed.tar.gz git-bf20fe4ca8c8d2ba2087c9c44b4ee09a1d1467ed.zip | |
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 'revision.c')
| -rw-r--r-- | revision.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/revision.c b/revision.c index 7d435f8048..4963ba7def 100644 --- a/revision.c +++ b/revision.c @@ -1456,10 +1456,9 @@ static int limit_list(struct rev_info *revs) if (revs->left_only || revs->right_only) limit_left_right(newlist, revs); - if (bottom) { + if (bottom) limit_to_ancestry(bottom, newlist); - free_commit_list(bottom); - } + free_commit_list(bottom); /* * Check if any commits have become TREESAME by some of their parents @@ -4080,10 +4079,8 @@ static void create_boundary_commit_list(struct rev_info *revs) * boundary commits anyway. (This is what the code has always * done.) */ - if (revs->commits) { - free_commit_list(revs->commits); - revs->commits = NULL; - } + free_commit_list(revs->commits); + revs->commits = NULL; /* * Put all of the actual boundary commits from revs->boundary_commits @@ -4220,10 +4217,8 @@ struct commit *get_revision(struct rev_info *revs) graph_update(revs->graph, c); if (!c) { free_saved_parents(revs); - if (revs->previous_parents) { - free_commit_list(revs->previous_parents); - revs->previous_parents = NULL; - } + free_commit_list(revs->previous_parents); + revs->previous_parents = NULL; } return c; } |
