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

[PATCH v3 1/2] Move find_ref_by_name_abbrev to refs.c so it can be used globally

From
Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
Date
Mar 27, 2009, 17:45 UTC
Message-ID
<1238175913-19175-2-git-send-email-tor.arne.vestbo@nokia.com>
In-Reply-To
<1238175913-19175-1-git-send-email-tor.arne.vestbo@nokia.com>
Signed-off-by: Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
---
 cache.h  |    1 +
 refs.c   |   10 ++++++++++
 remote.c |   10 ----------
 3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/cache.h b/cache.h
index f48e80b..23699a8 100644
--- a/cache.h
+++ b/cache.h
@@ -815,6 +815,7 @@ struct ref {
 #define REF_TAGS	(1u << 2)
 
 extern struct ref *find_ref_by_name(const struct ref *list, const char *name);
+extern struct ref *find_ref_by_name_abbrev(const struct ref *list, const char *name);
 
 #define CONNECT_VERBOSE       (1u << 0)
 extern struct child_process *git_connect(int fd[2], const char *url, const char *prog, int flags);
diff --git a/refs.c b/refs.c
index 26b0014..161e053 100644
--- a/refs.c
+++ b/refs.c
@@ -1644,3 +1644,13 @@ struct ref *find_ref_by_name(const struct ref *list, const char *name)
 			return (struct ref *)list;
 	return NULL;
 }
+
+struct ref *find_ref_by_name_abbrev(const struct ref *list, const char *name)
+{
+	for ( ; list; list = list->next) {
+		if (refname_match(name, list->name, ref_fetch_rules))
+			return (struct ref *)list;
+	}
+	return NULL;
+}
+
diff --git a/remote.c b/remote.c
index e5d6b10..e903b39 100644
--- a/remote.c
+++ b/remote.c
@@ -1220,16 +1220,6 @@ static struct ref *get_expanded_map(const struct ref *remote_refs,
 	return ret;
 }
 
-static const struct ref *find_ref_by_name_abbrev(const struct ref *refs, const char *name)
-{
-	const struct ref *ref;
-	for (ref = refs; ref; ref = ref->next) {
-		if (refname_match(name, ref->name, ref_fetch_rules))
-			return ref;
-	}
-	return NULL;
-}
-
 struct ref *get_remote_ref(const struct ref *remote_refs, const char *name)
 {
 	const struct ref *ref = find_ref_by_name_abbrev(remote_refs, name);
-- 
1.6.2.GIT
Previous: Tor Arne VestbøNext: Tor Arne Vestbø
Message 2 of 3 in “git-clone: Add new option --branch to override initial branch”
  1. 0/2 git-clone: Add new option --branch to override initial branchTor Arne Vestbø, Mar 27, 2009
  2. 1/2 Move find_ref_by_name_abbrev to refs.c so it can be used globallyTor Arne Vestbø, Mar 27, 2009
  3. 2/2 git-clone: Add new option --branch to override initial branchTor Arne Vestbø, Mar 27, 2009

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.