summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2025-03-18 18:50:21 -0400
committerJunio C Hamano <gitster@pobox.com>2025-03-21 01:45:16 -0700
commit0baad1f3aee508d84bf74b9670f283f8c91e55dd (patch)
treecb48414cc881f331b4e2d90da6c0485c0c9b648c
parent3809633d0adb77b02ba8cfe87578134e6a30f54d (diff)
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>
-rw-r--r--refspec.c12
-rw-r--r--refspec.h3
-rw-r--r--remote.c4
-rw-r--r--transport-helper.c2
4 files changed, 14 insertions, 7 deletions
diff --git a/refspec.c b/refspec.c
index db5a1c34a5..f6be0c54d7 100644
--- a/refspec.c
+++ b/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)
diff --git a/refspec.h b/refspec.h
index 155494cd3a..7db68e56c8 100644
--- a/refspec.h
+++ b/refspec.h
@@ -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, ...);
diff --git a/remote.c b/remote.c
index addd4a9999..25af97a44b 100644
--- a/remote.c
+++ b/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,
diff --git a/transport-helper.c b/transport-helper.c
index 43cd760119..69391ee7d2 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -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