Merge branch 'ps/leakfixes-part-10'

Leakfixes.

* 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
  ...
maint
Junio C Hamano 2024-12-04 10:14:38 +09:00
commit a5dd262a75
950 changed files with 360 additions and 1248 deletions

View File

@ -28,8 +28,8 @@ static struct oid_array skipped_revs;

static struct object_id *current_bad_oid;

static const char *term_bad;
static const char *term_good;
static char *term_bad;
static char *term_good;

/* Remember to update object flag allocation in object.h */
#define COUNTED (1u<<16)
@ -442,9 +442,12 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
best->next = NULL;
}
*reaches = weight(best);
} else {
free_commit_list(*commit_list);
}
free(weights);
*commit_list = best;

free(weights);
clear_commit_weight(&commit_weight);
}

@ -456,6 +459,7 @@ static int register_ref(const char *refname, const char *referent UNUSED, const
strbuf_addstr(&good_prefix, "-");

if (!strcmp(refname, term_bad)) {
free(current_bad_oid);
current_bad_oid = xmalloc(sizeof(*current_bad_oid));
oidcpy(current_bad_oid, oid);
} else if (starts_with(refname, good_prefix.buf)) {
@ -556,8 +560,11 @@ struct commit_list *filter_skipped(struct commit_list *list,
tried = &list->next;
} else {
if (!show_all) {
if (!skipped_first || !*skipped_first)
if (!skipped_first || !*skipped_first) {
free_commit_list(next);
free_commit_list(filtered);
return list;
}
} else if (skipped_first && !*skipped_first) {
/* This means we know it's not skipped */
*skipped_first = -1;
@ -613,7 +620,7 @@ static int sqrti(int val)

static struct commit_list *skip_away(struct commit_list *list, int count)
{
struct commit_list *cur, *previous;
struct commit_list *cur, *previous, *result = list;
int prn, index, i;

prn = get_prn(count);
@ -625,15 +632,23 @@ static struct commit_list *skip_away(struct commit_list *list, int count)
for (i = 0; cur; cur = cur->next, i++) {
if (i == index) {
if (!oideq(&cur->item->object.oid, current_bad_oid))
return cur;
if (previous)
return previous;
return list;
result = cur;
else if (previous)
result = previous;
else
result = list;
break;
}
previous = cur;
}

return list;
for (cur = list; cur != result; ) {
struct commit_list *next = cur->next;
free(cur);
cur = next;
}

return result;
}

static struct commit_list *managed_skipped(struct commit_list *list,
@ -801,6 +816,8 @@ static enum bisect_error handle_bad_merge_base(void)
"between %s and [%s].\n"),
bad_hex, term_bad, term_good, bad_hex, good_hex);
}

free(good_hex);
return BISECT_MERGE_BASE_CHECK;
}

@ -848,8 +865,8 @@ static enum bisect_error check_merge_bases(int rev_nr, struct commit **rev, int
rev + 1, &result) < 0)
exit(128);

