summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-12-04 17:07:10 -0800
committerJunio C Hamano <gitster@pobox.com>2007-12-04 17:07:10 -0800
commit9bbe6db85f368fc4f75cc9f6c4bfaf2269bf0068 (patch)
treed626f21e0b87a364d213d3fba26cc92d9fb5a3f6 /refs.c
parentf64c81d4282b1dacf2cf095bfb0f7708b99b3ecf (diff)
parent605b4978a105e2f40a353513f616be7d20f91c15 (diff)
downloadgit-9bbe6db85f368fc4f75cc9f6c4bfaf2269bf0068.tar.gz
Merge branch 'sp/refspec-match'
* sp/refspec-match: refactor fetch's ref matching to use refname_match() push: use same rules as git-rev-parse to resolve refspecs add refname_match() push: support pushing HEAD to real branch name
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/refs.c b/refs.c
index 54ec98d153..3e6e98c5eb 100644
--- a/refs.c
+++ b/refs.c
@@ -643,6 +643,37 @@ int check_ref_format(const char *ref)
}
}
+const char *ref_rev_parse_rules[] = {
+ "%.*s",
+ "refs/%.*s",
+ "refs/tags/%.*s",
+ "refs/heads/%.*s",
+ "refs/remotes/%.*s",
+ "refs/remotes/%.*s/HEAD",
+ NULL
+};
+
+const char *ref_fetch_rules[] = {
+ "%.*s",
+ "refs/%.*s",
+ "refs/heads/%.*s",
+ NULL
+};
+
+int refname_match(const char *abbrev_name, const char *full_name, const char **rules)
+{
+ const char **p;
+ const int abbrev_name_len = strlen(abbrev_name);
+
+ for (p = rules; *p; p++) {
+ if (!strcmp(full_name, mkpath(*p, abbrev_name_len, abbrev_name))) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
static struct ref_lock *verify_lock(struct ref_lock *lock,
const unsigned char *old_sha1, int mustexist)
{