]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refspec: replace `refspec_init()` with fetch/push variants
authorTaylor Blau <me@ttaylorr.com>
Tue, 18 Mar 2025 22:50:21 +0000 (18:50 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 Mar 2025 08:45:16 +0000 (01:45 -0700)
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>
refspec.c
refspec.h
remote.c
transport-helper.c

index db5a1c34a5bc2b1bfa3a308a6e5c7552a53c3ae3..f6be0c54d76c9d18f39984bb9862567258b1e453 100644 (file)
--- 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)
index 155494cd3ae1d012d8e56945dd408aadfc9dce23..7db68e56c8366fad449e8eed8c6157fd94690c2e 100644 (file)
--- 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, ...);
index addd4a9999d8d6fe4f772324c221cde4372d7271..25af97a44be046061804193765cbe6a466e9b289 100644 (file)
--- 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,
index 43cd760119fb6905004538a62ba4eb049e071c21..69391ee7d28e110f199f64cc86c8583a9815bd39 100644 (file)
@@ -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