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>
Junio C Hamano committed
Jan 29, 2013 at 12:58 UTC
def249911ad0e36a40a0603fc42b7e9cf0b21546
1 file changed
+12
-17
remote.c
+12
-17
@@ -538,7 +538,7 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp
538
539
/*
540
* Before going on, special case ":" (or "+:") as a refspec
541
- * for matching refs.
541
+ * for pushing matching refs.
542
*/
543
if (!fetch && rhs == lhs && rhs[1] == '\0') {
544
rs[i].matching = 1;
@@ -565,26 +565,21 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp
565
flags = REFNAME_ALLOW_ONELEVEL | (is_glob ? REFNAME_REFSPEC_PATTERN : 0);
566
567
if (fetch) {
568
- /*
569
- * LHS
570
- * - empty is allowed; it means HEAD.
571
- * - otherwise it must be a valid looking ref.
572
- */
568
+ /* LHS */
569
if (!*rs[i].src)
574
- ; /* empty is ok */
575
- else if (check_refname_format(rs[i].src, flags))
570
+ ; /* empty is ok; it means "HEAD" */
571
+ else if (!check_refname_format(rs[i].src, flags))
572
+ ; /* valid looking ref is ok */
573
+ else
574
goto invalid;
577
- /*
578
- * RHS
579
- * - missing is ok, and is same as empty.
580
- * - empty is ok; it means not to store.
581
- * - otherwise it must be a valid looking ref.
582
- */
575
+ /* RHS */
576
if (!rs[i].dst)
584
- ; /* ok */
577
+ ; /* missing is ok; it is the same as empty */
578
else if (!*rs[i].dst)
586
- ; /* ok */
587
- else if (check_refname_format(rs[i].dst, flags))
579
+ ; /* empty is ok; it means "do not store" */
580
+ else if (!check_refname_format(rs[i].dst, flags))
581
+ ; /* valid looking ref is ok */
582
+ else
583
goto invalid;
584
} else {
585
/*