Browse Source

Merge branch 'jk/c99'

Start using selected c99 constructs in small, stable and
essentialpart of the system to catch people who care about
older compilers that do not grok them.

* jk/c99:
  clean.c: use designated initializer
  strbuf: use designated initializers in STRBUF_INIT
maint
Junio C Hamano 7 years ago
parent
commit
e72ecd324c
  1. 19
      builtin/clean.c
  2. 2
      strbuf.h
  3. 10
      t/t7301-clean-interactive.sh

19
builtin/clean.c

@ -33,15 +33,6 @@ static const char *msg_skip_git_dir = N_("Skipping repository %s\n"); @@ -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 { @@ -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

2
strbuf.h

@ -68,7 +68,7 @@ struct strbuf { @@ -68,7 +68,7 @@ struct strbuf {
};

extern char strbuf_slopbuf[];
#define STRBUF_INIT { 0, 0, strbuf_slopbuf }
#define STRBUF_INIT { .alloc = 0, .len = 0, .buf = strbuf_slopbuf }

/**
* Life Cycle Functions

10
t/t7301-clean-interactive.sh

@ -472,4 +472,14 @@ test_expect_success 'git clean -id with prefix and path (ask)' ' @@ -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

Loading…
Cancel
Save