Skip to content

Commit 82e7ee7

Browse files
committed
Merge branch 'mg/advice-statushints'
* mg/advice-statushints: wt-status: take advice.statusHints seriously t7508: test advice.statusHints Conflicts: wt-status.c
2 parents b7ef48d + 980bde3 commit 82e7ee7

File tree

2 files changed

+60
-6
lines changed

2 files changed

+60
-6
lines changed

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
@@ -651,7 +651,9 @@ void wt_status_print(struct wt_status *s)
651651
if (s->show_ignored_files)
652652
wt_status_print_other(s, &s->ignored, "Ignored", "add -f");
653653
} else if (s->commitable)
654-
fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
654+
fprintf(s->fp, "# Untracked files not listed%s\n",
655+
advice_status_hints
656+
? " (use -u option to show untracked files)" : "");
655657

656658
if (s->verbose)
657659
wt_status_print_verbose(s);
@@ -661,15 +663,22 @@ void wt_status_print(struct wt_status *s)
661663
else if (s->nowarn)
662664
; /* nothing */
663665
else if (s->workdir_dirty)
664-
printf("no changes added to commit (use \"git add\" and/or \"git commit -a\")\n");
666+
printf("no changes added to commit%s\n",
667+
advice_status_hints
668+
? " (use \"git add\" and/or \"git commit -a\")" : "");
665669
else if (s->untracked.nr)
666-
printf("nothing added to commit but untracked files present (use \"git add\" to track)\n");
670+
printf("nothing added to commit but untracked files present%s\n",
671+
advice_status_hints
672+
? " (use \"git add\" to track)" : "");
667673
else if (s->is_initial)
668-
printf("nothing to commit (create/copy files and use \"git add\" to track)\n");
674+
printf("nothing to commit%s\n", advice_status_hints
675+
? " (create/copy files and use \"git add\" to track)" : "");
669676
else if (!s->show_untracked_files)
670-
printf("nothing to commit (use -u to show untracked files)\n");
677+
printf("nothing to commit%s\n", advice_status_hints
678+
? " (use -u to show untracked files)" : "");
671679
else
672-
printf("nothing to commit (working directory clean)\n");
680+
printf("nothing to commit%s\n", advice_status_hints
681+
? " (working directory clean)" : "");
673682
}
674683
}
675684

0 commit comments

Comments
 (0)