[PATCH v3 1/2] Move find_ref_by_name_abbrev to refs.c so it can be used globally
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