Browse Source

Merge branch 'ab/mark-leak-free-tests-more'

Bunch of tests are marked as "passing leak check".

* ab/mark-leak-free-tests-more:
  merge: add missing strbuf_release()
  ls-files: add missing string_list_clear()
  ls-files: fix a trivial dir_clear() leak
  tests: fix test-oid-array leak, test in SANITIZE=leak
  tests: fix a memory leak in test-oidtree.c
  tests: fix a memory leak in test-parse-options.c
  tests: fix a memory leak in test-prio-queue.c
maint
Junio C Hamano 3 years ago
parent
commit
54c4f8ce52
  1. 14
      builtin/ls-files.c
  2. 2
      builtin/merge.c
  3. 4
      t/helper/test-oid-array.c
  4. 3
      t/helper/test-oidtree.c
  5. 7
      t/helper/test-parse-options.c
  6. 2
      t/helper/test-prio-queue.c
  7. 2
      t/t0009-prio-queue.sh
  8. 1
      t/t0040-parse-options.sh
  9. 2
      t/t0064-oid-array.sh
  10. 1
      t/t0069-oidtree.sh
  11. 5
      t/t3001-ls-files-others-exclude.sh
  12. 1
      t/t3005-ls-files-relative.sh
  13. 2
      t/t3020-ls-files-error-unmatch.sh
  14. 1
      t/t3700-add.sh
  15. 1
      t/t7104-reset-hard.sh
  16. 1
      t/t7604-merge-custom-message.sh

14
builtin/ls-files.c

@ -672,6 +672,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) @@ -672,6 +672,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
N_("suppress duplicate entries")),
OPT_END()
};
int ret = 0;

if (argc == 2 && !strcmp(argv[1], "-h"))
usage_with_options(ls_files_usage, builtin_ls_files_options);
@ -775,16 +776,13 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) @@ -775,16 +776,13 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
if (show_resolve_undo)
show_ru_info(the_repository->index);

if (ps_matched) {
int bad;
bad = report_path_error(ps_matched, &pathspec);
if (bad)
fprintf(stderr, "Did you forget to 'git add'?\n");

return bad ? 1 : 0;
if (ps_matched && report_path_error(ps_matched, &pathspec)) {
fprintf(stderr, "Did you forget to 'git add'?\n");
ret = 1;
}

string_list_clear(&exclude_list, 0);
dir_clear(&dir);
free(max_prefix);
return 0;
return ret;
}

2
builtin/merge.c

@ -1578,6 +1578,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) @@ -1578,6 +1578,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)

finish(head_commit, remoteheads, &commit->object.oid, msg.buf);
remove_merge_branch_state(the_repository);
strbuf_release(&msg);
goto done;
} else if (!remoteheads->next && common->next)
;
@ -1748,6 +1749,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) @@ -1748,6 +1749,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
ret = suggest_conflicts();

done:
strbuf_release(&buf);
free(branch_to_free);
return ret;
}

4
t/helper/test-oid-array.c

@ -35,5 +35,9 @@ int cmd__oid_array(int argc, const char **argv) @@ -35,5 +35,9 @@ int cmd__oid_array(int argc, const char **argv)
else
die("unknown command: %s", line.buf);
}

strbuf_release(&line);
oid_array_clear(&array);

return 0;
}

3
t/helper/test-oidtree.c

@ -45,5 +45,8 @@ int cmd__oidtree(int argc, const char **argv) @@ -45,5 +45,8 @@ int cmd__oidtree(int argc, const char **argv)
die("unknown command: %s", line.buf);
}
}

strbuf_release(&line);

return 0;
}

7
t/helper/test-parse-options.c

@ -14,7 +14,6 @@ static int dry_run = 0, quiet = 0; @@ -14,7 +14,6 @@ static int dry_run = 0, quiet = 0;
static char *string = NULL;
static char *file = NULL;
static int ambiguous;
static struct string_list list = STRING_LIST_INIT_NODUP;

