33#include "refs.h"
44#include "builtin.h"
55#include "color.h"
6+ #include "argv-array.h"
67#include "parse-options.h"
78
89static const char * show_branch_usage [] = {
@@ -16,9 +17,7 @@ static const char* show_branch_usage[] = {
1617
1718static int showbranch_use_color = -1 ;
1819
19- static int default_num ;
20- static int default_alloc ;
21- static const char * * default_arg ;
20+ static struct argv_array default_args = ARGV_ARRAY_INIT ;
2221
2322#define UNINTERESTING 01
2423
@@ -556,16 +555,9 @@ static int git_show_branch_config(const char *var, const char *value, void *cb)
556555 * default_arg is now passed to parse_options(), so we need to
557556 * mimic the real argv a bit better.
558557 */
559- if (!default_num ) {
560- default_alloc = 20 ;
561- default_arg = xcalloc (default_alloc , sizeof (* default_arg ));
562- default_arg [default_num ++ ] = "show-branch" ;
563- } else if (default_alloc <= default_num + 1 ) {
564- default_alloc = default_alloc * 3 / 2 + 20 ;
565- REALLOC_ARRAY (default_arg , default_alloc );
566- }
567- default_arg [default_num ++ ] = xstrdup (value );
568- default_arg [default_num ] = NULL ;
558+ if (!default_args .argc )
559+ argv_array_push (& default_args , "show-branch" );
560+ argv_array_push (& default_args , value );
569561 return 0 ;
570562 }
571563
@@ -685,9 +677,9 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
685677 git_config (git_show_branch_config , NULL );
686678
687679 /* If nothing is specified, try the default first */
688- if (ac == 1 && default_num ) {
689- ac = default_num ;
690- av = default_arg ;
680+ if (ac == 1 && default_args . argc ) {
681+ ac = default_args . argc ;
682+ av = default_args . argv ;
691683 }
692684
693685 ac = parse_options (ac , av , prefix , builtin_show_branch_options ,
0 commit comments