summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/refs.c b/refs.c
index 8b7a77f..10f69da 100644
--- a/refs.c
+++ b/refs.c
@@ -13,6 +13,7 @@
#include "tag.h"
#include "submodule.h"
#include "worktree.h"
+#include "argv-array.h"
/*
* List of all available backends
@@ -502,6 +503,19 @@ int refname_match(const char *abbrev_name, const char *full_name)
}
/*
+ * Given a 'prefix' expand it by the rules in 'ref_rev_parse_rules' and add
+ * the results to 'prefixes'
+ */
+void expand_ref_prefix(struct argv_array *prefixes, const char *prefix)
+{
+ const char **p;
+ int len = strlen(prefix);
+
+ for (p = ref_rev_parse_rules; *p; p++)
+ argv_array_pushf(prefixes, *p, len, prefix);
+}
+
+/*
* *string and *len will only be substituted, and *string returned (for
* later free()ing) if the string passed in is a magic short-hand form
* to name a branch.