Merge branch 'rj/leakfixes' into next

Leakfixes

* rj/leakfixes:
  tests: mark as passing with SANITIZE=leak
  config: fix a leak in git_config_copy_or_rename_section_in_file
  branch: fix a leak in cmd_branch
  branch: fix a leak in setup_tracking
  rev-parse: fix a leak with --abbrev-ref
This commit is contained in:
Junio C Hamano
2023-06-17 17:04:42 -07:00
15 changed files with 19 additions and 2 deletions

View File

@ -334,7 +334,7 @@ static void setup_tracking(const char *new_ref, const char *orig_ref,
if (!skip_prefix(tracking.srcs->items[0].string, if (!skip_prefix(tracking.srcs->items[0].string,
"refs/heads/", &tracked_branch) || "refs/heads/", &tracked_branch) ||
strcmp(tracked_branch, new_ref)) strcmp(tracked_branch, new_ref))
return; goto cleanup;
} }
if (tracking.srcs->nr < 1) if (tracking.srcs->nr < 1)

View File

@ -832,6 +832,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
if (list) if (list)
setup_auto_pager("branch", 1); setup_auto_pager("branch", 1);
UNLEAK(sorting_options);
if (delete) { if (delete) {
if (!argc) if (!argc)
die(_("branch name required")); die(_("branch name required"));

View File

@ -158,9 +158,12 @@ static void show_rev(int type, const struct object_id *oid, const char *name)
*/ */
break; break;
case 1: /* happy */ case 1: /* happy */
if (abbrev_ref) if (abbrev_ref) {
char *old = full;
full = shorten_unambiguous_ref(full, full = shorten_unambiguous_ref(full,
abbrev_ref_strict); abbrev_ref_strict);
free(old);
}
show_with_type(type, full); show_with_type(type, full);
break; break;
default: /* ambiguous */ default: /* ambiguous */

View File

@ -3844,6 +3844,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
output[0] = '\t'; output[0] = '\t';
} }
} else { } else {
strbuf_release(&copystr);
copystr = store_create_section(new_name, &store); copystr = store_create_section(new_name, &store);
} }
} }

View File

@ -5,6 +5,7 @@ test_description='test <branch>@{upstream} syntax'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh

View File

@ -4,6 +4,7 @@ test_description='test various @{X} syntax combinations together'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
check() { check() {

View File

@ -4,6 +4,7 @@ test_description='test <branch>@{push} syntax'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
resolve () { resolve () {

View File

@ -5,6 +5,7 @@ test_description='tests for git branch --track'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
test_expect_success 'setup' ' test_expect_success 'setup' '

View File

@ -8,6 +8,7 @@ test_description='git branch assorted tests'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
. "$TEST_DIRECTORY"/lib-rebase.sh . "$TEST_DIRECTORY"/lib-rebase.sh

View File

@ -9,6 +9,7 @@ This script aims to check the behavior of those corner cases.
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
expect_branch() { expect_branch() {

View File

@ -5,6 +5,7 @@ test_description='tracking branch update checks for git push'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
test_expect_success 'setup' ' test_expect_success 'setup' '

View File

@ -5,6 +5,7 @@ test_description='pushing to a mirror repository'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
D=$(pwd) D=$(pwd)

View File

@ -2,6 +2,7 @@
test_description='tagopt variable affects "git fetch" and is overridden by commandline.' test_description='tagopt variable affects "git fetch" and is overridden by commandline.'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
setup_clone () { setup_clone () {

View File

@ -5,6 +5,7 @@ test_description='remote tracking stats'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
advance () { advance () {

View File

@ -5,6 +5,7 @@
test_description='git status' test_description='git status'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
. "$TEST_DIRECTORY"/lib-terminal.sh . "$TEST_DIRECTORY"/lib-terminal.sh