From 18f3b5a9d37de606604f00360df55e5a5fe70739 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Thu, 22 Apr 2010 22:30:19 +0200 Subject: [PATCH 1/2] t7508: test advice.statusHints edf563f (status: make "how to stage" messages optional, 2009-09-09) introduced advice.statusHints without tests. Add a few tests to describe and test the status quo. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/t7508-status.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/t/t7508-status.sh b/t/t7508-status.sh index 556d0faa77..7409a06c0b 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -68,6 +68,34 @@ test_expect_success 'status (2)' ' ' +cat >expect <<\EOF +# On branch master +# Changes to be committed: +# new file: dir2/added +# +# Changed but not updated: +# modified: dir1/modified +# +# Untracked files: +# dir1/untracked +# dir2/modified +# dir2/untracked +# expect +# output +# untracked +EOF + +git config advice.statusHints false + +test_expect_success 'status (advice.statusHints false)' ' + + git status >output && + test_cmp expect output + +' + +git config --unset advice.statusHints + cat >expect <<\EOF M dir1/modified A dir2/added @@ -115,6 +143,23 @@ test_expect_success 'status (status.showUntrackedFiles no)' ' test_cmp expect output ' +cat >expect <output && + test_cmp expect output +' +git config --unset advice.statusHints + cat >expect << EOF M dir1/modified A dir2/added From 980bde389491e65df3a6f26f755064013b65740c Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Thu, 22 Apr 2010 22:30:20 +0200 Subject: [PATCH 2/2] wt-status: take advice.statusHints seriously Currently, status gives a lot of hints even when advice.statusHints is false. Change this so that all hints depend on the config variable. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/t7508-status.sh | 2 +- wt-status.c | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/t/t7508-status.sh b/t/t7508-status.sh index 7409a06c0b..1301ec87e9 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -151,7 +151,7 @@ cat >expect <show_untracked_files) wt_status_print_untracked(s); else if (s->commitable) - fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n"); + fprintf(s->fp, "# Untracked files not listed%s\n", + advice_status_hints + ? " (use -u option to show untracked files)" : ""); if (s->verbose) wt_status_print_verbose(s); @@ -635,15 +637,22 @@ void wt_status_print(struct wt_status *s) else if (s->nowarn) ; /* nothing */ else if (s->workdir_dirty) - printf("no changes added to commit (use \"git add\" and/or \"git commit -a\")\n"); + printf("no changes added to commit%s\n", + advice_status_hints + ? " (use \"git add\" and/or \"git commit -a\")" : ""); else if (s->untracked.nr) - printf("nothing added to commit but untracked files present (use \"git add\" to track)\n"); + printf("nothing added to commit but untracked files present%s\n", + advice_status_hints + ? " (use \"git add\" to track)" : ""); else if (s->is_initial) - printf("nothing to commit (create/copy files and use \"git add\" to track)\n"); + printf("nothing to commit%s\n", advice_status_hints + ? " (create/copy files and use \"git add\" to track)" : ""); else if (!s->show_untracked_files) - printf("nothing to commit (use -u to show untracked files)\n"); + printf("nothing to commit%s\n", advice_status_hints + ? " (use -u to show untracked files)" : ""); else - printf("nothing to commit (working directory clean)\n"); + printf("nothing to commit%s\n", advice_status_hints + ? " (working directory clean)" : ""); } }