@matheusbsbs / matheus-bagliano / commits / 7d19da46fd
Fork 0

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 <gitster@pobox.com>

Junio C Hamano committed Mar 25, 2008 at 21:15 UTC 7d19da46fd108ec463e555cb9fd9efd13b582d4a
1 file changed +11 -7
remote.c
+11 -7
@@ -417,17 +417,21 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp
417 rhs++;
418 rlen = strlen(rhs);
419 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);
423 }
424
425 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;
430 llen -= 2;
429 - rlen -= 2;
431 + } else if (rhs && is_glob) {
432 + goto invalid;
433 }
434 +
435 rs[i].pattern = is_glob;
436 rs[i].src = xstrndup(lhs, llen);
437
@@ -446,7 +450,7 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp
450 }
451 /*
452 * RHS
449 - * - missing is allowed.
453 + * - missing is ok, and is same as empty.
454 * - empty is ok; it means not to store.
455 * - otherwise it must be a valid looking ref.
456 */