for (; result; result = result->next) {
const struct object_id *mb = &result->item->object.oid;
for (struct commit_list *l = result; l; l = l->next) {
const struct object_id *mb = &l->item->object.oid;
if (oideq(mb, current_bad_oid)) {
res = handle_bad_merge_base();
break;
@ -985,7 +1002,7 @@ static void show_commit(struct commit *commit)
* We read them and store them to adapt the messages accordingly.
* Default is bad/good.
*/
void read_bisect_terms(const char **read_bad, const char **read_good)
void read_bisect_terms(char **read_bad, char **read_good)
{
struct strbuf str = STRBUF_INIT;
const char *filename = git_path_bisect_terms();
@ -993,16 +1010,20 @@ void read_bisect_terms(const char **read_bad, const char **read_good)

if (!fp) {
if (errno == ENOENT) {
*read_bad = "bad";
*read_good = "good";
free(*read_bad);
*read_bad = xstrdup("bad");
free(*read_good);
*read_good = xstrdup("good");
return;
} else {
die_errno(_("could not read file '%s'"), filename);
}
} else {
strbuf_getline_lf(&str, fp);
free(*read_bad);
*read_bad = strbuf_detach(&str, NULL);
strbuf_getline_lf(&str, fp);
free(*read_good);
*read_good = strbuf_detach(&str, NULL);
}
strbuf_release(&str);
@ -1024,7 +1045,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
{
struct strvec rev_argv = STRVEC_INIT;
struct rev_info revs = REV_INFO_INIT;
struct commit_list *tried;
struct commit_list *tried = NULL;
int reaches = 0, all = 0, nr, steps;
enum bisect_error res = BISECT_OK;
struct object_id *bisect_rev;
@ -1091,7 +1112,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
if (oideq(bisect_rev, current_bad_oid)) {
res = error_if_skipped_commits(tried, current_bad_oid);
if (res)
return res;
goto cleanup;
printf("%s is the first %s commit\n", oid_to_hex(bisect_rev),
term_bad);

@ -1125,6 +1146,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)

res = bisect_checkout(bisect_rev, no_checkout);
cleanup:
free_commit_list(tried);
release_revisions(&revs);
strvec_clear(&rev_argv);
return res;

View File

@ -75,7 +75,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix);

int estimate_bisect_steps(int all);

void read_bisect_terms(const char **bad, const char **good);
void read_bisect_terms(char **bad, char **good);

int bisect_clean_state(void);


View File

@ -2931,6 +2931,7 @@ void setup_blame_bloom_data(struct blame_scoreboard *sb)
void cleanup_scoreboard(struct blame_scoreboard *sb)
{
free(sb->lineno);
free(sb->final_buf);
clear_prio_queue(&sb->commits);
oidset_clear(&sb->ignore_list);


View File

@ -116,7 +116,7 @@ struct blame_scoreboard {
* Used by many functions to obtain contents of the nth line,
* indexed with scoreboard.lineno[blame_entry.lno].
*/
const char *final_buf;
char *final_buf;
unsigned long final_buf_size;

/* linked list of blames */

View File

@ -1216,12 +1216,6 @@ parse_done:
output_option &= ~(OUTPUT_COLOR_LINE | OUTPUT_SHOW_AGE_WITH_COLOR);

output(&sb, output_option);
free((void *)sb.final_buf);
for (ent = sb.ent; ent; ) {
struct blame_entry *e = ent->next;
free(ent);
ent = e;
}

if (show_stats) {
printf("num read blob: %d\n", sb.num_read_blob);
@ -1230,6 +1224,12 @@ parse_done:
}

cleanup:
for (ent = sb.ent; ent; ) {
struct blame_entry *e = ent->next;
free(ent);
ent = e;
}

free(path);
cleanup_scoreboard(&sb);
release_revisions(&revs);

View File

@ -722,6 +722,7 @@ int cmd_branch(int argc,
static struct ref_sorting *sorting;
struct string_list sorting_options = STRING_LIST_INIT_DUP;
struct ref_format format = REF_FORMAT_INIT;
int ret;

struct option options[] = {
OPT_GROUP(N_("Generic options")),
@ -851,15 +852,15 @@ int cmd_branch(int argc,
if (list)
setup_auto_pager("branch", 1);

UNLEAK(sorting_options);

if (delete) {
if (!argc)
die(_("branch name required"));
return delete_branches(argc, argv, delete > 1, filter.kind, quiet);
ret = delete_branches(argc, argv, delete > 1, filter.kind, quiet);
goto out;
} else if (show_current) {
print_current_branch_name();
return 0;
ret = 0;
goto out;
} else if (list) {
/* git branch --list also shows HEAD when it is detached */
if ((filter.kind & FILTER_REFS_BRANCHES) && filter.detached)
@ -882,12 +883,13 @@ int cmd_branch(int argc,
ref_sorting_release(sorting);
ref_filter_clear(&filter);
ref_format_clear(&format);
return 0;

ret = 0;
goto out;
} else if (edit_description) {
const char *branch_name;
struct strbuf branch_ref = STRBUF_INIT;
struct strbuf buf = STRBUF_INIT;
int ret = 1; /* assume failure */

if (!argc) {
if (filter.detached)
@ -901,18 +903,22 @@ int cmd_branch(int argc,
}

strbuf_addf(&branch_ref, "refs/heads/%s", branch_name);
if (!refs_ref_exists(get_main_ref_store(the_repository), branch_ref.buf))
if (!refs_ref_exists(get_main_ref_store(the_repository), branch_ref.buf)) {
error((!argc || branch_checked_out(branch_ref.buf))
? _("no commit on branch '%s' yet")
: _("no branch named '%s'"),
branch_name);
else if (!edit_branch_description(branch_name))
ret = 1;
} else if (!edit_branch_description(branch_name)) {
ret = 0; /* happy */
} else {
ret = 1;
}

strbuf_release(&branch_ref);
strbuf_release(&buf);

return ret;
goto out;
} else if (copy || rename) {
if (!argc)
die(_("branch name required"));
@ -1000,12 +1006,17 @@ int cmd_branch(int argc,
create_branches_recursively(the_repository, branch_name,
start_name, NULL, force,
reflog, quiet, track, 0);
return 0;
ret = 0;
goto out;
}
create_branch(the_repository, branch_name, start_name, force, 0,
reflog, quiet, track, 0);
} else
usage_with_options(builtin_branch_usage, options);

return 0;
ret = 0;

out:
string_list_clear(&sorting_options, 0);
return ret;
}

View File

@ -1586,7 +1586,6 @@ int cmd_clone(int argc,
free(dir);
free(path);
free(repo_to_free);
UNLEAK(repo);
junk_mode = JUNK_LEAVE_ALL;

transport_ls_refs_options_release(&transport_ls_refs_options);

View File

@ -628,6 +628,5 @@ int cmd_diff(int argc,
release_revisions(&rev);
object_array_clear(&ent);
symdiff_release(&sdiff);
UNLEAK(blob);
return result;
}

View File

@ -551,12 +551,12 @@ static void show_html_page(const char *page)
open_html(page_path.buf);
}

static const char *check_git_cmd(const char* cmd)
static char *check_git_cmd(const char *cmd)
{
char *alias;

if (is_git_command(cmd))
return cmd;
return xstrdup(cmd);

alias = alias_lookup(cmd);
if (alias) {
@ -589,14 +589,13 @@ static const char *check_git_cmd(const char* cmd)
die(_("bad alias.%s string: %s"), cmd,
split_cmdline_strerror(count));
free(argv);
UNLEAK(alias);
return alias;
}

if (exclude_guides)
return help_unknown_cmd(cmd);

return cmd;
return xstrdup(cmd);
}

static void no_help_format(const char *opt_mode, enum help_format fmt)
@ -642,6 +641,7 @@ int cmd_help(int argc,
{
int nongit;
enum help_format parsed_help_format;
char *command = NULL;
const char *page;

argc = parse_options(argc, argv, prefix, builtin_help_options,
@ -713,9 +713,9 @@ int cmd_help(int argc,
if (help_format == HELP_FORMAT_NONE)
help_format = parse_help_format(DEFAULT_HELP_FORMAT);

argv[0] = check_git_cmd(argv[0]);
command = check_git_cmd(argv[0]);

page = cmd_to_page(argv[0]);
page = cmd_to_page(command);
switch (help_format) {
case HELP_FORMAT_NONE:
case HELP_FORMAT_MAN:
@ -729,5 +729,6 @@ int cmd_help(int argc,
break;
}

free(command);
return 0;
}

View File

@ -75,10 +75,12 @@ int cmd_init_db(int argc,
const char *prefix,
struct repository *repo UNUSED)
{
const char *git_dir;
char *git_dir;
const char *real_git_dir = NULL;
const char *work_tree;
char *real_git_dir_to_free = NULL;
char *work_tree = NULL;
const char *template_dir = NULL;
char *template_dir_to_free = NULL;
unsigned int flags = 0;
const char *object_format = NULL;
const char *ref_format = NULL;
@ -106,6 +108,7 @@ int cmd_init_db(int argc,
N_("specify the reference format to use")),
OPT_END()
};
int ret;

argc = parse_options(argc, argv, prefix, init_db_options, init_db_usage, 0);

@ -113,12 +116,10 @@ int cmd_init_db(int argc,
die(_("options '%s' and '%s' cannot be used together"), "--separate-git-dir", "--bare");

if (real_git_dir && !is_absolute_path(real_git_dir))
real_git_dir = real_pathdup(real_git_dir, 1);
real_git_dir = real_git_dir_to_free = real_pathdup(real_git_dir, 1);

if (template_dir && *template_dir && !is_absolute_path(template_dir)) {
template_dir = absolute_pathdup(template_dir);
UNLEAK(template_dir);
}
if (template_dir && *template_dir && !is_absolute_path(template_dir))
template_dir = template_dir_to_free = absolute_pathdup(template_dir);

if (argc == 1) {
int mkdir_tried = 0;
@ -192,7 +193,7 @@ int cmd_init_db(int argc,
* Set up the default .git directory contents
*/
if (!git_dir)
git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
git_dir = xstrdup(DEFAULT_GIT_DIR_ENVIRONMENT);

/*
* When --separate-git-dir is used inside a linked worktree, take
@ -213,6 +214,7 @@ int cmd_init_db(int argc,
if (chdir(mainwt.buf) < 0)
die_errno(_("cannot chdir to %s"), mainwt.buf);
strbuf_release(&mainwt);
free(git_dir);
git_dir = strbuf_detach(&sb, NULL);
}
strbuf_release(&sb);
@ -245,12 +247,14 @@ int cmd_init_db(int argc,
set_git_work_tree(work_tree);
}

UNLEAK(real_git_dir);
UNLEAK(git_dir);
UNLEAK(work_tree);

flags |= INIT_DB_EXIST_OK;
return init_db(git_dir, real_git_dir, template_dir, hash_algo,
ref_storage_format, initial_branch,
init_shared_repository, flags);
ret = init_db(git_dir, real_git_dir, template_dir, hash_algo,
ref_storage_format, initial_branch,
init_shared_repository, flags);

free(template_dir_to_free);
free(real_git_dir_to_free);
free(work_tree);
free(git_dir);
return ret;
}

View File

@ -669,7 +669,7 @@ static void add_patterns_literal(int argc, const char **argv,
add_patterns_from_input(pl, argc, argv, use_stdin ? stdin : NULL);
}

static int modify_pattern_list(int argc, const char **argv, int use_stdin,
static int modify_pattern_list(struct strvec *args, int use_stdin,
enum modify_type m)
{
int result;
@ -679,13 +679,13 @@ static int modify_pattern_list(int argc, const char **argv, int use_stdin,
switch (m) {
case ADD:
if (core_sparse_checkout_cone)
add_patterns_cone_mode(argc, argv, pl, use_stdin);
add_patterns_cone_mode(args->nr, args->v, pl, use_stdin);
else
add_patterns_literal(argc, argv, pl, use_stdin);
add_patterns_literal(args->nr, args->v, pl, use_stdin);
break;

case REPLACE:
add_patterns_from_input(pl, argc, argv,
add_patterns_from_input(pl, args->nr, args->v,
use_stdin ? stdin : NULL);
break;
}
@ -706,12 +706,12 @@ static int modify_pattern_list(int argc, const char **argv, int use_stdin,
return result;
}

static void sanitize_paths(int argc, const char **argv,
static void sanitize_paths(struct strvec *args,
const char *prefix, int skip_checks)
{
int i;

if (!argc)
if (!args->nr)
return;

if (prefix && *prefix && core_sparse_checkout_cone) {
@ -721,8 +721,11 @@ static void sanitize_paths(int argc, const char **argv,
*/
int prefix_len = strlen(prefix);

for (i = 0; i < argc; i++)
argv[i] = prefix_path(prefix, prefix_len, argv[i]);
for (i = 0; i < args->nr; i++) {
char *prefixed_path = prefix_path(prefix, prefix_len, args->v[i]);
strvec_replace(args, i, prefixed_path);
free(prefixed_path);
}
}

if (skip_checks)
@ -732,20 +735,20 @@ static void sanitize_paths(int argc, const char **argv,
die(_("please run from the toplevel directory in non-cone mode"));

if (core_sparse_checkout_cone) {
for (i = 0; i < argc; i++) {
if (argv[i][0] == '/')
for (i = 0; i < args->nr; i++) {
if (args->v[i][0] == '/')
die(_("specify directories rather than patterns (no leading slash)"));
if (argv[i][0] == '!')
if (args->v[i][0] == '!')
die(_("specify directories rather than patterns. If your directory starts with a '!', pass --skip-checks"));
if (strpbrk(argv[i], "*?[]"))
if (strpbrk(args->v[i], "*?[]"))
die(_("specify directories rather than patterns. If your directory really has any of '*?[]\\' in it, pass --skip-checks"));
}
}

for (i = 0; i < argc; i++) {
for (i = 0; i < args->nr; i++) {
struct cache_entry *ce;
struct index_state *index = the_repository->index;
int pos = index_name_pos(index, argv[i], strlen(argv[i]));
int pos = index_name_pos(index, args->v[i], strlen(args->v[i]));

if (pos < 0)
continue;
@ -754,9 +757,9 @@ static void sanitize_paths(int argc, const char **argv,
continue;

if (core_sparse_checkout_cone)
die(_("'%s' is not a directory; to treat it as a directory anyway, rerun with --skip-checks"), argv[i]);
die(_("'%s' is not a directory; to treat it as a directory anyway, rerun with --skip-checks"), args->v[i]);
else
warning(_("pass a leading slash before paths such as '%s' if you want a single file (see NON-CONE PROBLEMS in the git-sparse-checkout manual)."), argv[i]);
warning(_("pass a leading slash before paths such as '%s' if you want a single file (see NON-CONE PROBLEMS in the git-sparse-checkout manual)."), args->v[i]);
}
}

@ -780,6 +783,8 @@ static int sparse_checkout_add(int argc, const char **argv, const char *prefix)
N_("read patterns from standard in")),
OPT_END(),
};
struct strvec patterns = STRVEC_INIT;
int ret;

setup_work_tree();
if (!core_apply_sparse_checkout)
@ -791,9 +796,14 @@ static int sparse_checkout_add(int argc, const char **argv, const char *prefix)
builtin_sparse_checkout_add_options,
builtin_sparse_checkout_add_usage, 0);

sanitize_paths(argc, argv, prefix, add_opts.skip_checks);
for (int i = 0; i < argc; i++)
strvec_push(&patterns, argv[i]);
sanitize_paths(&patterns, prefix, add_opts.skip_checks);

return modify_pattern_list(argc, argv, add_opts.use_stdin, ADD);
ret = modify_pattern_list(&patterns, add_opts.use_stdin, ADD);

strvec_clear(&patterns);
return ret;
}

static char const * const builtin_sparse_checkout_set_usage[] = {
@ -826,6 +836,8 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix)
PARSE_OPT_NONEG),
OPT_END(),
};
struct strvec patterns = STRVEC_INIT;
int ret;

setup_work_tree();
repo_read_index(the_repository);
@ -846,13 +858,18 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix)
* top-level directory (much as 'init' would do).
*/
if (!core_sparse_checkout_cone && !set_opts.use_stdin && argc == 0) {
argv = default_patterns;
argc = default_patterns_nr;
for (int i = 0; i < default_patterns_nr; i++)
strvec_push(&patterns, default_patterns[i]);
} else {
sanitize_paths(argc, argv, prefix, set_opts.skip_checks);
for (int i = 0; i < argc; i++)
strvec_push(&patterns, argv[i]);
sanitize_paths(&patterns, prefix, set_opts.skip_checks);
}

return modify_pattern_list(argc, argv, set_opts.use_stdin, REPLACE);
ret = modify_pattern_list(&patterns, set_opts.use_stdin, REPLACE);

strvec_clear(&patterns);
return ret;
}

static char const * const builtin_sparse_checkout_reapply_usage[] = {

View File

@ -384,7 +384,6 @@ linux-musl)
;;
linux-leaks|linux-reftable-leaks)
export SANITIZE=leak
export GIT_TEST_PASSING_SANITIZE_LEAK=true
;;
linux-asan-ubsan)
export SANITIZE=address,undefined

View File

@ -1527,26 +1527,6 @@ int cmd_main(int, const char **);
int common_exit(const char *file, int line, int code);
#define exit(code) exit(common_exit(__FILE__, __LINE__, (code)))

/*
* You can mark a stack variable with UNLEAK(var) to avoid it being
* reported as a leak by tools like LSAN or valgrind. The argument
* should generally be the variable itself (not its address and not what
* it points to). It's safe to use this on pointers which may already
* have been freed, or on pointers which may still be in use.
*
* Use this _only_ for a variable that leaks by going out of scope at
* program exit (so only from cmd_* functions or their direct helpers).
* Normal functions, especially those which may be called multiple
* times, should actually free their memory. This is only meant as
* an annotation, and does nothing in non-leak-checking builds.
*/
#ifdef SUPPRESS_ANNOTATED_LEAKS
void unleak_memory(const void *ptr, size_t len);
#define UNLEAK(var) unleak_memory(&(var), sizeof(var))
#else
#define UNLEAK(var) do {} while (0)
#endif

#define z_const
#include <zlib.h>


122
git.c
View File

@ -362,7 +362,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
return (*argv) - orig_argv;
}

static int handle_alias(int *argcp, const char ***argv)
static int handle_alias(struct strvec *args)
{
int envchanged = 0, ret = 0, saved_errno = errno;
int count, option_count;
@ -370,10 +370,10 @@ static int handle_alias(int *argcp, const char ***argv)
const char *alias_command;
char *alias_string;

alias_command = (*argv)[0];
alias_command = args->v[0];
alias_string = alias_lookup(alias_command);
if (alias_string) {
if (*argcp > 1 && !strcmp((*argv)[1], "-h"))
if (args->nr > 1 && !strcmp(args->v[1], "-h"))
fprintf_ln(stderr, _("'%s' is aliased to '%s'"),
alias_command, alias_string);
if (alias_string[0] == '!') {
@ -390,7 +390,7 @@ static int handle_alias(int *argcp, const char ***argv)
child.wait_after_clean = 1;
child.trace2_child_class = "shell_alias";
strvec_push(&child.args, alias_string + 1);
strvec_pushv(&child.args, (*argv) + 1);
strvec_pushv(&child.args, args->v + 1);

trace2_cmd_alias(alias_command, child.args.v);
trace2_cmd_name("_run_shell_alias_");
@ -423,15 +423,13 @@ static int handle_alias(int *argcp, const char ***argv)
trace_argv_printf(new_argv,
"trace: alias expansion: %s =>",
alias_command);

REALLOC_ARRAY(new_argv, count + *argcp);
/* insert after command name */
COPY_ARRAY(new_argv + count, *argv + 1, *argcp);

trace2_cmd_alias(alias_command, new_argv);

*argv = new_argv;
*argcp += count - 1;
/* Replace the alias with the new arguments. */
strvec_splice(args, 0, 1, new_argv, count);

free(alias_string);
free(new_argv);

ret = 1;
}
@ -698,63 +696,57 @@ void load_builtin_commands(const char *prefix, struct cmdnames *cmds)
}

#ifdef STRIP_EXTENSION
static void strip_extension(const char **argv)
static void strip_extension(struct strvec *args)
{
size_t len;

if (strip_suffix(argv[0], STRIP_EXTENSION, &len))
argv[0] = xmemdupz(argv[0], len);
if (strip_suffix(args->v[0], STRIP_EXTENSION, &len)) {
char *stripped = xmemdupz(args->v[0], len);
strvec_replace(args, 0, stripped);
free(stripped);
}
}
#else
#define strip_extension(cmd)
#endif

static void handle_builtin(int argc, const char **argv)
static void handle_builtin(struct strvec *args)
{
struct strvec args = STRVEC_INIT;
const char **argv_copy = NULL;
const char *cmd;
struct cmd_struct *builtin;

strip_extension(argv);
cmd = argv[0];
strip_extension(args);
cmd = args->v[0];

/* Turn "git cmd --help" into "git help --exclude-guides cmd" */
if (argc > 1 && !strcmp(argv[1], "--help")) {
int i;
if (args->nr > 1 && !strcmp(args->v[1], "--help")) {
const char *exclude_guides_arg[] = { "--exclude-guides" };

argv[1] = argv[0];
argv[0] = cmd = "help";
strvec_replace(args, 1, args->v[0]);
strvec_replace(args, 0, "help");
cmd = "help";
strvec_splice(args, 2, 0, exclude_guides_arg,
ARRAY_SIZE(exclude_guides_arg));
}

for (i = 0; i < argc; i++) {
strvec_push(&args, argv[i]);
if (!i)
strvec_push(&args, "--exclude-guides");
}

argc++;
builtin = get_builtin(cmd);
if (builtin) {
const char **argv_copy = NULL;
int ret;

/*
* `run_builtin()` will modify the argv array, so we need to
* create a shallow copy such that we can free all of its
* strings.
*/
CALLOC_ARRAY(argv_copy, argc + 1);
COPY_ARRAY(argv_copy, args.v, argc);
if (args->nr)
DUP_ARRAY(argv_copy, args->v, args->nr + 1);

argv = argv_copy;
}

builtin = get_builtin(cmd);
if (builtin) {
int ret = run_builtin(builtin, argc, argv, the_repository);
strvec_clear(&args);
ret = run_builtin(builtin, args->nr, argv_copy, the_repository);
strvec_clear(args);
free(argv_copy);
exit(ret);
}

strvec_clear(&args);
free(argv_copy);
}

static void execv_dashed_external(const char **argv)
@ -800,10 +792,10 @@ static void execv_dashed_external(const char **argv)
exit(128);
}

static int run_argv(int *argcp, const char ***argv)
static int run_argv(struct strvec *args)
{
int done_alias = 0;
struct string_list cmd_list = STRING_LIST_INIT_NODUP;
struct string_list cmd_list = STRING_LIST_INIT_DUP;
struct string_list_item *seen;

while (1) {
@ -817,8 +809,8 @@ static int run_argv(int *argcp, const char ***argv)
* process.
*/
if (!done_alias)
handle_builtin(*argcp, *argv);
else if (get_builtin(**argv)) {
handle_builtin(args);
else if (get_builtin(args->v[0])) {
struct child_process cmd = CHILD_PROCESS_INIT;
int i;

@ -834,8 +826,8 @@ static int run_argv(int *argcp, const char ***argv)
commit_pager_choice();

strvec_push(&cmd.args, "git");
for (i = 0; i < *argcp; i++)
strvec_push(&cmd.args, (*argv)[i]);
for (i = 0; i < args->nr; i++)
strvec_push(&cmd.args, args->v[i]);

trace_argv_printf(cmd.args.v, "trace: exec:");

@ -850,13 +842,13 @@ static int run_argv(int *argcp, const char ***argv)
i = run_command(&cmd);
if (i >= 0 || errno != ENOENT)
exit(i);
die("could not execute builtin %s", **argv);
die("could not execute builtin %s", args->v[0]);
}

/* .. then try the external ones */
execv_dashed_external(*argv);
execv_dashed_external(args->v);

seen = unsorted_string_list_lookup(&cmd_list, *argv[0]);
seen = unsorted_string_list_lookup(&cmd_list, args->v[0]);
if (seen) {
int i;
struct strbuf sb = STRBUF_INIT;
@ -873,14 +865,14 @@ static int run_argv(int *argcp, const char ***argv)
" not terminate:%s"), cmd_list.items[0].string, sb.buf);
}

string_list_append(&cmd_list, *argv[0]);
string_list_append(&cmd_list, args->v[0]);

/*
* It could be an alias -- this works around the insanity
* of overriding "git log" with "git show" by having
* alias.log = show
*/
if (!handle_alias(argcp, argv))
if (!handle_alias(args))
break;
done_alias = 1;
}
@ -892,6 +884,7 @@ static int run_argv(int *argcp, const char ***argv)

int cmd_main(int argc, const char **argv)
{
struct strvec args = STRVEC_INIT;
const char *cmd;
int done_help = 0;

@ -917,8 +910,10 @@ int cmd_main(int argc, const char **argv)
* that one cannot handle it.
*/
if (skip_prefix(cmd, "git-", &cmd)) {
argv[0] = cmd;
handle_builtin(argc, argv);
strvec_push(&args, cmd);
strvec_pushv(&args, argv + 1);
handle_builtin(&args);
strvec_clear(&args);
die(_("cannot handle %s as a builtin"), cmd);
}

@ -951,25 +946,34 @@ int cmd_main(int argc, const char **argv)
*/
setup_path();

for (size_t i = 0; i < argc; i++)
strvec_push(&args, argv[i]);

while (1) {
int was_alias = run_argv(&argc, &argv);
int was_alias = run_argv(&args);
if (errno != ENOENT)
break;
if (was_alias) {
fprintf(stderr, _("expansion of alias '%s' failed; "
"'%s' is not a git command\n"),
cmd, argv[0]);
cmd, args.v[0]);
strvec_clear(&args);
exit(1);
}
if (!done_help) {
cmd = argv[0] = help_unknown_cmd(cmd);
char *assumed = help_unknown_cmd(cmd);
strvec_replace(&args, 0, assumed);
free(assumed);
cmd = args.v[0];
done_help = 1;
} else
} else {
break;
}
}

fprintf(stderr, _("failed to run command '%s': %s\n"),
cmd, strerror(errno));
strvec_clear(&args);

return 1;
}

58
help.c
View File

@ -546,8 +546,10 @@ int is_in_cmdlist(struct cmdnames *c, const char *s)
return 0;
}

static int autocorrect;
static struct cmdnames aliases;
struct help_unknown_cmd_config {
int autocorrect;
struct cmdnames aliases;
};

#define AUTOCORRECT_PROMPT (-3)
#define AUTOCORRECT_NEVER (-2)
@ -555,28 +557,29 @@ static struct cmdnames aliases;

static int git_unknown_cmd_config(const char *var, const char *value,
const struct config_context *ctx,
void *cb UNUSED)
void *cb)
{
struct help_unknown_cmd_config *cfg = cb;
const char *p;

if (!strcmp(var, "help.autocorrect")) {
if (!value)
return config_error_nonbool(var);
if (!strcmp(value, "never")) {
autocorrect = AUTOCORRECT_NEVER;
cfg->autocorrect = AUTOCORRECT_NEVER;
} else if (!strcmp(value, "immediate")) {
autocorrect = AUTOCORRECT_IMMEDIATELY;
cfg->autocorrect = AUTOCORRECT_IMMEDIATELY;
} else if (!strcmp(value, "prompt")) {
autocorrect = AUTOCORRECT_PROMPT;
cfg->autocorrect = AUTOCORRECT_PROMPT;
} else {
int v = git_config_int(var, value, ctx->kvi);
autocorrect = (v < 0)
cfg->autocorrect = (v < 0)
? AUTOCORRECT_IMMEDIATELY : v;
}
}
/* Also use aliases for command lookup */
if (skip_prefix(var, "alias.", &p))
add_cmdname(&aliases, p, strlen(p));
add_cmdname(&cfg->aliases, p, strlen(p));

return 0;
}
@ -609,32 +612,30 @@ static const char bad_interpreter_advice[] =
N_("'%s' appears to be a git command, but we were not\n"
"able to execute it. Maybe git-%s is broken?");

const char *help_unknown_cmd(const char *cmd)
char *help_unknown_cmd(const char *cmd)
{
struct help_unknown_cmd_config cfg = { 0 };
int i, n, best_similarity = 0;
struct cmdnames main_cmds, other_cmds;
struct cmdnames main_cmds = { 0 };
struct cmdnames other_cmds = { 0 };
struct cmdname_help *common_cmds;

memset(&main_cmds, 0, sizeof(main_cmds));
memset(&other_cmds, 0, sizeof(other_cmds));
memset(&aliases, 0, sizeof(aliases));

read_early_config(the_repository, git_unknown_cmd_config, NULL);
read_early_config(the_repository, git_unknown_cmd_config, &cfg);

/*
* Disable autocorrection prompt in a non-interactive session
*/
if ((autocorrect == AUTOCORRECT_PROMPT) && (!isatty(0) || !isatty(2)))
autocorrect = AUTOCORRECT_NEVER;
if ((cfg.autocorrect == AUTOCORRECT_PROMPT) && (!isatty(0) || !isatty(2)))
cfg.autocorrect = AUTOCORRECT_NEVER;

if (autocorrect == AUTOCORRECT_NEVER) {
if (cfg.autocorrect == AUTOCORRECT_NEVER) {
fprintf_ln(stderr, _("git: '%s' is not a git command. See 'git --help'."), cmd);
exit(1);
}

load_command_list("git-", &main_cmds, &other_cmds);

add_cmd_list(&main_cmds, &aliases);
add_cmd_list(&main_cmds, &cfg.aliases);
add_cmd_list(&main_cmds, &other_cmds);
QSORT(main_cmds.names, main_cmds.cnt, cmdname_compare);
uniq(&main_cmds);
@ -693,20 +694,19 @@ const char *help_unknown_cmd(const char *cmd)
n++)
; /* still counting */
}
if (autocorrect && n == 1 && SIMILAR_ENOUGH(best_similarity)) {
const char *assumed = main_cmds.names[0]->name;
main_cmds.names[0] = NULL;
cmdnames_release(&main_cmds);
if (cfg.autocorrect && n == 1 && SIMILAR_ENOUGH(best_similarity)) {
char *assumed = xstrdup(main_cmds.names[0]->name);

fprintf_ln(stderr,
_("WARNING: You called a Git command named '%s', "
"which does not exist."),
cmd);
if (autocorrect == AUTOCORRECT_IMMEDIATELY)
if (cfg.autocorrect == AUTOCORRECT_IMMEDIATELY)
fprintf_ln(stderr,
_("Continuing under the assumption that "
"you meant '%s'."),
assumed);
else if (autocorrect == AUTOCORRECT_PROMPT) {
else if (cfg.autocorrect == AUTOCORRECT_PROMPT) {
char *answer;
struct strbuf msg = STRBUF_INIT;
strbuf_addf(&msg, _("Run '%s' instead [y/N]? "), assumed);
@ -719,9 +719,13 @@ const char *help_unknown_cmd(const char *cmd)
fprintf_ln(stderr,
_("Continuing in %0.1f seconds, "
"assuming that you meant '%s'."),
(float)autocorrect/10.0, assumed);
sleep_millisec(autocorrect * 100);
(float)cfg.autocorrect/10.0, assumed);
sleep_millisec(cfg.autocorrect * 100);
}

cmdnames_release(&cfg.aliases);
cmdnames_release(&main_cmds);
cmdnames_release(&other_cmds);
return assumed;
}


2
help.h
View File

@ -32,7 +32,7 @@ void list_all_other_cmds(struct string_list *list);
void list_cmds_by_category(struct string_list *list,
const char *category);
void list_cmds_by_config(struct string_list *list);
const char *help_unknown_cmd(const char *cmd);
char *help_unknown_cmd(const char *cmd);
void load_command_list(const char *prefix,
struct cmdnames *main_cmds,
struct cmdnames *other_cmds);

View File

@ -1237,6 +1237,7 @@ static int process_ranges_merge_commit(struct rev_info *rev, struct commit *comm
* don't follow any other path in history
*/
add_line_range(rev, parents[i], cand[i]);
free_commit_list(commit->parents);
commit_list_append(parents[i], &commit->parents);

ret = 0;

View File

@ -51,8 +51,8 @@

volatile show_early_output_fn_t show_early_output;

static const char *term_bad;
static const char *term_good;
static char *term_bad;
static char *term_good;

implement_shared_commit_slab(revision_sources, char *);


View File

@ -97,7 +97,11 @@ void move_cache_to_base_index(struct index_state *istate)
mem_pool_combine(istate->ce_mem_pool, istate->split_index->base->ce_mem_pool);
}

ALLOC_ARRAY(si->base, 1);
if (si->base)
release_index(si->base);
else
ALLOC_ARRAY(si->base, 1);

index_state_init(si->base, istate->repo);
si->base->version = istate->version;
/* zero timestamp disables racy test in ce_write_index() */

View File

@ -56,6 +56,25 @@ void strvec_pushv(struct strvec *array, const char **items)
strvec_push(array, *items);
}

void strvec_splice(struct strvec *array, size_t idx, size_t len,
const char **replacement, size_t replacement_len)
{
if (idx + len > array->nr)
BUG("range outside of array boundary");
if (replacement_len > len)
ALLOC_GROW(array->v, array->nr + (replacement_len - len) + 1,
array->alloc);
for (size_t i = 0; i < len; i++)
free((char *)array->v[idx + i]);
if (replacement_len != len) {
memmove(array->v + idx + replacement_len, array->v + idx + len,
(array->nr - idx - len + 1) * sizeof(char *));
array->nr += (replacement_len - len);
}
for (size_t i = 0; i < replacement_len; i++)
array->v[idx + i] = xstrdup(replacement[i]);
}

const char *strvec_replace(struct strvec *array, size_t idx, const char *replacement)
{
char *to_free;

View File

@ -67,6 +67,15 @@ void strvec_pushl(struct strvec *, ...);
/* Push a null-terminated array of strings onto the end of the array. */
void strvec_pushv(struct strvec *, const char **);

/*
* Replace `len` values starting at `idx` with the provided replacement
* strings. If `len` is zero this is effectively an insert at the given `idx`.
* If `replacement_len` is zero this is effectively a delete of `len` items
* starting at `idx`.
*/
void strvec_splice(struct strvec *array, size_t idx, size_t len,
const char **replacement, size_t replacement_len);

/**
* Replace the value at the given index with a new value. The index must be
* valid. Returns a pointer to the inserted value.

View File

@ -368,27 +368,6 @@ excluded as so much relies on it, but this might change in the future.
GIT_TEST_SPLIT_INDEX=<boolean> forces split-index mode on the whole
test suite. Accept any boolean values that are accepted by git-config.

GIT_TEST_PASSING_SANITIZE_LEAK=true skips those tests that haven't
declared themselves as leak-free by setting
"TEST_PASSES_SANITIZE_LEAK=true" before sourcing "test-lib.sh". This
test mode is used by the "linux-leaks" CI target.

GIT_TEST_PASSING_SANITIZE_LEAK=check checks that our
"TEST_PASSES_SANITIZE_LEAK=true" markings are current. Rather than
skipping those tests that haven't set "TEST_PASSES_SANITIZE_LEAK=true"
before sourcing "test-lib.sh" this mode runs them with
"--invert-exit-code". This is used to check that there's a one-to-one
mapping between "TEST_PASSES_SANITIZE_LEAK=true" and those tests that
pass under "SANITIZE=leak". This is especially useful when testing a
series that fixes various memory leaks with "git rebase -x".

GIT_TEST_PASSING_SANITIZE_LEAK=check when combined with "--immediate"
will run to completion faster, and result in the same failing
tests.

GIT_TEST_PASSING_SANITIZE_LEAK=check-failing behaves the same as "check",
but skips all tests which are already marked as leak-free.

GIT_TEST_PROTOCOL_VERSION=<n>, when set, makes 'protocol.version'
default to n.


View File

@ -97,7 +97,6 @@ int cmd__read_graph(int argc, const char **argv)
}

done:
UNLEAK(graph);

free_commit_graph(graph);
return ret;
}

View File

@ -1,7 +1,3 @@
if test -z "$TEST_FAILS_SANITIZE_LEAK"
then
TEST_PASSES_SANITIZE_LEAK=true
fi
. ./test-lib.sh

if test -n "$NO_SVN_TESTS"

View File

@ -2,7 +2,6 @@

test_description='git init'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

check_config () {

View File

@ -7,7 +7,6 @@ Verify that plumbing commands work when .git is a file
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

objpath() {

View File

@ -2,7 +2,6 @@

test_description=gitattributes

TEST_PASSES_SANITIZE_LEAK=true
TEST_CREATE_REPO_NO_TEMPLATE=1
. ./test-lib.sh


View File

@ -2,7 +2,6 @@

test_description='detect unwritable repository and fail correctly'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success setup '

View File

@ -2,7 +2,6 @@

test_description='signals work as we expect'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

cat >expect <<EOF

View File

@ -2,7 +2,6 @@

test_description='test date parsing and printing'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

# arbitrary reference time: 2009-08-30 19:20:00

View File

@ -2,7 +2,6 @@

test_description='basic sanity checks for git var'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

sane_unset_all_editors () {

View File

@ -2,7 +2,6 @@

test_description=check-ignore

TEST_PASSES_SANITIZE_LEAK=true
TEST_CREATE_REPO_NO_TEMPLATE=1
. ./test-lib.sh


View File

@ -2,7 +2,6 @@

test_description='racy GIT'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

# This test can give false success if your machine is sufficiently

View File

@ -2,7 +2,6 @@

test_description='help'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

configure_help () {

View File

@ -2,7 +2,6 @@

test_description='test sha1 collision detection'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
TEST_DATA="$TEST_DIRECTORY/t0013"


View File

@ -2,7 +2,6 @@

test_description='test test-tool env-helper'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh



View File

@ -5,7 +5,6 @@ test_description='Test advise_if_enabled functionality'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=trunk
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'advice should be printed when config variable is unset' '

View File

@ -2,7 +2,6 @@

test_description='test json-writer JSON generation'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'unit test of json-writer routines' '

View File

@ -5,7 +5,6 @@ test_description='CRLF conversion'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

has_cr() {

View File

@ -5,7 +5,6 @@ test_description='blob conversion via gitattributes'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-terminal.sh


View File

@ -2,7 +2,6 @@

test_description='ignore CR in CRLF sequence while computing similiarity'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success setup '

View File

@ -2,7 +2,6 @@

test_description='Test am with auto.crlf'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

cat >patchfile <<\EOF

View File

@ -2,7 +2,6 @@

test_description='respect crlf in git archive'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success setup '

View File

@ -2,7 +2,6 @@

test_description='CRLF renormalization'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success setup '

View File

@ -2,7 +2,6 @@

test_description='CRLF conversion'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

has_cr() {

View File

@ -2,7 +2,6 @@

test_description='CRLF conversion all combinations'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

compare_files () {

View File

@ -5,7 +5,6 @@ test_description='working-tree-encoding conversion via gitattributes'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

TEST_PASSES_SANITIZE_LEAK=true
TEST_CREATE_REPO_NO_TEMPLATE=1
. ./test-lib.sh
. "$TEST_DIRECTORY/lib-encoding.sh"

View File

@ -2,7 +2,6 @@

test_description='test the Windows-only core.unsetenvvars setting'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

if ! test_have_prereq MINGW

View File

@ -5,7 +5,6 @@

test_description='git stripspace'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

t40='A quick brown fox jumps over the lazy do'

View File

@ -2,7 +2,6 @@

test_description='verify safe.directory checks'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

GIT_TEST_ASSUME_DIFFERENT_OWNER=1

View File

@ -2,7 +2,6 @@

test_description='verify safe.bareRepository checks'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

pwd="$(pwd)"

View File

@ -5,7 +5,6 @@

test_description='our own option parser'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

cat >expect <<\EOF

View File

@ -5,7 +5,6 @@ test_description='Test commands behavior when given invalid argument value'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'setup ' '

View File

@ -5,7 +5,6 @@ test_description='Various filesystem issues'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

auml=$(printf '\303\244')

View File

@ -2,7 +2,6 @@

test_description='simple command server'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test-tool simple-ipc SUPPORTS_SIMPLE_IPC || {

View File

@ -2,7 +2,6 @@

test_description='update-index and add refuse to add beyond symlinks'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success SYMLINKS setup '

View File

@ -2,7 +2,6 @@

test_description='"-C <path>" option and its effects on other path-related options'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success '"git -C <path>" runs git from the directory <path>' '

View File

@ -5,7 +5,6 @@

test_description='Test various path utilities'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

norm_path() {

View File

@ -5,7 +5,6 @@

test_description='Test run command'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

cat >hello-script <<-EOF

View File

@ -5,7 +5,6 @@

test_description='Test revision walking api'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

cat >run_twice_expected <<-EOF

View File

@ -5,7 +5,6 @@

test_description='Test string list functionality'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_split () {

View File

@ -2,7 +2,6 @@

test_description='Test the dir-iterator functionality'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'setup' '

View File

@ -2,7 +2,6 @@

test_description='Test parse_pathspec_file()'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'one item from stdin' '

View File

@ -2,7 +2,6 @@

test_description='git for-each-repo builtin'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'run based on configured value' '

View File

@ -6,7 +6,6 @@ test_description='check that the most basic functions work
Verify wrappers and compatibility functions.
'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'mktemp to nonexistent directory prints filename' '

View File

@ -2,7 +2,6 @@

test_description='verify sort functions'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'DEFINE_LIST_SORT_DEBUG' '

View File

@ -2,7 +2,6 @@

test_description='Test the output of the unit test framework'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'TAP output from unit tests' - <<\EOT

View File

@ -2,7 +2,6 @@

test_description='test `test-tool find-pack`'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'setup' '

View File

@ -6,7 +6,6 @@ Tests whether various commands properly update and/or rewrite the
cache-tree extension.
"

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

cmp_cache_tree () {

View File

@ -2,7 +2,6 @@

test_description='git bugreport'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'create a report' '

View File

@ -2,7 +2,6 @@

test_description='git diagnose'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success UNZIP 'creates diagnostics zip archive' '

View File

@ -2,7 +2,6 @@

test_description='Testing the various Bloom filter computations in bloom.c'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'compute unseeded murmur3 hash for empty string' '
@ -77,7 +76,7 @@ test_expect_success 'compute bloom key for test string 2' '
test_cmp expect actual
'

test_expect_success !SANITIZE_LEAK 'get bloom filters for commit with no changes' '
test_expect_success 'get bloom filters for commit with no changes' '
git init &&
git commit --allow-empty -m "c0" &&
cat >expect <<-\EOF &&

View File

@ -5,7 +5,6 @@ test_description='previous branch syntax @{-n}'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'branch -d @{-1}' '

View File

@ -2,7 +2,6 @@

test_description='various @{whatever} syntax tests'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'setup' '

View File

@ -5,7 +5,6 @@

test_description='Gettext support for Git'

TEST_PASSES_SANITIZE_LEAK=true
. ./lib-gettext.sh

test_expect_success "sanity: \$GIT_INTERNAL_GETTEXT_SH_SCHEME is set (to $GIT_INTERNAL_GETTEXT_SH_SCHEME)" '

View File

@ -8,7 +8,6 @@ test_description='Gettext Shell fallbacks'
GIT_INTERNAL_GETTEXT_TEST_FALLBACKS=YesPlease
export GIT_INTERNAL_GETTEXT_TEST_FALLBACKS

TEST_PASSES_SANITIZE_LEAK=true
. ./lib-gettext.sh

test_expect_success "sanity: \$GIT_INTERNAL_GETTEXT_SH_SCHEME is set (to $GIT_INTERNAL_GETTEXT_SH_SCHEME)" '

View File

@ -5,7 +5,6 @@

test_description='Perl gettext interface (Git::I18N)'

TEST_PASSES_SANITIZE_LEAK=true
. ./lib-gettext.sh
. "$TEST_DIRECTORY"/lib-perl.sh
skip_all_if_no_Test_More

View File

@ -5,7 +5,6 @@

test_description="The Git C functions aren't broken by setlocale(3)"

TEST_PASSES_SANITIZE_LEAK=true
. ./lib-gettext.sh

test_expect_success 'git show a ISO-8859-1 commit under C locale' '

View File

@ -5,7 +5,6 @@

test_description="Gettext reencoding of our *.po/*.mo files works"

TEST_PASSES_SANITIZE_LEAK=true
. ./lib-gettext.sh

# The constants used in a tricky observation for undefined behaviour

View File

@ -2,7 +2,6 @@

test_description='test trace2 facility (normal target)'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

# Turn off any inherited trace2 settings for this test.

View File

@ -2,7 +2,6 @@

test_description='test trace2 facility (perf target)'

TEST_PASSES_SANITIZE_LEAK=false
. ./test-lib.sh

# Turn off any inherited trace2 settings for this test.

View File

@ -2,7 +2,6 @@

test_description='test trace2 facility'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

# Turn off any inherited trace2 settings for this test.

View File

@ -2,7 +2,6 @@

test_description='basic credential helper tests'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-credential.sh


View File

@ -2,7 +2,6 @@

test_description='credential-cache tests'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-credential.sh


View File

@ -2,7 +2,6 @@

test_description='credential-store tests'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-credential.sh


View File

@ -29,7 +29,6 @@ you can set GIT_TEST_CREDENTIAL_HELPER_SETUP to a sequence of shell
commands.
'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-credential.sh


View File

@ -2,7 +2,6 @@

test_description='partial clone'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-terminal.sh


View File

@ -2,7 +2,6 @@

test_description='check that local clone does not fetch from promisor remotes'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'create evil repo' '

View File

@ -5,7 +5,6 @@ test_description='assert (unbuilt) Documentation/*.txt and -h output
Run this with --debug to see a summary of where we still fail to make
the two versions consistent with one another.'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'setup: list of builtins' '

View File

@ -2,7 +2,6 @@

test_description='progress display'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

show_cr () {

View File

@ -7,7 +7,6 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
GIT_TEST_DEFAULT_REF_FORMAT=files
export GIT_TEST_DEFAULT_REF_FORMAT

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'setup' '

View File

@ -15,7 +15,6 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
GIT_TEST_DEFAULT_REF_FORMAT=files
export GIT_TEST_DEFAULT_REF_FORMAT

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'enable reflogs' '

View File

@ -6,7 +6,6 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
GIT_TEST_DEFAULT_REF_FORMAT=files
export GIT_TEST_DEFAULT_REF_FORMAT
TEST_PASSES_SANITIZE_LEAK=true

. ./test-lib.sh


View File

@ -10,7 +10,6 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
GIT_TEST_DEFAULT_REF_FORMAT=reftable
export GIT_TEST_DEFAULT_REF_FORMAT

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

INVALID_OID=$(test_oid 001)

View File

@ -2,7 +2,6 @@

test_description='reftable HTTPD tests'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-httpd.sh


View File

@ -11,7 +11,6 @@ export GIT_TEST_DEFAULT_REF_FORMAT
GIT_TEST_SPLIT_INDEX=0
export GIT_TEST_SPLIT_INDEX

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

if ! test_have_prereq JGIT

View File

@ -16,7 +16,6 @@ export GIT_TEST_DEFAULT_HASH
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'default write options' '

View File

@ -72,7 +72,6 @@ In addition:

'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-read-tree.sh
. "$TEST_DIRECTORY"/lib-read-tree-m-3way.sh

View File

@ -21,7 +21,6 @@ In the test, these paths are used:
yomin - not in H or M
'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-read-tree.sh


View File

@ -9,7 +9,6 @@ This is identical to t1001, but uses -u to update the work tree as well.

'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-read-tree.sh


Some files were not shown because too many files have changed in this diff Show More