@@ -1074,35 +1074,34 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
10741074 return 0 ;
10751075}
10761076
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+ } ;
10821082
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+ }
10901090
1091+ static void read_pathspec_from_stdin (struct rev_info * revs , struct strbuf * sb ,
1092+ struct cmdline_pathspec * prune )
1093+ {
10911094 while (strbuf_getwholeline (sb , stdin , '\n' ) != EOF ) {
10921095 int len = sb -> len ;
10931096 if (len && sb -> buf [len - 1 ] == '\n' )
10941097 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 );
10971100 }
1098- if (prune ) {
1099- ALLOC_GROW (prune , prune_nr + 1 , prune_alloc );
1100- prune [prune_nr ] = NULL ;
1101- }
1102- * prune_data = prune ;
11031101}
11041102
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 )
11061105{
11071106 struct strbuf sb ;
11081107 int seen_dashdash = 0 ;
@@ -1445,34 +1444,6 @@ static int for_each_good_bisect_ref(const char *submodule, each_ref_fn fn, void
14451444 return for_each_ref_in_submodule (submodule , "refs/bisect/good" , fn , cb_data );
14461445}
14471446
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-
14761447/*
14771448 * Parse revision information, filling in the "rev_info" structure,
14781449 * and removing the used arguments from the argument list.
@@ -1483,11 +1454,12 @@ static void append_prune_data(const char ***prune_data, const char **av)
14831454int setup_revisions (int argc , const char * * argv , struct rev_info * revs , struct setup_revision_opt * opt )
14841455{
14851456 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 ;
14871458 const char * submodule = NULL ;
14881459 const char * optarg ;
14891460 int argcount ;
14901461
1462+ memset (& prune_data , 0 , sizeof (prune_data ));
14911463 if (opt )
14921464 submodule = opt -> submodule ;
14931465
@@ -1500,7 +1472,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
15001472 argv [i ] = NULL ;
15011473 argc = i ;
15021474 if (argv [i + 1 ])
1503- prune_data = argv + i + 1 ;
1475+ append_prune_data ( & prune_data , argv + i + 1 ) ;
15041476 seen_dashdash = 1 ;
15051477 break ;
15061478 }
@@ -1619,8 +1591,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
16191591 got_rev_arg = 1 ;
16201592 }
16211593
1622- if (prune_data )
1623- revs -> prune_data = get_pathspec (revs -> prefix , prune_data );
1594+ if (prune_data .nr ) {
1595+ ALLOC_GROW (prune_data .path , prune_data .nr + 1 , prune_data .alloc );
1596+ prune_data .path [prune_data .nr ++ ] = NULL ;
1597+ revs -> prune_data = get_pathspec (revs -> prefix , prune_data .path );
1598+ }
16241599
16251600 if (revs -> def == NULL )
16261601 revs -> def = opt ? opt -> def : NULL ;
0 commit comments