summaryrefslogtreecommitdiff
path: root/t/t7508-status.sh
diff options
context:
space:
mode:
authorKaartic Sivaraam <kaarticsivaraam91196@gmail.com>2017-06-21 18:16:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-22 02:10:27 (GMT)
commit4ddb1354e8d5daf5671d3d451a67d2d1e82d9b49 (patch)
treeeb1bde38d4ccabc7267c26ee737def7520b5b632 /t/t7508-status.sh
parentfd99e2bda0ca6a361ef03c04d6d7fdc7a9c40b78 (diff)
downloadgit-4ddb1354e8d5daf5671d3d451a67d2d1e82d9b49.zip
git-4ddb1354e8d5daf5671d3d451a67d2d1e82d9b49.tar.gz
git-4ddb1354e8d5daf5671d3d451a67d2d1e82d9b49.tar.bz2
status: contextually notify user about an initial commit
The existing message, "Initial commit", makes sense for the commit template notifying users that it's their initial commit, but is confusing when merely checking the status of a fresh repository (or orphan branch) without having any commits yet. Change the output of "status" to say "No commits yet" when "git status" is run on a fresh repo (or orphan branch), while retaining the current "Initial commit" message displayed in the template that's displayed in the editor when the initial commit is being authored. Correspondingly change the output of "short status" to "No commits yet on " when "git status -sb" is run on a fresh repo (or orphan branch). A few alternatives considered were, * Waiting for initial commit * Your current branch does not have any commits * Current branch waiting for initial commit The most succint one among the alternatives was chosen. [with help on tests from Ævar] Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7508-status.sh')
-rwxr-xr-xt/t7508-status.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index 5edcc6e..db70904 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -1499,4 +1499,34 @@ 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 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