Skip to content

Commit 2b7d947

Browse files
committed
Merge branch 'mg/advice-statushints' into maint
* mg/advice-statushints: wt-status: take advice.statusHints seriously t7508: test advice.statusHints
2 parents e1c07fa + 980bde3 commit 2b7d947

2 files changed

Lines changed: 60 additions & 6 deletions

File tree

t/t7508-status.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,34 @@ test_expect_success 'status (2)' '
6868
6969
'
7070

71+
cat >expect <<\EOF
72+
# On branch master
73+
# Changes to be committed:
74+
# new file: dir2/added
75+
#
76+
# Changed but not updated:
77+
# modified: dir1/modified
78+
#
79+
# Untracked files:
80+
# dir1/untracked
81+
# dir2/modified
82+
# dir2/untracked
83+
# expect
84+
# output
85+
# untracked
86+
EOF
87+
88+
git config advice.statusHints false
89+
90+
test_expect_success 'status (advice.statusHints false)' '
91+
92+
git status >output &&
93+
test_cmp expect output
94+
95+
'
96+
97+
git config --unset advice.statusHints
98+
7199
cat >expect <<\EOF
72100
M dir1/modified
73101
A dir2/added
@@ -115,6 +143,23 @@ test_expect_success 'status (status.showUntrackedFiles no)' '
115143
test_cmp expect output
116144
'
117145

146+
cat >expect <<EOF
147+
# On branch master
148+
# Changes to be committed:
149+
# new file: dir2/added
150+
#
151+
# Changed but not updated:
152+
# modified: dir1/modified
153+
#
154+
# Untracked files not listed
155+
EOF
156+
git config advice.statusHints false
157+
test_expect_success 'status -uno (advice.statusHints false)' '
158+
git status -uno >output &&
159+
test_cmp expect output
160+
'
161+
git config --unset advice.statusHints
162+
118163
cat >expect << EOF
119164
M dir1/modified
120165
A dir2/added

wt-status.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,9 @@ void wt_status_print(struct wt_status *s)
625625
if (s->show_untracked_files)
626626
wt_status_print_untracked(s);
627627
else if (s->commitable)
628-
fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
628+
fprintf(s->fp, "# Untracked files not listed%s\n",
629+
advice_status_hints
630+
? " (use -u option to show untracked files)" : "");
629631

630632
if (s->verbose)
631633
wt_status_print_verbose(s);
@@ -635,15 +637,22 @@ void wt_status_print(struct wt_status *s)
635637
else if (s->nowarn)
636638
; /* nothing */
637639
else if (s->workdir_dirty)
638-
printf("no changes added to commit (use \"git add\" and/or \"git commit -a\")\n");
640+
printf("no changes added to commit%s\n",
641+
advice_status_hints
642+
? " (use \"git add\" and/or \"git commit -a\")" : "");
639643
else if (s->untracked.nr)
640-
printf("nothing added to commit but untracked files present (use \"git add\" to track)\n");
644+
printf("nothing added to commit but untracked files present%s\n",
645+
advice_status_hints
646+
? " (use \"git add\" to track)" : "");
641647
else if (s->is_initial)
642-
printf("nothing to commit (create/copy files and use \"git add\" to track)\n");
648+
printf("nothing to commit%s\n", advice_status_hints
649+
? " (create/copy files and use \"git add\" to track)" : "");
643650
else if (!s->show_untracked_files)
644-
printf("nothing to commit (use -u to show untracked files)\n");
651+
printf("nothing to commit%s\n", advice_status_hints
652+
? " (use -u to show untracked files)" : "");
645653
else
646-
printf("nothing to commit (working directory clean)\n");
654+
printf("nothing to commit%s\n", advice_status_hints
655+
? " (working directory clean)" : "");
647656
}
648657
}
649658

0 commit comments

Comments
 (0)