git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] builtin-push: resurrect parsing of Push: lines
@ 2006-04-30 12:05 Johannes Schindelin
  2006-04-30 22:02 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Schindelin @ 2006-04-30 12:05 UTC (permalink / raw)
  To: git


The C'ification of push left these behind.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>

---

 builtin-push.c |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/builtin-push.c b/builtin-push.c
index a0c1caa..4e659f0 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -68,6 +68,10 @@ static void set_refspecs(const char **re
 	expand_refspecs();
 }
 
+#define MAX_REFSPECS 10
+static int current_refspec = 0;
+static char *refspecs_[MAX_REFSPECS];
+
 static int get_remotes_uri(const char *repo, const char *uri[MAX_URI])
 {
 	int n = 0;
@@ -76,11 +80,17 @@ static int get_remotes_uri(const char *r
 	if (!f)
 		return -1;
 	while (fgets(buffer, BUF_SIZE, f)) {
+		int is_refspec;
 		char *s, *p;
 
-		if (strncmp("URL: ", buffer, 5))
+		if (!strncmp("URL: ", buffer, 5)) {
+			is_refspec = 0;
+			s = buffer + 5;
+		} else if (!strncmp("Push: ", buffer, 6)) {
+			is_refspec = 1;
+			s = buffer + 6;
+		} else
 			continue;
-		s = buffer + 5;
 
 		/* Remove whitespace at the head.. */
 		while (isspace(*s))
@@ -93,9 +103,10 @@ static int get_remotes_uri(const char *r
 		while (isspace(p[-1]))
 			*--p = 0;
 
-		uri[n++] = strdup(s);
-		if (n == MAX_URI)
-			break;
+		if (!is_refspec && n < MAX_URI)
+			uri[n++] = strdup(s);
+		else if (is_refspec && current_refspec < MAX_REFSPECS)
+			refspecs_[current_refspec++] = strdup(s);
 	}
 	fclose(f);
 	if (!n)
@@ -140,6 +151,8 @@ static int get_uri(const char *repo, con
 	int n;
 
 	if (*repo != '/') {
+		current_refspec = 0;
+
 		n = get_remotes_uri(repo, uri);
 		if (n > 0)
 			return n;
@@ -165,6 +178,9 @@ static int do_push(const char *repo)
 	if (n <= 0)
 		die("bad repository '%s'", repo);
 
+	if (refspec_nr == 0)
+		set_refspecs((const char**)refspecs_, current_refspec);
+
 	argv = xmalloc((refspec_nr + 10) * sizeof(char *));
 	argv[0] = "dummy-send-pack";
 	argc = 1;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-04-30 23:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-30 12:05 [PATCH] builtin-push: resurrect parsing of Push: lines Johannes Schindelin
2006-04-30 22:02 ` Junio C Hamano
2006-04-30 22:59   ` Junio C Hamano
2006-04-30 23:32     ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).