diff options
author | Daniel Barkalow <barkalow@iabervon.org> | 2009-03-07 01:11:39 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-03-07 12:19:28 -0800 |
commit | abd2bde78bd994166900290434a2048e660dabed (patch) | |
tree | da95f1db0ca4b46c4220d22da637577cc1460c95 /refs.c | |
parent | 08fbdb30438fd7087c5abe15840a22fe21094515 (diff) | |
download | git-abd2bde78bd994166900290434a2048e660dabed.tar.gz |
Support '*' in the middle of a refspec
In order to keep the requirements strict, each * has to be a full path
component, and there may only be one * per side. This requirement is
enforced entirely by check_ref_format(); the matching implementation
will substitute the whatever matches the * in the lhs for the * in the
rhs.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r-- | refs.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -694,6 +694,7 @@ static inline int bad_ref_char(int ch) int check_ref_format(const char *ref) { int ch, level, bad_type; + int ret = CHECK_REF_FORMAT_OK; const char *cp = ref; level = 0; @@ -709,9 +710,11 @@ int check_ref_format(const char *ref) return CHECK_REF_FORMAT_ERROR; bad_type = bad_ref_char(ch); if (bad_type) { - return (bad_type == 2 && !*cp) - ? CHECK_REF_FORMAT_WILDCARD - : CHECK_REF_FORMAT_ERROR; + if (bad_type == 2 && (!*cp || *cp == '/') && + ret == CHECK_REF_FORMAT_OK) + ret = CHECK_REF_FORMAT_WILDCARD; + else + return CHECK_REF_FORMAT_ERROR; } /* scan the rest of the path component */ @@ -729,7 +732,7 @@ int check_ref_format(const char *ref) if (!ch) { if (level < 2) return CHECK_REF_FORMAT_ONELEVEL; - return CHECK_REF_FORMAT_OK; + return ret; } } } |