mirror of
https://github.com/git/git.git
synced 2024-11-23 09:56:28 +08:00
Merge branch 'ps/leakfixes-part-9'
More leakfixes. * ps/leakfixes-part-9: (22 commits) list-objects-filter-options: work around reported leak on error builtin/merge: release output buffer after performing merge dir: fix leak when parsing "status.showUntrackedFiles" t/helper: fix leaking buffer in "dump-untracked-cache" t/helper: stop re-initialization of `the_repository` sparse-index: correctly free EWAH contents dir: release untracked cache data combine-diff: fix leaking lost lines builtin/tag: fix leaking key ID on failure to sign transport-helper: fix leaking import/export marks builtin/commit: fix leaking cleanup config trailer: fix leaking strbufs when formatting trailers trailer: fix leaking trailer values builtin/commit: fix leaking change data contents upload-pack: fix leaking URI protocols pretty: clear signature check diff-lib: fix leaking diffopts in `do_diff_cache()` revision: fix leaking bloom filters builtin/grep: fix leak with `--max-count=0` grep: fix leak in `grep_splice_or()` ...
This commit is contained in:
commit
6890c99e38
@ -135,7 +135,7 @@ static struct strvec trailer_args = STRVEC_INIT;
|
|||||||
* is specified explicitly.
|
* is specified explicitly.
|
||||||
*/
|
*/
|
||||||
static enum commit_msg_cleanup_mode cleanup_mode;
|
static enum commit_msg_cleanup_mode cleanup_mode;
|
||||||
static char *cleanup_arg;
|
static char *cleanup_config;
|
||||||
|
|
||||||
static enum commit_whence whence;
|
static enum commit_whence whence;
|
||||||
static int use_editor = 1, include_status = 1;
|
static int use_editor = 1, include_status = 1;
|
||||||
@ -728,6 +728,13 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb,
|
|||||||
repo_unuse_commit_buffer(the_repository, commit, buffer);
|
repo_unuse_commit_buffer(the_repository, commit, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void change_data_free(void *util, const char *str UNUSED)
|
||||||
|
{
|
||||||
|
struct wt_status_change_data *d = util;
|
||||||
|
free(d->rename_source);
|
||||||
|
free(d);
|
||||||
|
}
|
||||||
|
|
||||||
static int prepare_to_commit(const char *index_file, const char *prefix,
|
static int prepare_to_commit(const char *index_file, const char *prefix,
|
||||||
struct commit *current_head,
|
struct commit *current_head,
|
||||||
struct wt_status *s,
|
struct wt_status *s,
|
||||||
@ -991,7 +998,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
|
|||||||
s->use_color = 0;
|
s->use_color = 0;
|
||||||
committable = run_status(s->fp, index_file, prefix, 1, s);
|
committable = run_status(s->fp, index_file, prefix, 1, s);
|
||||||
s->use_color = saved_color_setting;
|
s->use_color = saved_color_setting;
|
||||||
string_list_clear(&s->change, 1);
|
string_list_clear_func(&s->change, change_data_free);
|
||||||
} else {
|
} else {
|
||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
const char *parent = "HEAD";
|
const char *parent = "HEAD";
|
||||||
@ -1380,8 +1387,6 @@ static int parse_and_validate_options(int argc, const char *argv[],
|
|||||||
if (0 <= edit_flag)
|
if (0 <= edit_flag)
|
||||||
use_editor = edit_flag;
|
use_editor = edit_flag;
|
||||||
|
|
||||||
cleanup_mode = get_cleanup_mode(cleanup_arg, use_editor);
|
|
||||||
|
|
||||||
handle_untracked_files_arg(s);
|
handle_untracked_files_arg(s);
|
||||||
|
|
||||||
if (all && argc > 0)
|
if (all && argc > 0)
|
||||||
@ -1629,8 +1634,10 @@ static int git_commit_config(const char *k, const char *v,
|
|||||||
include_status = git_config_bool(k, v);
|
include_status = git_config_bool(k, v);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!strcmp(k, "commit.cleanup"))
|
if (!strcmp(k, "commit.cleanup")) {
|
||||||
return git_config_string(&cleanup_arg, k, v);
|
FREE_AND_NULL(cleanup_config);
|
||||||
|
return git_config_string(&cleanup_config, k, v);
|
||||||
|
}
|
||||||
if (!strcmp(k, "commit.gpgsign")) {
|
if (!strcmp(k, "commit.gpgsign")) {
|
||||||
sign_commit = git_config_bool(k, v) ? "" : NULL;
|
sign_commit = git_config_bool(k, v) ? "" : NULL;
|
||||||
return 0;
|
return 0;
|
||||||
@ -1651,6 +1658,7 @@ int cmd_commit(int argc,
|
|||||||
struct repository *repo UNUSED)
|
struct repository *repo UNUSED)
|
||||||
{
|
{
|
||||||
static struct wt_status s;
|
static struct wt_status s;
|
||||||
|
static const char *cleanup_arg = NULL;
|
||||||
static struct option builtin_commit_options[] = {
|
static struct option builtin_commit_options[] = {
|
||||||
OPT__QUIET(&quiet, N_("suppress summary after successful commit")),
|
OPT__QUIET(&quiet, N_("suppress summary after successful commit")),
|
||||||
OPT__VERBOSE(&verbose, N_("show diff in commit message template")),
|
OPT__VERBOSE(&verbose, N_("show diff in commit message template")),
|
||||||
@ -1750,6 +1758,12 @@ int cmd_commit(int argc,
|
|||||||
if (verbose == -1)
|
if (verbose == -1)
|
||||||
verbose = (config_commit_verbose < 0) ? 0 : config_commit_verbose;
|
verbose = (config_commit_verbose < 0) ? 0 : config_commit_verbose;
|
||||||
|
|
||||||
|
if (cleanup_arg) {
|
||||||
|
free(cleanup_config);
|
||||||
|
cleanup_config = xstrdup(cleanup_arg);
|
||||||
|
}
|
||||||
|
cleanup_mode = get_cleanup_mode(cleanup_config, use_editor);
|
||||||
|
|
||||||
if (dry_run)
|
if (dry_run)
|
||||||
return dry_run_commit(argv, prefix, current_head, &s);
|
return dry_run_commit(argv, prefix, current_head, &s);
|
||||||
index_file = prepare_index(argv, prefix, current_head, 0);
|
index_file = prepare_index(argv, prefix, current_head, 0);
|
||||||
|
@ -906,6 +906,7 @@ int cmd_grep(int argc,
|
|||||||
int dummy;
|
int dummy;
|
||||||
int use_index = 1;
|
int use_index = 1;
|
||||||
int allow_revs;
|
int allow_revs;
|
||||||
|
int ret;
|
||||||
|
|
||||||
struct option options[] = {
|
struct option options[] = {
|
||||||
OPT_BOOL(0, "cached", &cached,
|
OPT_BOOL(0, "cached", &cached,
|
||||||
@ -1172,8 +1173,10 @@ int cmd_grep(int argc,
|
|||||||
* Optimize out the case where the amount of matches is limited to zero.
|
* Optimize out the case where the amount of matches is limited to zero.
|
||||||
* We do this to keep results consistent with GNU grep(1).
|
* We do this to keep results consistent with GNU grep(1).
|
||||||
*/
|
*/
|
||||||
if (opt.max_count == 0)
|
if (opt.max_count == 0) {
|
||||||
return 1;
|
ret = 1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (show_in_pager) {
|
if (show_in_pager) {
|
||||||
if (num_threads > 1)
|
if (num_threads > 1)
|
||||||
@ -1267,10 +1270,14 @@ int cmd_grep(int argc,
|
|||||||
hit |= wait_all();
|
hit |= wait_all();
|
||||||
if (hit && show_in_pager)
|
if (hit && show_in_pager)
|
||||||
run_pager(&opt, prefix);
|
run_pager(&opt, prefix);
|
||||||
|
|
||||||
|
ret = !hit;
|
||||||
|
|
||||||
|
out:
|
||||||
clear_pathspec(&pathspec);
|
clear_pathspec(&pathspec);
|
||||||
string_list_clear(&path_list, 0);
|
string_list_clear(&path_list, 0);
|
||||||
free_grep_patterns(&opt);
|
free_grep_patterns(&opt);
|
||||||
object_array_clear(&list);
|
object_array_clear(&list);
|
||||||
free_repos();
|
free_repos();
|
||||||
return !hit;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -166,6 +166,7 @@ int cmd_ls_remote(int argc,
|
|||||||
status = 0; /* we found something */
|
status = 0; /* we found something */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string_list_clear(&server_options, 0);
|
||||||
ref_sorting_release(sorting);
|
ref_sorting_release(sorting);
|
||||||
ref_array_clear(&ref_array);
|
ref_array_clear(&ref_array);
|
||||||
if (transport_disconnect(transport))
|
if (transport_disconnect(transport))
|
||||||
|
@ -754,6 +754,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
|
|||||||
clean = merge_recursive(&o, head, remoteheads->item,
|
clean = merge_recursive(&o, head, remoteheads->item,
|
||||||
reversed, &result);
|
reversed, &result);
|
||||||
free_commit_list(reversed);
|
free_commit_list(reversed);
|
||||||
|
strbuf_release(&o.obuf);
|
||||||
|
|
||||||
if (clean < 0) {
|
if (clean < 0) {
|
||||||
rollback_lock_file(&lock);
|
rollback_lock_file(&lock);
|
||||||
|
@ -164,7 +164,7 @@ static int do_sign(struct strbuf *buffer, struct object_id **compat_oid,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (sign_buffer(buffer, &sig, keyid))
|
if (sign_buffer(buffer, &sig, keyid))
|
||||||
return -1;
|
goto out;
|
||||||
|
|
||||||
if (compat) {
|
if (compat) {
|
||||||
const struct git_hash_algo *algo = the_repository->hash_algo;
|
const struct git_hash_algo *algo = the_repository->hash_algo;
|
||||||
|
@ -1185,7 +1185,8 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
|
|||||||
result_file.ptr = result;
|
result_file.ptr = result;
|
||||||
result_file.size = result_size;
|
result_file.size = result_size;
|
||||||
|
|
||||||
/* Even p_lno[cnt+1] is valid -- that is for the end line number
|
/*
|
||||||
|
* Even p_lno[cnt+1] is valid -- that is for the end line number
|
||||||
* for deletion hunk at the end.
|
* for deletion hunk at the end.
|
||||||
*/
|
*/
|
||||||
CALLOC_ARRAY(sline[0].p_lno, st_mult(st_add(cnt, 2), num_parent));
|
CALLOC_ARRAY(sline[0].p_lno, st_mult(st_add(cnt, 2), num_parent));
|
||||||
@ -1220,7 +1221,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
|
|||||||
}
|
}
|
||||||
free(result);
|
free(result);
|
||||||
|
|
||||||
for (lno = 0; lno < cnt; lno++) {
|
for (lno = 0; lno < cnt + 2; lno++) {
|
||||||
if (sline[lno].lost) {
|
if (sline[lno].lost) {
|
||||||
struct lline *ll = sline[lno].lost;
|
struct lline *ll = sline[lno].lost;
|
||||||
while (ll) {
|
while (ll) {
|
||||||
|
@ -661,6 +661,7 @@ int do_diff_cache(const struct object_id *tree_oid, struct diff_options *opt)
|
|||||||
|
|
||||||
repo_init_revisions(opt->repo, &revs, NULL);
|
repo_init_revisions(opt->repo, &revs, NULL);
|
||||||
copy_pathspec(&revs.prune_data, &opt->pathspec);
|
copy_pathspec(&revs.prune_data, &opt->pathspec);
|
||||||
|
diff_free(&revs.diffopt);
|
||||||
revs.diffopt = *opt;
|
revs.diffopt = *opt;
|
||||||
revs.diffopt.no_free = 1;
|
revs.diffopt.no_free = 1;
|
||||||
|
|
||||||
|
12
dir.c
12
dir.c
@ -1056,6 +1056,8 @@ static void do_invalidate_gitignore(struct untracked_cache_dir *dir)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
dir->valid = 0;
|
dir->valid = 0;
|
||||||
|
for (size_t i = 0; i < dir->untracked_nr; i++)
|
||||||
|
free(dir->untracked[i]);
|
||||||
dir->untracked_nr = 0;
|
dir->untracked_nr = 0;
|
||||||
for (i = 0; i < dir->dirs_nr; i++)
|
for (i = 0; i < dir->dirs_nr; i++)
|
||||||
do_invalidate_gitignore(dir->dirs[i]);
|
do_invalidate_gitignore(dir->dirs[i]);
|
||||||
@ -1083,6 +1085,8 @@ static void invalidate_directory(struct untracked_cache *uc,
|
|||||||
uc->dir_invalidated++;
|
uc->dir_invalidated++;
|
||||||
|
|
||||||
dir->valid = 0;
|
dir->valid = 0;
|
||||||
|
for (size_t i = 0; i < dir->untracked_nr; i++)
|
||||||
|
free(dir->untracked[i]);
|
||||||
dir->untracked_nr = 0;
|
dir->untracked_nr = 0;
|
||||||
for (i = 0; i < dir->dirs_nr; i++)
|
for (i = 0; i < dir->dirs_nr; i++)
|
||||||
dir->dirs[i]->recurse = 0;
|
dir->dirs[i]->recurse = 0;
|
||||||
@ -2868,14 +2872,14 @@ static void set_untracked_ident(struct untracked_cache *uc)
|
|||||||
static unsigned new_untracked_cache_flags(struct index_state *istate)
|
static unsigned new_untracked_cache_flags(struct index_state *istate)
|
||||||
{
|
{
|
||||||
struct repository *repo = istate->repo;
|
struct repository *repo = istate->repo;
|
||||||
char *val;
|
const char *val;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This logic is coordinated with the setting of these flags in
|
* This logic is coordinated with the setting of these flags in
|
||||||
* wt-status.c#wt_status_collect_untracked(), and the evaluation
|
* wt-status.c#wt_status_collect_untracked(), and the evaluation
|
||||||
* of the config setting in commit.c#git_status_config()
|
* of the config setting in commit.c#git_status_config()
|
||||||
*/
|
*/
|
||||||
if (!repo_config_get_string(repo, "status.showuntrackedfiles", &val) &&
|
if (!repo_config_get_string_tmp(repo, "status.showuntrackedfiles", &val) &&
|
||||||
!strcmp(val, "all"))
|
!strcmp(val, "all"))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -3573,6 +3577,8 @@ static void write_one_dir(struct untracked_cache_dir *untracked,
|
|||||||
* for safety..
|
* for safety..
|
||||||
*/
|
*/
|
||||||
if (!untracked->valid) {
|
if (!untracked->valid) {
|
||||||
|
for (size_t i = 0; i < untracked->untracked_nr; i++)
|
||||||
|
free(untracked->untracked[i]);
|
||||||
untracked->untracked_nr = 0;
|
untracked->untracked_nr = 0;
|
||||||
untracked->check_only = 0;
|
untracked->check_only = 0;
|
||||||
}
|
}
|
||||||
@ -3905,6 +3911,8 @@ static void invalidate_one_directory(struct untracked_cache *uc,
|
|||||||
{
|
{
|
||||||
uc->dir_invalidated++;
|
uc->dir_invalidated++;
|
||||||
ucd->valid = 0;
|
ucd->valid = 0;
|
||||||
|
for (size_t i = 0; i < ucd->untracked_nr; i++)
|
||||||
|
free(ucd->untracked[i]);
|
||||||
ucd->untracked_nr = 0;
|
ucd->untracked_nr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
grep.c
1
grep.c
@ -756,6 +756,7 @@ static struct grep_expr *grep_splice_or(struct grep_expr *x, struct grep_expr *y
|
|||||||
assert(x->node == GREP_NODE_OR);
|
assert(x->node == GREP_NODE_OR);
|
||||||
if (x->u.binary.right &&
|
if (x->u.binary.right &&
|
||||||
x->u.binary.right->node == GREP_NODE_TRUE) {
|
x->u.binary.right->node == GREP_NODE_TRUE) {
|
||||||
|
free(x->u.binary.right);
|
||||||
x->u.binary.right = y;
|
x->u.binary.right = y;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -252,16 +252,14 @@ void parse_list_objects_filter(
|
|||||||
const char *arg)
|
const char *arg)
|
||||||
{
|
{
|
||||||
struct strbuf errbuf = STRBUF_INIT;
|
struct strbuf errbuf = STRBUF_INIT;
|
||||||
int parse_error;
|
|
||||||
|
|
||||||
if (!filter_options->filter_spec.buf)
|
if (!filter_options->filter_spec.buf)
|
||||||
BUG("filter_options not properly initialized");
|
BUG("filter_options not properly initialized");
|
||||||
|
|
||||||
if (!filter_options->choice) {
|
if (!filter_options->choice) {
|
||||||
|
if (gently_parse_list_objects_filter(filter_options, arg, &errbuf))
|
||||||
|
die("%s", errbuf.buf);
|
||||||
strbuf_addstr(&filter_options->filter_spec, arg);
|
strbuf_addstr(&filter_options->filter_spec, arg);
|
||||||
|
|
||||||
parse_error = gently_parse_list_objects_filter(
|
|
||||||
filter_options, arg, &errbuf);
|
|
||||||
} else {
|
} else {
|
||||||
struct list_objects_filter_options *sub;
|
struct list_objects_filter_options *sub;
|
||||||
|
|
||||||
@ -271,18 +269,17 @@ void parse_list_objects_filter(
|
|||||||
*/
|
*/
|
||||||
transform_to_combine_type(filter_options);
|
transform_to_combine_type(filter_options);
|
||||||
|
|
||||||
strbuf_addch(&filter_options->filter_spec, '+');
|
|
||||||
filter_spec_append_urlencode(filter_options, arg);
|
|
||||||
ALLOC_GROW_BY(filter_options->sub, filter_options->sub_nr, 1,
|
ALLOC_GROW_BY(filter_options->sub, filter_options->sub_nr, 1,
|
||||||
filter_options->sub_alloc);
|
filter_options->sub_alloc);
|
||||||
sub = &filter_options->sub[filter_options->sub_nr - 1];
|
sub = &filter_options->sub[filter_options->sub_nr - 1];
|
||||||
|
|
||||||
list_objects_filter_init(sub);
|
list_objects_filter_init(sub);
|
||||||
parse_error = gently_parse_list_objects_filter(sub, arg,
|
if (gently_parse_list_objects_filter(sub, arg, &errbuf))
|
||||||
&errbuf);
|
die("%s", errbuf.buf);
|
||||||
|
|
||||||
|
strbuf_addch(&filter_options->filter_spec, '+');
|
||||||
|
filter_spec_append_urlencode(filter_options, arg);
|
||||||
}
|
}
|
||||||
if (parse_error)
|
|
||||||
die("%s", errbuf.buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int opt_parse_list_objects_filter(const struct option *opt,
|
int opt_parse_list_objects_filter(const struct option *opt,
|
||||||
|
1
pretty.c
1
pretty.c
@ -2032,6 +2032,7 @@ void repo_format_commit_message(struct repository *r,
|
|||||||
|
|
||||||
free(context.commit_encoding);
|
free(context.commit_encoding);
|
||||||
repo_unuse_commit_buffer(r, commit, context.message);
|
repo_unuse_commit_buffer(r, commit, context.message);
|
||||||
|
signature_check_clear(&context.signature_check);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pp_header(struct pretty_print_context *pp,
|
static void pp_header(struct pretty_print_context *pp,
|
||||||
|
@ -3227,6 +3227,11 @@ void release_revisions(struct rev_info *revs)
|
|||||||
clear_decoration(&revs->treesame, free);
|
clear_decoration(&revs->treesame, free);
|
||||||
line_log_free(revs);
|
line_log_free(revs);
|
||||||
oidset_clear(&revs->missing_commits);
|
oidset_clear(&revs->missing_commits);
|
||||||
|
|
||||||
|
for (int i = 0; i < revs->bloom_keys_nr; i++)
|
||||||
|
clear_bloom_key(&revs->bloom_keys[i]);
|
||||||
|
FREE_AND_NULL(revs->bloom_keys);
|
||||||
|
revs->bloom_keys_nr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_child(struct rev_info *revs, struct commit *parent, struct commit *child)
|
static void add_child(struct rev_info *revs, struct commit *parent, struct commit *child)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "git-compat-util.h"
|
#include "git-compat-util.h"
|
||||||
#include "environment.h"
|
#include "environment.h"
|
||||||
|
#include "ewah/ewok.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "name-hash.h"
|
#include "name-hash.h"
|
||||||
#include "read-cache-ll.h"
|
#include "read-cache-ll.h"
|
||||||
@ -242,7 +243,8 @@ int convert_to_sparse(struct index_state *istate, int flags)
|
|||||||
cache_tree_update(istate, 0);
|
cache_tree_update(istate, 0);
|
||||||
|
|
||||||
istate->fsmonitor_has_run_once = 0;
|
istate->fsmonitor_has_run_once = 0;
|
||||||
FREE_AND_NULL(istate->fsmonitor_dirty);
|
ewah_free(istate->fsmonitor_dirty);
|
||||||
|
istate->fsmonitor_dirty = NULL;
|
||||||
FREE_AND_NULL(istate->fsmonitor_last_update);
|
FREE_AND_NULL(istate->fsmonitor_last_update);
|
||||||
|
|
||||||
istate->sparse_index = INDEX_COLLAPSED;
|
istate->sparse_index = INDEX_COLLAPSED;
|
||||||
@ -438,7 +440,8 @@ void expand_index(struct index_state *istate, struct pattern_list *pl)
|
|||||||
istate->cache_nr = full->cache_nr;
|
istate->cache_nr = full->cache_nr;
|
||||||
istate->cache_alloc = full->cache_alloc;
|
istate->cache_alloc = full->cache_alloc;
|
||||||
istate->fsmonitor_has_run_once = 0;
|
istate->fsmonitor_has_run_once = 0;
|
||||||
FREE_AND_NULL(istate->fsmonitor_dirty);
|
ewah_free(istate->fsmonitor_dirty);
|
||||||
|
istate->fsmonitor_dirty = NULL;
|
||||||
FREE_AND_NULL(istate->fsmonitor_last_update);
|
FREE_AND_NULL(istate->fsmonitor_last_update);
|
||||||
|
|
||||||
strbuf_release(&base);
|
strbuf_release(&base);
|
||||||
|
@ -68,5 +68,7 @@ int cmd__dump_untracked_cache(int ac UNUSED, const char **av UNUSED)
|
|||||||
printf("flags %08x\n", uc->dir_flags);
|
printf("flags %08x\n", uc->dir_flags);
|
||||||
if (uc->root)
|
if (uc->root)
|
||||||
dump(uc->root, &base);
|
dump(uc->root, &base);
|
||||||
|
|
||||||
|
strbuf_release(&base);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -127,10 +127,12 @@ int cmd__reach(int ac, const char **av)
|
|||||||
exit(128);
|
exit(128);
|
||||||
printf("%s(A,X):\n", av[1]);
|
printf("%s(A,X):\n", av[1]);
|
||||||
print_sorted_commit_ids(list);
|
print_sorted_commit_ids(list);
|
||||||
|
free_commit_list(list);
|
||||||
} else if (!strcmp(av[1], "reduce_heads")) {
|
} else if (!strcmp(av[1], "reduce_heads")) {
|
||||||
struct commit_list *list = reduce_heads(X);
|
struct commit_list *list = reduce_heads(X);
|
||||||
printf("%s(X):\n", av[1]);
|
printf("%s(X):\n", av[1]);
|
||||||
print_sorted_commit_ids(list);
|
print_sorted_commit_ids(list);
|
||||||
|
free_commit_list(list);
|
||||||
} else if (!strcmp(av[1], "can_all_from_reach")) {
|
} else if (!strcmp(av[1], "can_all_from_reach")) {
|
||||||
printf("%s(X,Y):%d\n", av[1], can_all_from_reach(X, Y, 1));
|
printf("%s(X,Y):%d\n", av[1], can_all_from_reach(X, Y, 1));
|
||||||
} else if (!strcmp(av[1], "can_all_from_reach_with_flag")) {
|
} else if (!strcmp(av[1], "can_all_from_reach_with_flag")) {
|
||||||
@ -153,6 +155,7 @@ int cmd__reach(int ac, const char **av)
|
|||||||
filter.with_commit_tag_algo = 0;
|
filter.with_commit_tag_algo = 0;
|
||||||
|
|
||||||
printf("%s(_,A,X,_):%d\n", av[1], commit_contains(&filter, A, X, &cache));
|
printf("%s(_,A,X,_):%d\n", av[1], commit_contains(&filter, A, X, &cache));
|
||||||
|
clear_contains_cache(&cache);
|
||||||
} else if (!strcmp(av[1], "get_reachable_subset")) {
|
} else if (!strcmp(av[1], "get_reachable_subset")) {
|
||||||
const int reachable_flag = 1;
|
const int reachable_flag = 1;
|
||||||
int i, count = 0;
|
int i, count = 0;
|
||||||
@ -176,7 +179,14 @@ int cmd__reach(int ac, const char **av)
|
|||||||
die(_("too many commits marked reachable"));
|
die(_("too many commits marked reachable"));
|
||||||
|
|
||||||
print_sorted_commit_ids(list);
|
print_sorted_commit_ids(list);
|
||||||
|
free_commit_list(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object_array_clear(&X_obj);
|
||||||
|
strbuf_release(&buf);
|
||||||
|
free_commit_list(X);
|
||||||
|
free_commit_list(Y);
|
||||||
|
free(X_array);
|
||||||
|
free(Y_array);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,6 @@ int cmd__read_cache(int argc, const char **argv)
|
|||||||
int i, cnt = 1;
|
int i, cnt = 1;
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
|
|
||||||
initialize_repository(the_repository);
|
|
||||||
|
|
||||||
if (argc > 1 && skip_prefix(argv[1], "--print-and-refresh=", &name)) {
|
if (argc > 1 && skip_prefix(argv[1], "--print-and-refresh=", &name)) {
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
|
@ -5,6 +5,7 @@ test_description='combined diff'
|
|||||||
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-diff.sh
|
. "$TEST_DIRECTORY"/lib-diff.sh
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ test_description='git log'
|
|||||||
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-gpg.sh"
|
. "$TEST_DIRECTORY/lib-gpg.sh"
|
||||||
. "$TEST_DIRECTORY/lib-terminal.sh"
|
. "$TEST_DIRECTORY/lib-terminal.sh"
|
||||||
|
@ -4,6 +4,7 @@ test_description='git log for a path with Bloom filters'
|
|||||||
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-chunk.sh
|
. "$TEST_DIRECTORY"/lib-chunk.sh
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ TEST_NO_CREATE_REPO=1
|
|||||||
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 protocol v2 with 'git://' transport
|
# Test protocol v2 with 'git://' transport
|
||||||
|
@ -8,6 +8,7 @@ test_description='Test remote-helper import and export commands'
|
|||||||
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-gpg.sh
|
. "$TEST_DIRECTORY"/lib-gpg.sh
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ test_description='git rev-list using object filtering'
|
|||||||
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 the blob:none filter.
|
# Test the blob:none filter.
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
test_description="merges with unrelated index changes"
|
test_description="merges with unrelated index changes"
|
||||||
|
|
||||||
|
TEST_PASSES_SANITIZE_LEAK=true
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
# Testcase for some simple merges
|
# Testcase for some simple merges
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
test_description='basic commit reachability tests'
|
test_description='basic commit reachability tests'
|
||||||
|
|
||||||
|
TEST_PASSES_SANITIZE_LEAK=true
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
# Construct a grid-like commit graph with points (x,y)
|
# Construct a grid-like commit graph with points (x,y)
|
||||||
|
@ -10,6 +10,7 @@ Tests for operations with tags.'
|
|||||||
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-gpg.sh
|
. "$TEST_DIRECTORY"/lib-gpg.sh
|
||||||
. "$TEST_DIRECTORY"/lib-terminal.sh
|
. "$TEST_DIRECTORY"/lib-terminal.sh
|
||||||
|
@ -4,6 +4,7 @@ test_description='signed tag 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-gpg.sh"
|
. "$TEST_DIRECTORY/lib-gpg.sh"
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ test_description='test untracked cache'
|
|||||||
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
|
||||||
|
|
||||||
# On some filesystems (e.g. FreeBSD's ext2 and ufs) directory mtime
|
# On some filesystems (e.g. FreeBSD's ext2 and ufs) directory mtime
|
||||||
|
@ -7,6 +7,7 @@ test_description='git commit
|
|||||||
|
|
||||||
Tests for template, signoff, squash and -F functions.'
|
Tests for template, signoff, squash and -F functions.'
|
||||||
|
|
||||||
|
TEST_PASSES_SANITIZE_LEAK=true
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
. "$TEST_DIRECTORY"/lib-rebase.sh
|
. "$TEST_DIRECTORY"/lib-rebase.sh
|
||||||
|
@ -5,6 +5,7 @@ test_description='git commit porcelain-ish'
|
|||||||
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
|
||||||
|
|
||||||
commit_msg_is () {
|
commit_msg_is () {
|
||||||
|
@ -4,6 +4,7 @@ test_description='signed commit 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
|
||||||
GNUPGHOME_NOT_USED=$GNUPGHOME
|
GNUPGHOME_NOT_USED=$GNUPGHOME
|
||||||
. "$TEST_DIRECTORY/lib-gpg.sh"
|
. "$TEST_DIRECTORY/lib-gpg.sh"
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
test_description='git interpret-trailers'
|
test_description='git interpret-trailers'
|
||||||
|
|
||||||
|
TEST_PASSES_SANITIZE_LEAK=true
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
# When we want one trailing space at the end of each line, let's use sed
|
# When we want one trailing space at the end of each line, let's use sed
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
test_description='git status with file system watcher'
|
test_description='git status with file system watcher'
|
||||||
|
|
||||||
|
TEST_PASSES_SANITIZE_LEAK=true
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
# Note, after "git reset --hard HEAD" no extensions exist other than 'TREE'
|
# Note, after "git reset --hard HEAD" no extensions exist other than 'TREE'
|
||||||
|
@ -4,6 +4,7 @@ test_description='ssh signed commit 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
|
||||||
GNUPGHOME_NOT_USED=$GNUPGHOME
|
GNUPGHOME_NOT_USED=$GNUPGHOME
|
||||||
. "$TEST_DIRECTORY/lib-gpg.sh"
|
. "$TEST_DIRECTORY/lib-gpg.sh"
|
||||||
|
@ -10,6 +10,7 @@ Testing basic merge tool invocation'
|
|||||||
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
|
||||||
|
|
||||||
# All the mergetool test work by checking out a temporary branch based
|
# All the mergetool test work by checking out a temporary branch based
|
||||||
|
@ -9,6 +9,7 @@ test_description='git grep various.
|
|||||||
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_invalid_grep_expression() {
|
test_invalid_grep_expression() {
|
||||||
|
22
trailer.c
22
trailer.c
@ -249,7 +249,9 @@ static char *apply_command(struct conf_info *conf, const char *arg)
|
|||||||
static void apply_item_command(struct trailer_item *in_tok, struct arg_item *arg_tok)
|
static void apply_item_command(struct trailer_item *in_tok, struct arg_item *arg_tok)
|
||||||
{
|
{
|
||||||
if (arg_tok->conf.command || arg_tok->conf.cmd) {
|
if (arg_tok->conf.command || arg_tok->conf.cmd) {
|
||||||
const char *arg;
|
char *value_to_free = NULL;
|
||||||
|
char *arg;
|
||||||
|
|
||||||
if (arg_tok->value && arg_tok->value[0]) {
|
if (arg_tok->value && arg_tok->value[0]) {
|
||||||
arg = arg_tok->value;
|
arg = arg_tok->value;
|
||||||
} else {
|
} else {
|
||||||
@ -257,9 +259,13 @@ static void apply_item_command(struct trailer_item *in_tok, struct arg_item *arg
|
|||||||
arg = xstrdup(in_tok->value);
|
arg = xstrdup(in_tok->value);
|
||||||
else
|
else
|
||||||
arg = xstrdup("");
|
arg = xstrdup("");
|
||||||
|
value_to_free = arg_tok->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
arg_tok->value = apply_command(&arg_tok->conf, arg);
|
arg_tok->value = apply_command(&arg_tok->conf, arg);
|
||||||
free((char *)arg);
|
|
||||||
|
free(value_to_free);
|
||||||
|
free(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1105,6 +1111,8 @@ void format_trailers(const struct process_trailer_options *opts,
|
|||||||
struct list_head *trailers,
|
struct list_head *trailers,
|
||||||
struct strbuf *out)
|
struct strbuf *out)
|
||||||
{
|
{
|
||||||
|
struct strbuf tok = STRBUF_INIT;
|
||||||
|
struct strbuf val = STRBUF_INIT;
|
||||||
size_t origlen = out->len;
|
size_t origlen = out->len;
|
||||||
struct list_head *pos;
|
struct list_head *pos;
|
||||||
struct trailer_item *item;
|
struct trailer_item *item;
|
||||||
@ -1112,9 +1120,9 @@ void format_trailers(const struct process_trailer_options *opts,
|
|||||||
list_for_each(pos, trailers) {
|
list_for_each(pos, trailers) {
|
||||||
item = list_entry(pos, struct trailer_item, list);
|
item = list_entry(pos, struct trailer_item, list);
|
||||||
if (item->token) {
|
if (item->token) {
|
||||||
struct strbuf tok = STRBUF_INIT;
|
strbuf_reset(&tok);
|
||||||
struct strbuf val = STRBUF_INIT;
|
|
||||||
strbuf_addstr(&tok, item->token);
|
strbuf_addstr(&tok, item->token);
|
||||||
|
strbuf_reset(&val);
|
||||||
strbuf_addstr(&val, item->value);
|
strbuf_addstr(&val, item->value);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1145,9 +1153,6 @@ void format_trailers(const struct process_trailer_options *opts,
|
|||||||
if (!opts->separator)
|
if (!opts->separator)
|
||||||
strbuf_addch(out, '\n');
|
strbuf_addch(out, '\n');
|
||||||
}
|
}
|
||||||
strbuf_release(&tok);
|
|
||||||
strbuf_release(&val);
|
|
||||||
|
|
||||||
} else if (!opts->only_trailers) {
|
} else if (!opts->only_trailers) {
|
||||||
if (opts->separator && out->len != origlen) {
|
if (opts->separator && out->len != origlen) {
|
||||||
strbuf_addbuf(out, opts->separator);
|
strbuf_addbuf(out, opts->separator);
|
||||||
@ -1159,6 +1164,9 @@ void format_trailers(const struct process_trailer_options *opts,
|
|||||||
strbuf_addch(out, '\n');
|
strbuf_addch(out, '\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strbuf_release(&tok);
|
||||||
|
strbuf_release(&val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void format_trailers_from_commit(const struct process_trailer_options *opts,
|
void format_trailers_from_commit(const struct process_trailer_options *opts,
|
||||||
|
@ -399,6 +399,8 @@ static int release_helper(struct transport *transport)
|
|||||||
int res = 0;
|
int res = 0;
|
||||||
struct helper_data *data = transport->data;
|
struct helper_data *data = transport->data;
|
||||||
refspec_clear(&data->rs);
|
refspec_clear(&data->rs);
|
||||||
|
free(data->import_marks);
|
||||||
|
free(data->export_marks);
|
||||||
res = disconnect_helper(transport);
|
res = disconnect_helper(transport);
|
||||||
free(transport->data);
|
free(transport->data);
|
||||||
return res;
|
return res;
|
||||||
|
@ -166,6 +166,7 @@ static void upload_pack_data_clear(struct upload_pack_data *data)
|
|||||||
object_array_clear(&data->extra_edge_obj);
|
object_array_clear(&data->extra_edge_obj);
|
||||||
list_objects_filter_release(&data->filter_options);
|
list_objects_filter_release(&data->filter_options);
|
||||||
string_list_clear(&data->allowed_filters, 0);
|
string_list_clear(&data->allowed_filters, 0);
|
||||||
|
string_list_clear(&data->uri_protocols, 0);
|
||||||
|
|
||||||
free((char *)data->pack_objects_hook);
|
free((char *)data->pack_objects_hook);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user