Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
push: convert to use struct refspec
author
Brandon Williams
<bmwill@google.com>
Wed, 16 May 2018 22:58:16 +0000
(15:58 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 17 May 2018 21:19:44 +0000
(06:19 +0900)
Convert the refspecs in builtin/push.c to be stored in a 'struct
refspec' instead of being stored in a list of 'struct refspec_item's.
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/push.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
800a4ab
)
diff --git
a/builtin/push.c
b/builtin/push.c
index df5df6c0dc737044464a0d0c9e1757bcfa4717ff..ef42979d1e399007fbaf74c1972a21931200a4b1 100644
(file)
--- a/
builtin/push.c
+++ b/
builtin/push.c
@@
-57,19
+57,10
@@
static enum transport_family family;
static struct push_cas_option cas;
static struct push_cas_option cas;
-static const char **refspec;
-static int refspec_nr;
-static int refspec_alloc;
+static struct refspec rs = REFSPEC_INIT_PUSH;
static struct string_list push_options_config = STRING_LIST_INIT_DUP;
static struct string_list push_options_config = STRING_LIST_INIT_DUP;
-static void add_refspec(const char *ref)
-{
- refspec_nr++;
- ALLOC_GROW(refspec, refspec_nr, refspec_alloc);
- refspec[refspec_nr-1] = ref;
-}
-
static const char *map_refspec(const char *ref,
struct remote *remote, struct ref *local_refs)
{
static const char *map_refspec(const char *ref,
struct remote *remote, struct ref *local_refs)
{
@@
-138,7
+129,7
@@
static void set_refspecs(const char **refs, int nr, const char *repo)
}
ref = map_refspec(ref, remote, local_refs);
}
}
ref = map_refspec(ref, remote, local_refs);
}
-
add_refspec(
ref);
+
refspec_append(&rs,
ref);
}
}
}
}
@@
-226,7
+217,7
@@
static void setup_push_upstream(struct remote *remote, struct branch *branch,
}
strbuf_addf(&refspec, "%s:%s", branch->refname, branch->merge[0]->src);
}
strbuf_addf(&refspec, "%s:%s", branch->refname, branch->merge[0]->src);
-
add_refspec(
refspec.buf);
+
refspec_append(&rs,
refspec.buf);
}
static void setup_push_current(struct remote *remote, struct branch *branch)
}
static void setup_push_current(struct remote *remote, struct branch *branch)
@@
-236,7
+227,7
@@
static void setup_push_current(struct remote *remote, struct branch *branch)
if (!branch)
die(_(message_detached_head_die), remote->name);
strbuf_addf(&refspec, "%s:%s", branch->refname, branch->refname);
if (!branch)
die(_(message_detached_head_die), remote->name);
strbuf_addf(&refspec, "%s:%s", branch->refname, branch->refname);
-
add_refspec(
refspec.buf);
+
refspec_append(&rs,
refspec.buf);
}
static int is_workflow_triangular(struct remote *remote)
}
static int is_workflow_triangular(struct remote *remote)
@@
-253,7
+244,7
@@
static void setup_default_push_refspecs(struct remote *remote)
switch (push_default) {
default:
case PUSH_DEFAULT_MATCHING:
switch (push_default) {
default:
case PUSH_DEFAULT_MATCHING:
-
add_refspec(
":");
+
refspec_append(&rs,
":");
break;
case PUSH_DEFAULT_UNSPECIFIED:
break;
case PUSH_DEFAULT_UNSPECIFIED:
@@
-341,7
+332,8
@@
static void advise_ref_needs_force(void)
advise(_(message_advice_ref_needs_force));
}
advise(_(message_advice_ref_needs_force));
}
-static int push_with_options(struct transport *transport, int flags)
+static int push_with_options(struct transport *transport, struct refspec *rs,
+ int flags)
{
int err;
unsigned int reject_reasons;
{
int err;
unsigned int reject_reasons;
@@
-363,7
+355,7
@@
static int push_with_options(struct transport *transport, int flags)
if (verbosity > 0)
fprintf(stderr, _("Pushing to %s\n"), transport->url);
if (verbosity > 0)
fprintf(stderr, _("Pushing to %s\n"), transport->url);
- err = transport_push(transport, r
efspec_nr, refspec
, flags,
+ err = transport_push(transport, r
s->raw_nr, rs->raw
, flags,
&reject_reasons);
if (err != 0) {
fprintf(stderr, "%s", push_get_color(PUSH_COLOR_ERROR));
&reject_reasons);
if (err != 0) {
fprintf(stderr, "%s", push_get_color(PUSH_COLOR_ERROR));
@@
-397,6
+389,7
@@
static int do_push(const char *repo, int flags,
struct remote *remote = pushremote_get(repo);
const char **url;
int url_nr;
struct remote *remote = pushremote_get(repo);
const char **url;
int url_nr;
+ struct refspec *push_refspec = &rs;
if (!remote) {
if (repo)
if (!remote) {
if (repo)
@@
-417,10
+410,9
@@
static int do_push(const char *repo, int flags,
if (push_options->nr)
flags |= TRANSPORT_PUSH_OPTIONS;
if (push_options->nr)
flags |= TRANSPORT_PUSH_OPTIONS;
- if (!refspec && !(flags & TRANSPORT_PUSH_ALL)) {
- if (remote->push.raw_nr) {
- refspec = remote->push.raw;
- refspec_nr = remote->push.raw_nr;
+ if (!push_refspec->nr && !(flags & TRANSPORT_PUSH_ALL)) {
+ if (remote->push.nr) {
+ push_refspec = &remote->push;
} else if (!(flags & TRANSPORT_PUSH_MIRROR))
setup_default_push_refspecs(remote);
}
} else if (!(flags & TRANSPORT_PUSH_MIRROR))
setup_default_push_refspecs(remote);
}
@@
-432,7
+424,7
@@
static int do_push(const char *repo, int flags,
transport_get(remote, url[i]);
if (flags & TRANSPORT_PUSH_OPTIONS)
transport->push_options = push_options;
transport_get(remote, url[i]);
if (flags & TRANSPORT_PUSH_OPTIONS)
transport->push_options = push_options;
- if (push_with_options(transport, flags))
+ if (push_with_options(transport,
push_refspec,
flags))
errs++;
}
} else {
errs++;
}
} else {
@@
-440,7
+432,7
@@
static int do_push(const char *repo, int flags,
transport_get(remote, NULL);
if (flags & TRANSPORT_PUSH_OPTIONS)
transport->push_options = push_options;
transport_get(remote, NULL);
if (flags & TRANSPORT_PUSH_OPTIONS)
transport->push_options = push_options;
- if (push_with_options(transport, flags))
+ if (push_with_options(transport,
push_refspec,
flags))
errs++;
}
return !!errs;
errs++;
}
return !!errs;
@@
-631,7
+623,7
@@
int cmd_push(int argc, const char **argv, const char *prefix)
flags |= TRANSPORT_RECURSE_SUBMODULES_ONLY;
if (tags)
flags |= TRANSPORT_RECURSE_SUBMODULES_ONLY;
if (tags)
-
add_refspec(
"refs/tags/*");
+
refspec_append(&rs,
"refs/tags/*");
if (argc > 0) {
repo = argv[0];
if (argc > 0) {
repo = argv[0];