Git fork

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>

authored by

Taylor Blau and committed by
Junio C Hamano
0baad1f3 3809633d

+14 -7
+9 -3
refspec.c
··· 178 178 item->exact_sha1 = 0; 179 179 } 180 180 181 - void refspec_init(struct refspec *rs, int fetch) 181 + void refspec_init_fetch(struct refspec *rs) 182 182 { 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)); 185 191 } 186 192 187 193 void refspec_append(struct refspec *rs, const char *refspec)
+2 -1
refspec.h
··· 52 52 void refspec_item_init_or_die(struct refspec_item *item, const char *refspec, 53 53 int fetch); 54 54 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); 56 57 void refspec_append(struct refspec *rs, const char *refspec); 57 58 __attribute__((format (printf,2,3))) 58 59 void refspec_appendf(struct refspec *rs, const char *fmt, ...);
+2 -2
remote.c
··· 143 143 ret->prune = -1; /* unspecified */ 144 144 ret->prune_tags = -1; /* unspecified */ 145 145 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); 148 148 string_list_init_dup(&ret->server_options); 149 149 150 150 ALLOC_GROW(remote_state->remotes, remote_state->remotes_nr + 1,
+1 -1
transport-helper.c
··· 162 162 163 163 data->helper = helper; 164 164 data->no_disconnect_req = 0; 165 - refspec_init(&data->rs, 1); 165 + refspec_init_fetch(&data->rs); 166 166 167 167 /* 168 168 * Open the output as FILE* so strbuf_getline_*() family of