aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archive.c10
-rw-r--r--builtin/archive.c7
-rw-r--r--builtin/bundle.c2
-rw-r--r--builtin/fetch-pack.c20
-rw-r--r--builtin/fetch.c8
-rw-r--r--builtin/merge-tree.c13
-rw-r--r--builtin/repack.c36
-rw-r--r--builtin/send-pack.c1
-rw-r--r--builtin/upload-archive.c8
-rw-r--r--bundle.c4
-rw-r--r--convert.c3
-rw-r--r--mailinfo.c17
-rw-r--r--midx-write.c24
-rw-r--r--pretty.c13
-rw-r--r--remote.c85
-rw-r--r--sideband.c15
-rw-r--r--t/helper/test-read-midx.c8
-rwxr-xr-xt/t4150-am.sh1
-rwxr-xr-xt/t4205-log-pretty-formats.sh2
-rwxr-xr-xt/t4301-merge-tree-write-tree.sh1
-rwxr-xr-xt/t5000-tar-tree.sh1
-rwxr-xr-xt/t5003-archive-zip.sh1
-rwxr-xr-xt/t5100-mailinfo.sh1
-rwxr-xr-xt/t5319-multi-pack-index.sh2
-rwxr-xr-xt/t5400-send-pack.sh1
-rwxr-xr-xt/t5401-update-hooks.sh2
-rwxr-xr-xt/t5408-send-pack-stdin.sh2
-rwxr-xr-xt/t5409-colorize-remote-messages.sh1
-rwxr-xr-xt/t5501-fetch-push-alternates.sh1
-rwxr-xr-xt/t5505-remote.sh1
-rwxr-xr-xt/t5510-fetch.sh1
-rwxr-xr-xt/t5519-push-alternates.sh1
-rwxr-xr-xt/t5536-fetch-conflicts.sh1
-rwxr-xr-xt/t5548-push-porcelain.sh1
-rwxr-xr-xt/t5553-set-upstream.sh1
-rwxr-xr-xt/t5574-fetch-output.sh1
-rwxr-xr-xt/t5703-upload-pack-ref-in-want.sh1
-rwxr-xr-xt/t5812-proto-disable-http.sh2
-rwxr-xr-xt/t6050-replace.sh1
-rwxr-xr-xt/t7704-repack-cruft.sh1
-rw-r--r--transport.c8
41 files changed, 237 insertions, 73 deletions
diff --git a/archive.c b/archive.c
index 7bd60d0632..9ba96aae4f 100644
--- a/archive.c
+++ b/archive.c
@@ -736,6 +736,7 @@ int write_archive(int argc, const char **argv, const char *prefix,
struct pretty_print_describe_status describe_status = {0};
struct pretty_print_context ctx = {0};
struct archiver_args args;
+ const char **argv_copy;
int rc;
git_config_get_bool("uploadarchive.allowunreachable", &remote_allow_unreachable);
@@ -749,6 +750,14 @@ int write_archive(int argc, const char **argv, const char *prefix,
args.repo = repo;
args.prefix = prefix;
string_list_init_dup(&args.extra_files);
+
+ /*
+ * `parse_archive_args()` modifies contents of `argv`, which is what we
+ * want. Our callers may not want it though, so we create a copy here.
+ */
+ DUP_ARRAY(argv_copy, argv, argc);
+ argv = argv_copy;
+
argc = parse_archive_args(argc, argv, &ar, &args, name_hint, remote);
if (!startup_info->have_repository) {
/*
@@ -767,6 +776,7 @@ int write_archive(int argc, const char **argv, const char *prefix,
string_list_clear_func(&args.extra_files, extra_file_info_clear);
free(args.refname);
clear_pathspec(&args.pathspec);
+ free(argv_copy);
return rc;
}
diff --git a/builtin/archive.c b/builtin/archive.c
index b50981504f..63f02990d1 100644
--- a/builtin/archive.c
+++ b/builtin/archive.c
@@ -100,13 +100,16 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
if (output)
create_output_file(output);
- if (remote)
- return run_remote_archiver(argc, argv, remote, exec, output);
+ if (remote) {
+ ret = run_remote_archiver(argc, argv, remote, exec, output);
+ goto out;
+ }
setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
ret = write_archive(argc, argv, prefix, the_repository, output, 0);
+out:
free(output);
return ret;
}
diff --git a/builtin/bundle.c b/builtin/bundle.c
index 86d0ed7049..b858552ee6 100644
--- a/builtin/bundle.c
+++ b/builtin/bundle.c
@@ -221,7 +221,9 @@ static int cmd_bundle_unbundle(int argc, const char **argv, const char *prefix)
&extra_index_pack_args, 0) ||
list_bundle_refs(&header, argc, argv);
bundle_header_release(&header);
+
cleanup:
+ strvec_clear(&extra_index_pack_args);
free(bundle_file);
return ret;
}
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index af329e8d5c..fe404d1305 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -46,7 +46,7 @@ static void add_sought_entry(struct ref ***sought, int *nr, int *alloc,
int cmd_fetch_pack(int argc, const char **argv, const char *prefix UNUSED)
{
int i, ret;
- struct ref *ref = NULL;
+ struct ref *fetched_refs = NULL, *remote_refs = NULL;
const char *dest = NULL;
struct ref **sought = NULL;
int nr_sought = 0, alloc_sought = 0;
@@ -228,19 +228,20 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix UNUSED)
version = discover_version(&reader);
switch (version) {
case protocol_v2:
- get_remote_refs(fd[1], &reader, &ref, 0, NULL, NULL,
+ get_remote_refs(fd[1], &reader, &remote_refs, 0, NULL, NULL,
args.stateless_rpc);
break;
case protocol_v1:
case protocol_v0:
- get_remote_heads(&reader, &ref, 0, NULL, &shallow);
+ get_remote_heads(&reader, &remote_refs, 0, NULL, &shallow);
break;
case protocol_unknown_version:
BUG("unknown protocol version");
}
- ref = fetch_pack(&args, fd, ref, sought, nr_sought,
+ fetched_refs = fetch_pack(&args, fd, remote_refs, sought, nr_sought,
&shallow, pack_lockfiles_ptr, version);
+
if (pack_lockfiles.nr) {
int i;
@@ -260,7 +261,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix UNUSED)
if (finish_connect(conn))
return 1;
- ret = !ref;
+ ret = !fetched_refs;
/*
* If the heads to pull were given, we should have consumed
@@ -270,11 +271,14 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix UNUSED)
*/
ret |= report_unmatched_refs(sought, nr_sought);
- while (ref) {
+ for (struct ref *ref = fetched_refs; ref; ref = ref->next)
printf("%s %s\n",
oid_to_hex(&ref->old_oid), ref->name);
- ref = ref->next;
- }
+ for (size_t i = 0; i < nr_sought; i++)
+ free_one_ref(sought[i]);
+ free(sought);
+ free_refs(fetched_refs);
+ free_refs(remote_refs);
return ret;
}
diff --git a/builtin/fetch.c b/builtin/fetch.c
index c297569a47..0264483c0e 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1731,11 +1731,8 @@ static int do_fetch(struct transport *transport,
goto cleanup;
retcode = ref_transaction_commit(transaction, &err);
- if (retcode) {
- ref_transaction_free(transaction);
- transaction = NULL;
+ if (retcode)
goto cleanup;
- }
}
commit_fetch_head(&fetch_head);
@@ -1803,8 +1800,11 @@ cleanup:
if (transaction && ref_transaction_abort(transaction, &err) &&
err.len)
error("%s", err.buf);
+ transaction = NULL;
}
+ if (transaction)
+ ref_transaction_free(transaction);
display_state_release(&display_state);
close_fetch_head(&fetch_head);
strbuf_release(&err);
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 9bca9b5f33..c00469ed3d 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -533,6 +533,7 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)
int expected_remaining_argc;
int original_argc;
const char *merge_base = NULL;
+ int ret;
const char * const merge_tree_usage[] = {
N_("git merge-tree [--write-tree] [<options>] <branch1> <branch2>"),
@@ -625,7 +626,9 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)
strbuf_list_free(split);
}
strbuf_release(&buf);
- return 0;
+
+ ret = 0;
+ goto out;
}
/* Figure out which mode to use */
@@ -664,7 +667,11 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)
/* Do the relevant type of merge */
if (o.mode == MODE_REAL)
- return real_merge(&o, merge_base, argv[0], argv[1], prefix);
+ ret = real_merge(&o, merge_base, argv[0], argv[1], prefix);
else
- return trivial_merge(argv[0], argv[1], argv[2]);
+ ret = trivial_merge(argv[0], argv[1], argv[2]);
+
+out:
+ strvec_clear(&xopts);
+ return ret;
}
diff --git a/builtin/repack.c b/builtin/repack.c
index 62cfa50c50..8bb875532b 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -732,14 +732,23 @@ static void midx_included_packs(struct string_list *include,
struct pack_geometry *geometry)
{
struct string_list_item *item;
+ struct strbuf buf = STRBUF_INIT;
+
+ for_each_string_list_item(item, &existing->kept_packs) {
+ strbuf_reset(&buf);
+ strbuf_addf(&buf, "%s.idx", item->string);
+ string_list_insert(include, buf.buf);
+ }
+
+ for_each_string_list_item(item, names) {
+ strbuf_reset(&buf);
+ strbuf_addf(&buf, "pack-%s.idx", item->string);
+ string_list_insert(include, buf.buf);
+ }
- for_each_string_list_item(item, &existing->kept_packs)
- string_list_insert(include, xstrfmt("%s.idx", item->string));
- for_each_string_list_item(item, names)
- string_list_insert(include, xstrfmt("pack-%s.idx", item->string));
if (geometry->split_factor) {
- struct strbuf buf = STRBUF_INIT;
uint32_t i;
+
for (i = geometry->split; i < geometry->pack_nr; i++) {
struct packed_git *p = geometry->pack[i];
@@ -754,17 +763,21 @@ static void midx_included_packs(struct string_list *include,
if (!p->pack_local)
continue;
+ strbuf_reset(&buf);
strbuf_addstr(&buf, pack_basename(p));
strbuf_strip_suffix(&buf, ".pack");
strbuf_addstr(&buf, ".idx");
- string_list_insert(include, strbuf_detach(&buf, NULL));
+ string_list_insert(include, buf.buf);
}
} else {
for_each_string_list_item(item, &existing->non_kept_packs) {
if (pack_is_marked_for_deletion(item))
continue;
- string_list_insert(include, xstrfmt("%s.idx", item->string));
+
+ strbuf_reset(&buf);
+ strbuf_addf(&buf, "%s.idx", item->string);
+ string_list_insert(include, buf.buf);
}
}
@@ -784,8 +797,13 @@ static void midx_included_packs(struct string_list *include,
*/
if (pack_is_marked_for_deletion(item))
continue;
- string_list_insert(include, xstrfmt("%s.idx", item->string));
+
+ strbuf_reset(&buf);
+ strbuf_addf(&buf, "%s.idx", item->string);
+ string_list_insert(include, buf.buf);
}
+
+ strbuf_release(&buf);
}
static int write_midx_included_packs(struct string_list *include,
@@ -1476,7 +1494,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
mark_packs_for_deletion(&existing, &names);
if (write_midx) {
- struct string_list include = STRING_LIST_INIT_NODUP;
+ struct string_list include = STRING_LIST_INIT_DUP;
midx_included_packs(&include, &existing, &names, &geometry);
ret = write_midx_included_packs(&include, &geometry, &names,
diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index 17cae6bbbd..ef0df80824 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -338,5 +338,6 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
free_refs(remote_refs);
free_refs(local_refs);
+ refspec_clear(&rs);
return ret;
}
diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c
index 1b09e5e1aa..313a8dfa81 100644
--- a/builtin/upload-archive.c
+++ b/builtin/upload-archive.c
@@ -22,6 +22,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
{
struct strvec sent_argv = STRVEC_INIT;
const char *arg_cmd = "argument ";
+ int ret;
if (argc != 2 || !strcmp(argv[1], "-h"))
usage(upload_archive_usage);
@@ -46,8 +47,11 @@ int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix)
}
/* parse all options sent by the client */
- return write_archive(sent_argv.nr, sent_argv.v, prefix,
- the_repository, NULL, 1);
+ ret = write_archive(sent_argv.nr, sent_argv.v, prefix,
+ the_repository, NULL, 1);
+
+ strvec_clear(&sent_argv);
+ return ret;
}
__attribute__((format (printf, 1, 2)))
diff --git a/bundle.c b/bundle.c
index b0a8a925cb..4773b51eb1 100644
--- a/bundle.c
+++ b/bundle.c
@@ -644,10 +644,8 @@ int unbundle(struct repository *r, struct bundle_header *header,
if (flags & VERIFY_BUNDLE_FSCK)
strvec_push(&ip.args, "--fsck-objects");
- if (extra_index_pack_args) {
+ if (extra_index_pack_args)
strvec_pushv(&ip.args, extra_index_pack_args->v);
- strvec_clear(extra_index_pack_args);
- }
ip.in = bundle_fd;
ip.no_stdout = 1;
diff --git a/convert.c b/convert.c
index e6184d21f2..c9a31eb4f0 100644
--- a/convert.c
+++ b/convert.c
@@ -1371,6 +1371,9 @@ void reset_parsed_attributes(void)
for (drv = user_convert; drv; drv = next) {
next = drv->next;
free((void *)drv->name);
+ free((void *)drv->smudge);
+ free((void *)drv->clean);
+ free((void *)drv->process);
free(drv);
}
user_convert = NULL;
diff --git a/mailinfo.c b/mailinfo.c
index 95228531a6..ce1455f943 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -1292,8 +1292,21 @@ void clear_mailinfo(struct mailinfo *mi)
strbuf_release(&mi->inbody_header_accum);
free(mi->message_id);
- strbuf_list_free(mi->p_hdr_data);
- strbuf_list_free(mi->s_hdr_data);
+ for (size_t i = 0; header[i]; i++) {
+ if (!mi->p_hdr_data[i])
+ continue;
+ strbuf_release(mi->p_hdr_data[i]);
+ free(mi->p_hdr_data[i]);
+ }
+ free(mi->p_hdr_data);
+
+ for (size_t i = 0; header[i]; i++) {
+ if (!mi->s_hdr_data[i])
+ continue;
+ strbuf_release(mi->s_hdr_data[i]);
+ free(mi->s_hdr_data[i]);
+ }
+ free(mi->s_hdr_data);
while (mi->content < mi->content_top) {
free(*(mi->content_top));
diff --git a/midx-write.c b/midx-write.c
index c7413ae3ca..1ef62c4f4b 100644
--- a/midx-write.c
+++ b/midx-write.c
@@ -1306,6 +1306,18 @@ static int write_midx_internal(const char *object_dir,
pack_name_concat_len += MIDX_CHUNK_ALIGNMENT -
(pack_name_concat_len % MIDX_CHUNK_ALIGNMENT);
+ if (ctx.nr - dropped_packs == 0) {
+ error(_("no pack files to index."));
+ result = 1;
+ goto cleanup;
+ }
+
+ if (!ctx.entries_nr) {
+ if (flags & MIDX_WRITE_BITMAP)
+ warning(_("refusing to write multi-pack .bitmap without any objects"));
+ flags &= ~(MIDX_WRITE_REV_INDEX | MIDX_WRITE_BITMAP);
+ }
+
if (ctx.incremental) {
struct strbuf lock_name = STRBUF_INIT;
@@ -1331,18 +1343,6 @@ static int write_midx_internal(const char *object_dir,
f = hashfd(get_lock_file_fd(&lk), get_lock_file_path(&lk));
}
- if (ctx.nr - dropped_packs == 0) {
- error(_("no pack files to index."));
- result = 1;
- goto cleanup;
- }
-
- if (!ctx.entries_nr) {
- if (flags & MIDX_WRITE_BITMAP)
- warning(_("refusing to write multi-pack .bitmap without any objects"));
- flags &= ~(MIDX_WRITE_REV_INDEX | MIDX_WRITE_BITMAP);
- }
-
cf = init_chunkfile(f);
add_chunk(cf, MIDX_CHUNKID_PACKNAMES, pack_name_concat_len,
diff --git a/pretty.c b/pretty.c
index 44222fb83c..5e5ae45253 100644
--- a/pretty.c
+++ b/pretty.c
@@ -63,7 +63,7 @@ static int git_pretty_formats_config(const char *var, const char *value,
void *cb UNUSED)
{
struct cmt_fmt_map *commit_format = NULL;
- const char *name;
+ const char *name, *stripped;
char *fmt;
int i;
@@ -90,15 +90,21 @@ static int git_pretty_formats_config(const char *var, const char *value,
commit_formats_len++;
}
+ free((char *)commit_format->name);
commit_format->name = xstrdup(name);
commit_format->format = CMIT_FMT_USERFORMAT;
if (git_config_string(&fmt, var, value))
return -1;
- if (skip_prefix(fmt, "format:", &commit_format->user_format)) {
+ free((char *)commit_format->user_format);
+ if (skip_prefix(fmt, "format:", &stripped)) {
commit_format->is_tformat = 0;
- } else if (skip_prefix(fmt, "tformat:", &commit_format->user_format)) {
+ commit_format->user_format = xstrdup(stripped);
+ free(fmt);
+ } else if (skip_prefix(fmt, "tformat:", &stripped)) {
commit_format->is_tformat = 1;
+ commit_format->user_format = xstrdup(stripped);
+ free(fmt);
} else if (strchr(fmt, '%')) {
commit_format->is_tformat = 1;
commit_format->user_format = fmt;
@@ -1770,6 +1776,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
}
trailer_out:
string_list_clear(&filter_list, 0);
+ strbuf_release(&kvsepbuf);
strbuf_release(&sepbuf);
return ret;
}
diff --git a/remote.c b/remote.c
index 7d5b8f750d..8f3dee1318 100644
--- a/remote.c
+++ b/remote.c
@@ -243,6 +243,17 @@ static struct branch *make_branch(struct remote_state *remote_state,
return ret;
}
+static void branch_release(struct branch *branch)
+{
+ free((char *)branch->name);
+ free((char *)branch->refname);
+ free(branch->remote_name);
+ free(branch->pushremote_name);
+ for (int i = 0; i < branch->merge_nr; i++)
+ refspec_item_clear(branch->merge[i]);
+ free(branch->merge);
+}
+
static struct rewrite *make_rewrite(struct rewrites *r,
const char *base, size_t len)
{
@@ -263,6 +274,14 @@ static struct rewrite *make_rewrite(struct rewrites *r,
return ret;
}
+static void rewrites_release(struct rewrites *r)
+{
+ for (int i = 0; i < r->rewrite_nr; i++)
+ free((char *)r->rewrite[i]->base);
+ free(r->rewrite);
+ memset(r, 0, sizeof(*r));
+}
+
static void add_instead_of(struct rewrite *rewrite, const char *instead_of)
{
ALLOC_GROW(rewrite->instead_of, rewrite->instead_of_nr + 1, rewrite->instead_of_alloc);
@@ -373,8 +392,10 @@ static int handle_config(const char *key, const char *value,
return -1;
branch = make_branch(remote_state, name, namelen);
if (!strcmp(subkey, "remote")) {
+ FREE_AND_NULL(branch->remote_name);
return git_config_string(&branch->remote_name, key, value);
} else if (!strcmp(subkey, "pushremote")) {
+ FREE_AND_NULL(branch->pushremote_name);
return git_config_string(&branch->pushremote_name, key, value);
} else if (!strcmp(subkey, "merge")) {
if (!value)
@@ -406,9 +427,11 @@ static int handle_config(const char *key, const char *value,
return 0;
/* Handle remote.* variables */
- if (!name && !strcmp(subkey, "pushdefault"))
+ if (!name && !strcmp(subkey, "pushdefault")) {
+ FREE_AND_NULL(remote_state->pushremote_name);
return git_config_string(&remote_state->pushremote_name, key,
value);
+ }
if (!name)
return 0;
@@ -475,12 +498,15 @@ static int handle_config(const char *key, const char *value,
else if (!strcmp(value, "--tags"))
remote->fetch_tags = 2;
} else if (!strcmp(subkey, "proxy")) {
+ FREE_AND_NULL(remote->http_proxy);
return git_config_string(&remote->http_proxy,
key, value);
} else if (!strcmp(subkey, "proxyauthmethod")) {
+ FREE_AND_NULL(remote->http_proxy_authmethod);
return git_config_string(&remote->http_proxy_authmethod,
key, value);
} else if (!strcmp(subkey, "vcs")) {
+ FREE_AND_NULL(remote->foreign_vcs);
return git_config_string(&remote->foreign_vcs, key, value);
}
return 0;
@@ -1318,18 +1344,21 @@ static int match_explicit(struct ref *src, struct ref *dst,
struct ref ***dst_tail,
struct refspec_item *rs)
{
- struct ref *matched_src, *matched_dst;
- int allocated_src;
+ struct ref *matched_src = NULL, *matched_dst = NULL;
+ int allocated_src = 0, ret;
const char *dst_value = rs->dst;
char *dst_guess;
- if (rs->pattern || rs->matching || rs->negative)
- return 0;
+ if (rs->pattern || rs->matching || rs->negative) {
+ ret = 0;
+ goto out;
+ }
- matched_src = matched_dst = NULL;
- if (match_explicit_lhs(src, rs, &matched_src, &allocated_src) < 0)
- return -1;
+ if (match_explicit_lhs(src, rs, &matched_src, &allocated_src) < 0) {
+ ret = -1;
+ goto out;
+ }
if (!dst_value) {
int flag;
@@ -1368,18 +1397,30 @@ static int match_explicit(struct ref *src, struct ref *dst,
dst_value);
break;
}
- if (!matched_dst)
- return -1;
- if (matched_dst->peer_ref)
- return error(_("dst ref %s receives from more than one src"),
- matched_dst->name);
- else {
+
+ if (!matched_dst) {
+ ret = -1;
+ goto out;
+ }
+
+ if (matched_dst->peer_ref) {
+ ret = error(_("dst ref %s receives from more than one src"),
+ matched_dst->name);
+ goto out;
+ } else {
matched_dst->peer_ref = allocated_src ?
matched_src :
copy_ref(matched_src);
matched_dst->force = rs->force;
+ matched_src = NULL;
}
- return 0;
+
+ ret = 0;
+
+out:
+ if (allocated_src)
+ free_one_ref(matched_src);
+ return ret;
}
static int match_explicit_refs(struct ref *src, struct ref *dst,
@@ -2040,6 +2081,8 @@ static struct ref *get_expanded_map(const struct ref *remote_refs,
!ignore_symref_update(expn_name, &scratch)) {
struct ref *cpy = copy_ref(ref);
+ if (cpy->peer_ref)
+ free_one_ref(cpy->peer_ref);
cpy->peer_ref = alloc_ref(expn_name);
if (refspec->force)
cpy->peer_ref->force = 1;
@@ -2797,16 +2840,26 @@ struct remote_state *remote_state_new(void)
void remote_state_clear(struct remote_state *remote_state)
{
+ struct hashmap_iter iter;
+ struct branch *b;
int i;
for (i = 0; i < remote_state->remotes_nr; i++)
remote_clear(remote_state->remotes[i]);
FREE_AND_NULL(remote_state->remotes);
+ FREE_AND_NULL(remote_state->pushremote_name);
remote_state->remotes_alloc = 0;
remote_state->remotes_nr = 0;
+ rewrites_release(&remote_state->rewrites);
+ rewrites_release(&remote_state->rewrites_push);
+
hashmap_clear_and_free(&remote_state->remotes_hash, struct remote, ent);
- hashmap_clear_and_free(&remote_state->branches_hash, struct remote, ent);
+ hashmap_for_each_entry(&remote_state->branches_hash, &iter, b, ent) {
+ branch_release(b);
+ free(b);
+ }
+ hashmap_clear(&remote_state->branches_hash);
}
/*
diff --git a/sideband.c b/sideband.c
index 5b6b872a1c..4e816be4e9 100644
--- a/sideband.c
+++ b/sideband.c
@@ -32,28 +32,27 @@ static int use_sideband_colors(void)
const char *key = "color.remote";
struct strbuf sb = STRBUF_INIT;
- char *value;
+ const char *value;
int i;
if (use_sideband_colors_cached >= 0)
return use_sideband_colors_cached;
- if (!git_config_get_string(key, &value)) {
+ if (!git_config_get_string_tmp(key, &value))
use_sideband_colors_cached = git_config_colorbool(key, value);
- } else if (!git_config_get_string("color.ui", &value)) {
+ else if (!git_config_get_string_tmp("color.ui", &value))
use_sideband_colors_cached = git_config_colorbool("color.ui", value);
- } else {
+ else
use_sideband_colors_cached = GIT_COLOR_AUTO;
- }
for (i = 0; i < ARRAY_SIZE(keywords); i++) {
strbuf_reset(&sb);
strbuf_addf(&sb, "%s.%s", key, keywords[i].keyword);
- if (git_config_get_string(sb.buf, &value))
- continue;
- if (color_parse(value, keywords[i].color))
+ if (git_config_get_string_tmp(sb.buf, &value))
continue;
+ color_parse(value, keywords[i].color);
}
+
strbuf_release(&sb);
return use_sideband_colors_cached;
}
diff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c
index 69757e94fc..438fb9fc61 100644
--- a/t/helper/test-read-midx.c
+++ b/t/helper/test-read-midx.c
@@ -86,6 +86,8 @@ static int read_midx_checksum(const char *object_dir)
if (!m)
return 1;
printf("%s\n", hash_to_hex(get_midx_checksum(m)));
+
+ close_midx(m);
return 0;
}
@@ -102,10 +104,12 @@ static int read_midx_preferred_pack(const char *object_dir)
if (midx_preferred_pack(midx, &preferred_pack) < 0) {
warning(_("could not determine MIDX preferred pack"));
+ close_midx(midx);
return 1;
}
printf("%s\n", midx->pack_names[preferred_pack]);
+ close_midx(midx);
return 0;
}
@@ -122,8 +126,10 @@ static int read_midx_bitmapped_packs(const char *object_dir)
return 1;
for (i = 0; i < midx->num_packs + midx->num_packs_in_base; i++) {
- if (nth_bitmapped_pack(the_repository, midx, &pack, i) < 0)
+ if (nth_bitmapped_pack(the_repository, midx, &pack, i) < 0) {
+ close_midx(midx);
return 1;
+ }
printf("%s\n", pack_basename(pack.p));
printf(" bitmap_pos: %"PRIuMAX"\n", (uintmax_t)pack.bitmap_pos);
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index 5e2b6c80ea..232e1394e8 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -5,6 +5,7 @@ test_description='git am running'
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: messages' '
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 158b49d4b6..eb63ce011f 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -5,6 +5,8 @@
#
test_description='Test pretty formats'
+
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
# Tested non-UTF-8 encoding
diff --git a/t/t4301-merge-tree-write-tree.sh b/t/t4301-merge-tree-write-tree.sh
index eea19907b5..37f1cd7364 100755
--- a/t/t4301-merge-tree-write-tree.sh
+++ b/t/t4301-merge-tree-write-tree.sh
@@ -2,6 +2,7 @@
test_description='git merge-tree --write-tree'
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
# This test is ort-specific
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 72b8d0ff02..7abba8a4b2 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -25,6 +25,7 @@ commit id embedding:
'
TEST_CREATE_REPO_NO_TEMPLATE=1
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
SUBSTFORMAT=%H%n
diff --git a/t/t5003-archive-zip.sh b/t/t5003-archive-zip.sh
index 961c6aac25..01f591c99b 100755
--- a/t/t5003-archive-zip.sh
+++ b/t/t5003-archive-zip.sh
@@ -3,6 +3,7 @@
test_description='git archive --format=zip test'
TEST_CREATE_REPO_NO_TEMPLATE=1
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
SUBSTFORMAT=%H%n
diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh
index c8d0655454..065156c1f3 100755
--- a/t/t5100-mailinfo.sh
+++ b/t/t5100-mailinfo.sh
@@ -5,6 +5,7 @@
test_description='git mailinfo and git mailsplit test'
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
DATA="$TEST_DIRECTORY/t5100"
diff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh
index ce1b58c732..fbbc218d04 100755
--- a/t/t5319-multi-pack-index.sh
+++ b/t/t5319-multi-pack-index.sh
@@ -1,6 +1,8 @@
#!/bin/sh
test_description='multi-pack-indexes'
+
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-chunk.sh
. "$TEST_DIRECTORY"/lib-midx.sh
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index 3f81f16e13..248c74d8ef 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -9,6 +9,7 @@ test_description='See why rewinding head breaks send-pack
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
cnt=64
diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh
index d8cadeec73..3c1ea6086e 100755
--- a/t/t5401-update-hooks.sh
+++ b/t/t5401-update-hooks.sh
@@ -4,6 +4,8 @@
#
test_description='Test the update hook infrastructure.'
+
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success setup '
diff --git a/t/t5408-send-pack-stdin.sh b/t/t5408-send-pack-stdin.sh
index e8737df6f9..c3695a4d4e 100755
--- a/t/t5408-send-pack-stdin.sh
+++ b/t/t5408-send-pack-stdin.sh
@@ -1,6 +1,8 @@
#!/bin/sh
test_description='send-pack --stdin tests'
+
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
create_ref () {
diff --git a/t/t5409-colorize-remote-messages.sh b/t/t5409-colorize-remote-messages.sh
index fa5de4500a..516b22fd96 100755
--- a/t/t5409-colorize-remote-messages.sh
+++ b/t/t5409-colorize-remote-messages.sh
@@ -2,6 +2,7 @@
test_description='remote messages are colorized on the client'
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup' '
diff --git a/t/t5501-fetch-push-alternates.sh b/t/t5501-fetch-push-alternates.sh
index 66f19a4ef2..0c8668a1b8 100755
--- a/t/t5501-fetch-push-alternates.sh
+++ b/t/t5501-fetch-push-alternates.sh
@@ -4,6 +4,7 @@ test_description='fetch/push involving alternates'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
count_objects () {
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 08424e878e..532035933f 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -2,6 +2,7 @@
test_description='git remote porcelain-ish'
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
setup_repository () {
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 3b3991ab86..0890b9f61c 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -5,6 +5,7 @@ test_description='Per branch config variables affects "git fetch".
'
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-bundle.sh
diff --git a/t/t5519-push-alternates.sh b/t/t5519-push-alternates.sh
index 20ba604dfd..72e97b15fa 100755
--- a/t/t5519-push-alternates.sh
+++ b/t/t5519-push-alternates.sh
@@ -5,6 +5,7 @@ test_description='push to a repository that borrows from elsewhere'
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 '
diff --git a/t/t5536-fetch-conflicts.sh b/t/t5536-fetch-conflicts.sh
index 23bf696170..2dcbe79052 100755
--- a/t/t5536-fetch-conflicts.sh
+++ b/t/t5536-fetch-conflicts.sh
@@ -2,6 +2,7 @@
test_description='fetch handles conflicting refspecs correctly'
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
D=$(pwd)
diff --git a/t/t5548-push-porcelain.sh b/t/t5548-push-porcelain.sh
index 6282728eaf..ecb3877aa4 100755
--- a/t/t5548-push-porcelain.sh
+++ b/t/t5548-push-porcelain.sh
@@ -4,6 +4,7 @@
#
test_description='Test git push porcelain output'
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
# Create commits in <repo> and assign each commit's oid to shell variables
diff --git a/t/t5553-set-upstream.sh b/t/t5553-set-upstream.sh
index 70e3376d31..33e919a17e 100755
--- a/t/t5553-set-upstream.sh
+++ b/t/t5553-set-upstream.sh
@@ -4,6 +4,7 @@ test_description='"git fetch/pull --set-upstream" basic tests.'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
check_config () {
diff --git a/t/t5574-fetch-output.sh b/t/t5574-fetch-output.sh
index 5883839a04..f7707326ea 100755
--- a/t/t5574-fetch-output.sh
+++ b/t/t5574-fetch-output.sh
@@ -5,6 +5,7 @@ test_description='git fetch output format'
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 'fetch with invalid output format configuration' '
diff --git a/t/t5703-upload-pack-ref-in-want.sh b/t/t5703-upload-pack-ref-in-want.sh
index 191097171b..f75fae52c8 100755
--- a/t/t5703-upload-pack-ref-in-want.sh
+++ b/t/t5703-upload-pack-ref-in-want.sh
@@ -2,6 +2,7 @@
test_description='upload-pack ref-in-want'
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
get_actual_refs () {
diff --git a/t/t5812-proto-disable-http.sh b/t/t5812-proto-disable-http.sh
index 769c717e88..f69959c64c 100755
--- a/t/t5812-proto-disable-http.sh
+++ b/t/t5812-proto-disable-http.sh
@@ -1,6 +1,8 @@
#!/bin/sh
test_description='test disabling of git-over-http in clone/fetch'
+
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY/lib-proto-disable.sh"
. "$TEST_DIRECTORY/lib-httpd.sh"
diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh
index c6e9b33e44..d7702fc756 100755
--- a/t/t6050-replace.sh
+++ b/t/t6050-replace.sh
@@ -7,6 +7,7 @@ test_description='Tests replace refs functionality'
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-gpg.sh"
diff --git a/t/t7704-repack-cruft.sh b/t/t7704-repack-cruft.sh
index 959e6e2648..5db9f4e10f 100755
--- a/t/t7704-repack-cruft.sh
+++ b/t/t7704-repack-cruft.sh
@@ -2,6 +2,7 @@
test_description='git repack works correctly'
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
objdir=.git/objects
diff --git a/transport.c b/transport.c
index bab28965f9..3c4714581f 100644
--- a/transport.c
+++ b/transport.c
@@ -189,6 +189,8 @@ static int fetch_refs_from_bundle(struct transport *transport,
&extra_index_pack_args,
fetch_pack_fsck_objects() ? VERIFY_BUNDLE_FSCK : 0);
transport->hash_algo = data->header.hash_algo;
+
+ strvec_clear(&extra_index_pack_args);
return ret;
}
@@ -945,7 +947,13 @@ static int disconnect_git(struct transport *transport)
finish_connect(data->conn);
}
+ if (data->options.negotiation_tips) {
+ oid_array_clear(data->options.negotiation_tips);
+ free(data->options.negotiation_tips);
+ }
list_objects_filter_release(&data->options.filter_options);
+ oid_array_clear(&data->extra_have);
+ oid_array_clear(&data->shallow);
free(data);
return 0;
}