{"thread":{"id":"8566","subject":"[PATCH 2/3] Add refspec search for push destinations","startedAt":"2007-06-12T03:10:50Z","lastAt":"2007-06-12T03:10:50Z","messageCount":1,"participants":["Daniel Barkalow"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"44784","messageId":"Pine.LNX.4.64.0706112306340.5848@iabervon.org","threadId":"8566","inReplyTo":null,"subject":"[PATCH 2/3] Add refspec search for push destinations","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2007-06-12T03:10:50Z","receivedAt":"2007-06-12T03:10:50Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"Also clarifies the comment for tracking refs, and shares the implementation.\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\n remote.c |   17 ++++++++++++++---\n remote.h |    9 ++++++++-\n 2 files changed, 22 insertions(+), 4 deletions(-)\n\ndiff --git a/remote.c b/remote.c\nindex 1fbceeb..b6d6fd6 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -339,11 +339,12 @@ int remote_has_uri(struct remote *remote, const char *uri)\n \treturn 0;\n }\n \n-int remote_find_tracking(struct remote *remote, struct refspec *refspec)\n+static int find_refspec(struct refspec *refspecs, int refspec_nr,\n+\t\t\tstruct refspec *refspec)\n {\n \tint i;\n-\tfor (i = 0; i < remote->fetch_refspec_nr; i++) {\n-\t\tstruct refspec *fetch = &remote->fetch[i];\n+\tfor (i = 0; i < refspec_nr; i++) {\n+\t\tstruct refspec *fetch = &refspecs[i];\n \t\tif (!fetch->dst)\n \t\t\tcontinue;\n \t\tif (fetch->pattern) {\n@@ -370,6 +371,16 @@ int remote_find_tracking(struct remote *remote, struct refspec *refspec)\n \treturn -1;\n }\n \n+int remote_find_tracking(struct remote *remote, struct refspec *refspec)\n+{\n+\treturn find_refspec(remote->fetch, remote->fetch_refspec_nr, refspec);\n+}\n+\n+int remote_find_push(struct remote *remote, struct refspec *refspec)\n+{\n+\treturn find_refspec(remote->push, remote->push_refspec_nr, refspec);\n+}\n+\n static int count_refspec_match(const char *pattern,\n \t\t\t       struct ref *refs,\n \t\t\t       struct ref **matched_ref)\ndiff --git a/remote.h b/remote.h\nindex 14615e8..01f83b7 100644\n--- a/remote.h\n+++ b/remote.h\n@@ -34,10 +34,17 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,\n \t       int nr_refspec, char **refspec, int all);\n \n /*\n- * For the given remote, reads the refspec's src and sets the other fields.\n+ * For the given remote, reads the refspec's src and sets the other\n+ * fields for a fetch refspec.\n  */\n int remote_find_tracking(struct remote *remote, struct refspec *refspec);\n \n+/*\n+ * For the given remote, reads the refspec's src and sets the other\n+ * fields for a push refspec.\n+ */\n+int remote_find_push(struct remote *remote, struct refspec *refspec);\n+\n struct branch {\n \tconst char *name;\n \tconst char *refname;\n-- \n1.5.2.901.g27ad4-dirty\n"}]}