git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/6] Disable "git status" comment prefix
       [not found] <vpq38phsvuc.fsf@anie.imag.frvpq38phsvuc.fsf@anie.imag.fr>
@ 2013-09-06 17:43 ` Matthieu Moy
  2013-09-06 17:43   ` [PATCH v5 1/6] builtin/stripspace.c: fix broken indentation Matthieu Moy
                     ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Matthieu Moy @ 2013-09-06 17:43 UTC (permalink / raw)
  To: git, gitster; +Cc: Matthieu Moy

Compared to v5:

* One test update I had forgotten. Now, the testsuite actually pass.

* Changed the config to status.displayCommentPrefix.

* Added the last patch, to add a missing blank line.

Matthieu Moy (6):
  builtin/stripspace.c: fix broken indentation
  wt-status: use argv_array API
  submodule summary: ignore --for-status option
  status: disable display of '#' comment prefix by default
  tests: don't set status.displayCommentPrefix file-wide
  status: add missing blank line after list of "other" files

 Documentation/config.txt           |   7 +
 builtin/commit.c                   |  10 +
 builtin/stripspace.c               |   8 +-
 git-submodule.sh                   |  13 +-
 t/t3001-ls-files-others-exclude.sh |   2 +-
 t/t7060-wtstatus.sh                | 109 +++--
 t/t7401-submodule-summary.sh       |  12 +-
 t/t7508-status.sh                  | 965 ++++++++++++++++++++-----------------
 t/t7512-status-help.sh             | 600 +++++++++++------------
 wt-status.c                        |  91 +++-
 wt-status.h                        |   1 +
 11 files changed, 966 insertions(+), 852 deletions(-)

-- 
1.8.4.5.g8688bea

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v5 1/6] builtin/stripspace.c: fix broken indentation
  2013-09-06 17:43 ` [PATCH v5 0/6] Disable "git status" comment prefix Matthieu Moy
@ 2013-09-06 17:43   ` Matthieu Moy
  2013-09-06 17:43   ` [PATCH v5 2/6] wt-status: use argv_array API Matthieu Moy
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Matthieu Moy @ 2013-09-06 17:43 UTC (permalink / raw)
  To: git, gitster; +Cc: Matthieu Moy

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/stripspace.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/builtin/stripspace.c b/builtin/stripspace.c
index e981dfb..1259ed7 100644
--- a/builtin/stripspace.c
+++ b/builtin/stripspace.c
@@ -89,11 +89,11 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)
 
 	if (argc == 2) {
 		if (!strcmp(argv[1], "-s") ||
-			!strcmp(argv[1], "--strip-comments")) {
-			 strip_comments = 1;
+		    !strcmp(argv[1], "--strip-comments")) {
+			strip_comments = 1;
 		} else if (!strcmp(argv[1], "-c") ||
-					 !strcmp(argv[1], "--comment-lines")) {
-			 mode = COMMENT_LINES;
+			   !strcmp(argv[1], "--comment-lines")) {
+			mode = COMMENT_LINES;
 		} else {
 			mode = INVAL;
 		}
-- 
1.8.4.5.g8688bea

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v5 2/6] wt-status: use argv_array API
  2013-09-06 17:43 ` [PATCH v5 0/6] Disable "git status" comment prefix Matthieu Moy
  2013-09-06 17:43   ` [PATCH v5 1/6] builtin/stripspace.c: fix broken indentation Matthieu Moy
@ 2013-09-06 17:43   ` Matthieu Moy
  2013-09-06 17:43   ` [PATCH v5 3/6] submodule summary: ignore --for-status option Matthieu Moy
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Matthieu Moy @ 2013-09-06 17:43 UTC (permalink / raw)
  To: git, gitster; +Cc: Matthieu Moy

No behavior change, but two slight code reorganization: argv_array_push
doesn't accept NULL strings, and duplicates its argument hence
summary_limit must be written to before being inserted into argv.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 wt-status.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index cb24f1f..958a53c 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -8,6 +8,7 @@
 #include "diffcore.h"
 #include "quote.h"
 #include "run-command.h"
+#include "argv-array.h"
 #include "remote.h"
 #include "refs.h"
 #include "submodule.h"
@@ -663,29 +664,30 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
 	char summary_limit[64];
 	char index[PATH_MAX];
 	const char *env[] = { NULL, NULL };
-	const char *argv[8];
-
-	env[0] =	index;
-	argv[0] =	"submodule";
-	argv[1] =	"summary";
-	argv[2] =	uncommitted ? "--files" : "--cached";
-	argv[3] =	"--for-status";
-	argv[4] =	"--summary-limit";
-	argv[5] =	summary_limit;
-	argv[6] =	uncommitted ? NULL : (s->amend ? "HEAD^" : "HEAD");
-	argv[7] =	NULL;
+	struct argv_array argv = ARGV_ARRAY_INIT;
 
 	sprintf(summary_limit, "%d", s->submodule_summary);
 	snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", s->index_file);
 
+	env[0] = index;
+	argv_array_push(&argv, "submodule");
+	argv_array_push(&argv, "summary");
+	argv_array_push(&argv, uncommitted ? "--files" : "--cached");
+	argv_array_push(&argv, "--for-status");
+	argv_array_push(&argv, "--summary-limit");
+	argv_array_push(&argv, summary_limit);
+	if (!uncommitted)
+		argv_array_push(&argv, s->amend ? "HEAD^" : "HEAD");
+
 	memset(&sm_summary, 0, sizeof(sm_summary));
-	sm_summary.argv = argv;
+	sm_summary.argv = argv.argv;
 	sm_summary.env = env;
 	sm_summary.git_cmd = 1;
 	sm_summary.no_stdin = 1;
 	fflush(s->fp);
 	sm_summary.out = dup(fileno(s->fp));    /* run_command closes it */
 	run_command(&sm_summary);
+	argv_array_clear(&argv);
 }
 
 static void wt_status_print_other(struct wt_status *s,
-- 
1.8.4.5.g8688bea

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v5 3/6] submodule summary: ignore --for-status option
  2013-09-06 17:43 ` [PATCH v5 0/6] Disable "git status" comment prefix Matthieu Moy
  2013-09-06 17:43   ` [PATCH v5 1/6] builtin/stripspace.c: fix broken indentation Matthieu Moy
  2013-09-06 17:43   ` [PATCH v5 2/6] wt-status: use argv_array API Matthieu Moy
@ 2013-09-06 17:43   ` Matthieu Moy
  2013-09-06 17:43   ` [PATCH v5 4/6] status: disable display of '#' comment prefix by default Matthieu Moy
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Matthieu Moy @ 2013-09-06 17:43 UTC (permalink / raw)
  To: git, gitster; +Cc: Matthieu Moy

The --for-status option was an undocumented option used only by
wt-status.c, which inserted a header and commented out the output. We can
achieve the same result within wt-status.c, without polluting the
submodule command-line options.

This will make it easier to disable the comments from wt-status.c later.

The --for-status is kept so that another topic in flight
(bc/submodule-status-ignored) can continue relying on it, although it is
currently a no-op.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-submodule.sh             | 13 +------------
 t/t7401-submodule-summary.sh | 12 +++++-------
 wt-status.c                  | 27 ++++++++++++++++++++++++++-
 3 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 2979197..c17bef1 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -1149,18 +1149,7 @@ cmd_summary() {
 			echo
 		fi
 		echo
-	done |
-	if test -n "$for_status"; then
-		if [ -n "$files" ]; then
-			gettextln "Submodules changed but not updated:" | git stripspace -c
-		else
-			gettextln "Submodule changes to be committed:" | git stripspace -c
-		fi
-		printf "\n" | git stripspace -c
-		git stripspace -c
-	else
-		cat
-	fi
+	done
 }
 #
 # List all submodules, prefixed with:
diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh
index ac2434c..5a6d6d6 100755
--- a/t/t7401-submodule-summary.sh
+++ b/t/t7401-submodule-summary.sh
@@ -265,13 +265,11 @@ EOF
 test_expect_success '--for-status' "
 	git submodule summary --for-status HEAD^ >actual &&
 	test_i18ncmp actual - <<EOF
-# Submodule changes to be committed:
-#
-# * sm1 $head6...0000000:
-#
-# * sm2 0000000...$head7 (2):
-#   > Add foo9
-#
+* sm1 $head6...0000000:
+
+* sm2 0000000...$head7 (2):
+  > Add foo9
+
 EOF
 "
 
diff --git a/wt-status.c b/wt-status.c
index 958a53c..853813f 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -665,6 +665,10 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
 	char index[PATH_MAX];
 	const char *env[] = { NULL, NULL };
 	struct argv_array argv = ARGV_ARRAY_INIT;
+	struct strbuf cmd_stdout = STRBUF_INIT;
+	struct strbuf summary = STRBUF_INIT;
+	char *summary_content;
+	size_t len;
 
 	sprintf(summary_limit, "%d", s->submodule_summary);
 	snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", s->index_file);
@@ -685,9 +689,30 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
 	sm_summary.git_cmd = 1;
 	sm_summary.no_stdin = 1;
 	fflush(s->fp);
-	sm_summary.out = dup(fileno(s->fp));    /* run_command closes it */
+	sm_summary.out = -1;
+
 	run_command(&sm_summary);
 	argv_array_clear(&argv);
+
+	len = strbuf_read(&cmd_stdout, sm_summary.out, 1024);
+
+	/* prepend header, only if there's an actual output */
+	if (len) {
+		if (uncommitted)
+			strbuf_addstr(&summary, _("Submodules changed but not updated:"));
+		else
+			strbuf_addstr(&summary, _("Submodule changes to be committed:"));
+		strbuf_addstr(&summary, "\n\n");
+	}
+	strbuf_addbuf(&summary, &cmd_stdout);
+	strbuf_release(&cmd_stdout);
+
+	summary_content = strbuf_detach(&summary, &len);
+	strbuf_add_commented_lines(&summary, summary_content, len);
+	free(summary_content);
+
+	fputs(summary.buf, s->fp);
+	strbuf_release(&summary);
 }
 
 static void wt_status_print_other(struct wt_status *s,
-- 
1.8.4.5.g8688bea

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v5 4/6] status: disable display of '#' comment prefix by default
  2013-09-06 17:43 ` [PATCH v5 0/6] Disable "git status" comment prefix Matthieu Moy
                     ` (2 preceding siblings ...)
  2013-09-06 17:43   ` [PATCH v5 3/6] submodule summary: ignore --for-status option Matthieu Moy
@ 2013-09-06 17:43   ` Matthieu Moy
  2013-09-06 17:43   ` [PATCH v5 5/6] tests: don't set status.displayCommentPrefix file-wide Matthieu Moy
  2013-09-06 17:43   ` [PATCH v5 6/6] status: add missing blank line after list of "other" files Matthieu Moy
  5 siblings, 0 replies; 12+ messages in thread
From: Matthieu Moy @ 2013-09-06 17:43 UTC (permalink / raw)
  To: git, gitster; +Cc: Matthieu Moy

Historically, "git status" needed to prefix each output line with '#' so
that the output could be added as comment to the commit message. This
prefix comment has no real purpose when "git status" is ran from the
command-line, and this may distract users from the real content.

Disable this prefix comment by default, and make it re-activable for
users needing backward compatibility with status.displayCommentPrefix.

Obviously, "git commit" ignores status.displayCommentPrefix and keeps the
comment unconditionnaly when writing to COMMIT_EDITMSG (but not when
writing to stdout for an error message or with --dry-run).

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/config.txt           |  7 +++++
 builtin/commit.c                   | 10 ++++++
 t/t3001-ls-files-others-exclude.sh |  2 +-
 t/t7060-wtstatus.sh                |  4 +++
 t/t7508-status.sh                  | 63 +++++++++++++++++++++++++++++++++++---
 t/t7512-status-help.sh             |  4 +++
 wt-status.c                        | 40 +++++++++++++++++-------
 wt-status.h                        |  1 +
 8 files changed, 114 insertions(+), 17 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index ec57a15..60c6bc9 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2118,6 +2118,13 @@ status.branch::
 	Set to true to enable --branch by default in linkgit:git-status[1].
 	The option --no-branch takes precedence over this variable.
 
+status.displayCommentPrefix::
+	If set to true, linkgit:git-status[1] will insert a comment
+	prefix before each output line (starting with
+	`core.commentChar`, i.e. `#` by default). This was the
+	behavior of linkgit:git-status[1] in Git 1.8.4 and previous.
+	Defaults to false.
+
 status.showUntrackedFiles::
 	By default, linkgit:git-status[1] and linkgit:git-commit[1] show
 	files which are not currently tracked by Git. Directories which
diff --git a/builtin/commit.c b/builtin/commit.c
index 10acc53..61975ad 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -599,6 +599,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 	const char *hook_arg2 = NULL;
 	int ident_shown = 0;
 	int clean_message_contents = (cleanup_mode != CLEANUP_NONE);
+	int old_display_comment_prefix;
 
 	/* This checks and barfs if author is badly specified */
 	determine_author_info(author_ident);
@@ -696,6 +697,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 	if (s->fp == NULL)
 		die_errno(_("could not open '%s'"), git_path(commit_editmsg));
 
+	/* Ignore status.displayCommentPrefix: we do need comments in COMMIT_EDITMSG. */
+	old_display_comment_prefix = s->display_comment_prefix;
+	s->display_comment_prefix = 1;
+
 	if (clean_message_contents)
 		stripspace(&sb, 0);
 
@@ -821,6 +826,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 	 */
 	if (!commitable && whence != FROM_MERGE && !allow_empty &&
 	    !(amend && is_a_merge(current_head))) {
+		s->display_comment_prefix = old_display_comment_prefix;
 		run_status(stdout, index_file, prefix, 0, s);
 		if (amend)
 			fputs(_(empty_amend_advice), stderr);
@@ -1182,6 +1188,10 @@ static int git_status_config(const char *k, const char *v, void *cb)
 		s->use_color = git_config_colorbool(k, v);
 		return 0;
 	}
+	if (!strcmp(k, "status.displaycommentprefix")) {
+		s->display_comment_prefix = git_config_bool(k, v);
+		return 0;
+	}
 	if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
 		int slot = parse_status_slot(k, 13);
 		if (slot < 0)
diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh
index f0421c0..b2798fe 100755
--- a/t/t3001-ls-files-others-exclude.sh
+++ b/t/t3001-ls-files-others-exclude.sh
@@ -115,7 +115,7 @@ EOF
 
 git config core.excludesFile excludes-file
 
-git status | grep "^#	" > output
+git -c status.displayCommentPrefix=true status | grep "^#	" > output
 
 cat > expect << EOF
 #	.gitignore
diff --git a/t/t7060-wtstatus.sh b/t/t7060-wtstatus.sh
index 52ef06b..5ecafac 100755
--- a/t/t7060-wtstatus.sh
+++ b/t/t7060-wtstatus.sh
@@ -4,6 +4,10 @@ test_description='basic work tree status reporting'
 
 . ./test-lib.sh
 
+test_expect_success 'use status.displayCommentPrefix by default ' '
+	git config --global status.displayCommentPrefix true
+'
+
 test_expect_success setup '
 	git config --global advice.statusuoption false &&
 	test_commit A &&
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index ac3d0fe..8d28280 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -7,6 +7,10 @@ test_description='git status'
 
 . ./test-lib.sh
 
+test_expect_success 'use status.displayCommentPrefix by default ' '
+	git config --global status.displayCommentPrefix true
+'
+
 test_expect_success 'status -h in broken repository' '
 	git config --global advice.statusuoption false &&
 	mkdir broken &&
@@ -60,8 +64,12 @@ test_expect_success 'status (1)' '
 	test_i18ngrep "use \"git rm --cached <file>\.\.\.\" to unstage" output
 '
 
+strip_comments () {
+	sed "s/^\# //; s/^\#$//; s/^#\t/\t/" <"$1" >"$1".tmp &&
+	rm "$1" && mv "$1".tmp "$1"
+}
+
 test_expect_success 'status --column' '
-	COLUMNS=50 git status --column="column dense" >output &&
 	cat >expect <<\EOF &&
 # On branch master
 # Changes to be committed:
@@ -78,9 +86,16 @@ test_expect_success 'status --column' '
 # Untracked files:
 #   (use "git add <file>..." to include in what will be committed)
 #
-#	dir1/untracked dir2/untracked untracked
-#	dir2/modified  output
+#	dir1/untracked dir2/untracked output
+#	dir2/modified  expect         untracked
 EOF
+	COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
+	test_i18ncmp expect output
+'
+
+test_expect_success 'status --column status.displayCommentPrefix=false' '
+	strip_comments expect &&
+	COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output &&
 	test_i18ncmp expect output
 '
 
@@ -108,11 +123,39 @@ cat >expect <<\EOF
 #	untracked
 EOF
 
-test_expect_success 'status (2)' '
-	git status >output &&
+test_expect_success 'status with status.displayCommentPrefix=true' '
+	git -c status.displayCommentPrefix=true status >output &&
+	test_i18ncmp expect output
+'
+
+test_expect_success 'status with status.displayCommentPrefix=false' '
+	strip_comments expect &&
+	git -c status.displayCommentPrefix=false status >output &&
 	test_i18ncmp expect output
 '
 
+test_expect_success 'setup fake editor' '
+	cat >.git/editor <<-\EOF &&
+	#! /bin/sh
+	cp "$1" output
+EOF
+	chmod 755 .git/editor
+'
+
+commit_template_commented () {
+	(
+		EDITOR=.git/editor &&
+		export EDITOR &&
+		# Fails due to empty message
+		test_must_fail git commit
+	) &&
+	! grep '^[^#]' output
+}
+
+test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_EDITMSG' '
+	commit_template_commented
+'
+
 cat >expect <<\EOF
 # On branch master
 # Changes to be committed:
@@ -872,6 +915,16 @@ test_expect_success 'status submodule summary' '
 	test_i18ncmp expect output
 '
 
+test_expect_success 'status submodule summary with status.displayCommentPrefix=false' '
+	strip_comments expect &&
+	git -c status.displayCommentPrefix=false status >output &&
+	test_i18ncmp expect output
+'
+
+test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' '
+	commit_template_commented
+'
+
 cat >expect <<EOF
  M dir1/modified
 A  dir2/added
diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index 31a798f..312f417 100755
--- a/t/t7512-status-help.sh
+++ b/t/t7512-status-help.sh
@@ -13,6 +13,10 @@ test_description='git status advice'
 
 set_fake_editor
 
+test_expect_success 'use status.displayCommentPrefix by default ' '
+	git config --global status.displayCommentPrefix true
+'
+
 test_expect_success 'prepare for conflicts' '
 	git config --global advice.statusuoption false &&
 	test_commit init main.txt init &&
diff --git a/wt-status.c b/wt-status.c
index 853813f..3c795da 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -46,9 +46,11 @@ static void status_vprintf(struct wt_status *s, int at_bol, const char *color,
 
 	strbuf_vaddf(&sb, fmt, ap);
 	if (!sb.len) {
-		strbuf_addch(&sb, comment_line_char);
-		if (!trail)
-			strbuf_addch(&sb, ' ');
+		if (s->display_comment_prefix) {
+			strbuf_addch(&sb, comment_line_char);
+			if (!trail)
+				strbuf_addch(&sb, ' ');
+		}
 		color_print_strbuf(s->fp, color, &sb);
 		if (trail)
 			fprintf(s->fp, "%s", trail);
@@ -59,7 +61,7 @@ static void status_vprintf(struct wt_status *s, int at_bol, const char *color,
 		eol = strchr(line, '\n');
 
 		strbuf_reset(&linebuf);
-		if (at_bol) {
+		if (at_bol && s->display_comment_prefix) {
 			strbuf_addch(&linebuf, comment_line_char);
 			if (*line != '\n' && *line != '\t')
 				strbuf_addch(&linebuf, ' ');
@@ -129,6 +131,7 @@ void wt_status_prepare(struct wt_status *s)
 	s->untracked.strdup_strings = 1;
 	s->ignored.strdup_strings = 1;
 	s->show_branch = -1;  /* unspecified */
+	s->display_comment_prefix = 0;
 }
 
 static void wt_status_print_unmerged_header(struct wt_status *s)
@@ -707,9 +710,11 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
 	strbuf_addbuf(&summary, &cmd_stdout);
 	strbuf_release(&cmd_stdout);
 
-	summary_content = strbuf_detach(&summary, &len);
-	strbuf_add_commented_lines(&summary, summary_content, len);
-	free(summary_content);
+	if (s->display_comment_prefix) {
+		summary_content = strbuf_detach(&summary, &len);
+		strbuf_add_commented_lines(&summary, summary_content, len);
+		free(summary_content);
+	}
 
 	fputs(summary.buf, s->fp);
 	strbuf_release(&summary);
@@ -748,8 +753,9 @@ static void wt_status_print_other(struct wt_status *s,
 	if (!column_active(s->colopts))
 		return;
 
-	strbuf_addf(&buf, "%s#\t%s",
+	strbuf_addf(&buf, "%s%s\t%s",
 		    color(WT_STATUS_HEADER, s),
+		    s->display_comment_prefix ? "#" : "",
 		    color(WT_STATUS_UNTRACKED, s));
 	memset(&copts, 0, sizeof(copts));
 	copts.padding = 1;
@@ -793,6 +799,8 @@ static void wt_status_print_tracking(struct wt_status *s)
 	struct strbuf sb = STRBUF_INIT;
 	const char *cp, *ep;
 	struct branch *branch;
+	char comment_line_string[3];
+	int i;
 
 	assert(s->branch && !s->is_initial);
 	if (prefixcmp(s->branch, "refs/heads/"))
@@ -801,12 +809,22 @@ static void wt_status_print_tracking(struct wt_status *s)
 	if (!format_tracking_info(branch, &sb))
 		return;
 
+	i = 0;
+	if (s->display_comment_prefix) {
+		comment_line_string[i++] = comment_line_char;
+		comment_line_string[i++] = ' ';
+	}
+	comment_line_string[i] = '\0';
+
 	for (cp = sb.buf; (ep = strchr(cp, '\n')) != NULL; cp = ep + 1)
 		color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s),
-				 "%c %.*s", comment_line_char,
+				 "%s%.*s", comment_line_string,
 				 (int)(ep - cp), cp);
-	color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%c",
-			 comment_line_char);
+	if (s->display_comment_prefix)
+		color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%c",
+				 comment_line_char);
+	else
+		fprintf_ln(s->fp, "");
 }
 
 static int has_unmerged(struct wt_status *s)
diff --git a/wt-status.h b/wt-status.h
index fb7152e..fac16ca 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -50,6 +50,7 @@ struct wt_status {
 	enum commit_whence whence;
 	int nowarn;
 	int use_color;
+	int display_comment_prefix;
 	int relative_paths;
 	int submodule_summary;
 	int show_ignored_files;
-- 
1.8.4.5.g8688bea

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v5 5/6] tests: don't set status.displayCommentPrefix file-wide
  2013-09-06 17:43 ` [PATCH v5 0/6] Disable "git status" comment prefix Matthieu Moy
                     ` (3 preceding siblings ...)
  2013-09-06 17:43   ` [PATCH v5 4/6] status: disable display of '#' comment prefix by default Matthieu Moy
@ 2013-09-06 17:43   ` Matthieu Moy
  2013-09-06 17:43   ` [PATCH v5 6/6] status: add missing blank line after list of "other" files Matthieu Moy
  5 siblings, 0 replies; 12+ messages in thread
From: Matthieu Moy @ 2013-09-06 17:43 UTC (permalink / raw)
  To: git, gitster; +Cc: Matthieu Moy

The previous commit set status.displayCommentPrefix file-wide in
t7060-wtstatus.sh, t7508-status.sh and t/t7512-status-help.sh to make the
patch small. However, now that status.displayCommentPrefix is not the
default, it is better to disable it in tests so that the most common
situation is also the most tested.

While we're there, move the "cat > expect << EOF" blocks inside the
tests.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 t/t7060-wtstatus.sh    | 113 +++----
 t/t7508-status.sh      | 889 ++++++++++++++++++++++++-------------------------
 t/t7512-status-help.sh | 604 +++++++++++++++++----------------
 3 files changed, 793 insertions(+), 813 deletions(-)

diff --git a/t/t7060-wtstatus.sh b/t/t7060-wtstatus.sh
index 5ecafac..7d467c0 100755
--- a/t/t7060-wtstatus.sh
+++ b/t/t7060-wtstatus.sh
@@ -4,10 +4,6 @@ test_description='basic work tree status reporting'
 
 . ./test-lib.sh
 
-test_expect_success 'use status.displayCommentPrefix by default ' '
-	git config --global status.displayCommentPrefix true
-'
-
 test_expect_success setup '
 	git config --global advice.statusuoption false &&
 	test_commit A &&
@@ -33,20 +29,19 @@ test_expect_success 'Report new path with conflict' '
 	test_cmp expect actual
 '
 
-cat >expect <<EOF
-# On branch side
-# You have unmerged paths.
-#   (fix conflicts and run "git commit")
-#
-# Unmerged paths:
-#   (use "git add/rm <file>..." as appropriate to mark resolution)
-#
-#	deleted by us:      foo
-#
+test_expect_success 'M/D conflict does not segfault' '
+	cat >expect <<EOF &&
+On branch side
+You have unmerged paths.
+  (fix conflicts and run "git commit")
+
+Unmerged paths:
+  (use "git add/rm <file>..." as appropriate to mark resolution)
+
+	deleted by us:      foo
+
 no changes added to commit (use "git add" and/or "git commit -a")
 EOF
-
-test_expect_success 'M/D conflict does not segfault' '
 	mkdir mdconflict &&
 	(
 		cd mdconflict &&
@@ -139,19 +134,19 @@ test_expect_success 'status when conflicts with add and rm advice (deleted by th
 	test_commit on_second main.txt on_second &&
 	test_commit master conflict.txt master &&
 	test_must_fail git merge second_branch &&
-	cat >expected <<-\EOF &&
-	# On branch master
-	# You have unmerged paths.
-	#   (fix conflicts and run "git commit")
-	#
-	# Unmerged paths:
-	#   (use "git add/rm <file>..." as appropriate to mark resolution)
-	#
-	#	both added:         conflict.txt
-	#	deleted by them:    main.txt
-	#
-	no changes added to commit (use "git add" and/or "git commit -a")
-	EOF
+	cat >expected <<\EOF &&
+On branch master
+You have unmerged paths.
+  (fix conflicts and run "git commit")
+
+Unmerged paths:
+  (use "git add/rm <file>..." as appropriate to mark resolution)
+
+	both added:         conflict.txt
+	deleted by them:    main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -172,20 +167,20 @@ test_expect_success 'prepare for conflicts' '
 
 test_expect_success 'status when conflicts with add and rm advice (both deleted)' '
 	test_must_fail git merge conflict &&
-	cat >expected <<-\EOF &&
-	# On branch conflict_second
-	# You have unmerged paths.
-	#   (fix conflicts and run "git commit")
-	#
-	# Unmerged paths:
-	#   (use "git add/rm <file>..." as appropriate to mark resolution)
-	#
-	#	both deleted:       main.txt
-	#	added by them:      sub_master.txt
-	#	added by us:        sub_second.txt
-	#
-	no changes added to commit (use "git add" and/or "git commit -a")
-	EOF
+	cat >expected <<\EOF &&
+On branch conflict_second
+You have unmerged paths.
+  (fix conflicts and run "git commit")
+
+Unmerged paths:
+  (use "git add/rm <file>..." as appropriate to mark resolution)
+
+	both deleted:       main.txt
+	added by them:      sub_master.txt
+	added by us:        sub_second.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -196,22 +191,22 @@ test_expect_success 'status when conflicts with only rm advice (both deleted)' '
 	test_must_fail git merge conflict &&
 	git add sub_master.txt &&
 	git add sub_second.txt &&
-	cat >expected <<-\EOF &&
-	# On branch conflict_second
-	# You have unmerged paths.
-	#   (fix conflicts and run "git commit")
-	#
-	# Changes to be committed:
-	#
-	#	new file:   sub_master.txt
-	#
-	# Unmerged paths:
-	#   (use "git rm <file>..." to mark resolution)
-	#
-	#	both deleted:       main.txt
-	#
-	# Untracked files not listed (use -u option to show untracked files)
-	EOF
+	cat >expected <<\EOF &&
+On branch conflict_second
+You have unmerged paths.
+  (fix conflicts and run "git commit")
+
+Changes to be committed:
+
+	new file:   sub_master.txt
+
+Unmerged paths:
+  (use "git rm <file>..." to mark resolution)
+
+	both deleted:       main.txt
+
+Untracked files not listed (use -u option to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual &&
 	git reset --hard &&
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index 8d28280..d0444d3 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -7,10 +7,6 @@ test_description='git status'
 
 . ./test-lib.sh
 
-test_expect_success 'use status.displayCommentPrefix by default ' '
-	git config --global status.displayCommentPrefix true
-'
-
 test_expect_success 'status -h in broken repository' '
 	git config --global advice.statusuoption false &&
 	mkdir broken &&
@@ -157,20 +153,20 @@ test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_
 '
 
 cat >expect <<\EOF
-# On branch master
-# Changes to be committed:
-#	new file:   dir2/added
-#
-# Changes not staged for commit:
-#	modified:   dir1/modified
-#
-# Untracked files:
-#	dir1/untracked
-#	dir2/modified
-#	dir2/untracked
-#	expect
-#	output
-#	untracked
+On branch master
+Changes to be committed:
+	new file:   dir2/added
+
+Changes not staged for commit:
+	modified:   dir1/modified
+
+Untracked files:
+	dir1/untracked
+	dir2/modified
+	dir2/untracked
+	expect
+	output
+	untracked
 EOF
 
 test_expect_success 'status (advice.statusHints false)' '
@@ -228,33 +224,33 @@ test_expect_success 'status with gitignore' '
 	git status -s --ignored >output &&
 	test_cmp expect output &&
 
-	cat >expect <<-\EOF &&
-	# On branch master
-	# Changes to be committed:
-	#   (use "git reset HEAD <file>..." to unstage)
-	#
-	#	new file:   dir2/added
-	#
-	# Changes not staged for commit:
-	#   (use "git add <file>..." to update what will be committed)
-	#   (use "git checkout -- <file>..." to discard changes in working directory)
-	#
-	#	modified:   dir1/modified
-	#
-	# Untracked files:
-	#   (use "git add <file>..." to include in what will be committed)
-	#
-	#	dir2/modified
-	# Ignored files:
-	#   (use "git add -f <file>..." to include in what will be committed)
-	#
-	#	.gitignore
-	#	dir1/untracked
-	#	dir2/untracked
-	#	expect
-	#	output
-	#	untracked
-	EOF
+	cat >expect <<\EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+	new file:   dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+	dir2/modified
+Ignored files:
+  (use "git add -f <file>..." to include in what will be committed)
+
+	.gitignore
+	dir1/untracked
+	dir2/untracked
+	expect
+	output
+	untracked
+EOF
 	git status --ignored >output &&
 	test_i18ncmp expect output
 '
@@ -289,30 +285,30 @@ test_expect_success 'status with gitignore (nothing untracked)' '
 	git status -s --ignored >output &&
 	test_cmp expect output &&
 
-	cat >expect <<-\EOF &&
-	# On branch master
-	# Changes to be committed:
-	#   (use "git reset HEAD <file>..." to unstage)
-	#
-	#	new file:   dir2/added
-	#
-	# Changes not staged for commit:
-	#   (use "git add <file>..." to update what will be committed)
-	#   (use "git checkout -- <file>..." to discard changes in working directory)
-	#
-	#	modified:   dir1/modified
-	#
-	# Ignored files:
-	#   (use "git add -f <file>..." to include in what will be committed)
-	#
-	#	.gitignore
-	#	dir1/untracked
-	#	dir2/modified
-	#	dir2/untracked
-	#	expect
-	#	output
-	#	untracked
-	EOF
+	cat >expect <<\EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+	new file:   dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	modified:   dir1/modified
+
+Ignored files:
+  (use "git add -f <file>..." to include in what will be committed)
+
+	.gitignore
+	dir1/untracked
+	dir2/modified
+	dir2/untracked
+	expect
+	output
+	untracked
+EOF
 	git status --ignored >output &&
 	test_i18ncmp expect output
 '
@@ -353,22 +349,22 @@ test_expect_success 'setup dir3' '
 	: >dir3/untracked2
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#	new file:   dir2/added
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#	modified:   dir1/modified
-#
-# Untracked files not listed (use -u option to show untracked files)
-EOF
 test_expect_success 'status -uno' '
+	cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+	new file:   dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	modified:   dir1/modified
+
+Untracked files not listed (use -u option to show untracked files)
+EOF
 	git status -uno >output &&
 	test_i18ncmp expect output
 '
@@ -379,17 +375,17 @@ test_expect_success 'status (status.showUntrackedFiles no)' '
 	test_i18ncmp expect output
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#	new file:   dir2/added
-#
-# Changes not staged for commit:
-#	modified:   dir1/modified
-#
-# Untracked files not listed
-EOF
 test_expect_success 'status -uno (advice.statusHints false)' '
+	cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+	new file:   dir2/added
+
+Changes not staged for commit:
+	modified:   dir1/modified
+
+Untracked files not listed
+EOF
 	test_config advice.statusHints false &&
 	git status -uno >output &&
 	test_i18ncmp expect output
@@ -410,31 +406,31 @@ test_expect_success 'status -s (status.showUntrackedFiles no)' '
 	test_cmp expect output
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#	new file:   dir2/added
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#	modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#	dir1/untracked
-#	dir2/modified
-#	dir2/untracked
-#	dir3/
-#	expect
-#	output
-#	untracked
-EOF
 test_expect_success 'status -unormal' '
+	cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+	new file:   dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+	dir1/untracked
+	dir2/modified
+	dir2/untracked
+	dir3/
+	expect
+	output
+	untracked
+EOF
 	git status -unormal >output &&
 	test_i18ncmp expect output
 '
@@ -467,32 +463,32 @@ test_expect_success 'status -s (status.showUntrackedFiles normal)' '
 	test_cmp expect output
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#	new file:   dir2/added
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#	modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#	dir1/untracked
-#	dir2/modified
-#	dir2/untracked
-#	dir3/untracked1
-#	dir3/untracked2
-#	expect
-#	output
-#	untracked
-EOF
 test_expect_success 'status -uall' '
+	cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+	new file:   dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+	dir1/untracked
+	dir2/modified
+	dir2/untracked
+	dir3/untracked1
+	dir3/untracked2
+	expect
+	output
+	untracked
+EOF
 	git status -uall >output &&
 	test_i18ncmp expect output
 '
@@ -529,31 +525,30 @@ test_expect_success 'status -s (status.showUntrackedFiles all)' '
 	test_cmp expect output
 '
 
-cat >expect <<\EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#	new file:   ../dir2/added
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#	modified:   modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#	untracked
-#	../dir2/modified
-#	../dir2/untracked
-#	../expect
-#	../output
-#	../untracked
-EOF
-
 test_expect_success 'status with relative paths' '
+	cat >expect <<\EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+	new file:   ../dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	modified:   modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+	untracked
+	../dir2/modified
+	../dir2/untracked
+	../expect
+	../output
+	../untracked
+EOF
 	(cd dir1 && git status) >output &&
 	test_i18ncmp expect output
 '
@@ -600,31 +595,30 @@ test_expect_success 'setup unique colors' '
 
 '
 
-cat >expect <<\EOF
-# On branch <GREEN>master<RESET>
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#	<GREEN>new file:   dir2/added<RESET>
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#	<RED>modified:   dir1/modified<RESET>
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#	<BLUE>dir1/untracked<RESET>
-#	<BLUE>dir2/modified<RESET>
-#	<BLUE>dir2/untracked<RESET>
-#	<BLUE>expect<RESET>
-#	<BLUE>output<RESET>
-#	<BLUE>untracked<RESET>
-EOF
-
 test_expect_success 'status with color.ui' '
+	cat >expect <<\EOF &&
+On branch <GREEN>master<RESET>
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+	<GREEN>new file:   dir2/added<RESET>
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	<RED>modified:   dir1/modified<RESET>
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+	<BLUE>dir1/untracked<RESET>
+	<BLUE>dir2/modified<RESET>
+	<BLUE>dir2/untracked<RESET>
+	<BLUE>expect<RESET>
+	<BLUE>output<RESET>
+	<BLUE>untracked<RESET>
+EOF
 	test_config color.ui always &&
 	git status | test_decode_color >output &&
 	test_i18ncmp expect output
@@ -728,33 +722,32 @@ test_expect_success 'status --porcelain respects -b' '
 
 '
 
-cat >expect <<\EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#	new file:   dir2/added
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#	modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#	dir1/untracked
-#	dir2/modified
-#	dir2/untracked
-#	expect
-#	output
-#	untracked
-EOF
 
 
 test_expect_success 'status without relative paths' '
+	cat >expect <<\EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+	new file:   dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
 
+	modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+	dir1/untracked
+	dir2/modified
+	dir2/untracked
+	expect
+	output
+	untracked
+EOF
 	test_config status.relativePaths false &&
 	(cd dir1 && git status) >output &&
 	test_i18ncmp expect output
@@ -780,23 +773,23 @@ test_expect_success 'status -s without relative paths' '
 
 '
 
-cat <<EOF >expect
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#	modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#	dir1/untracked
-#	dir2/
-#	expect
-#	output
-#	untracked
-EOF
 test_expect_success 'dry-run of partial commit excluding new file in index' '
+	cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+	modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+	dir1/untracked
+	dir2/
+	expect
+	output
+	untracked
+EOF
 	git commit --dry-run dir1/modified >output &&
 	test_i18ncmp expect output
 '
@@ -821,31 +814,31 @@ test_expect_success 'setup status submodule summary' '
 	git add sm
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#	new file:   dir2/added
-#	new file:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#	modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#	dir1/untracked
-#	dir2/modified
-#	dir2/untracked
-#	expect
-#	output
-#	untracked
-EOF
 test_expect_success 'status submodule summary is disabled by default' '
+	cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+	new file:   dir2/added
+	new file:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+	dir1/untracked
+	dir2/modified
+	dir2/untracked
+	expect
+	output
+	untracked
+EOF
 	git status >output &&
 	test_i18ncmp expect output
 '
@@ -880,36 +873,36 @@ test_expect_success 'status -s --untracked-files=all does not show submodule' '
 
 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#	new file:   dir2/added
-#	new file:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#	modified:   dir1/modified
-#
-# Submodule changes to be committed:
-#
-# * sm 0000000...$head (1):
-#   > Add foo
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#	dir1/untracked
-#	dir2/modified
-#	dir2/untracked
-#	expect
-#	output
-#	untracked
-EOF
 test_expect_success 'status submodule summary' '
+	cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+	new file:   dir2/added
+	new file:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	modified:   dir1/modified
+
+Submodule changes to be committed:
+
+* sm 0000000...$head (1):
+  > Add foo
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+	dir1/untracked
+	dir2/modified
+	dir2/untracked
+	expect
+	output
+	untracked
+EOF
 	git config status.submodulesummary 10 &&
 	git status >output &&
 	test_i18ncmp expect output
@@ -941,26 +934,26 @@ test_expect_success 'status -s submodule summary' '
 	test_cmp expect output
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#	modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#	dir1/untracked
-#	dir2/modified
-#	dir2/untracked
-#	expect
-#	output
-#	untracked
+test_expect_success 'status submodule summary (clean submodule): commit' '
+	cat >expect <<EOF &&
+On branch master
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+	dir1/untracked
+	dir2/modified
+	dir2/untracked
+	expect
+	output
+	untracked
 no changes added to commit (use "git add" and/or "git commit -a")
 EOF
-test_expect_success 'status submodule summary (clean submodule): commit' '
 	git commit -m "commit submodule" &&
 	git config status.submodulesummary 10 &&
 	test_must_fail git commit --dry-run >output &&
@@ -990,36 +983,36 @@ test_expect_success 'status -z implies porcelain' '
 	test_cmp expect output
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD^1 <file>..." to unstage)
-#
-#	new file:   dir2/added
-#	new file:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#	modified:   dir1/modified
-#
-# Submodule changes to be committed:
-#
-# * sm 0000000...$head (1):
-#   > Add foo
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#	dir1/untracked
-#	dir2/modified
-#	dir2/untracked
-#	expect
-#	output
-#	untracked
-EOF
 test_expect_success 'commit --dry-run submodule summary (--amend)' '
+	cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD^1 <file>..." to unstage)
+
+	new file:   dir2/added
+	new file:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	modified:   dir1/modified
+
+Submodule changes to be committed:
+
+* sm 0000000...$head (1):
+  > Add foo
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+	dir1/untracked
+	dir2/modified
+	dir2/untracked
+	expect
+	output
+	untracked
+EOF
 	git config status.submodulesummary 10 &&
 	git commit --dry-run --amend >output &&
 	test_i18ncmp expect output
@@ -1044,37 +1037,36 @@ test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository'
 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
 touch .gitmodules
 
-cat > expect << EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#	modified:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#	modified:   dir1/modified
-#
-# Submodule changes to be committed:
-#
-# * sm $head...$new_head (1):
-#   > Add bar
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#	.gitmodules
-#	dir1/untracked
-#	dir2/modified
-#	dir2/untracked
-#	expect
-#	output
-#	untracked
-EOF
-
 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
+	cat > expect << EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+	modified:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	modified:   dir1/modified
+
+Submodule changes to be committed:
+
+* sm $head...$new_head (1):
+  > Add bar
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+	.gitmodules
+	dir1/untracked
+	dir2/modified
+	dir2/untracked
+	expect
+	output
+	untracked
+EOF
 	echo modified  sm/untracked &&
 	git status --ignore-submodules=untracked >output &&
 	test_i18ncmp expect output
@@ -1154,39 +1146,38 @@ test_expect_success '.git/config ignore=dirty suppresses submodules with modifie
 	git config -f .gitmodules  --remove-section submodule.subname
 '
 
-cat > expect << EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#	modified:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#   (commit or discard the untracked or modified content in submodules)
-#
-#	modified:   dir1/modified
-#	modified:   sm (modified content)
-#
-# Submodule changes to be committed:
-#
-# * sm $head...$new_head (1):
-#   > Add bar
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#	.gitmodules
-#	dir1/untracked
-#	dir2/modified
-#	dir2/untracked
-#	expect
-#	output
-#	untracked
-EOF
-
 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
+	cat > expect << EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+	modified:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+  (commit or discard the untracked or modified content in submodules)
+
+	modified:   dir1/modified
+	modified:   sm (modified content)
+
+Submodule changes to be committed:
+
+* sm $head...$new_head (1):
+  > Add bar
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+	.gitmodules
+	dir1/untracked
+	dir2/modified
+	dir2/untracked
+	expect
+	output
+	untracked
+EOF
 	git status --ignore-submodules=untracked > output &&
 	test_i18ncmp expect output
 '
@@ -1212,43 +1203,42 @@ test_expect_success ".git/config ignore=untracked doesn't suppress submodules wi
 
 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
 
-cat > expect << EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#	modified:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#	modified:   dir1/modified
-#	modified:   sm (new commits)
-#
-# Submodule changes to be committed:
-#
-# * sm $head...$new_head (1):
-#   > Add bar
-#
-# Submodules changed but not updated:
-#
-# * sm $new_head...$head2 (1):
-#   > 2nd commit
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#	.gitmodules
-#	dir1/untracked
-#	dir2/modified
-#	dir2/untracked
-#	expect
-#	output
-#	untracked
-EOF
-
 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
+	cat > expect << EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+	modified:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	modified:   dir1/modified
+	modified:   sm (new commits)
+
+Submodule changes to be committed:
+
+* sm $head...$new_head (1):
+  > Add bar
+
+Submodules changed but not updated:
+
+* sm $new_head...$head2 (1):
+  > 2nd commit
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+	.gitmodules
+	dir1/untracked
+	dir2/modified
+	dir2/untracked
+	expect
+	output
+	untracked
+EOF
 	git status --ignore-submodules=untracked > output &&
 	test_i18ncmp expect output
 '
@@ -1333,38 +1323,37 @@ EOF
 
 test_expect_success "status (core.commentchar with submodule summary)" '
 	test_config core.commentchar ";" &&
-	git status >output &&
+	git -c status.displayCommentPrefix=true status >output &&
 	test_i18ncmp expect output
 '
 
 test_expect_success "status (core.commentchar with two chars with submodule summary)" '
 	test_config core.commentchar ";;" &&
-	git status >output &&
+	git -c status.displayCommentPrefix=true status >output &&
 	test_i18ncmp expect output
 '
 
-cat > expect << EOF
-# On branch master
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#	modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#	.gitmodules
-#	dir1/untracked
-#	dir2/modified
-#	dir2/untracked
-#	expect
-#	output
-#	untracked
+test_expect_success "--ignore-submodules=all suppresses submodule summary" '
+	cat > expect << EOF &&
+On branch master
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+	.gitmodules
+	dir1/untracked
+	dir2/modified
+	dir2/untracked
+	expect
+	output
+	untracked
 no changes added to commit (use "git add" and/or "git commit -a")
 EOF
-
-test_expect_success "--ignore-submodules=all suppresses submodule summary" '
 	git status --ignore-submodules=all > output &&
 	test_i18ncmp expect output
 '
diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index 312f417..0688d58 100755
--- a/t/t7512-status-help.sh
+++ b/t/t7512-status-help.sh
@@ -13,10 +13,6 @@ test_description='git status advice'
 
 set_fake_editor
 
-test_expect_success 'use status.displayCommentPrefix by default ' '
-	git config --global status.displayCommentPrefix true
-'
-
 test_expect_success 'prepare for conflicts' '
 	git config --global advice.statusuoption false &&
 	test_commit init main.txt init &&
@@ -29,18 +25,18 @@ test_expect_success 'prepare for conflicts' '
 
 test_expect_success 'status when conflicts unresolved' '
 	test_must_fail git merge master &&
-	cat >expected <<-\EOF &&
-	# On branch conflicts
-	# You have unmerged paths.
-	#   (fix conflicts and run "git commit")
-	#
-	# Unmerged paths:
-	#   (use "git add <file>..." to mark resolution)
-	#
-	#	both modified:      main.txt
-	#
-	no changes added to commit (use "git add" and/or "git commit -a")
-	EOF
+	cat >expected <<\EOF &&
+On branch conflicts
+You have unmerged paths.
+  (fix conflicts and run "git commit")
+
+Unmerged paths:
+  (use "git add <file>..." to mark resolution)
+
+	both modified:      main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -51,17 +47,17 @@ test_expect_success 'status when conflicts resolved before commit' '
 	test_must_fail git merge master &&
 	echo one >main.txt &&
 	git add main.txt &&
-	cat >expected <<-\EOF &&
-	# On branch conflicts
-	# All conflicts fixed but you are still merging.
-	#   (use "git commit" to conclude merge)
-	#
-	# Changes to be committed:
-	#
-	#	modified:   main.txt
-	#
-	# Untracked files not listed (use -u option to show untracked files)
-	EOF
+	cat >expected <<\EOF &&
+On branch conflicts
+All conflicts fixed but you are still merging.
+  (use "git commit" to conclude merge)
+
+Changes to be committed:
+
+	modified:   main.txt
+
+Untracked files not listed (use -u option to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -80,21 +76,21 @@ test_expect_success 'status when rebase in progress before resolving conflicts'
 	test_when_finished "git rebase --abort" &&
 	ONTO=$(git rev-parse --short HEAD^^) &&
 	test_must_fail git rebase HEAD^ --onto HEAD^^ &&
-	cat >expected <<-EOF &&
-	# rebase in progress; onto $ONTO
-	# You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
-	#   (fix conflicts and then run "git rebase --continue")
-	#   (use "git rebase --skip" to skip this patch)
-	#   (use "git rebase --abort" to check out the original branch)
-	#
-	# Unmerged paths:
-	#   (use "git reset HEAD <file>..." to unstage)
-	#   (use "git add <file>..." to mark resolution)
-	#
-	#	both modified:      main.txt
-	#
-	no changes added to commit (use "git add" and/or "git commit -a")
-	EOF
+	cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
+  (fix conflicts and then run "git rebase --continue")
+  (use "git rebase --skip" to skip this patch)
+  (use "git rebase --abort" to check out the original branch)
+
+Unmerged paths:
+  (use "git reset HEAD <file>..." to unstage)
+  (use "git add <file>..." to mark resolution)
+
+	both modified:      main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -107,18 +103,18 @@ test_expect_success 'status when rebase in progress before rebase --continue' '
 	test_must_fail git rebase HEAD^ --onto HEAD^^ &&
 	echo three >main.txt &&
 	git add main.txt &&
-	cat >expected <<-EOF &&
-	# rebase in progress; onto $ONTO
-	# You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
-	#   (all conflicts fixed: run "git rebase --continue")
-	#
-	# Changes to be committed:
-	#   (use "git reset HEAD <file>..." to unstage)
-	#
-	#	modified:   main.txt
-	#
-	# Untracked files not listed (use -u option to show untracked files)
-	EOF
+	cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
+  (all conflicts fixed: run "git rebase --continue")
+
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+	modified:   main.txt
+
+Untracked files not listed (use -u option to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -139,21 +135,21 @@ test_expect_success 'status during rebase -i when conflicts unresolved' '
 	test_when_finished "git rebase --abort" &&
 	ONTO=$(git rev-parse --short rebase_i_conflicts) &&
 	test_must_fail git rebase -i rebase_i_conflicts &&
-	cat >expected <<-EOF &&
-	# rebase in progress; onto $ONTO
-	# You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
-	#   (fix conflicts and then run "git rebase --continue")
-	#   (use "git rebase --skip" to skip this patch)
-	#   (use "git rebase --abort" to check out the original branch)
-	#
-	# Unmerged paths:
-	#   (use "git reset HEAD <file>..." to unstage)
-	#   (use "git add <file>..." to mark resolution)
-	#
-	#	both modified:      main.txt
-	#
-	no changes added to commit (use "git add" and/or "git commit -a")
-	EOF
+	cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
+  (fix conflicts and then run "git rebase --continue")
+  (use "git rebase --skip" to skip this patch)
+  (use "git rebase --abort" to check out the original branch)
+
+Unmerged paths:
+  (use "git reset HEAD <file>..." to unstage)
+  (use "git add <file>..." to mark resolution)
+
+	both modified:      main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -165,18 +161,18 @@ test_expect_success 'status during rebase -i after resolving conflicts' '
 	ONTO=$(git rev-parse --short rebase_i_conflicts) &&
 	test_must_fail git rebase -i rebase_i_conflicts &&
 	git add main.txt &&
-	cat >expected <<-EOF &&
-	# rebase in progress; onto $ONTO
-	# You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
-	#   (all conflicts fixed: run "git rebase --continue")
-	#
-	# Changes to be committed:
-	#   (use "git reset HEAD <file>..." to unstage)
-	#
-	#	modified:   main.txt
-	#
-	# Untracked files not listed (use -u option to show untracked files)
-	EOF
+	cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
+  (all conflicts fixed: run "git rebase --continue")
+
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+	modified:   main.txt
+
+Untracked files not listed (use -u option to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -193,14 +189,14 @@ test_expect_success 'status when rebasing -i in edit mode' '
 	test_when_finished "git rebase --abort" &&
 	ONTO=$(git rev-parse --short HEAD~2) &&
 	git rebase -i HEAD~2 &&
-	cat >expected <<-EOF &&
-	# rebase in progress; onto $ONTO
-	# You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''.
-	#   (use "git commit --amend" to amend the current commit)
-	#   (use "git rebase --continue" once you are satisfied with your changes)
-	#
-	nothing to commit (use -u to show untracked files)
-	EOF
+	cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''.
+  (use "git commit --amend" to amend the current commit)
+  (use "git rebase --continue" once you are satisfied with your changes)
+
+nothing to commit (use -u to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -219,19 +215,19 @@ test_expect_success 'status when splitting a commit' '
 	ONTO=$(git rev-parse --short HEAD~3) &&
 	git rebase -i HEAD~3 &&
 	git reset HEAD^ &&
-	cat >expected <<-EOF &&
-	# rebase in progress; onto $ONTO
-	# You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
-	#   (Once your working directory is clean, run "git rebase --continue")
-	#
-	# Changes not staged for commit:
-	#   (use "git add <file>..." to update what will be committed)
-	#   (use "git checkout -- <file>..." to discard changes in working directory)
-	#
-	#	modified:   main.txt
-	#
-	no changes added to commit (use "git add" and/or "git commit -a")
-	EOF
+	cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
+  (Once your working directory is clean, run "git rebase --continue")
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	modified:   main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -250,14 +246,14 @@ test_expect_success 'status after editing the last commit with --amend during a
 	ONTO=$(git rev-parse --short HEAD~3) &&
 	git rebase -i HEAD~3 &&
 	git commit --amend -m "foo" &&
-	cat >expected <<-EOF &&
-	# rebase in progress; onto $ONTO
-	# You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''.
-	#   (use "git commit --amend" to amend the current commit)
-	#   (use "git rebase --continue" once you are satisfied with your changes)
-	#
-	nothing to commit (use -u to show untracked files)
-	EOF
+	cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''.
+  (use "git commit --amend" to amend the current commit)
+  (use "git rebase --continue" once you are satisfied with your changes)
+
+nothing to commit (use -u to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -280,14 +276,14 @@ test_expect_success 'status: (continue first edit) second edit' '
 	ONTO=$(git rev-parse --short HEAD~3) &&
 	git rebase -i HEAD~3 &&
 	git rebase --continue &&
-	cat >expected <<-EOF &&
-	# rebase in progress; onto $ONTO
-	# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
-	#   (use "git commit --amend" to amend the current commit)
-	#   (use "git rebase --continue" once you are satisfied with your changes)
-	#
-	nothing to commit (use -u to show untracked files)
-	EOF
+	cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
+  (use "git commit --amend" to amend the current commit)
+  (use "git rebase --continue" once you are satisfied with your changes)
+
+nothing to commit (use -u to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -302,19 +298,19 @@ test_expect_success 'status: (continue first edit) second edit and split' '
 	git rebase -i HEAD~3 &&
 	git rebase --continue &&
 	git reset HEAD^ &&
-	cat >expected <<-EOF &&
-	# rebase in progress; onto $ONTO
-	# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
-	#   (Once your working directory is clean, run "git rebase --continue")
-	#
-	# Changes not staged for commit:
-	#   (use "git add <file>..." to update what will be committed)
-	#   (use "git checkout -- <file>..." to discard changes in working directory)
-	#
-	#	modified:   main.txt
-	#
-	no changes added to commit (use "git add" and/or "git commit -a")
-	EOF
+	cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
+  (Once your working directory is clean, run "git rebase --continue")
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	modified:   main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -329,14 +325,14 @@ test_expect_success 'status: (continue first edit) second edit and amend' '
 	git rebase -i HEAD~3 &&
 	git rebase --continue &&
 	git commit --amend -m "foo" &&
-	cat >expected <<-EOF &&
-	# rebase in progress; onto $ONTO
-	# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
-	#   (use "git commit --amend" to amend the current commit)
-	#   (use "git rebase --continue" once you are satisfied with your changes)
-	#
-	nothing to commit (use -u to show untracked files)
-	EOF
+	cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
+  (use "git commit --amend" to amend the current commit)
+  (use "git rebase --continue" once you are satisfied with your changes)
+
+nothing to commit (use -u to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -351,14 +347,14 @@ test_expect_success 'status: (amend first edit) second edit' '
 	git rebase -i HEAD~3 &&
 	git commit --amend -m "a" &&
 	git rebase --continue &&
-	cat >expected <<-EOF &&
-	# rebase in progress; onto $ONTO
-	# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
-	#   (use "git commit --amend" to amend the current commit)
-	#   (use "git rebase --continue" once you are satisfied with your changes)
-	#
-	nothing to commit (use -u to show untracked files)
-	EOF
+	cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
+  (use "git commit --amend" to amend the current commit)
+  (use "git rebase --continue" once you are satisfied with your changes)
+
+nothing to commit (use -u to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -374,19 +370,19 @@ test_expect_success 'status: (amend first edit) second edit and split' '
 	git commit --amend -m "b" &&
 	git rebase --continue &&
 	git reset HEAD^ &&
-	cat >expected <<-EOF &&
-	# rebase in progress; onto $ONTO
-	# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
-	#   (Once your working directory is clean, run "git rebase --continue")
-	#
-	# Changes not staged for commit:
-	#   (use "git add <file>..." to update what will be committed)
-	#   (use "git checkout -- <file>..." to discard changes in working directory)
-	#
-	#	modified:   main.txt
-	#
-	no changes added to commit (use "git add" and/or "git commit -a")
-	EOF
+	cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
+  (Once your working directory is clean, run "git rebase --continue")
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	modified:   main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -402,14 +398,14 @@ test_expect_success 'status: (amend first edit) second edit and amend' '
 	git commit --amend -m "c" &&
 	git rebase --continue &&
 	git commit --amend -m "d" &&
-	cat >expected <<-EOF &&
-	# rebase in progress; onto $ONTO
-	# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
-	#   (use "git commit --amend" to amend the current commit)
-	#   (use "git rebase --continue" once you are satisfied with your changes)
-	#
-	nothing to commit (use -u to show untracked files)
-	EOF
+	cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
+  (use "git commit --amend" to amend the current commit)
+  (use "git rebase --continue" once you are satisfied with your changes)
+
+nothing to commit (use -u to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -426,14 +422,14 @@ test_expect_success 'status: (split first edit) second edit' '
 	git add main.txt &&
 	git commit -m "e" &&
 	git rebase --continue &&
-	cat >expected <<-EOF &&
-	# rebase in progress; onto $ONTO
-	# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
-	#   (use "git commit --amend" to amend the current commit)
-	#   (use "git rebase --continue" once you are satisfied with your changes)
-	#
-	nothing to commit (use -u to show untracked files)
-	EOF
+	cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
+  (use "git commit --amend" to amend the current commit)
+  (use "git rebase --continue" once you are satisfied with your changes)
+
+nothing to commit (use -u to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -451,19 +447,19 @@ test_expect_success 'status: (split first edit) second edit and split' '
 	git commit --amend -m "f" &&
 	git rebase --continue &&
 	git reset HEAD^ &&
-	cat >expected <<-EOF &&
-	# rebase in progress; onto $ONTO
-	# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
-	#   (Once your working directory is clean, run "git rebase --continue")
-	#
-	# Changes not staged for commit:
-	#   (use "git add <file>..." to update what will be committed)
-	#   (use "git checkout -- <file>..." to discard changes in working directory)
-	#
-	#	modified:   main.txt
-	#
-	no changes added to commit (use "git add" and/or "git commit -a")
-	EOF
+	cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
+  (Once your working directory is clean, run "git rebase --continue")
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+	modified:   main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -481,14 +477,14 @@ test_expect_success 'status: (split first edit) second edit and amend' '
 	git commit --amend -m "g" &&
 	git rebase --continue &&
 	git commit --amend -m "h" &&
-	cat >expected <<-EOF &&
-	# rebase in progress; onto $ONTO
-	# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
-	#   (use "git commit --amend" to amend the current commit)
-	#   (use "git rebase --continue" once you are satisfied with your changes)
-	#
-	nothing to commit (use -u to show untracked files)
-	EOF
+	cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
+  (use "git commit --amend" to amend the current commit)
+  (use "git rebase --continue" once you are satisfied with your changes)
+
+nothing to commit (use -u to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -508,15 +504,15 @@ test_expect_success 'status in an am session: file already exists' '
 	test_when_finished "rm Maildir/* && git am --abort" &&
 	git format-patch -1 -oMaildir &&
 	test_must_fail git am Maildir/*.patch &&
-	cat >expected <<-\EOF &&
-	# On branch am_already_exists
-	# You are in the middle of an am session.
-	#   (fix conflicts and then run "git am --continue")
-	#   (use "git am --skip" to skip this patch)
-	#   (use "git am --abort" to restore the original branch)
-	#
-	nothing to commit (use -u to show untracked files)
-	EOF
+	cat >expected <<\EOF &&
+On branch am_already_exists
+You are in the middle of an am session.
+  (fix conflicts and then run "git am --continue")
+  (use "git am --skip" to skip this patch)
+  (use "git am --abort" to restore the original branch)
+
+nothing to commit (use -u to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -530,15 +526,15 @@ test_expect_success 'status in an am session: file does not exist' '
 	test_when_finished "rm Maildir/* && git am --abort" &&
 	git format-patch -1 -oMaildir &&
 	test_must_fail git am Maildir/*.patch &&
-	cat >expected <<-\EOF &&
-	# On branch am_not_exists
-	# You are in the middle of an am session.
-	#   (fix conflicts and then run "git am --continue")
-	#   (use "git am --skip" to skip this patch)
-	#   (use "git am --abort" to restore the original branch)
-	#
-	nothing to commit (use -u to show untracked files)
-	EOF
+	cat >expected <<\EOF &&
+On branch am_not_exists
+You are in the middle of an am session.
+  (fix conflicts and then run "git am --continue")
+  (use "git am --skip" to skip this patch)
+  (use "git am --abort" to restore the original branch)
+
+nothing to commit (use -u to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -553,15 +549,15 @@ test_expect_success 'status in an am session: empty patch' '
 	git commit -m "delete all am_empty" &&
 	echo error >Maildir/0002-two_am.patch &&
 	test_must_fail git am Maildir/*.patch &&
-	cat >expected <<-\EOF &&
-	# On branch am_empty
-	# You are in the middle of an am session.
-	# The current patch is empty.
-	#   (use "git am --skip" to skip this patch)
-	#   (use "git am --abort" to restore the original branch)
-	#
-	nothing to commit (use -u to show untracked files)
-	EOF
+	cat >expected <<\EOF &&
+On branch am_empty
+You are in the middle of an am session.
+The current patch is empty.
+  (use "git am --skip" to skip this patch)
+  (use "git am --abort" to restore the original branch)
+
+nothing to commit (use -u to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -578,13 +574,13 @@ test_expect_success 'status when bisecting' '
 	git bisect bad &&
 	git bisect good one_bisect &&
 	TGT=$(git rev-parse --short two_bisect) &&
-	cat >expected <<-EOF &&
-	# HEAD detached at $TGT
-	# You are currently bisecting, started from branch '\''bisect'\''.
-	#   (use "git bisect reset" to get back to the original branch)
-	#
-	nothing to commit (use -u to show untracked files)
-	EOF
+	cat >expected <<EOF &&
+HEAD detached at $TGT
+You are currently bisecting, started from branch '\''bisect'\''.
+  (use "git bisect reset" to get back to the original branch)
+
+nothing to commit (use -u to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -601,15 +597,15 @@ test_expect_success 'status when rebase conflicts with statushints disabled' '
 	test_when_finished "git rebase --abort" &&
 	ONTO=$(git rev-parse --short HEAD^^) &&
 	test_must_fail git rebase HEAD^ --onto HEAD^^ &&
-	cat >expected <<-EOF &&
-	# rebase in progress; onto $ONTO
-	# You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
-	#
-	# Unmerged paths:
-	#	both modified:      main.txt
-	#
-	no changes added to commit
-	EOF
+	cat >expected <<EOF &&
+rebase in progress; onto $ONTO
+You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
+
+Unmerged paths:
+	both modified:      main.txt
+
+no changes added to commit
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -630,19 +626,19 @@ test_expect_success 'prepare for cherry-pick conflicts' '
 test_expect_success 'status when cherry-picking before resolving conflicts' '
 	test_when_finished "git cherry-pick --abort" &&
 	test_must_fail git cherry-pick cherry_branch_second &&
-	cat >expected <<-\EOF &&
-	# On branch cherry_branch
-	# You are currently cherry-picking.
-	#   (fix conflicts and run "git cherry-pick --continue")
-	#   (use "git cherry-pick --abort" to cancel the cherry-pick operation)
-	#
-	# Unmerged paths:
-	#   (use "git add <file>..." to mark resolution)
-	#
-	#	both modified:      main.txt
-	#
-	no changes added to commit (use "git add" and/or "git commit -a")
-	EOF
+	cat >expected <<\EOF &&
+On branch cherry_branch
+You are currently cherry-picking.
+  (fix conflicts and run "git cherry-pick --continue")
+  (use "git cherry-pick --abort" to cancel the cherry-pick operation)
+
+Unmerged paths:
+  (use "git add <file>..." to mark resolution)
+
+	both modified:      main.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -654,18 +650,18 @@ test_expect_success 'status when cherry-picking after resolving conflicts' '
 	test_must_fail git cherry-pick cherry_branch_second &&
 	echo end >main.txt &&
 	git add main.txt &&
-	cat >expected <<-\EOF &&
-	# On branch cherry_branch
-	# You are currently cherry-picking.
-	#   (all conflicts fixed: run "git cherry-pick --continue")
-	#   (use "git cherry-pick --abort" to cancel the cherry-pick operation)
-	#
-	# Changes to be committed:
-	#
-	#	modified:   main.txt
-	#
-	# Untracked files not listed (use -u option to show untracked files)
-	EOF
+	cat >expected <<\EOF &&
+On branch cherry_branch
+You are currently cherry-picking.
+  (all conflicts fixed: run "git cherry-pick --continue")
+  (use "git cherry-pick --abort" to cancel the cherry-pick operation)
+
+Changes to be committed:
+
+	modified:   main.txt
+
+Untracked files not listed (use -u option to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -673,18 +669,18 @@ test_expect_success 'status when cherry-picking after resolving conflicts' '
 test_expect_success 'status showing detached at and from a tag' '
 	test_commit atag tagging &&
 	git checkout atag &&
-	cat >expected <<-\EOF
-	# HEAD detached at atag
-	nothing to commit (use -u to show untracked files)
-	EOF
+	cat >expected <<\EOF
+HEAD detached at atag
+nothing to commit (use -u to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual &&
 
 	git reset --hard HEAD^ &&
-	cat >expected <<-\EOF
-	# HEAD detached from atag
-	nothing to commit (use -u to show untracked files)
-	EOF
+	cat >expected <<\EOF
+HEAD detached from atag
+nothing to commit (use -u to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -699,20 +695,20 @@ test_expect_success 'status while reverting commit (conflicts)' '
 	test_commit new to-revert.txt &&
 	TO_REVERT=$(git rev-parse --short HEAD^) &&
 	test_must_fail git revert $TO_REVERT &&
-	cat >expected <<-EOF
-	# On branch master
-	# You are currently reverting commit $TO_REVERT.
-	#   (fix conflicts and run "git revert --continue")
-	#   (use "git revert --abort" to cancel the revert operation)
-	#
-	# Unmerged paths:
-	#   (use "git reset HEAD <file>..." to unstage)
-	#   (use "git add <file>..." to mark resolution)
-	#
-	#	both modified:      to-revert.txt
-	#
-	no changes added to commit (use "git add" and/or "git commit -a")
-	EOF
+	cat >expected <<EOF
+On branch master
+You are currently reverting commit $TO_REVERT.
+  (fix conflicts and run "git revert --continue")
+  (use "git revert --abort" to cancel the revert operation)
+
+Unmerged paths:
+  (use "git reset HEAD <file>..." to unstage)
+  (use "git add <file>..." to mark resolution)
+
+	both modified:      to-revert.txt
+
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
@@ -720,29 +716,29 @@ test_expect_success 'status while reverting commit (conflicts)' '
 test_expect_success 'status while reverting commit (conflicts resolved)' '
 	echo reverted >to-revert.txt &&
 	git add to-revert.txt &&
-	cat >expected <<-EOF
-	# On branch master
-	# You are currently reverting commit $TO_REVERT.
-	#   (all conflicts fixed: run "git revert --continue")
-	#   (use "git revert --abort" to cancel the revert operation)
-	#
-	# Changes to be committed:
-	#   (use "git reset HEAD <file>..." to unstage)
-	#
-	#	modified:   to-revert.txt
-	#
-	# Untracked files not listed (use -u option to show untracked files)
-	EOF
+	cat >expected <<EOF
+On branch master
+You are currently reverting commit $TO_REVERT.
+  (all conflicts fixed: run "git revert --continue")
+  (use "git revert --abort" to cancel the revert operation)
+
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+	modified:   to-revert.txt
+
+Untracked files not listed (use -u option to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
 
 test_expect_success 'status after reverting commit' '
 	git revert --continue &&
-	cat >expected <<-\EOF
-	# On branch master
-	nothing to commit (use -u to show untracked files)
-	EOF
+	cat >expected <<\EOF
+On branch master
+nothing to commit (use -u to show untracked files)
+EOF
 	git status --untracked-files=no >actual &&
 	test_i18ncmp expected actual
 '
-- 
1.8.4.5.g8688bea

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v5 6/6] status: add missing blank line after list of "other" files
  2013-09-06 17:43 ` [PATCH v5 0/6] Disable "git status" comment prefix Matthieu Moy
                     ` (4 preceding siblings ...)
  2013-09-06 17:43   ` [PATCH v5 5/6] tests: don't set status.displayCommentPrefix file-wide Matthieu Moy
@ 2013-09-06 17:43   ` Matthieu Moy
  2013-09-06 18:22     ` Junio C Hamano
  5 siblings, 1 reply; 12+ messages in thread
From: Matthieu Moy @ 2013-09-06 17:43 UTC (permalink / raw)
  To: git, gitster; +Cc: Matthieu Moy

List of files in other sections ("Changes to be committed", ...) end with
a blank line. It is not the case with the "Untracked files" and "Ignored
files" sections. The issue become particularly visible after the #-prefix
removal, as the last line (e.g. "nothing added to commit but untracked
files present") seems mixed with the untracked files.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 t/t7508-status.sh | 21 +++++++++++++++++++++
 wt-status.c       |  4 +++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index d0444d3..9bf9701 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -84,6 +84,7 @@ test_expect_success 'status --column' '
 #
 #	dir1/untracked dir2/untracked output
 #	dir2/modified  expect         untracked
+#
 EOF
 	COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
 	test_i18ncmp expect output
@@ -117,6 +118,7 @@ cat >expect <<\EOF
 #	expect
 #	output
 #	untracked
+#
 EOF
 
 test_expect_success 'status with status.displayCommentPrefix=true' '
@@ -167,6 +169,7 @@ Untracked files:
 	expect
 	output
 	untracked
+
 EOF
 
 test_expect_success 'status (advice.statusHints false)' '
@@ -241,6 +244,7 @@ Untracked files:
   (use "git add <file>..." to include in what will be committed)
 
 	dir2/modified
+
 Ignored files:
   (use "git add -f <file>..." to include in what will be committed)
 
@@ -250,6 +254,7 @@ Ignored files:
 	expect
 	output
 	untracked
+
 EOF
 	git status --ignored >output &&
 	test_i18ncmp expect output
@@ -308,6 +313,7 @@ Ignored files:
 	expect
 	output
 	untracked
+
 EOF
 	git status --ignored >output &&
 	test_i18ncmp expect output
@@ -430,6 +436,7 @@ Untracked files:
 	expect
 	output
 	untracked
+
 EOF
 	git status -unormal >output &&
 	test_i18ncmp expect output
@@ -488,6 +495,7 @@ Untracked files:
 	expect
 	output
 	untracked
+
 EOF
 	git status -uall >output &&
 	test_i18ncmp expect output
@@ -548,6 +556,7 @@ Untracked files:
 	../expect
 	../output
 	../untracked
+
 EOF
 	(cd dir1 && git status) >output &&
 	test_i18ncmp expect output
@@ -618,6 +627,7 @@ Untracked files:
 	<BLUE>expect<RESET>
 	<BLUE>output<RESET>
 	<BLUE>untracked<RESET>
+
 EOF
 	test_config color.ui always &&
 	git status | test_decode_color >output &&
@@ -747,6 +757,7 @@ Untracked files:
 	expect
 	output
 	untracked
+
 EOF
 	test_config status.relativePaths false &&
 	(cd dir1 && git status) >output &&
@@ -789,6 +800,7 @@ Untracked files:
 	expect
 	output
 	untracked
+
 EOF
 	git commit --dry-run dir1/modified >output &&
 	test_i18ncmp expect output
@@ -838,6 +850,7 @@ Untracked files:
 	expect
 	output
 	untracked
+
 EOF
 	git status >output &&
 	test_i18ncmp expect output
@@ -902,6 +915,7 @@ Untracked files:
 	expect
 	output
 	untracked
+
 EOF
 	git config status.submodulesummary 10 &&
 	git status >output &&
@@ -952,6 +966,7 @@ Untracked files:
 	expect
 	output
 	untracked
+
 no changes added to commit (use "git add" and/or "git commit -a")
 EOF
 	git commit -m "commit submodule" &&
@@ -1012,6 +1027,7 @@ Untracked files:
 	expect
 	output
 	untracked
+
 EOF
 	git config status.submodulesummary 10 &&
 	git commit --dry-run --amend >output &&
@@ -1066,6 +1082,7 @@ Untracked files:
 	expect
 	output
 	untracked
+
 EOF
 	echo modified  sm/untracked &&
 	git status --ignore-submodules=untracked >output &&
@@ -1177,6 +1194,7 @@ Untracked files:
 	expect
 	output
 	untracked
+
 EOF
 	git status --ignore-submodules=untracked > output &&
 	test_i18ncmp expect output
@@ -1238,6 +1256,7 @@ Untracked files:
 	expect
 	output
 	untracked
+
 EOF
 	git status --ignore-submodules=untracked > output &&
 	test_i18ncmp expect output
@@ -1319,6 +1338,7 @@ cat > expect << EOF
 ;	expect
 ;	output
 ;	untracked
+;
 EOF
 
 test_expect_success "status (core.commentchar with submodule summary)" '
@@ -1352,6 +1372,7 @@ Untracked files:
 	expect
 	output
 	untracked
+
 no changes added to commit (use "git add" and/or "git commit -a")
 EOF
 	git status --ignore-submodules=all > output &&
diff --git a/wt-status.c b/wt-status.c
index 3c795da..2a9ca0f 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -751,7 +751,7 @@ static void wt_status_print_other(struct wt_status *s,
 
 	strbuf_release(&buf);
 	if (!column_active(s->colopts))
-		return;
+		goto conclude;
 
 	strbuf_addf(&buf, "%s%s\t%s",
 		    color(WT_STATUS_HEADER, s),
@@ -765,6 +765,8 @@ static void wt_status_print_other(struct wt_status *s,
 	print_columns(&output, s->colopts, &copts);
 	string_list_clear(&output, 0);
 	strbuf_release(&buf);
+conclude:
+	status_printf_ln(s, GIT_COLOR_NORMAL, "");
 }
 
 static void wt_status_print_verbose(struct wt_status *s)
-- 
1.8.4.5.g8688bea

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v5 6/6] status: add missing blank line after list of "other" files
  2013-09-06 17:43   ` [PATCH v5 6/6] status: add missing blank line after list of "other" files Matthieu Moy
@ 2013-09-06 18:22     ` Junio C Hamano
  2013-09-06 18:42       ` Junio C Hamano
  2013-09-06 18:45       ` Matthieu Moy
  0 siblings, 2 replies; 12+ messages in thread
From: Junio C Hamano @ 2013-09-06 18:22 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

Matthieu Moy <Matthieu.Moy@imag.fr> writes:

> List of files in other sections ("Changes to be committed", ...) end with
> a blank line.

It is not like we want to add a blank line at the end of each
element; it is rather that we want to have a blank line between each
element, so that they can have a bit of breathing room between them.

The output looks especially bad when there is nothing after the
'untracked' list.


> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
> ---
>  t/t7508-status.sh | 21 +++++++++++++++++++++
>  wt-status.c       |  4 +++-
>  2 files changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/t/t7508-status.sh b/t/t7508-status.sh
> index d0444d3..9bf9701 100755
> --- a/t/t7508-status.sh
> +++ b/t/t7508-status.sh
> @@ -84,6 +84,7 @@ test_expect_success 'status --column' '
>  #
>  #	dir1/untracked dir2/untracked output
>  #	dir2/modified  expect         untracked
> +#
>  EOF
>  	COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
>  	test_i18ncmp expect output
> @@ -117,6 +118,7 @@ cat >expect <<\EOF
>  #	expect
>  #	output
>  #	untracked
> +#
>  EOF
>  
>  test_expect_success 'status with status.displayCommentPrefix=true' '
> @@ -167,6 +169,7 @@ Untracked files:
>  	expect
>  	output
>  	untracked
> +
>  EOF
>  
>  test_expect_success 'status (advice.statusHints false)' '
> @@ -241,6 +244,7 @@ Untracked files:
>    (use "git add <file>..." to include in what will be committed)
>  
>  	dir2/modified
> +
>  Ignored files:
>    (use "git add -f <file>..." to include in what will be committed)
>  
> @@ -250,6 +254,7 @@ Ignored files:
>  	expect
>  	output
>  	untracked
> +
>  EOF
>  	git status --ignored >output &&
>  	test_i18ncmp expect output
> @@ -308,6 +313,7 @@ Ignored files:
>  	expect
>  	output
>  	untracked
> +
>  EOF
>  	git status --ignored >output &&
>  	test_i18ncmp expect output
> @@ -430,6 +436,7 @@ Untracked files:
>  	expect
>  	output
>  	untracked
> +
>  EOF
>  	git status -unormal >output &&
>  	test_i18ncmp expect output
> @@ -488,6 +495,7 @@ Untracked files:
>  	expect
>  	output
>  	untracked
> +
>  EOF
>  	git status -uall >output &&
>  	test_i18ncmp expect output
> @@ -548,6 +556,7 @@ Untracked files:
>  	../expect
>  	../output
>  	../untracked
> +
>  EOF
>  	(cd dir1 && git status) >output &&
>  	test_i18ncmp expect output
> @@ -618,6 +627,7 @@ Untracked files:
>  	<BLUE>expect<RESET>
>  	<BLUE>output<RESET>
>  	<BLUE>untracked<RESET>
> +
>  EOF
>  	test_config color.ui always &&
>  	git status | test_decode_color >output &&
> @@ -747,6 +757,7 @@ Untracked files:
>  	expect
>  	output
>  	untracked
> +
>  EOF
>  	test_config status.relativePaths false &&
>  	(cd dir1 && git status) >output &&
> @@ -789,6 +800,7 @@ Untracked files:
>  	expect
>  	output
>  	untracked
> +
>  EOF
>  	git commit --dry-run dir1/modified >output &&
>  	test_i18ncmp expect output
> @@ -838,6 +850,7 @@ Untracked files:
>  	expect
>  	output
>  	untracked
> +
>  EOF
>  	git status >output &&
>  	test_i18ncmp expect output
> @@ -902,6 +915,7 @@ Untracked files:
>  	expect
>  	output
>  	untracked
> +
>  EOF
>  	git config status.submodulesummary 10 &&
>  	git status >output &&
> @@ -952,6 +966,7 @@ Untracked files:
>  	expect
>  	output
>  	untracked
> +
>  no changes added to commit (use "git add" and/or "git commit -a")
>  EOF
>  	git commit -m "commit submodule" &&
> @@ -1012,6 +1027,7 @@ Untracked files:
>  	expect
>  	output
>  	untracked
> +
>  EOF
>  	git config status.submodulesummary 10 &&
>  	git commit --dry-run --amend >output &&
> @@ -1066,6 +1082,7 @@ Untracked files:
>  	expect
>  	output
>  	untracked
> +
>  EOF
>  	echo modified  sm/untracked &&
>  	git status --ignore-submodules=untracked >output &&
> @@ -1177,6 +1194,7 @@ Untracked files:
>  	expect
>  	output
>  	untracked
> +
>  EOF
>  	git status --ignore-submodules=untracked > output &&
>  	test_i18ncmp expect output
> @@ -1238,6 +1256,7 @@ Untracked files:
>  	expect
>  	output
>  	untracked
> +
>  EOF
>  	git status --ignore-submodules=untracked > output &&
>  	test_i18ncmp expect output
> @@ -1319,6 +1338,7 @@ cat > expect << EOF
>  ;	expect
>  ;	output
>  ;	untracked
> +;
>  EOF
>  
>  test_expect_success "status (core.commentchar with submodule summary)" '
> @@ -1352,6 +1372,7 @@ Untracked files:
>  	expect
>  	output
>  	untracked
> +
>  no changes added to commit (use "git add" and/or "git commit -a")
>  EOF
>  	git status --ignore-submodules=all > output &&
> diff --git a/wt-status.c b/wt-status.c
> index 3c795da..2a9ca0f 100644
> --- a/wt-status.c
> +++ b/wt-status.c
> @@ -751,7 +751,7 @@ static void wt_status_print_other(struct wt_status *s,
>  
>  	strbuf_release(&buf);
>  	if (!column_active(s->colopts))
> -		return;
> +		goto conclude;
>  
>  	strbuf_addf(&buf, "%s%s\t%s",
>  		    color(WT_STATUS_HEADER, s),
> @@ -765,6 +765,8 @@ static void wt_status_print_other(struct wt_status *s,
>  	print_columns(&output, s->colopts, &copts);
>  	string_list_clear(&output, 0);
>  	strbuf_release(&buf);
> +conclude:
> +	status_printf_ln(s, GIT_COLOR_NORMAL, "");
>  }
>  
>  static void wt_status_print_verbose(struct wt_status *s)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v5 6/6] status: add missing blank line after list of "other" files
  2013-09-06 18:22     ` Junio C Hamano
@ 2013-09-06 18:42       ` Junio C Hamano
  2013-09-06 22:09         ` Jeff King
  2013-09-06 18:45       ` Matthieu Moy
  1 sibling, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2013-09-06 18:42 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

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

> Matthieu Moy <Matthieu.Moy@imag.fr> writes:
>
>> List of files in other sections ("Changes to be committed", ...) end with
>> a blank line.
>
> It is not like we want to add a blank line at the end of each
> element; it is rather that we want to have a blank line between each
> element, so that they can have a bit of breathing room between them.
>
> The output looks especially bad when there is nothing after the
> 'untracked' list.

We might want to revisit this later, but I take the above back at
least for now.

If we have absolutely nothing, we get this:

	$ git status
	On branch master
        nothing to commit
	$

And if we have something, we get this:

	$ git status
	On branch master
	Changes to be committed:
	  (use "git reset HEAD <file>..." to unstage)

	        new file:   foo

	$ git status
	On branch master
	Untracked files:
	  (use "git add <file>..." to include in what will be committed)

		bar
	nothing added to commit
	$ git status
	On branch master
	Changes to be committed:
	  (use "git reset HEAD <file>..." to unstage)

	        new file:   foo

	Untracked files:
	  (use "git add <file>..." to include in what will be committed)

		bar
	$

Given that we are already giving an unnecessary trailing blank line
in the "fully added without no untracked" case, it is not too bad to
add the same after the list of untracked files.

To properly "fix" this, we would need to refactor wt_status_print_*
which will get rid of wt_status_print_trailer(), so that routines
that produce each section is told if there is a previous output and
adds a separating line _before_ it emits anything on its own
(i.e. we switch from the "after we spit our stuff out, we leave a
blank line" mental model to "we are going to spit our stuff out but
we need a blank before it to separate our stuff from the previous
output"), and returns if the output now has something to the caller
so that the caller can pass that information to the function that
outputs the next section.

But until that happens, adding a trailing blank line unconditionally
is an OK thing to do, I think.

>> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
>> ---
>>  t/t7508-status.sh | 21 +++++++++++++++++++++
>>  wt-status.c       |  4 +++-
>>  2 files changed, 24 insertions(+), 1 deletion(-)
>>
>> diff --git a/t/t7508-status.sh b/t/t7508-status.sh
>> index d0444d3..9bf9701 100755
>> --- a/t/t7508-status.sh
>> +++ b/t/t7508-status.sh
>> @@ -84,6 +84,7 @@ test_expect_success 'status --column' '
>>  #
>>  #	dir1/untracked dir2/untracked output
>>  #	dir2/modified  expect         untracked
>> +#
>>  EOF
>>  	COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
>>  	test_i18ncmp expect output
>> @@ -117,6 +118,7 @@ cat >expect <<\EOF
>>  #	expect
>>  #	output
>>  #	untracked
>> +#
>>  EOF
>>  
>>  test_expect_success 'status with status.displayCommentPrefix=true' '
>> @@ -167,6 +169,7 @@ Untracked files:
>>  	expect
>>  	output
>>  	untracked
>> +
>>  EOF
>>  
>>  test_expect_success 'status (advice.statusHints false)' '
>> @@ -241,6 +244,7 @@ Untracked files:
>>    (use "git add <file>..." to include in what will be committed)
>>  
>>  	dir2/modified
>> +
>>  Ignored files:
>>    (use "git add -f <file>..." to include in what will be committed)
>>  
>> @@ -250,6 +254,7 @@ Ignored files:
>>  	expect
>>  	output
>>  	untracked
>> +
>>  EOF
>>  	git status --ignored >output &&
>>  	test_i18ncmp expect output
>> @@ -308,6 +313,7 @@ Ignored files:
>>  	expect
>>  	output
>>  	untracked
>> +
>>  EOF
>>  	git status --ignored >output &&
>>  	test_i18ncmp expect output
>> @@ -430,6 +436,7 @@ Untracked files:
>>  	expect
>>  	output
>>  	untracked
>> +
>>  EOF
>>  	git status -unormal >output &&
>>  	test_i18ncmp expect output
>> @@ -488,6 +495,7 @@ Untracked files:
>>  	expect
>>  	output
>>  	untracked
>> +
>>  EOF
>>  	git status -uall >output &&
>>  	test_i18ncmp expect output
>> @@ -548,6 +556,7 @@ Untracked files:
>>  	../expect
>>  	../output
>>  	../untracked
>> +
>>  EOF
>>  	(cd dir1 && git status) >output &&
>>  	test_i18ncmp expect output
>> @@ -618,6 +627,7 @@ Untracked files:
>>  	<BLUE>expect<RESET>
>>  	<BLUE>output<RESET>
>>  	<BLUE>untracked<RESET>
>> +
>>  EOF
>>  	test_config color.ui always &&
>>  	git status | test_decode_color >output &&
>> @@ -747,6 +757,7 @@ Untracked files:
>>  	expect
>>  	output
>>  	untracked
>> +
>>  EOF
>>  	test_config status.relativePaths false &&
>>  	(cd dir1 && git status) >output &&
>> @@ -789,6 +800,7 @@ Untracked files:
>>  	expect
>>  	output
>>  	untracked
>> +
>>  EOF
>>  	git commit --dry-run dir1/modified >output &&
>>  	test_i18ncmp expect output
>> @@ -838,6 +850,7 @@ Untracked files:
>>  	expect
>>  	output
>>  	untracked
>> +
>>  EOF
>>  	git status >output &&
>>  	test_i18ncmp expect output
>> @@ -902,6 +915,7 @@ Untracked files:
>>  	expect
>>  	output
>>  	untracked
>> +
>>  EOF
>>  	git config status.submodulesummary 10 &&
>>  	git status >output &&
>> @@ -952,6 +966,7 @@ Untracked files:
>>  	expect
>>  	output
>>  	untracked
>> +
>>  no changes added to commit (use "git add" and/or "git commit -a")
>>  EOF
>>  	git commit -m "commit submodule" &&
>> @@ -1012,6 +1027,7 @@ Untracked files:
>>  	expect
>>  	output
>>  	untracked
>> +
>>  EOF
>>  	git config status.submodulesummary 10 &&
>>  	git commit --dry-run --amend >output &&
>> @@ -1066,6 +1082,7 @@ Untracked files:
>>  	expect
>>  	output
>>  	untracked
>> +
>>  EOF
>>  	echo modified  sm/untracked &&
>>  	git status --ignore-submodules=untracked >output &&
>> @@ -1177,6 +1194,7 @@ Untracked files:
>>  	expect
>>  	output
>>  	untracked
>> +
>>  EOF
>>  	git status --ignore-submodules=untracked > output &&
>>  	test_i18ncmp expect output
>> @@ -1238,6 +1256,7 @@ Untracked files:
>>  	expect
>>  	output
>>  	untracked
>> +
>>  EOF
>>  	git status --ignore-submodules=untracked > output &&
>>  	test_i18ncmp expect output
>> @@ -1319,6 +1338,7 @@ cat > expect << EOF
>>  ;	expect
>>  ;	output
>>  ;	untracked
>> +;
>>  EOF
>>  
>>  test_expect_success "status (core.commentchar with submodule summary)" '
>> @@ -1352,6 +1372,7 @@ Untracked files:
>>  	expect
>>  	output
>>  	untracked
>> +
>>  no changes added to commit (use "git add" and/or "git commit -a")
>>  EOF
>>  	git status --ignore-submodules=all > output &&
>> diff --git a/wt-status.c b/wt-status.c
>> index 3c795da..2a9ca0f 100644
>> --- a/wt-status.c
>> +++ b/wt-status.c
>> @@ -751,7 +751,7 @@ static void wt_status_print_other(struct wt_status *s,
>>  
>>  	strbuf_release(&buf);
>>  	if (!column_active(s->colopts))
>> -		return;
>> +		goto conclude;
>>  
>>  	strbuf_addf(&buf, "%s%s\t%s",
>>  		    color(WT_STATUS_HEADER, s),
>> @@ -765,6 +765,8 @@ static void wt_status_print_other(struct wt_status *s,
>>  	print_columns(&output, s->colopts, &copts);
>>  	string_list_clear(&output, 0);
>>  	strbuf_release(&buf);
>> +conclude:
>> +	status_printf_ln(s, GIT_COLOR_NORMAL, "");
>>  }
>>  
>>  static void wt_status_print_verbose(struct wt_status *s)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v5 6/6] status: add missing blank line after list of "other" files
  2013-09-06 18:22     ` Junio C Hamano
  2013-09-06 18:42       ` Junio C Hamano
@ 2013-09-06 18:45       ` Matthieu Moy
  2013-09-06 18:56         ` Junio C Hamano
  1 sibling, 1 reply; 12+ messages in thread
From: Matthieu Moy @ 2013-09-06 18:45 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

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

> Matthieu Moy <Matthieu.Moy@imag.fr> writes:
>
>> List of files in other sections ("Changes to be committed", ...) end with
>> a blank line.
>
> It is not like we want to add a blank line at the end of each
> element; it is rather that we want to have a blank line between each
> element, so that they can have a bit of breathing room between them.

Well, "between each element, and at the end of the output" sounds a lot
like "after each element" ;-).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v5 6/6] status: add missing blank line after list of "other" files
  2013-09-06 18:45       ` Matthieu Moy
@ 2013-09-06 18:56         ` Junio C Hamano
  0 siblings, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2013-09-06 18:56 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>> Matthieu Moy <Matthieu.Moy@imag.fr> writes:
>>
>>> List of files in other sections ("Changes to be committed", ...) end with
>>> a blank line.
>>
>> It is not like we want to add a blank line at the end of each
>> element; it is rather that we want to have a blank line between each
>> element, so that they can have a bit of breathing room between them.
>
> Well, "between each element, and at the end of the output" sounds a lot
> like "after each element" ;-).

There is a difference between terminator and separator semantics.

LF is a line terminator; it is attached to the end of each line, it
does not come between each pair of adjacent lines. Hence a text file
ends with a LF.

A blank line that separates each C function in our sources is a
separator.  That is why a patch that does

	@@ -99,3 +99,8 @@ int false(void)
	 {
	 	return 0;
	 }
	+
	+int true(void)
        +{
        +	return 1;
	+}

does not add a trailing blank line at the end.

And I am saying that the blank lines in "status" output should be
separators, not terminators of sections.

But see the other message.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v5 6/6] status: add missing blank line after list of "other" files
  2013-09-06 18:42       ` Junio C Hamano
@ 2013-09-06 22:09         ` Jeff King
  0 siblings, 0 replies; 12+ messages in thread
From: Jeff King @ 2013-09-06 22:09 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Matthieu Moy, git

On Fri, Sep 06, 2013 at 11:42:02AM -0700, Junio C Hamano wrote:

> > It is not like we want to add a blank line at the end of each
> > element; it is rather that we want to have a blank line between each
> > element, so that they can have a bit of breathing room between them.
> >
> > The output looks especially bad when there is nothing after the
> > 'untracked' list.
> 
> We might want to revisit this later, but I take the above back at
> least for now.

I agree with most of what you say here, and I started to look at a
simple patch to give separator semantics. But there's an interesting
case.

Given this:

> If we have absolutely nothing, we get this:
> 
> 	$ git status
> 	On branch master
>         nothing to commit
> 	$

I think the lack of extra line delimiter looks fine.

But here:

> And if we have something, we get this:
> 
> 	$ git status
> 	On branch master
> 	Changes to be committed:
> 	  (use "git reset HEAD <file>..." to unstage)
> 
> 	        new file:   foo

I think it looks kind of bad, because the branch specifier is is
smooshed into the "to be committed" header.

So the logic is not just "separate with a newline". It's more like
"separate big chunks with a newline, but if we only have small chunks,
it's OK to stick them together".

-Peff

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-09-06 22:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <vpq38phsvuc.fsf@anie.imag.frvpq38phsvuc.fsf@anie.imag.fr>
2013-09-06 17:43 ` [PATCH v5 0/6] Disable "git status" comment prefix Matthieu Moy
2013-09-06 17:43   ` [PATCH v5 1/6] builtin/stripspace.c: fix broken indentation Matthieu Moy
2013-09-06 17:43   ` [PATCH v5 2/6] wt-status: use argv_array API Matthieu Moy
2013-09-06 17:43   ` [PATCH v5 3/6] submodule summary: ignore --for-status option Matthieu Moy
2013-09-06 17:43   ` [PATCH v5 4/6] status: disable display of '#' comment prefix by default Matthieu Moy
2013-09-06 17:43   ` [PATCH v5 5/6] tests: don't set status.displayCommentPrefix file-wide Matthieu Moy
2013-09-06 17:43   ` [PATCH v5 6/6] status: add missing blank line after list of "other" files Matthieu Moy
2013-09-06 18:22     ` Junio C Hamano
2013-09-06 18:42       ` Junio C Hamano
2013-09-06 22:09         ` Jeff King
2013-09-06 18:45       ` Matthieu Moy
2013-09-06 18:56         ` Junio C Hamano

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 NNTP newsgroup(s).