Skip to content

Commit 0baad1f

Browse files
ttaylorrgitster
authored andcommitted
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 <[email protected]> Acked-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3809633 commit 0baad1f

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

refspec.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,16 @@ void refspec_item_clear(struct refspec_item *item)
178178
item->exact_sha1 = 0;
179179
}
180180

181-
void refspec_init(struct refspec *rs, int fetch)
181+
void refspec_init_fetch(struct refspec *rs)
182182
{
183-
memset(rs, 0, sizeof(*rs));
184-
rs->fetch = fetch;
183+
struct refspec blank = REFSPEC_INIT_FETCH;
184+
memcpy(rs, &blank, sizeof(*rs));
185+
}
186+
187+
void refspec_init_push(struct refspec *rs)
188+
{
189+
struct refspec blank = REFSPEC_INIT_PUSH;
190+
memcpy(rs, &blank, sizeof(*rs));
185191
}
186192

187193
void refspec_append(struct refspec *rs, const char *refspec)

refspec.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ int refspec_item_init(struct refspec_item *item, const char *refspec,
5252
void refspec_item_init_or_die(struct refspec_item *item, const char *refspec,
5353
int fetch);
5454
void refspec_item_clear(struct refspec_item *item);
55-
void refspec_init(struct refspec *rs, int fetch);
55+
void refspec_init_fetch(struct refspec *rs);
56+
void refspec_init_push(struct refspec *rs);
5657
void refspec_append(struct refspec *rs, const char *refspec);
5758
__attribute__((format (printf,2,3)))
5859
void refspec_appendf(struct refspec *rs, const char *fmt, ...);

remote.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ static struct remote *make_remote(struct remote_state *remote_state,
143143
ret->prune = -1; /* unspecified */
144144
ret->prune_tags = -1; /* unspecified */
145145
ret->name = xstrndup(name, len);
146-
refspec_init(&ret->push, 0);
147-
refspec_init(&ret->fetch, 1);
146+
refspec_init_push(&ret->push);
147+
refspec_init_fetch(&ret->fetch);
148148
string_list_init_dup(&ret->server_options);
149149

150150
ALLOC_GROW(remote_state->remotes, remote_state->remotes_nr + 1,

transport-helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static struct child_process *get_helper(struct transport *transport)
162162

163163
data->helper = helper;
164164
data->no_disconnect_req = 0;
165-
refspec_init(&data->rs, 1);
165+
refspec_init_fetch(&data->rs);
166166

167167
/*
168168
* Open the output as FILE* so strbuf_getline_*() family of

0 commit comments

Comments
 (0)