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>
This commit is contained in:

committed by
Junio C Hamano

parent
08fbdb3043
commit
abd2bde78b
11
refs.c
11
refs.c
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user