static struct {
int called;
@ -107,6 +106,8 @@ int cmd__parse_options(int argc, const char **argv) @@ -107,6 +106,8 @@ int cmd__parse_options(int argc, const char **argv)
NULL
};
struct string_list expect = STRING_LIST_INIT_NODUP;
struct string_list list = STRING_LIST_INIT_NODUP;

struct option options[] = {
OPT_BOOL(0, "yes", &boolean, "get a boolean"),
OPT_BOOL('D', "no-doubt", &boolean, "begins with 'no-'"),
@ -185,5 +186,9 @@ int cmd__parse_options(int argc, const char **argv) @@ -185,5 +186,9 @@ int cmd__parse_options(int argc, const char **argv)
for (i = 0; i < argc; i++)
show(&expect, &ret, "arg %02d: %s", i, argv[i]);

expect.strdup_strings = 1;
string_list_clear(&expect, 0);
string_list_clear(&list, 0);

return ret;
}

2
t/helper/test-prio-queue.c

@ -46,5 +46,7 @@ int cmd__prio_queue(int argc, const char **argv) @@ -46,5 +46,7 @@ int cmd__prio_queue(int argc, const char **argv)
}
}

clear_prio_queue(&pq);

return 0;
}

2
t/t0009-prio-queue.sh

@ -1,6 +1,8 @@ @@ -1,6 +1,8 @@
#!/bin/sh

test_description='basic tests for priority queue implementation'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

cat >expect <<'EOF'

1
t/t0040-parse-options.sh

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@

test_description='our own option parser'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

cat >expect <<\EOF

2
t/t0064-oid-array.sh

@ -1,6 +1,8 @@ @@ -1,6 +1,8 @@
#!/bin/sh

test_description='basic tests for the oid array implementation'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

echoid () {

1
t/t0069-oidtree.sh

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#!/bin/sh

test_description='basic tests for the oidtree implementation'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

maxhexsz=$(test_oid hexsz)

5
t/t3001-ls-files-others-exclude.sh

@ -8,6 +8,7 @@ test_description='git ls-files --others --exclude @@ -8,6 +8,7 @@ test_description='git ls-files --others --exclude
This test runs git ls-files --others and tests --exclude patterns.
'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

rm -fr one three
@ -102,7 +103,7 @@ test_expect_success \ @@ -102,7 +103,7 @@ test_expect_success \
>output &&
test_cmp expect output'

test_expect_success 'restore gitignore' '
test_expect_success !SANITIZE_LEAK 'restore gitignore' '
git checkout --ignore-skip-worktree-bits $allignores &&
rm .git/index
'
@ -125,7 +126,7 @@ cat > expect << EOF @@ -125,7 +126,7 @@ cat > expect << EOF
# three/
EOF

test_expect_success 'git status honors core.excludesfile' \
test_expect_success !SANITIZE_LEAK 'git status honors core.excludesfile' \
'test_cmp expect output'

test_expect_success 'trailing slash in exclude allows directory match(1)' '

1
t/t3005-ls-files-relative.sh

@ -5,6 +5,7 @@ test_description='ls-files tests with relative paths @@ -5,6 +5,7 @@ test_description='ls-files tests with relative paths
This test runs git ls-files with various relative path arguments.
'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'prepare' '

2
t/t3020-ls-files-error-unmatch.sh

@ -9,6 +9,8 @@ This test runs git ls-files --error-unmatch to ensure it correctly @@ -9,6 +9,8 @@ This test runs git ls-files --error-unmatch to ensure it correctly
returns an error when a non-existent path is provided on the command
line.
'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'setup' '

1
t/t3700-add.sh

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@

test_description='Test of git add, including the -- option.'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

# Test the file mode "$1" of the file "$2" in the index.

1
t/t7104-reset-hard.sh

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@

test_description='reset --hard unmerged'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success setup '

1
t/t7604-merge-custom-message.sh

@ -4,6 +4,7 @@ test_description='git merge @@ -4,6 +4,7 @@ test_description='git merge

Testing merge when using a custom message for the merge commit.'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

create_merge_msgs() {

Loading…
Cancel
Save