Skip to content

Commit 7d19da4

Browse files
committed
refspec: allow colon-less wildcard "refs/category/*"
"git push --tags elsewhere" is implemented in terms of wildcarded refspec "refs/tags/*" these days, and the user wants to push the tags under the same name to the other branch. This resurrects the support for it. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5cc8f37 commit 7d19da4

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

remote.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -417,17 +417,21 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp
417417
rhs++;
418418
rlen = strlen(rhs);
419419
is_glob = (2 <= rlen && !strcmp(rhs + rlen - 2, "/*"));
420-
rs[i].dst = xstrndup(rhs, rlen - is_glob * 2);
420+
if (is_glob)
421+
rlen -= 2;
422+
rs[i].dst = xstrndup(rhs, rlen);
421423
}
422424

423425
llen = (rhs ? (rhs - lhs - 1) : strlen(lhs));
424-
if (is_glob != (2 <= llen && !memcmp(lhs + llen - 2, "/*", 2)))
425-
goto invalid;
426-
427-
if (is_glob) {
426+
if (2 <= llen && !memcmp(lhs + llen - 2, "/*", 2)) {
427+
if ((rhs && !is_glob) || (!rhs && fetch))
428+
goto invalid;
429+
is_glob = 1;
428430
llen -= 2;
429-
rlen -= 2;
431+
} else if (rhs && is_glob) {
432+
goto invalid;
430433
}
434+
431435
rs[i].pattern = is_glob;
432436
rs[i].src = xstrndup(lhs, llen);
433437

@@ -446,7 +450,7 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp
446450
}
447451
/*
448452
* RHS
449-
* - missing is allowed.
453+
* - missing is ok, and is same as empty.
450454
* - empty is ok; it means not to store.
451455
* - otherwise it must be a valid looking ref.
452456
*/

0 commit comments

Comments
 (0)