@matheusbsbs / matheus-bagliano / commits / 5c477b9725
Fork 0

builtin-push: resurrect parsing of Push: lines

The C'ification of push left these behind. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Apr 30, 2006 at 14:05 UTC 5c477b972583e96b65ef1613c5d0fb1b90af3d0e
1 file changed +21 -5
builtin-push.c
+21 -5
@@ -68,6 +68,10 @@ static void set_refspecs(const char **refs, int nr)
68 expand_refspecs();
69 }
70
71 +#define MAX_REFSPECS 10
72 +static int current_refspec = 0;
73 +static char *refspecs_[MAX_REFSPECS];
74 +
75 static int get_remotes_uri(const char *repo, const char *uri[MAX_URI])
76 {
77 int n = 0;
@@ -76,11 +80,17 @@ static int get_remotes_uri(const char *repo, const char *uri[MAX_URI])
80 if (!f)
81 return -1;
82 while (fgets(buffer, BUF_SIZE, f)) {
83 + int is_refspec;
84 char *s, *p;
85
81 - if (strncmp("URL: ", buffer, 5))
86 + if (!strncmp("URL: ", buffer, 5)) {
87 + is_refspec = 0;
88 + s = buffer + 5;
89 + } else if (!strncmp("Push: ", buffer, 6)) {
90 + is_refspec = 1;
91 + s = buffer + 6;
92 + } else
93 continue;
83 - s = buffer + 5;
94
95 /* Remove whitespace at the head.. */
96 while (isspace(*s))
@@ -93,9 +103,10 @@ static int get_remotes_uri(const char *repo, const char *uri[MAX_URI])
103 while (isspace(p[-1]))
104 *--p = 0;
105
96 - uri[n++] = strdup(s);
97 - if (n == MAX_URI)
98 - break;
106 + if (!is_refspec && n < MAX_URI)
107 + uri[n++] = strdup(s);
108 + else if (is_refspec && current_refspec < MAX_REFSPECS)
109 + refspecs_[current_refspec++] = strdup(s);
110 }
111 fclose(f);
112 if (!n)
@@ -140,6 +151,8 @@ static int get_uri(const char *repo, const char *uri[MAX_URI])
151 int n;
152
153 if (*repo != '/') {
154 + current_refspec = 0;
155 +
156 n = get_remotes_uri(repo, uri);
157 if (n > 0)
158 return n;
@@ -165,6 +178,9 @@ static int do_push(const char *repo)
178 if (n <= 0)
179 die("bad repository '%s'", repo);
180
181 + if (refspec_nr == 0)
182 + set_refspecs((const char**)refspecs_, current_refspec);
183 +
184 argv = xmalloc((refspec_nr + 10) * sizeof(char *));
185 argv[0] = "dummy-send-pack";
186 argc = 1;