clean.c: use designated initializer
This is another test balloon to see if we get complaints from people whose compilers do not support designated initializer for arrays. The use of the feature is not all that interesting for cases like the one this patch touches, where the initialized elements of the array is dense, but it would be nice if we can use the feature to initialize an array that has elements initialized to interesting values only sparsely. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jul 14, 2017 at 08:38 UTC
512f41cfac55c9dd2f6c47531ee6cbe803ed7ec2
2 files changed
+20
-9
builtin/clean.c
+10
-9
@@ -33,15 +33,6 @@ static const char *msg_skip_git_dir = N_("Skipping repository %s\n");
33
static const char *msg_would_skip_git_dir = N_("Would skip repository %s\n");
34
static const char *msg_warn_remove_failed = N_("failed to remove %s");
35
36
-static int clean_use_color = -1;
37
-static char clean_colors[][COLOR_MAXLEN] = {
38
- GIT_COLOR_RESET,
39
- GIT_COLOR_NORMAL, /* PLAIN */
40
- GIT_COLOR_BOLD_BLUE, /* PROMPT */
41
- GIT_COLOR_BOLD, /* HEADER */
42
- GIT_COLOR_BOLD_RED, /* HELP */
43
- GIT_COLOR_BOLD_RED, /* ERROR */
44
-};
36
enum color_clean {
37
CLEAN_COLOR_RESET = 0,
38
CLEAN_COLOR_PLAIN = 1,
@@ -51,6 +42,16 @@ enum color_clean {
42
CLEAN_COLOR_ERROR = 5
43
};
44
45
+static int clean_use_color = -1;
46
+static char clean_colors[][COLOR_MAXLEN] = {
47
+ [CLEAN_COLOR_ERROR] = GIT_COLOR_BOLD_RED,
48
+ [CLEAN_COLOR_HEADER] = GIT_COLOR_BOLD,
49
+ [CLEAN_COLOR_HELP] = GIT_COLOR_BOLD_RED,
50
+ [CLEAN_COLOR_PLAIN] = GIT_COLOR_NORMAL,
51
+ [CLEAN_COLOR_PROMPT] = GIT_COLOR_BOLD_BLUE,
52
+ [CLEAN_COLOR_RESET] = GIT_COLOR_RESET,
53
+};
54
+
55
#define MENU_OPTS_SINGLETON 01
56
#define MENU_OPTS_IMMEDIATE 02
57
#define MENU_OPTS_LIST_ONLY 04
t/t7301-clean-interactive.sh
+10
@@ -472,4 +472,14 @@ test_expect_success 'git clean -id with prefix and path (ask)' '
472
473
'
474
475
+test_expect_success 'git clean -i paints the header in HEADER color' '
476
+ >a.out &&
477
+ echo q |
478
+ git -c color.ui=always clean -i |
479
+ test_decode_color |
480
+ head -n 1 >header &&
481
+ # not i18ngrep
482
+ grep "^<BOLD>" header
483
+'
484
+
485
test_done