Update callers of check_ref_format()
This updates send-pack and fast-import to use symbolic constants for checking the return values from check_ref_format(), and also futureproof the logic in lock_any_ref_for_update() to explicitly name the case that is usually considered an error but is Ok for this particular use. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
321b1842dc
commit
257f3020f6
@ -541,10 +541,12 @@ static void verify_remote_names(int nr_heads, const char **heads)
|
|||||||
remote = remote ? (remote + 1) : heads[i];
|
remote = remote ? (remote + 1) : heads[i];
|
||||||
switch (check_ref_format(remote)) {
|
switch (check_ref_format(remote)) {
|
||||||
case 0: /* ok */
|
case 0: /* ok */
|
||||||
case -2: /* ok but a single level -- that is fine for
|
case CHECK_REF_FORMAT_ONELEVEL:
|
||||||
|
/* ok but a single level -- that is fine for
|
||||||
* a match pattern.
|
* a match pattern.
|
||||||
*/
|
*/
|
||||||
case -3: /* ok but ends with a pattern-match character */
|
case CHECK_REF_FORMAT_WILDCARD:
|
||||||
|
/* ok but ends with a pattern-match character */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
die("remote part of refspec is not a valid name in %s",
|
die("remote part of refspec is not a valid name in %s",
|
||||||
|
@ -643,7 +643,8 @@ static struct branch *new_branch(const char *name)
|
|||||||
die("Invalid attempt to create duplicate branch: %s", name);
|
die("Invalid attempt to create duplicate branch: %s", name);
|
||||||
switch (check_ref_format(name)) {
|
switch (check_ref_format(name)) {
|
||||||
case 0: break; /* its valid */
|
case 0: break; /* its valid */
|
||||||
case -2: break; /* valid, but too few '/', allow anyway */
|
case CHECK_REF_FORMAT_ONELEVEL:
|
||||||
|
break; /* valid, but too few '/', allow anyway */
|
||||||
default:
|
default:
|
||||||
die("Branch name doesn't conform to GIT standards: %s", name);
|
die("Branch name doesn't conform to GIT standards: %s", name);
|
||||||
}
|
}
|
||||||
|
6
refs.c
6
refs.c
@ -822,10 +822,10 @@ struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1)
|
|||||||
struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1, int flags)
|
struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1, int flags)
|
||||||
{
|
{
|
||||||
switch (check_ref_format(ref)) {
|
switch (check_ref_format(ref)) {
|
||||||
case CHECK_REF_FORMAT_ERROR:
|
|
||||||
case CHECK_REF_FORMAT_WILDCARD:
|
|
||||||
return NULL;
|
|
||||||
default:
|
default:
|
||||||
|
return NULL;
|
||||||
|
case 0:
|
||||||
|
case CHECK_REF_FORMAT_ONELEVEL:
|
||||||
return lock_ref_sha1_basic(ref, old_sha1, flags, NULL);
|
return lock_ref_sha1_basic(ref, old_sha1, flags, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user