@@ -126,8 +126,7 @@ static int send_pack_config(const char *k, const char *v, void *cb)
126
126
127
127
int cmd_send_pack (int argc , const char * * argv , const char * prefix )
128
128
{
129
- int i , nr_refspecs = 0 ;
130
- const char * * refspecs = NULL ;
129
+ struct refspec rs = REFSPEC_INIT_PUSH ;
131
130
const char * remote_name = NULL ;
132
131
struct remote * remote = NULL ;
133
132
const char * dest = NULL ;
@@ -189,8 +188,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
189
188
argc = parse_options (argc , argv , prefix , options , send_pack_usage , 0 );
190
189
if (argc > 0 ) {
191
190
dest = argv [0 ];
192
- refspecs = (const char * * )(argv + 1 );
193
- nr_refspecs = argc - 1 ;
191
+ refspec_appendn (& rs , argv + 1 , argc - 1 );
194
192
}
195
193
196
194
if (!dest )
@@ -209,31 +207,23 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
209
207
args .push_options = push_options .nr ? & push_options : NULL ;
210
208
211
209
if (from_stdin ) {
212
- struct argv_array all_refspecs = ARGV_ARRAY_INIT ;
213
-
214
- for (i = 0 ; i < nr_refspecs ; i ++ )
215
- argv_array_push (& all_refspecs , refspecs [i ]);
216
-
217
210
if (args .stateless_rpc ) {
218
211
const char * buf ;
219
212
while ((buf = packet_read_line (0 , NULL )))
220
- argv_array_push ( & all_refspecs , buf );
213
+ refspec_append ( & rs , buf );
221
214
} else {
222
215
struct strbuf line = STRBUF_INIT ;
223
216
while (strbuf_getline (& line , stdin ) != EOF )
224
- argv_array_push ( & all_refspecs , line .buf );
217
+ refspec_append ( & rs , line .buf );
225
218
strbuf_release (& line );
226
219
}
227
-
228
- refspecs = all_refspecs .argv ;
229
- nr_refspecs = all_refspecs .argc ;
230
220
}
231
221
232
222
/*
233
223
* --all and --mirror are incompatible; neither makes sense
234
224
* with any refspecs.
235
225
*/
236
- if ((nr_refspecs > 0 && (send_all || args .send_mirror )) ||
226
+ if ((rs . nr > 0 && (send_all || args .send_mirror )) ||
237
227
(send_all && args .send_mirror ))
238
228
usage_with_options (send_pack_usage , options );
239
229
@@ -275,7 +265,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
275
265
BUG ("unknown protocol version" );
276
266
}
277
267
278
- transport_verify_remote_names (nr_refspecs , refspecs );
268
+ transport_verify_remote_names (rs . raw_nr , rs . raw );
279
269
280
270
local_refs = get_local_heads ();
281
271
@@ -287,7 +277,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
287
277
flags |= MATCH_REFS_MIRROR ;
288
278
289
279
/* match them up */
290
- if (match_push_refs (local_refs , & remote_refs , nr_refspecs , refspecs , flags ))
280
+ if (match_push_refs (local_refs , & remote_refs , rs . raw_nr , rs . raw , flags ))
291
281
return -1 ;
292
282
293
283
if (!is_empty_cas (& cas ))
0 commit comments