Merge branch 'ks/status-initial-commit'
authorJunio C Hamano <gitster@pobox.com>
Fri, 30 Jun 2017 20:45:22 +0000 (13:45 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 30 Jun 2017 20:45:22 +0000 (13:45 -0700)
"git status" has long shown essentially the same message as "git
commit"; the message it gives while preparing for the root commit,
i.e. "Initial commit", was hard to understand for some new users.
Now it says "No commits yet" to stress more on the current status
(rather than the commit the user is preparing for, which is more in
line with the focus of "git commit").

* ks/status-initial-commit:
status: contextually notify user about an initial commit

builtin/commit.c
t/t7501-commit.sh
t/t7508-status.sh
wt-status.c
wt-status.h
index 00a01f07c3e56f96230bf5e382f2ad3cb976bb96..03b97c644992b22748ef5ac4de45d4ebcbaeb9c8 100644 (file)
@@ -1660,6 +1660,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;
 
index 0b6da7ae1fd3d15f0d47783d3af50cb17d2c66df..fa61b1a4ee4a1d5ba457cb30e5cc045f724ed503 100755 (executable)
@@ -18,7 +18,7 @@ test_expect_success 'initial status' '
        echo bongo bongo >file &&
        git add file &&
        git status >actual &&
-       test_i18ngrep "Initial commit" actual
+       test_i18ngrep "No commits yet" actual
 '
 
 test_expect_success 'fail initial amend' '
index f7fe22a195e437d5a2aa9c28ea5991b53ae2c7e7..43d19a9b2292033fd0297afb7df162efa2eb5621 100755 (executable)
@@ -1640,4 +1640,34 @@ test_expect_success 'no additionnal info if no stash entries' '
        test_cmp expected_without_stash actual
 '
 
+test_expect_success '"No commits yet" should be noted in status output' '
+       git checkout --orphan empty-branch-1 &&
+       git status >output &&
+       test_i18ngrep "No commits yet" output
+'
+
+test_expect_success '"No commits yet" should not be noted in status output' '
+       git checkout --orphan empty-branch-2 &&
+       test_commit test-commit-1 &&
+       git status >output &&
+       test_i18ngrep ! "No commits yet" output
+'
+
+test_expect_success '"Initial commit" should be noted in commit template' '
+       git checkout --orphan empty-branch-3 &&
+       touch to_be_committed_1 &&
+       git add to_be_committed_1 &&
+       git commit --dry-run >output &&
+       test_i18ngrep "Initial commit" output
+'
+
+test_expect_success '"Initial commit" should not be noted in commit template' '
+       git checkout --orphan empty-branch-4 &&
+       test_commit test-commit-2 &&
+       touch to_be_committed_2 &&
+       git add to_be_committed_2 &&
+       git commit --dry-run >output &&
+       test_i18ngrep ! "Initial commit" output
+'
+
 test_done
index 7992a73902ae5c3fa70d8937faec4ce1e0a4f78b..8d2fb35b08037a0e435573066d6e3f28e7529db4 100644 (file)
@@ -1601,7 +1601,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"));
                status_printf_ln(s, color(WT_STATUS_HEADER, s), "%s", "");
        }
 
@@ -1773,7 +1776,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
 #define LABEL(string) (s->no_gettext ? (string) : _(string))
 
        if (s->is_initial)
-               color_fprintf(s->fp, header_color, LABEL(N_("Initial commit on ")));
+               color_fprintf(s->fp, header_color, LABEL(N_("No commits yet on ")));
 
        if (!strcmp(s->branch, "HEAD")) {
                color_fprintf(s->fp, color(WT_STATUS_NOBRANCH, s), "%s",
index d8ae2e590dafb87b92f5e3a4b183f0ccdeb4c359..64f4d33ea183c1a6e700f1f6667b83f0e904773e 100644 (file)
@@ -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 show_stash;
        int hints;