@@ -1074,35 +1074,34 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
1074
1074
return 0 ;
1075
1075
}
1076
1076
1077
- static void read_pathspec_from_stdin ( struct rev_info * revs , struct strbuf * sb , const char * * * prune_data )
1078
- {
1079
- const char * * prune = * prune_data ;
1080
- int prune_nr ;
1081
- int prune_alloc ;
1077
+ struct cmdline_pathspec {
1078
+ int alloc ;
1079
+ int nr ;
1080
+ const char * * path ;
1081
+ } ;
1082
1082
1083
- /* count existing ones */
1084
- if (! prune )
1085
- prune_nr = 0 ;
1086
- else
1087
- for ( prune_nr = 0 ; prune [ prune_nr ]; prune_nr ++ )
1088
- ;
1089
- prune_alloc = prune_nr ; /* not really, but we do not know */
1083
+ static void append_prune_data ( struct cmdline_pathspec * prune , const char * * av )
1084
+ {
1085
+ while ( * av ) {
1086
+ ALLOC_GROW ( prune -> path , prune -> nr + 1 , prune -> alloc );
1087
+ prune -> path [ prune -> nr ++ ] = * ( av ++ );
1088
+ }
1089
+ }
1090
1090
1091
+ static void read_pathspec_from_stdin (struct rev_info * revs , struct strbuf * sb ,
1092
+ struct cmdline_pathspec * prune )
1093
+ {
1091
1094
while (strbuf_getwholeline (sb , stdin , '\n' ) != EOF ) {
1092
1095
int len = sb -> len ;
1093
1096
if (len && sb -> buf [len - 1 ] == '\n' )
1094
1097
sb -> buf [-- len ] = '\0' ;
1095
- ALLOC_GROW (prune , prune_nr + 1 , prune_alloc );
1096
- prune [ prune_nr ++ ] = xstrdup (sb -> buf );
1098
+ ALLOC_GROW (prune -> path , prune -> nr + 1 , prune -> alloc );
1099
+ prune -> path [ prune -> nr ++ ] = xstrdup (sb -> buf );
1097
1100
}
1098
- if (prune ) {
1099
- ALLOC_GROW (prune , prune_nr + 1 , prune_alloc );
1100
- prune [prune_nr ] = NULL ;
1101
- }
1102
- * prune_data = prune ;
1103
1101
}
1104
1102
1105
- static void read_revisions_from_stdin (struct rev_info * revs , const char * * * prune )
1103
+ static void read_revisions_from_stdin (struct rev_info * revs ,
1104
+ struct cmdline_pathspec * prune )
1106
1105
{
1107
1106
struct strbuf sb ;
1108
1107
int seen_dashdash = 0 ;
@@ -1445,34 +1444,6 @@ static int for_each_good_bisect_ref(const char *submodule, each_ref_fn fn, void
1445
1444
return for_each_ref_in_submodule (submodule , "refs/bisect/good" , fn , cb_data );
1446
1445
}
1447
1446
1448
- static void append_prune_data (const char * * * prune_data , const char * * av )
1449
- {
1450
- const char * * prune = * prune_data ;
1451
- int prune_nr ;
1452
- int prune_alloc ;
1453
-
1454
- if (!prune ) {
1455
- * prune_data = av ;
1456
- return ;
1457
- }
1458
-
1459
- /* count existing ones */
1460
- for (prune_nr = 0 ; prune [prune_nr ]; prune_nr ++ )
1461
- ;
1462
- prune_alloc = prune_nr ; /* not really, but we do not know */
1463
-
1464
- while (* av ) {
1465
- ALLOC_GROW (prune , prune_nr + 1 , prune_alloc );
1466
- prune [prune_nr ++ ] = * av ;
1467
- av ++ ;
1468
- }
1469
- if (prune ) {
1470
- ALLOC_GROW (prune , prune_nr + 1 , prune_alloc );
1471
- prune [prune_nr ] = NULL ;
1472
- }
1473
- * prune_data = prune ;
1474
- }
1475
-
1476
1447
/*
1477
1448
* Parse revision information, filling in the "rev_info" structure,
1478
1449
* and removing the used arguments from the argument list.
@@ -1483,11 +1454,13 @@ static void append_prune_data(const char ***prune_data, const char **av)
1483
1454
int setup_revisions (int argc , const char * * argv , struct rev_info * revs , struct setup_revision_opt * opt )
1484
1455
{
1485
1456
int i , flags , left , seen_dashdash , read_from_stdin , got_rev_arg = 0 ;
1486
- const char * * prune_data = NULL ;
1457
+ struct cmdline_pathspec prune_data ;
1487
1458
const char * submodule = NULL ;
1488
1459
const char * optarg ;
1489
1460
int argcount ;
1490
1461
1462
+ memset (& prune_data , 0 , sizeof (prune_data ));
1463
+
1491
1464
if (opt )
1492
1465
submodule = opt -> submodule ;
1493
1466
@@ -1500,7 +1473,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
1500
1473
argv [i ] = NULL ;
1501
1474
argc = i ;
1502
1475
if (argv [i + 1 ])
1503
- prune_data = argv + i + 1 ;
1476
+ append_prune_data ( & prune_data , argv + i + 1 ) ;
1504
1477
seen_dashdash = 1 ;
1505
1478
break ;
1506
1479
}
@@ -1619,8 +1592,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
1619
1592
got_rev_arg = 1 ;
1620
1593
}
1621
1594
1622
- if (prune_data )
1623
- revs -> prune_data = get_pathspec (revs -> prefix , prune_data );
1595
+ if (prune_data .nr ) {
1596
+ ALLOC_GROW (prune_data .path , prune_data .nr + 1 , prune_data .alloc );
1597
+ prune_data .path [prune_data .nr ++ ] = NULL ;
1598
+ revs -> prune_data = get_pathspec (revs -> prefix , prune_data .path );
1599
+ }
1624
1600
1625
1601
if (revs -> def == NULL )
1626
1602
revs -> def = opt ? opt -> def : NULL ;
0 commit comments