All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Daniel Barkalow <barkalow@iabervon.org>,
	git@vger.kernel.org, Samuel Tardieu <sam@rfc1149.net>
Subject: Re: [PATCH] remote.c: Fix overtight refspec validation
Date: Tue, 25 Mar 2008 21:11:42 -0700	[thread overview]
Message-ID: <7vfxuejf9d.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <7vod92jh3u.fsf@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Tue, 25 Mar 2008 20:31:49 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> Especially that "refs/tags/*" is sad in that it is leaking an internal
> implementation detail.  I do not think the original code ever used
> wildcards on the push side, and it probably was a good idea to allow
> wildcards when the code was rewritten.

Having thought about this a bit more, I think this patch would be more
useful.  Please discard the previous patch to builtin-push.c and replace
with this patch.

Now it allows you to say:

	[remote "neigh"]
        	url = ../neighbour
                push = refs/tags/*

to propagate all tags one-to-one, without having to say
"refs/tags/*:refs/tags/*".

This however has unintended side effect of allowing 

	[remote "bour"]
        	url = ../neighbour
                fetch = refs/heads/*

at the syntax level.  I do not know offhand the fetch backends are
prepared to deal with such wildcard patterns.

Daniel?

---
 remote.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/remote.c b/remote.c
index 40ed246..c39d831 100644
--- a/remote.c
+++ b/remote.c
@@ -417,17 +417,21 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp
 			rhs++;
 			rlen = strlen(rhs);
 			is_glob = (2 <= rlen && !strcmp(rhs + rlen - 2, "/*"));
-			rs[i].dst = xstrndup(rhs, rlen - is_glob * 2);
+			if (is_glob)
+				rlen -= 2;
+			rs[i].dst = xstrndup(rhs, rlen);
 		}
 
 		llen = (rhs ? (rhs - lhs - 1) : strlen(lhs));
-		if (is_glob != (2 <= llen && !memcmp(lhs + llen - 2, "/*", 2)))
-			goto invalid;
-
-		if (is_glob) {
+		if (2 <= llen && !memcmp(lhs + llen - 2, "/*", 2)) {
+			if (rhs && !is_glob)
+				goto invalid;
+			is_glob = 1;
 			llen -= 2;
-			rlen -= 2;
+		} else if (rhs && is_glob) {
+			goto invalid;
 		}
+
 		rs[i].pattern = is_glob;
 		rs[i].src = xstrndup(lhs, llen);
 
@@ -446,7 +450,7 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp
 			}
 			/*
 			 * RHS
-			 * - missing is allowed.
+			 * - missing is ok, and is same as empty.
 			 * - empty is ok; it means not to store.
 			 * - otherwise it must be a valid looking ref.
 			 */

  reply	other threads:[~2008-03-26  4:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-21  0:54 [PATCH] Permit refspec source side to parse as a sha1 Daniel Barkalow
2008-03-21  4:10 ` Junio C Hamano
2008-03-21  4:50   ` Junio C Hamano
2008-03-21  5:09   ` Daniel Barkalow
2008-03-21  5:30     ` Junio C Hamano
2008-03-21  5:57       ` Daniel Barkalow
2008-03-21  6:26         ` Junio C Hamano
2008-03-21 16:08           ` Daniel Barkalow
2008-03-21 22:17             ` [PATCH] remote.c: Fix overtight refspec validation Junio C Hamano
2008-03-21 23:12               ` Daniel Barkalow
2008-03-21 23:59                 ` Junio C Hamano
2008-03-22  0:36                   ` Daniel Barkalow
2008-03-22 19:48                     ` Junio C Hamano
2008-03-22 20:45                       ` Daniel Barkalow
2008-03-26  1:45               ` Linus Torvalds
2008-03-26  3:31                 ` Junio C Hamano
2008-03-26  4:11                   ` Junio C Hamano [this message]
2008-03-26  5:42                     ` Daniel Barkalow
2008-03-26  5:46                       ` Junio C Hamano
2008-03-26  6:22                         ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vfxuejf9d.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=barkalow@iabervon.org \
    --cc=git@vger.kernel.org \
    --cc=sam@rfc1149.net \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.