refspec: replace `refspec_init()` with fetch/push variants
To avoid having a Boolean argument in the refspec_init() function, replace it with two variants: - `refspec_init_fetch()` - `refspec_init_push()` to codify the meaning of that Boolean into the function's name itself. Signed-off-by: Taylor Blau <me@ttaylorr.com> Acked-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
3809633d0a
commit
0baad1f3ae
12
refspec.c
12
refspec.c
|
@ -178,10 +178,16 @@ void refspec_item_clear(struct refspec_item *item)
|
|||
item->exact_sha1 = 0;
|
||||
}
|
||||
|
||||
void refspec_init(struct refspec *rs, int fetch)
|
||||
void refspec_init_fetch(struct refspec *rs)
|
||||
{
|
||||
memset(rs, 0, sizeof(*rs));
|
||||
rs->fetch = fetch;
|
||||
struct refspec blank = REFSPEC_INIT_FETCH;
|
||||
memcpy(rs, &blank, sizeof(*rs));
|
||||
}
|
||||
|
||||
void refspec_init_push(struct refspec *rs)
|
||||
{
|
||||
struct refspec blank = REFSPEC_INIT_PUSH;
|
||||
memcpy(rs, &blank, sizeof(*rs));
|
||||
}
|
||||
|
||||
void refspec_append(struct refspec *rs, const char *refspec)
|
||||
|
|
|
@ -52,7 +52,8 @@ int refspec_item_init(struct refspec_item *item, const char *refspec,
|
|||
void refspec_item_init_or_die(struct refspec_item *item, const char *refspec,
|
||||
int fetch);
|
||||
void refspec_item_clear(struct refspec_item *item);
|
||||
void refspec_init(struct refspec *rs, int fetch);
|
||||
void refspec_init_fetch(struct refspec *rs);
|
||||
void refspec_init_push(struct refspec *rs);
|
||||
void refspec_append(struct refspec *rs, const char *refspec);
|
||||
__attribute__((format (printf,2,3)))
|
||||
void refspec_appendf(struct refspec *rs, const char *fmt, ...);
|
||||
|
|
4
remote.c
4
remote.c
|
@ -143,8 +143,8 @@ static struct remote *make_remote(struct remote_state *remote_state,
|
|||
ret->prune = -1; /* unspecified */
|
||||
ret->prune_tags = -1; /* unspecified */
|
||||
ret->name = xstrndup(name, len);
|
||||
refspec_init(&ret->push, 0);
|
||||
refspec_init(&ret->fetch, 1);
|
||||
refspec_init_push(&ret->push);
|
||||
refspec_init_fetch(&ret->fetch);
|
||||
string_list_init_dup(&ret->server_options);
|
||||
|
||||
ALLOC_GROW(remote_state->remotes, remote_state->remotes_nr + 1,
|
||||
|
|
|
@ -162,7 +162,7 @@ static struct child_process *get_helper(struct transport *transport)
|
|||
|
||||
data->helper = helper;
|
||||
data->no_disconnect_req = 0;
|
||||
refspec_init(&data->rs, 1);
|
||||
refspec_init_fetch(&data->rs);
|
||||
|
||||
/*
|
||||
* Open the output as FILE* so strbuf_getline_*() family of
|
||||
|
|
Loading…
Reference in New Issue