@@ -518,88 +518,102 @@ static char *normalize_value(const char *key, const char *value,
518
518
BUG ("cannot normalize type %d" , type );
519
519
}
520
520
521
- static int get_color_found ;
522
- static const char * get_color_slot ;
523
- static const char * get_colorbool_slot ;
524
- static char parsed_color [COLOR_MAXLEN ];
521
+ struct get_color_config_data {
522
+ int get_color_found ;
523
+ const char * get_color_slot ;
524
+ char parsed_color [COLOR_MAXLEN ];
525
+ };
525
526
526
527
static int git_get_color_config (const char * var , const char * value ,
527
528
const struct config_context * ctx UNUSED ,
528
- void * cb UNUSED )
529
+ void * cb )
529
530
{
530
- if (!strcmp (var , get_color_slot )) {
531
+ struct get_color_config_data * data = cb ;
532
+
533
+ if (!strcmp (var , data -> get_color_slot )) {
531
534
if (!value )
532
535
config_error_nonbool (var );
533
- if (color_parse (value , parsed_color ) < 0 )
536
+ if (color_parse (value , data -> parsed_color ) < 0 )
534
537
return -1 ;
535
- get_color_found = 1 ;
538
+ data -> get_color_found = 1 ;
536
539
}
537
540
return 0 ;
538
541
}
539
542
540
543
static void get_color (const struct config_location_options * opts ,
541
544
const char * var , const char * def_color )
542
545
{
543
- get_color_slot = var ;
544
- get_color_found = 0 ;
545
- parsed_color [0 ] = '\0' ;
546
- config_with_options (git_get_color_config , NULL ,
546
+ struct get_color_config_data data = {
547
+ .get_color_slot = var ,
548
+ .parsed_color [0 ] = '\0' ,
549
+ };
550
+
551
+ config_with_options (git_get_color_config , & data ,
547
552
& opts -> source , the_repository ,
548
553
& opts -> options );
549
554
550
- if (!get_color_found && def_color ) {
551
- if (color_parse (def_color , parsed_color ) < 0 )
555
+ if (!data . get_color_found && def_color ) {
556
+ if (color_parse (def_color , data . parsed_color ) < 0 )
552
557
die (_ ("unable to parse default color value" ));
553
558
}
554
559
555
- fputs (parsed_color , stdout );
560
+ fputs (data . parsed_color , stdout );
556
561
}
557
562
558
- static int get_colorbool_found ;
559
- static int get_diff_color_found ;
560
- static int get_color_ui_found ;
563
+ struct get_colorbool_config_data {
564
+ int get_colorbool_found ;
565
+ int get_diff_color_found ;
566
+ int get_color_ui_found ;
567
+ const char * get_colorbool_slot ;
568
+ };
569
+
561
570
static int git_get_colorbool_config (const char * var , const char * value ,
562
571
const struct config_context * ctx UNUSED ,
563
- void * data UNUSED )
572
+ void * cb )
564
573
{
565
- if (!strcmp (var , get_colorbool_slot ))
566
- get_colorbool_found = git_config_colorbool (var , value );
574
+ struct get_colorbool_config_data * data = cb ;
575
+
576
+ if (!strcmp (var , data -> get_colorbool_slot ))
577
+ data -> get_colorbool_found = git_config_colorbool (var , value );
567
578
else if (!strcmp (var , "diff.color" ))
568
- get_diff_color_found = git_config_colorbool (var , value );
579
+ data -> get_diff_color_found = git_config_colorbool (var , value );
569
580
else if (!strcmp (var , "color.ui" ))
570
- get_color_ui_found = git_config_colorbool (var , value );
581
+ data -> get_color_ui_found = git_config_colorbool (var , value );
571
582
return 0 ;
572
583
}
573
584
574
585
static int get_colorbool (const struct config_location_options * opts ,
575
586
const char * var , int print )
576
587
{
577
- get_colorbool_slot = var ;
578
- get_colorbool_found = -1 ;
579
- get_diff_color_found = -1 ;
580
- get_color_ui_found = -1 ;
581
- config_with_options (git_get_colorbool_config , NULL ,
588
+ struct get_colorbool_config_data data = {
589
+ .get_colorbool_slot = var ,
590
+ .get_colorbool_found = -1 ,
591
+ .get_diff_color_found = -1 ,
592
+ .get_color_ui_found = -1 ,
593
+ };
594
+
595
+ config_with_options (git_get_colorbool_config , & data ,
582
596
& opts -> source , the_repository ,
583
597
& opts -> options );
584
598
585
- if (get_colorbool_found < 0 ) {
586
- if (!strcmp (get_colorbool_slot , "color.diff" ))
587
- get_colorbool_found = get_diff_color_found ;
588
- if (get_colorbool_found < 0 )
589
- get_colorbool_found = get_color_ui_found ;
599
+ if (data . get_colorbool_found < 0 ) {
600
+ if (!strcmp (data . get_colorbool_slot , "color.diff" ))
601
+ data . get_colorbool_found = data . get_diff_color_found ;
602
+ if (data . get_colorbool_found < 0 )
603
+ data . get_colorbool_found = data . get_color_ui_found ;
590
604
}
591
605
592
- if (get_colorbool_found < 0 )
606
+ if (data . get_colorbool_found < 0 )
593
607
/* default value if none found in config */
594
- get_colorbool_found = GIT_COLOR_AUTO ;
608
+ data . get_colorbool_found = GIT_COLOR_AUTO ;
595
609
596
- get_colorbool_found = want_color (get_colorbool_found );
610
+ data . get_colorbool_found = want_color (data . get_colorbool_found );
597
611
598
612
if (print ) {
599
- printf ("%s\n" , get_colorbool_found ? "true" : "false" );
613
+ printf ("%s\n" , data . get_colorbool_found ? "true" : "false" );
600
614
return 0 ;
601
615
} else
602
- return get_colorbool_found ? 0 : 1 ;
616
+ return data . get_colorbool_found ? 0 : 1 ;
603
617
}
604
618
605
619
static void check_write (const struct git_config_source * source )
0 commit comments