revisions API: call diff_free(&revs->pruning) in revisions_release()

Call diff_free() on the "pruning" member of "struct rev_info". Doing so makes several tests pass under SANITIZE=leak. This was also the last missing piece that allows us to remove the UNLEAK() in "cmd_diff" and "cmd_diff_index", which allows us to use those commands as a canary for general leaks in the revisions API. See [1] for further rationale, and 886e1084d78 (builtin/: add UNLEAKs, 2017-10-01) for the commit that added the UNLEAK() there. 1. https://lore.kernel.org/git/220218.861r00ib86.gmgdl@evledraar.gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Apr 13, 2022 at 22:01 UTC 6ab75ac83926c154a58104ac832363f128f8ed56
9 files changed +9 -2
builtin/diff-index.c
-1
@@ -70,7 +70,6 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
70 return -1;
71 }
72 result = run_diff_index(&rev, option);
73 - UNLEAK(rev);
73 result = diff_result_code(&rev.diffopt, result);
74 release_revisions(&rev);
75 return result;
builtin/diff.c
-1
@@ -594,7 +594,6 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
594 result = diff_result_code(&rev.diffopt, result);
595 if (1 < rev.diffopt.skip_stat_unmatch)
596 refresh_index_quietly();
597 - UNLEAK(rev);
597 release_revisions(&rev);
598 UNLEAK(ent);
599 UNLEAK(blob);
revision.c
+1
@@ -2953,6 +2953,7 @@ void release_revisions(struct rev_info *revs)
2953 clear_pathspec(&revs->prune_data);
2954 release_revisions_mailmap(revs->mailmap);
2955 free_grep_patterns(&revs->grep_filter);
2956 + diff_free(&revs->pruning);
2957 reflog_walk_info_release(revs->reflog_info);
2958 }
2959
t/t1001-read-tree-m-2way.sh
+1
@@ -21,6 +21,7 @@ In the test, these paths are used:
21 yomin - not in H or M
22 '
23
24 +TEST_PASSES_SANITIZE_LEAK=true
25 . ./test-lib.sh
26 . "$TEST_DIRECTORY"/lib-read-tree.sh
27
t/t1002-read-tree-m-u-2way.sh
+1
@@ -9,6 +9,7 @@ This is identical to t1001, but uses -u to update the work tree as well.
9
10 '
11
12 +TEST_PASSES_SANITIZE_LEAK=true
13 . ./test-lib.sh
14 . "$TEST_DIRECTORY"/lib-read-tree.sh
15
t/t2200-add-update.sh
+1
@@ -14,6 +14,7 @@ only the updates to dir/sub.
14 Also tested are "git add -u" without limiting, and "git add -u"
15 without contents changes, and other conditions'
16
17 +TEST_PASSES_SANITIZE_LEAK=true
18 . ./test-lib.sh
19
20 test_expect_success setup '
t/t4039-diff-assume-unchanged.sh
+1
@@ -2,6 +2,7 @@
2
3 test_description='diff with assume-unchanged entries'
4
5 +TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 # external diff has been tested in t4020-diff-external.sh
t/t4206-log-follow-harder-copies.sh
+2
@@ -6,6 +6,8 @@
6 test_description='Test --follow should always find copies hard in git log.
7
8 '
9 +
10 +TEST_PASSES_SANITIZE_LEAK=true
11 . ./test-lib.sh
12 . "$TEST_DIRECTORY"/lib-diff.sh
13
t/t6131-pathspec-icase.sh
+2
@@ -1,6 +1,8 @@
1 #!/bin/sh
2
3 test_description='test case insensitive pathspec limiting'
4 +
5 +TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 if test_have_prereq CASE_INSENSITIVE_FS