@@ -1096,35 +1096,34 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
1096
1096
return 0 ;
1097
1097
}
1098
1098
1099
- static void read_pathspec_from_stdin ( struct rev_info * revs , struct strbuf * sb , const char * * * prune_data )
1100
- {
1101
- const char * * prune = * prune_data ;
1102
- int prune_nr ;
1103
- int prune_alloc ;
1099
+ struct cmdline_pathspec {
1100
+ int alloc ;
1101
+ int nr ;
1102
+ const char * * path ;
1103
+ } ;
1104
1104
1105
- /* count existing ones */
1106
- if (! prune )
1107
- prune_nr = 0 ;
1108
- else
1109
- for ( prune_nr = 0 ; prune [ prune_nr ]; prune_nr ++ )
1110
- ;
1111
- prune_alloc = prune_nr ; /* not really, but we do not know */
1105
+ static void append_prune_data ( struct cmdline_pathspec * prune , const char * * av )
1106
+ {
1107
+ while ( * av ) {
1108
+ ALLOC_GROW ( prune -> path , prune -> nr + 1 , prune -> alloc );
1109
+ prune -> path [ prune -> nr ++ ] = * ( av ++ );
1110
+ }
1111
+ }
1112
1112
1113
+ static void read_pathspec_from_stdin (struct rev_info * revs , struct strbuf * sb ,
1114
+ struct cmdline_pathspec * prune )
1115
+ {
1113
1116
while (strbuf_getwholeline (sb , stdin , '\n' ) != EOF ) {
1114
1117
int len = sb -> len ;
1115
1118
if (len && sb -> buf [len - 1 ] == '\n' )
1116
1119
sb -> buf [-- len ] = '\0' ;
1117
- ALLOC_GROW (prune , prune_nr + 1 , prune_alloc );
1118
- prune [ prune_nr ++ ] = xstrdup (sb -> buf );
1120
+ ALLOC_GROW (prune -> path , prune -> nr + 1 , prune -> alloc );
1121
+ prune -> path [ prune -> nr ++ ] = xstrdup (sb -> buf );
1119
1122
}
1120
- if (prune ) {
1121
- ALLOC_GROW (prune , prune_nr + 1 , prune_alloc );
1122
- prune [prune_nr ] = NULL ;
1123
- }
1124
- * prune_data = prune ;
1125
1123
}
1126
1124
1127
- static void read_revisions_from_stdin (struct rev_info * revs , const char * * * prune )
1125
+ static void read_revisions_from_stdin (struct rev_info * revs ,
1126
+ struct cmdline_pathspec * prune )
1128
1127
{
1129
1128
struct strbuf sb ;
1130
1129
int seen_dashdash = 0 ;
@@ -1498,34 +1497,6 @@ static int for_each_good_bisect_ref(const char *submodule, each_ref_fn fn, void
1498
1497
return for_each_ref_in_submodule (submodule , "refs/bisect/good" , fn , cb_data );
1499
1498
}
1500
1499
1501
- static void append_prune_data (const char * * * prune_data , const char * * av )
1502
- {
1503
- const char * * prune = * prune_data ;
1504
- int prune_nr ;
1505
- int prune_alloc ;
1506
-
1507
- if (!prune ) {
1508
- * prune_data = av ;
1509
- return ;
1510
- }
1511
-
1512
- /* count existing ones */
1513
- for (prune_nr = 0 ; prune [prune_nr ]; prune_nr ++ )
1514
- ;
1515
- prune_alloc = prune_nr ; /* not really, but we do not know */
1516
-
1517
- while (* av ) {
1518
- ALLOC_GROW (prune , prune_nr + 1 , prune_alloc );
1519
- prune [prune_nr ++ ] = * av ;
1520
- av ++ ;
1521
- }
1522
- if (prune ) {
1523
- ALLOC_GROW (prune , prune_nr + 1 , prune_alloc );
1524
- prune [prune_nr ] = NULL ;
1525
- }
1526
- * prune_data = prune ;
1527
- }
1528
-
1529
1500
/*
1530
1501
* Parse revision information, filling in the "rev_info" structure,
1531
1502
* and removing the used arguments from the argument list.
@@ -1536,11 +1507,12 @@ static void append_prune_data(const char ***prune_data, const char **av)
1536
1507
int setup_revisions (int argc , const char * * argv , struct rev_info * revs , struct setup_revision_opt * opt )
1537
1508
{
1538
1509
int i , flags , left , seen_dashdash , read_from_stdin , got_rev_arg = 0 ;
1539
- const char * * prune_data = NULL ;
1510
+ struct cmdline_pathspec prune_data ;
1540
1511
const char * submodule = NULL ;
1541
1512
const char * optarg ;
1542
1513
int argcount ;
1543
1514
1515
+ memset (& prune_data , 0 , sizeof (prune_data ));
1544
1516
if (opt )
1545
1517
submodule = opt -> submodule ;
1546
1518
@@ -1553,7 +1525,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
1553
1525
argv [i ] = NULL ;
1554
1526
argc = i ;
1555
1527
if (argv [i + 1 ])
1556
- prune_data = argv + i + 1 ;
1528
+ append_prune_data ( & prune_data , argv + i + 1 ) ;
1557
1529
seen_dashdash = 1 ;
1558
1530
break ;
1559
1531
}
@@ -1672,8 +1644,12 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
1672
1644
got_rev_arg = 1 ;
1673
1645
}
1674
1646
1675
- if (prune_data )
1676
- init_pathspec (& revs -> prune_data , get_pathspec (revs -> prefix , prune_data ));
1647
+ if (prune_data .nr ) {
1648
+ ALLOC_GROW (prune_data .path , prune_data .nr + 1 , prune_data .alloc );
1649
+ prune_data .path [prune_data .nr ++ ] = NULL ;
1650
+ init_pathspec (& revs -> prune_data ,
1651
+ get_pathspec (revs -> prefix , prune_data .path ));
1652
+ }
1677
1653
1678
1654
if (revs -> def == NULL )
1679
1655
revs -> def = opt ? opt -> def : NULL ;
0 commit comments