21
21
#include "bisect.h"
22
22
#include "packfile.h"
23
23
#include "worktree.h"
24
+ #include "argv-array.h"
24
25
25
26
volatile show_early_output_fn_t show_early_output ;
26
27
@@ -1672,31 +1673,15 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
1672
1673
return 0 ;
1673
1674
}
1674
1675
1675
- struct cmdline_pathspec {
1676
- int alloc ;
1677
- int nr ;
1678
- const char * * path ;
1679
- };
1680
-
1681
- static void append_prune_data (struct cmdline_pathspec * prune , const char * * av )
1682
- {
1683
- while (* av ) {
1684
- ALLOC_GROW (prune -> path , prune -> nr + 1 , prune -> alloc );
1685
- prune -> path [prune -> nr ++ ] = * (av ++ );
1686
- }
1687
- }
1688
-
1689
1676
static void read_pathspec_from_stdin (struct rev_info * revs , struct strbuf * sb ,
1690
- struct cmdline_pathspec * prune )
1677
+ struct argv_array * prune )
1691
1678
{
1692
- while (strbuf_getline (sb , stdin ) != EOF ) {
1693
- ALLOC_GROW (prune -> path , prune -> nr + 1 , prune -> alloc );
1694
- prune -> path [prune -> nr ++ ] = xstrdup (sb -> buf );
1695
- }
1679
+ while (strbuf_getline (sb , stdin ) != EOF )
1680
+ argv_array_push (prune , sb -> buf );
1696
1681
}
1697
1682
1698
1683
static void read_revisions_from_stdin (struct rev_info * revs ,
1699
- struct cmdline_pathspec * prune )
1684
+ struct argv_array * prune )
1700
1685
{
1701
1686
struct strbuf sb ;
1702
1687
int seen_dashdash = 0 ;
@@ -2286,10 +2271,9 @@ static void NORETURN diagnose_missing_default(const char *def)
2286
2271
int setup_revisions (int argc , const char * * argv , struct rev_info * revs , struct setup_revision_opt * opt )
2287
2272
{
2288
2273
int i , flags , left , seen_dashdash , read_from_stdin , got_rev_arg = 0 , revarg_opt ;
2289
- struct cmdline_pathspec prune_data ;
2274
+ struct argv_array prune_data = ARGV_ARRAY_INIT ;
2290
2275
const char * submodule = NULL ;
2291
2276
2292
- memset (& prune_data , 0 , sizeof (prune_data ));
2293
2277
if (opt )
2294
2278
submodule = opt -> submodule ;
2295
2279
@@ -2305,7 +2289,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
2305
2289
argv [i ] = NULL ;
2306
2290
argc = i ;
2307
2291
if (argv [i + 1 ])
2308
- append_prune_data (& prune_data , argv + i + 1 );
2292
+ argv_array_pushv (& prune_data , argv + i + 1 );
2309
2293
seen_dashdash = 1 ;
2310
2294
break ;
2311
2295
}
@@ -2366,14 +2350,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
2366
2350
for (j = i ; j < argc ; j ++ )
2367
2351
verify_filename (revs -> prefix , argv [j ], j == i );
2368
2352
2369
- append_prune_data (& prune_data , argv + i );
2353
+ argv_array_pushv (& prune_data , argv + i );
2370
2354
break ;
2371
2355
}
2372
2356
else
2373
2357
got_rev_arg = 1 ;
2374
2358
}
2375
2359
2376
- if (prune_data .nr ) {
2360
+ if (prune_data .argc ) {
2377
2361
/*
2378
2362
* If we need to introduce the magic "a lone ':' means no
2379
2363
* pathspec whatsoever", here is the place to do so.
@@ -2388,11 +2372,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
2388
2372
* call init_pathspec() to set revs->prune_data here.
2389
2373
* }
2390
2374
*/
2391
- ALLOC_GROW (prune_data .path , prune_data .nr + 1 , prune_data .alloc );
2392
- prune_data .path [prune_data .nr ++ ] = NULL ;
2393
2375
parse_pathspec (& revs -> prune_data , 0 , 0 ,
2394
- revs -> prefix , prune_data .path );
2376
+ revs -> prefix , prune_data .argv );
2395
2377
}
2378
+ argv_array_clear (& prune_data );
2396
2379
2397
2380
if (revs -> def == NULL )
2398
2381
revs -> def = opt ? opt -> def : NULL ;
0 commit comments