From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Cc: gitster@pobox.com, peff@peff.net, git@vger.kernel.org,
sandals@crustytoothpaste.net
Subject: Re: [PATCH/ALMOST FINAL] Contextually notify user about an initial commit
Date: Sun, 18 Jun 2017 10:34:59 +0200 [thread overview]
Message-ID: <87shix8zik.fsf@gmail.com> (raw)
In-Reply-To: <20170618075301.6431-1-kaarticsivaraam91196@gmail.com>
On Sun, Jun 18 2017, Kaartic Sivaraam jotted:
> "git status" indicated "Initial commit" when HEAD points at
> an unborn branch. This message is shared with the commit
> log template "git commit" prepares for the user when
> creating a commit (i.e. "You are about to create the initial
> commit"), and is OK as long as the reader is aware of the
> nature of the message (i.e. it guides the user working
> toward the next commit), but was confusing to new users,
> especially the ones who do "git commit -m message" without
> having a chance to pay attention to the commit log template.
>
> The "Initial commit" indication wasn't an issue in the commit
> template. Taking that into consideration, a good solution would
> be to contextually use different messages to indicate the user
> that there were no commits in this branch.
>
> A few alternatives considered were,
>
> * Waiting for initial commit
> * Your current branch does not have any commits
> * Current branch waiting for initial commit
>
> Patch-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
> ---
> builtin/commit.c | 1 +
> wt-status.c | 5 ++++-
> wt-status.h | 1 +
> 3 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/builtin/commit.c b/builtin/commit.c
> index 1d805f5da..0f36d2ac3 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -1648,6 +1648,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
> usage_with_options(builtin_commit_usage, builtin_commit_options);
>
> status_init_config(&s, git_commit_config);
> + s.commit_template = 1;
> status_format = STATUS_FORMAT_NONE; /* Ignore status.short */
> s.colopts = 0;
>
> diff --git a/wt-status.c b/wt-status.c
> index 037548496..34aa1af66 100644
> --- a/wt-status.c
> +++ b/wt-status.c
> @@ -1576,7 +1576,10 @@ static void wt_longstatus_print(struct wt_status *s)
>
> if (s->is_initial) {
> status_printf_ln(s, color(WT_STATUS_HEADER, s), "%s", "");
> - status_printf_ln(s, color(WT_STATUS_HEADER, s), _("Initial commit"));
> + status_printf_ln(s, color(WT_STATUS_HEADER, s),
> + s->commit_template
> + ? _("Initial commit")
> + : _("No commits yet on the branch"));
Why not simply "No commits yet", saying "on the branch" is needlessy
duplicating information in the context of the status output in which
this is printed, i.e. now you have:
$ ~/g/git/git-status
On branch master
No commits yet on the branch
nothing to commit (create/copy files and use "git add" to track)
But we can just more succinctly say:
$ ~/g/git/git-status
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)
Since we've already pointed out that the user is on a branch.
Also, if something is worth fixing it's worth testing for, so you can
fix this test into the patch:
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index 79427840a4..b9532d201d 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -1608,4 +1608,15 @@ test_expect_success 'git commit -m will commit a staged but ignored submodule' '
git config -f .gitmodules --remove-section submodule.subname
'
+test_expect_success 'No commits yet should be noted in status output' '
+ git init initial &&
+ cd initial &&
+ git status >output &&
+ test_i18ngrep "No commits yet" output &&
+ test_commit initial &&
+ git status >output &&
+ test_i18ngrep ! "No commits yet" output &&
+ test_i18ngrep "nothing.*to commit" output
+'
+
test_done
diff --git a/wt-status.c b/wt-status.c
index 7991fd1098..f324ea20a6 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1582,7 +1582,7 @@ static void wt_longstatus_print(struct wt_status *s)
status_printf_ln(s, color(WT_STATUS_HEADER, s),
s->commit_template
? _("Initial commit")
- : _("No commits yet on the branch"));
+ : _("No commits yet"));
status_printf_ln(s, color(WT_STATUS_HEADER, s), "%s", "");
}
> status_printf_ln(s, color(WT_STATUS_HEADER, s), "%s", "");
> }
>
> diff --git a/wt-status.h b/wt-status.h
> index 6018c627b..782b2997f 100644
> --- a/wt-status.h
> +++ b/wt-status.h
> @@ -76,6 +76,7 @@ struct wt_status {
> char color_palette[WT_STATUS_MAXSLOT][COLOR_MAXLEN];
> unsigned colopts;
> int null_termination;
> + int commit_template;
> int show_branch;
> int hints;
next prev parent reply other threads:[~2017-06-18 8:35 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-10 1:52 [PATCH] wt-status.c: Modified status message shown for a parent-less branch Kaartic Sivaraam
2017-06-10 2:10 ` Kaartic Sivaraam
2017-06-10 2:23 ` Junio C Hamano
2017-06-10 8:44 ` Kaartic Sivaraam
2017-06-10 9:36 ` Kaartic Sivaraam
2017-06-10 10:21 ` Jeff King
2017-06-10 11:02 ` Junio C Hamano
2017-06-12 8:10 ` Kaartic Sivaraam
2017-06-12 18:28 ` Junio C Hamano
2017-06-12 21:20 ` Jeff King
2017-06-12 21:31 ` Junio C Hamano
2017-06-12 21:37 ` Jeff King
2017-06-15 8:19 ` Kaartic Sivaraam
2017-06-15 8:42 ` Jeff King
2017-06-15 11:43 ` Samuel Lijin
2017-06-15 13:12 ` Jeff King
2017-06-16 10:36 ` Kaartic Sivaraam
2017-06-16 10:50 ` Jeff King
2017-06-18 7:35 ` [PATCH/Almost final] " Kaartic Sivaraam
2017-06-18 7:53 ` [PATCH/ALMOST FINAL] Contextually notify user about an initial commit Kaartic Sivaraam
2017-06-18 8:34 ` Ævar Arnfjörð Bjarmason [this message]
2017-06-19 2:41 ` [PATCH 1/2] " Kaartic Sivaraam
2017-06-19 2:44 ` [PATCH 2/2] Add test for the new status message Kaartic Sivaraam
2017-06-19 4:32 ` Junio C Hamano
2017-06-19 17:59 ` Kaartic Sivaraam
2017-06-19 18:04 ` Jeff King
2017-06-19 18:33 ` Kaartic Sivaraam
2017-06-19 4:29 ` [PATCH 1/2] Contextually notify user about an initial commit Junio C Hamano
2017-06-19 2:41 ` [PATCH 2/2] Add test for the new status message Kaartic Sivaraam
2017-06-19 9:10 ` [PATCH/ALMOST FINAL] Contextually notify user about an initial commit Jeff King
2017-06-19 13:24 ` Kaartic Sivaraam
2017-06-19 15:47 ` Junio C Hamano
2017-06-20 3:02 ` [PATCH 1/3] " Kaartic Sivaraam
2017-06-20 3:02 ` [PATCH 2/3] Update test(s) that used old status message Kaartic Sivaraam
2017-06-20 3:02 ` [PATCH 3/3] Add tests for the contextual initial " Kaartic Sivaraam
2017-06-20 7:26 ` [PATCH 1/3] Contextually notify user about an initial commit Ævar Arnfjörð Bjarmason
2017-06-20 13:37 ` Kaartic Sivaraam
2017-06-20 14:41 ` Ævar Arnfjörð Bjarmason
2017-06-21 2:34 ` Kaartic Sivaraam
2017-06-21 2:37 ` [PATCH/FINAL] status: contextually " Kaartic Sivaraam
2017-06-21 14:35 ` Kaartic Sivaraam
2017-06-21 14:52 ` Ævar Arnfjörð Bjarmason
2017-06-21 17:45 ` Kaartic Sivaraam
2017-06-21 18:45 ` Junio C Hamano
2017-06-21 18:16 ` Kaartic Sivaraam
2017-06-22 2:10 ` Junio C Hamano
2017-06-22 3:01 ` Kaartic Sivaraam
2017-06-10 14:44 ` [PATCH] wt-status.c: Modified status message shown for a parent-less branch Philip Oakley
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=87shix8zik.fsf@gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=kaarticsivaraam91196@gmail.com \
--cc=peff@peff.net \
--cc=sandals@crustytoothpaste.net \
/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).