summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-07-14 15:38:09 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-07-18 19:45:20 (GMT)
commit512f41cfac55c9dd2f6c47531ee6cbe803ed7ec2 (patch)
tree2ae9ad576d45228908b96a77b2ae315585f56fc1
parentcbc0f81d96f05d8c88dd29a69d7571baa204f933 (diff)
downloadgit-512f41cfac55c9dd2f6c47531ee6cbe803ed7ec2.zip
git-512f41cfac55c9dd2f6c47531ee6cbe803ed7ec2.tar.gz
git-512f41cfac55c9dd2f6c47531ee6cbe803ed7ec2.tar.bz2
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>
-rw-r--r--builtin/clean.c19
-rwxr-xr-xt/t7301-clean-interactive.sh10
2 files changed, 20 insertions, 9 deletions
diff --git a/builtin/clean.c b/builtin/clean.c
index 057fc97..e2bb3c6 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -33,15 +33,6 @@ static const char *msg_skip_git_dir = N_("Skipping repository %s\n");
static const char *msg_would_skip_git_dir = N_("Would skip repository %s\n");
static const char *msg_warn_remove_failed = N_("failed to remove %s");
-static int clean_use_color = -1;
-static char clean_colors[][COLOR_MAXLEN] = {
- GIT_COLOR_RESET,
- GIT_COLOR_NORMAL, /* PLAIN */
- GIT_COLOR_BOLD_BLUE, /* PROMPT */
- GIT_COLOR_BOLD, /* HEADER */
- GIT_COLOR_BOLD_RED, /* HELP */
- GIT_COLOR_BOLD_RED, /* ERROR */
-};
enum color_clean {
CLEAN_COLOR_RESET = 0,
CLEAN_COLOR_PLAIN = 1,
@@ -51,6 +42,16 @@ enum color_clean {
CLEAN_COLOR_ERROR = 5
};
+static int clean_use_color = -1;
+static char clean_colors[][COLOR_MAXLEN] = {
+ [CLEAN_COLOR_ERROR] = GIT_COLOR_BOLD_RED,
+ [CLEAN_COLOR_HEADER] = GIT_COLOR_BOLD,
+ [CLEAN_COLOR_HELP] = GIT_COLOR_BOLD_RED,
+ [CLEAN_COLOR_PLAIN] = GIT_COLOR_NORMAL,
+ [CLEAN_COLOR_PROMPT] = GIT_COLOR_BOLD_BLUE,
+ [CLEAN_COLOR_RESET] = GIT_COLOR_RESET,
+};
+
#define MENU_OPTS_SINGLETON 01
#define MENU_OPTS_IMMEDIATE 02
#define MENU_OPTS_LIST_ONLY 04
diff --git a/t/t7301-clean-interactive.sh b/t/t7301-clean-interactive.sh
index 3ae394e..556e185 100755
--- a/t/t7301-clean-interactive.sh
+++ b/t/t7301-clean-interactive.sh
@@ -472,4 +472,14 @@ test_expect_success 'git clean -id with prefix and path (ask)' '
'
+test_expect_success 'git clean -i paints the header in HEADER color' '
+ >a.out &&
+ echo q |
+ git -c color.ui=always clean -i |
+ test_decode_color |
+ head -n 1 >header &&
+ # not i18ngrep
+ grep "^<BOLD>" header
+'
+
test_done