1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-09 01:16:11 +02:00

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

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
This commit is contained in:
Junio C Hamano 2021-10-18 16:00:28 -07:00
commit fe798f77b8
16 changed files with 38 additions and 11 deletions

View File

@ -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)
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;
}

View File

@ -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)
ret = suggest_conflicts();
done:
strbuf_release(&buf);
free(branch_to_free);
return ret;
}

View File

@ -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;
}

View File

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

View File

@ -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)
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)
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;
}

View File

@ -46,5 +46,7 @@ int cmd__prio_queue(int argc, const char **argv)
}
}
clear_prio_queue(&pq);
return 0;
}

View File

@ -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'

View File

@ -5,6 +5,7 @@
test_description='our own option parser'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
cat >expect <<\EOF

View File

@ -1,6 +1,8 @@
#!/bin/sh
test_description='basic tests for the oid array implementation'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
echoid () {

View File

@ -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)

View File

@ -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 \
>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
# 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)' '

View File

@ -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' '

View File

@ -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' '

View File

@ -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.

View File

@ -2,6 +2,7 @@
test_description='reset --hard unmerged'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success setup '

View File

@ -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() {