mirror of
https://github.com/git/git
synced 2024-09-13 13:24:41 +00:00
Merge branch 'ab/release-transport-ls-refs-options'
* ab/release-transport-ls-refs-options: ls-remote & transport API: release "struct transport_ls_refs_options"
This commit is contained in:
commit
18636afdce
|
@ -1235,7 +1235,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
|||
}
|
||||
else {
|
||||
const char *branch;
|
||||
char *ref;
|
||||
const char *ref;
|
||||
char *ref_free = NULL;
|
||||
|
||||
if (option_branch)
|
||||
die(_("Remote branch %s not found in upstream %s"),
|
||||
|
@ -1251,17 +1252,16 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
|||
skip_prefix(transport_ls_refs_options.unborn_head_target,
|
||||
"refs/heads/", &branch)) {
|
||||
ref = transport_ls_refs_options.unborn_head_target;
|
||||
transport_ls_refs_options.unborn_head_target = NULL;
|
||||
create_symref("HEAD", ref, reflog_msg.buf);
|
||||
} else {
|
||||
branch = git_default_branch_name(0);
|
||||
ref = xstrfmt("refs/heads/%s", branch);
|
||||
ref_free = xstrfmt("refs/heads/%s", branch);
|
||||
ref = ref_free;
|
||||
}
|
||||
|
||||
if (!option_bare)
|
||||
install_branch_config(0, branch, remote_name, ref);
|
||||
|
||||
free(ref);
|
||||
free(ref_free);
|
||||
}
|
||||
|
||||
write_refspec_config(src_ref_prefix, our_head_points_at,
|
||||
|
@ -1313,7 +1313,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
|||
UNLEAK(repo);
|
||||
junk_mode = JUNK_LEAVE_ALL;
|
||||
|
||||
strvec_clear(&transport_ls_refs_options.ref_prefixes);
|
||||
free(transport_ls_refs_options.unborn_head_target);
|
||||
transport_ls_refs_options_release(&transport_ls_refs_options);
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -1594,7 +1594,7 @@ static int do_fetch(struct transport *transport,
|
|||
} else
|
||||
remote_refs = NULL;
|
||||
|
||||
strvec_clear(&transport_ls_refs_options.ref_prefixes);
|
||||
transport_ls_refs_options_release(&transport_ls_refs_options);
|
||||
|
||||
ref_map = get_ref_map(transport->remote, remote_refs, rs,
|
||||
tags, &autotags);
|
||||
|
|
|
@ -155,6 +155,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
|
|||
|
||||
ref_array_clear(&ref_array);
|
||||
if (transport_disconnect(transport))
|
||||
return 1;
|
||||
status = 1;
|
||||
transport_ls_refs_options_release(&transport_options);
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -379,7 +379,7 @@ struct ref **get_remote_heads(struct packet_reader *reader,
|
|||
|
||||
/* Returns 1 when a valid ref has been added to `list`, 0 otherwise */
|
||||
static int process_ref_v2(struct packet_reader *reader, struct ref ***list,
|
||||
char **unborn_head_target)
|
||||
const char **unborn_head_target)
|
||||
{
|
||||
int ret = 1;
|
||||
int i = 0;
|
||||
|
@ -483,7 +483,7 @@ struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,
|
|||
const char *hash_name;
|
||||
struct strvec *ref_prefixes = transport_options ?
|
||||
&transport_options->ref_prefixes : NULL;
|
||||
char **unborn_head_target = transport_options ?
|
||||
const char **unborn_head_target = transport_options ?
|
||||
&transport_options->unborn_head_target : NULL;
|
||||
*list = NULL;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
test_description='refspec parsing'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_refspec () {
|
||||
|
|
|
@ -1292,7 +1292,7 @@ int transport_push(struct repository *r,
|
|||
&transport_options);
|
||||
trace2_region_leave("transport_push", "get_refs_list", r);
|
||||
|
||||
strvec_clear(&transport_options.ref_prefixes);
|
||||
transport_ls_refs_options_release(&transport_options);
|
||||
|
||||
if (flags & TRANSPORT_PUSH_ALL)
|
||||
match_flags |= MATCH_REFS_ALL;
|
||||
|
@ -1420,6 +1420,12 @@ const struct ref *transport_get_remote_refs(struct transport *transport,
|
|||
return transport->remote_refs;
|
||||
}
|
||||
|
||||
void transport_ls_refs_options_release(struct transport_ls_refs_options *opts)
|
||||
{
|
||||
strvec_clear(&opts->ref_prefixes);
|
||||
free((char *)opts->unborn_head_target);
|
||||
}
|
||||
|
||||
int transport_fetch_refs(struct transport *transport, struct ref *refs)
|
||||
{
|
||||
int rc;
|
||||
|
|
10
transport.h
10
transport.h
|
@ -257,15 +257,19 @@ struct transport_ls_refs_options {
|
|||
/*
|
||||
* If unborn_head_target is not NULL, and the remote reports HEAD as
|
||||
* pointing to an unborn branch, transport_get_remote_refs() stores the
|
||||
* unborn branch in unborn_head_target. It should be freed by the
|
||||
* caller.
|
||||
* unborn branch in unborn_head_target.
|
||||
*/
|
||||
char *unborn_head_target;
|
||||
const char *unborn_head_target;
|
||||
};
|
||||
#define TRANSPORT_LS_REFS_OPTIONS_INIT { \
|
||||
.ref_prefixes = STRVEC_INIT, \
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the "struct transport_ls_refs_options".
|
||||
*/
|
||||
void transport_ls_refs_options_release(struct transport_ls_refs_options *opts);
|
||||
|
||||
/*
|
||||
* Retrieve refs from a remote.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue