git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: John Lin <johnlinp@gmail.com>
To: git@vger.kernel.org
Cc: John Lin <johnlinp@gmail.com>
Subject: [PATCH v2] status: add an empty line when there is no hint
Date: Tue, 30 Apr 2019 14:02:10 +0800	[thread overview]
Message-ID: <20190430060210.79610-1-johnlinp@gmail.com> (raw)

When typing "git status", there is an empty line between
the "Changes not staged for commit:" block and the list
of changed files. However, when typing "git commit" with
no files added, there are no empty lines between them.

This patch adds empty lines in the above case and some
similar cases.

Signed-off-by: John Lin <johnlinp@gmail.com>
---
 t/t7500-commit-template-squash-signoff.sh |  1 +
 t/t7508-status.sh                         |  5 +++++
 t/t7512-status-help.sh                    |  1 +
 wt-status.c                               | 12 ++++++++----
 4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/t/t7500-commit-template-squash-signoff.sh b/t/t7500-commit-template-squash-signoff.sh
index 46a5cd4b73..0423e77d1d 100755
--- a/t/t7500-commit-template-squash-signoff.sh
+++ b/t/t7500-commit-template-squash-signoff.sh
@@ -345,6 +345,7 @@ cat >expected-template <<EOF
 #
 # On branch commit-template-check
 # Changes to be committed:
+#
 #	new file:   commit-template-check
 #
 # Untracked files not listed
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index e1f11293e2..949b1dbcc4 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -204,12 +204,15 @@ Your branch and 'upstream' have diverged,
 and have 1 and 2 different commits each, respectively.
 
 Changes to be committed:
+
 	new file:   dir2/added
 
 Changes not staged for commit:
+
 	modified:   dir1/modified
 
 Untracked files:
+
 	dir1/untracked
 	dir2/modified
 	dir2/untracked
@@ -449,9 +452,11 @@ Your branch and '\''upstream'\'' have diverged,
 and have 1 and 2 different commits each, respectively.
 
 Changes to be committed:
+
 	new file:   dir2/added
 
 Changes not staged for commit:
+
 	modified:   dir1/modified
 
 Untracked files not listed
diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index 458608cc1e..0a29fa66a2 100755
--- a/t/t7512-status-help.sh
+++ b/t/t7512-status-help.sh
@@ -714,6 +714,7 @@ 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
diff --git a/wt-status.c b/wt-status.c
index 445a36204a..0766e3ee12 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -175,7 +175,7 @@ static void wt_longstatus_print_unmerged_header(struct wt_status *s)
 	}
 
 	if (!s->hints)
-		return;
+		goto conclude;
 	if (s->whence != FROM_COMMIT)
 		;
 	else if (!s->is_initial)
@@ -193,6 +193,7 @@ static void wt_longstatus_print_unmerged_header(struct wt_status *s)
 	} else {
 		status_printf_ln(s, c, _("  (use \"git add/rm <file>...\" as appropriate to mark resolution)"));
 	}
+conclude:
 	status_printf_ln(s, c, "%s", "");
 }
 
@@ -202,13 +203,14 @@ static void wt_longstatus_print_cached_header(struct wt_status *s)
 
 	status_printf_ln(s, c, _("Changes to be committed:"));
 	if (!s->hints)
-		return;
+		goto conclude;
 	if (s->whence != FROM_COMMIT)
 		; /* NEEDSWORK: use "git reset --unresolve"??? */
 	else if (!s->is_initial)
 		status_printf_ln(s, c, _("  (use \"git reset %s <file>...\" to unstage)"), s->reference);
 	else
 		status_printf_ln(s, c, _("  (use \"git rm --cached <file>...\" to unstage)"));
+conclude:
 	status_printf_ln(s, c, "%s", "");
 }
 
@@ -220,7 +222,7 @@ static void wt_longstatus_print_dirty_header(struct wt_status *s,
 
 	status_printf_ln(s, c, _("Changes not staged for commit:"));
 	if (!s->hints)
-		return;
+		goto conclude;
 	if (!has_deleted)
 		status_printf_ln(s, c, _("  (use \"git add <file>...\" to update what will be committed)"));
 	else
@@ -228,6 +230,7 @@ static void wt_longstatus_print_dirty_header(struct wt_status *s,
 	status_printf_ln(s, c, _("  (use \"git checkout -- <file>...\" to discard changes in working directory)"));
 	if (has_dirty_submodules)
 		status_printf_ln(s, c, _("  (commit or discard the untracked or modified content in submodules)"));
+conclude:
 	status_printf_ln(s, c, "%s", "");
 }
 
@@ -238,8 +241,9 @@ static void wt_longstatus_print_other_header(struct wt_status *s,
 	const char *c = color(WT_STATUS_HEADER, s);
 	status_printf_ln(s, c, "%s:", what);
 	if (!s->hints)
-		return;
+		goto conclude;
 	status_printf_ln(s, c, _("  (use \"git %s <file>...\" to include in what will be committed)"), how);
+conclude:
 	status_printf_ln(s, c, "%s", "");
 }
 
-- 
2.21.0


             reply	other threads:[~2019-04-30  6:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-30  6:02 John Lin [this message]
2019-04-30 11:15 ` [PATCH v2] status: add an empty line when there is no hint Phillip Wood
2019-04-30 22:23   ` 林自均
2019-05-01 23:45   ` brian m. carlson
2019-05-02  0:35     ` 林自均
2019-05-02 23:15       ` brian m. carlson
2019-05-03  4:15         ` 林自均
2019-05-10  0:56           ` 林自均
2019-05-13  5:51             ` Junio C Hamano
2019-05-14  0:30               ` 林自均
2019-05-14  2:04               ` brian m. carlson
2019-05-14  7:33                 ` Junio C Hamano
2019-05-14  9:43                   ` 林自均
2019-05-15  0:48                     ` Junio C Hamano
2019-05-15  3:02                       ` 林自均
2019-05-22 23:01                         ` 林自均

Reply instructions:

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

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

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

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

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

  git send-email \
    --in-reply-to=20190430060210.79610-1-johnlinp@gmail.com \
    --to=johnlinp@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

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

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

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

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