parse_fetch_refspec(): clarify the codeflow a bit
Most parts of the cascaded if/else if/... checked an allowable condition but some checked forbidden conditions. This makes adding new allowable conditions unnecessarily inconvenient. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
daebaa7813
commit
def249911a
29
remote.c
29
remote.c
@ -538,7 +538,7 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Before going on, special case ":" (or "+:") as a refspec
|
* Before going on, special case ":" (or "+:") as a refspec
|
||||||
* for matching refs.
|
* for pushing matching refs.
|
||||||
*/
|
*/
|
||||||
if (!fetch && rhs == lhs && rhs[1] == '\0') {
|
if (!fetch && rhs == lhs && rhs[1] == '\0') {
|
||||||
rs[i].matching = 1;
|
rs[i].matching = 1;
|
||||||
@ -565,26 +565,21 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp
|
|||||||
flags = REFNAME_ALLOW_ONELEVEL | (is_glob ? REFNAME_REFSPEC_PATTERN : 0);
|
flags = REFNAME_ALLOW_ONELEVEL | (is_glob ? REFNAME_REFSPEC_PATTERN : 0);
|
||||||
|
|
||||||
if (fetch) {
|
if (fetch) {
|
||||||
/*
|
/* LHS */
|
||||||
* LHS
|
|
||||||
* - empty is allowed; it means HEAD.
|
|
||||||
* - otherwise it must be a valid looking ref.
|
|
||||||
*/
|
|
||||||
if (!*rs[i].src)
|
if (!*rs[i].src)
|
||||||
; /* empty is ok */
|
; /* empty is ok; it means "HEAD" */
|
||||||
else if (check_refname_format(rs[i].src, flags))
|
else if (!check_refname_format(rs[i].src, flags))
|
||||||
|
; /* valid looking ref is ok */
|
||||||
|
else
|
||||||
goto invalid;
|
goto invalid;
|
||||||
/*
|
/* RHS */
|
||||||
* RHS
|
|
||||||
* - missing is ok, and is same as empty.
|
|
||||||
* - empty is ok; it means not to store.
|
|
||||||
* - otherwise it must be a valid looking ref.
|
|
||||||
*/
|
|
||||||
if (!rs[i].dst)
|
if (!rs[i].dst)
|
||||||
; /* ok */
|
; /* missing is ok; it is the same as empty */
|
||||||
else if (!*rs[i].dst)
|
else if (!*rs[i].dst)
|
||||||
; /* ok */
|
; /* empty is ok; it means "do not store" */
|
||||||
else if (check_refname_format(rs[i].dst, flags))
|
else if (!check_refname_format(rs[i].dst, flags))
|
||||||
|
; /* valid looking ref is ok */
|
||||||
|
else
|
||||||
goto invalid;
|
goto invalid;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user