git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] status: add an empty line when there is no hint

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Apr 30, 2019, 11:15 UTC
Message-ID
<ae1332b8-a227-e83a-8862-8811b6a81251@gmail.com>
In-Reply-To
<20190430060210.79610-1-johnlinp@gmail.com>
Hi John
On 30/04/2019 07:02, John Lin wrote:
> When typing "git status", there is an empty line between
> the "Changes not staged for commit:" block and the list
> of changed files.

I'm a bit confused by this as you change a status test below by inserting these blank lines into the expected output, implying they are not there now. I think maybe the blank line is only shown when status prints advice.

> However, when typing "git commit" with
> no files added, there are no empty lines between them.

I have to say looking at the changes to the output I prefer the original, the lists are nicely indented so there is no need for a blank line to separate the header from the list and having the header immediately before the list means the blank line at the end of the block makes the extent of the block clear. It also saves screen space which is useful for small laptop screens. I can see why one might want a blank line to separate the advice and list of changes (though even there the indention of the list and advice is different) but for a one line header I think it is better to start the list on the next line.

Best Wishes
Phillip
Show 133 quoted lines
> 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", "");
>   }
>   
> 
Previous: John LinNext: 林自均
Message 2 of 16 in “status: add an empty line when there is no hint”
  1. status: add an empty line when there is no hintJohn Lin, Apr 30, 2019
  2. Phillip WoodApr 30, 2019
  3. 林自均Apr 30, 2019
  4. brian m. carlsonMay 1, 2019
  5. 林自均May 2, 2019
  6. brian m. carlsonMay 2, 2019
  7. 林自均May 3, 2019
  8. 林自均May 10, 2019
  9. Junio C HamanoMay 13, 2019
  10. 林自均May 14, 2019
  11. brian m. carlsonMay 14, 2019
  12. Junio C HamanoMay 14, 2019
  13. 林自均May 14, 2019
  14. Junio C HamanoMay 15, 2019
  15. 林自均May 15, 2019
  16. 林自均May 22, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.