[PATCH 2/3] Add refspec search for push destinations
From: Daniel Barkalow <hidden>
Date: 2016-06-15 22:43:15
Subsystem:
the rest · Maintainer:
Linus Torvalds
Also clarifies the comment for tracking refs, and shares the implementation. Signed-off-by: Daniel Barkalow <redacted> --- remote.c | 17 ++++++++++++++--- remote.h | 9 ++++++++- 2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/remote.c b/remote.c
index 1fbceeb..b6d6fd6 100644
--- a/remote.c
+++ b/remote.c@@ -339,11 +339,12 @@ int remote_has_uri(struct remote *remote, const char *uri) return 0; } -int remote_find_tracking(struct remote *remote, struct refspec *refspec) +static int find_refspec(struct refspec *refspecs, int refspec_nr, + struct refspec *refspec) { int i; - for (i = 0; i < remote->fetch_refspec_nr; i++) { - struct refspec *fetch = &remote->fetch[i]; + for (i = 0; i < refspec_nr; i++) { + struct refspec *fetch = &refspecs[i]; if (!fetch->dst) continue; if (fetch->pattern) {
@@ -370,6 +371,16 @@ int remote_find_tracking(struct remote *remote, struct refspec *refspec) return -1; } +int remote_find_tracking(struct remote *remote, struct refspec *refspec) +{ + return find_refspec(remote->fetch, remote->fetch_refspec_nr, refspec); +} + +int remote_find_push(struct remote *remote, struct refspec *refspec) +{ + return find_refspec(remote->push, remote->push_refspec_nr, refspec); +} + static int count_refspec_match(const char *pattern, struct ref *refs, struct ref **matched_ref)
diff --git a/remote.h b/remote.h
index 14615e8..01f83b7 100644
--- a/remote.h
+++ b/remote.h@@ -34,10 +34,17 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail, int nr_refspec, char **refspec, int all); /* - * For the given remote, reads the refspec's src and sets the other fields. + * For the given remote, reads the refspec's src and sets the other + * fields for a fetch refspec. */ int remote_find_tracking(struct remote *remote, struct refspec *refspec); +/* + * For the given remote, reads the refspec's src and sets the other + * fields for a push refspec. + */ +int remote_find_push(struct remote *remote, struct refspec *refspec); + struct branch { const char *name; const char *refname;
--
1.5.2.901.g27ad4-dirty