git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Git List" <git@vger.kernel.org>, "René Scharfe" <l.s.r@web.de>,
	"Andreas Schwab" <schwab@linux-m68k.org>,
	"Johannes Sixt" <j6t@kdbg.org>
Subject: Re: [PATCH] strbuf: use designated initializers in STRBUF_INIT
Date: Fri, 14 Jul 2017 12:16:51 -0700	[thread overview]
Message-ID: <xmqq8tjqrfq4.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <xmqqd192rh1t.fsf@gitster.mtv.corp.google.com> (Junio C. Hamano's message of "Fri, 14 Jul 2017 11:48:14 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> Do we need to have a check to detect a buggy compiler that takes the
> syntax but produces an incorrectly initialized array?  I could add a
> test to ensure that HEADER comes out BOLD, etc. (or we may already
> have such a test) and then reorder these lines in this patch, if
> that is the kind of breakage we anticipate.

So here is a lunch-time hack I did to replace the patch I sent
earlier.  I kind of like the ordering of the elements better than
the original, in that it somehow feels more logical, even though I
merely sorted alphabetically ;-).


 builtin/clean.c              | 19 ++++++++++---------
 t/t7301-clean-interactive.sh | 10 ++++++++++
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/builtin/clean.c b/builtin/clean.c
index 057fc97fe4..e2bb3c69ed 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 3ae394e934..556e1850e2 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

  reply	other threads:[~2017-07-14 19:16 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-10  7:03 [PATCH] strbuf: use designated initializers in STRBUF_INIT Jeff King
2017-07-10 14:57 ` Ben Peart
2017-07-10 16:04   ` Jeff King
2017-07-10 17:57     ` Ben Peart
2017-07-11  5:01   ` Mike Hommey
2017-07-11 15:31   ` Junio C Hamano
2017-07-12 19:12     ` Ævar Arnfjörð Bjarmason
2017-07-12 21:08       ` Junio C Hamano
2017-07-13 22:24       ` Johannes Sixt
2017-07-10 16:44 ` Junio C Hamano
2017-07-10 17:33   ` Stefan Beller
2017-07-10 21:46     ` Junio C Hamano
2017-07-10 17:10 ` Andreas Schwab
2017-07-10 19:57 ` Johannes Sixt
2017-07-10 20:38   ` Junio C Hamano
2017-07-10 21:11     ` Johannes Sixt
2017-07-10 21:38       ` Junio C Hamano
2017-07-14 16:11         ` Junio C Hamano
2017-07-14 17:13           ` Stefan Beller
2017-07-14 17:36           ` Jeff King
2017-07-14 18:48             ` Junio C Hamano
2017-07-14 19:16               ` Junio C Hamano [this message]
2017-07-19 18:19                 ` [PATCH] objects: scope count variable to loop Stefan Beller
2017-07-19 18:23                   ` Brandon Williams
2017-07-24 17:08                     ` Jeff King
2017-07-24 17:12                       ` Stefan Beller
2017-07-24 18:05                         ` Jeff King
2017-07-14 19:28           ` [PATCH] strbuf: use designated initializers in STRBUF_INIT Ævar Arnfjörð Bjarmason
2017-07-14 22:26             ` Junio C Hamano
2017-07-14 22:43           ` Mike Hommey
2017-07-15 11:08             ` Jeff King
2017-07-11  4:38       ` Jeff King
2017-07-11  0:05   ` brian m. carlson
2017-07-11  0:07     ` Stefan Beller
2017-07-11  0:10       ` brian m. carlson
2017-07-11  5:24     ` Johannes Sixt
2017-07-12  1:26       ` brian m. carlson
2017-07-12 18:25         ` Johannes Sixt
2017-07-10 22:41 ` Brandon Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq8tjqrfq4.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=l.s.r@web.de \
    --cc=peff@peff.net \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).