revision.h: store hidden refs in a strvec
In subsequent commits, it will be convenient to have a 'const char **'
of hidden refs (matching `transfer.hiderefs`, `uploadpack.hideRefs`,
etc.), instead of a `string_list`.
Convert spots throughout the tree that store the list of hidden refs
from a `string_list` to a `strvec`.
Note that in `parse_hide_refs_config()` there is an ugly const-cast used
to avoid an extra copy of each value before trimming any trailing slash
characters. This could instead be written as:
ref = xstrdup(value);
len = strlen(ref);
while (len && ref[len - 1] == '/')
ref[--len] = '\0';
strvec_push(hide_refs, ref);
free(ref);
but the double-copy (once when calling `xstrdup()`, and another via
`strvec_push()`) is wasteful.
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
c489f47a64
commit
c45841fff8
@ -69,7 +69,7 @@ struct upload_pack_data {
|
||||
struct object_array have_obj;
|
||||
struct oid_array haves; /* v2 only */
|
||||
struct string_list wanted_refs; /* v2 only */
|
||||
struct string_list hidden_refs;
|
||||
struct strvec hidden_refs;
|
||||
|
||||
struct object_array shallows;
|
||||
struct string_list deepen_not;
|
||||
@ -127,7 +127,7 @@ static void upload_pack_data_init(struct upload_pack_data *data)
|
||||
{
|
||||
struct string_list symref = STRING_LIST_INIT_DUP;
|
||||
struct string_list wanted_refs = STRING_LIST_INIT_DUP;
|
||||
struct string_list hidden_refs = STRING_LIST_INIT_DUP;
|
||||
struct strvec hidden_refs = STRVEC_INIT;
|
||||
struct object_array want_obj = OBJECT_ARRAY_INIT;
|
||||
struct object_array have_obj = OBJECT_ARRAY_INIT;
|
||||
struct oid_array haves = OID_ARRAY_INIT;
|
||||
@ -162,7 +162,7 @@ static void upload_pack_data_clear(struct upload_pack_data *data)
|
||||
{
|
||||
string_list_clear(&data->symref, 1);
|
||||
string_list_clear(&data->wanted_refs, 1);
|
||||
string_list_clear(&data->hidden_refs, 0);
|
||||
strvec_clear(&data->hidden_refs);
|
||||
object_array_clear(&data->want_obj);
|
||||
object_array_clear(&data->have_obj);
|
||||
oid_array_clear(&data->haves);
|
||||
@ -1170,7 +1170,7 @@ static void receive_needs(struct upload_pack_data *data,
|
||||
|
||||
/* return non-zero if the ref is hidden, otherwise 0 */
|
||||
static int mark_our_ref(const char *refname, const char *refname_full,
|
||||
const struct object_id *oid, const struct string_list *hidden_refs)
|
||||
const struct object_id *oid, const struct strvec *hidden_refs)
|
||||
{
|
||||
struct object *o = lookup_unknown_object(the_repository, oid);
|
||||
|
||||
@ -1465,7 +1465,7 @@ static int parse_want(struct packet_writer *writer, const char *line,
|
||||
|
||||
static int parse_want_ref(struct packet_writer *writer, const char *line,
|
||||
struct string_list *wanted_refs,
|
||||
struct string_list *hidden_refs,
|
||||
struct strvec *hidden_refs,
|
||||
struct object_array *want_obj)
|
||||
{
|
||||
const char *refname_nons;
|
||||
|
||||
Reference in New Issue
Block a user