git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] Add refspec search for push destinations

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Jun 12, 2007, 03:10 UTC
Message-ID
<Pine.LNX.4.64.0706112306340.5848@iabervon.org>
Also clarifies the comment for tracking refs, and shares the implementation.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
---
 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
Message 1 of 1 in “Add refspec search for push destinations”
  1. 2/3 Add refspec search for push destinationsDaniel Barkalow, Jun 12, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.