Merge branch 'ps/leakfixes-part-10' into ps/bisect-double-free-fix

* ps/leakfixes-part-10: (27 commits)
  t: remove TEST_PASSES_SANITIZE_LEAK annotations
  test-lib: unconditionally enable leak checking
  t: remove unneeded !SANITIZE_LEAK prerequisites
  t: mark some tests as leak free
  t5601: work around leak sanitizer issue
  git-compat-util: drop now-unused `UNLEAK()` macro
  global: drop `UNLEAK()` annotation
  t/helper: fix leaking commit graph in "read-graph" subcommand
  builtin/branch: fix leaking sorting options
  builtin/init-db: fix leaking directory paths
  builtin/help: fix leaks in `check_git_cmd()`
  help: fix leaking return value from `help_unknown_cmd()`
  help: fix leaking `struct cmdnames`
  help: refactor to not use globals for reading config
  builtin/sparse-checkout: fix leaking sanitized patterns
  split-index: fix memory leak in `move_cache_to_base_index()`
  git: refactor builtin handling to use a `struct strvec`
  git: refactor alias handling to use a `struct strvec`
  strvec: introduce new `strvec_splice()` function
  line-log: fix leak when rewriting commit parents
  ...
This commit is contained in:
Junio C Hamano
2024-11-26 10:21:58 +09:00
950 changed files with 360 additions and 1248 deletions

View File

@ -88,6 +88,71 @@ void test_strvec__pushv(void)
strvec_clear(&vec);
}
void test_strvec__splice_with_same_size_replacement(void)
{
struct strvec vec = STRVEC_INIT;
const char *replacement[] = { "1" };
strvec_pushl(&vec, "foo", "bar", "baz", NULL);
strvec_splice(&vec, 1, 1, replacement, ARRAY_SIZE(replacement));
check_strvec(&vec, "foo", "1", "baz", NULL);
strvec_clear(&vec);
}
void test_strvec__splice_with_smaller_replacement(void)
{
struct strvec vec = STRVEC_INIT;
const char *replacement[] = { "1" };
strvec_pushl(&vec, "foo", "bar", "baz", NULL);
strvec_splice(&vec, 1, 2, replacement, ARRAY_SIZE(replacement));
check_strvec(&vec, "foo", "1", NULL);
strvec_clear(&vec);
}
void test_strvec__splice_with_bigger_replacement(void)
{
struct strvec vec = STRVEC_INIT;
const char *replacement[] = { "1", "2", "3" };
strvec_pushl(&vec, "foo", "bar", "baz", NULL);
strvec_splice(&vec, 0, 2, replacement, ARRAY_SIZE(replacement));
check_strvec(&vec, "1", "2", "3", "baz", NULL);
strvec_clear(&vec);
}
void test_strvec__splice_with_empty_replacement(void)
{
struct strvec vec = STRVEC_INIT;
strvec_pushl(&vec, "foo", "bar", "baz", NULL);
strvec_splice(&vec, 0, 2, NULL, 0);
check_strvec(&vec, "baz", NULL);
strvec_clear(&vec);
}
void test_strvec__splice_with_empty_original(void)
{
struct strvec vec = STRVEC_INIT;
const char *replacement[] = { "1", "2" };
strvec_pushl(&vec, "foo", "bar", "baz", NULL);
strvec_splice(&vec, 1, 0, replacement, ARRAY_SIZE(replacement));
check_strvec(&vec, "foo", "1", "2", "bar", "baz", NULL);
strvec_clear(&vec);
}
void test_strvec__splice_at_tail(void)
{
struct strvec vec = STRVEC_INIT;
const char *replacement[] = { "1", "2" };
strvec_pushl(&vec, "foo", "bar", NULL);
strvec_splice(&vec, 2, 0, replacement, ARRAY_SIZE(replacement));
check_strvec(&vec, "foo", "bar", "1", "2", NULL);
strvec_clear(&vec);
}
void test_strvec__replace_at_head(void)
{
struct strvec vec = STRVEC_INIT;