Skip to content

Commit 6a964f5

Browse files
moygitster
authored andcommitted
wt-status: turn advice_status_hints into a field of wt_status
No behavior change in this patch, but this makes the display of status hints more flexible as they can be enabled or disabled for individual calls to commit.c:run_status(). Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5c25dfa commit 6a964f5

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

builtin/commit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ static void status_init_config(struct wt_status *s, config_fn_t fn)
169169
gitmodules_config();
170170
git_config(fn, s);
171171
determine_whence(s);
172+
s->hints = advice_status_hints; /* must come after git_config() */
172173
}
173174

174175
static void rollback_index_files(void)

wt-status.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static void wt_status_print_unmerged_header(struct wt_status *s)
160160
}
161161
}
162162

163-
if (!advice_status_hints)
163+
if (!s->hints)
164164
return;
165165
if (s->whence != FROM_COMMIT)
166166
;
@@ -187,7 +187,7 @@ static void wt_status_print_cached_header(struct wt_status *s)
187187
const char *c = color(WT_STATUS_HEADER, s);
188188

189189
status_printf_ln(s, c, _("Changes to be committed:"));
190-
if (!advice_status_hints)
190+
if (!s->hints)
191191
return;
192192
if (s->whence != FROM_COMMIT)
193193
; /* NEEDSWORK: use "git reset --unresolve"??? */
@@ -205,7 +205,7 @@ static void wt_status_print_dirty_header(struct wt_status *s,
205205
const char *c = color(WT_STATUS_HEADER, s);
206206

207207
status_printf_ln(s, c, _("Changes not staged for commit:"));
208-
if (!advice_status_hints)
208+
if (!s->hints)
209209
return;
210210
if (!has_deleted)
211211
status_printf_ln(s, c, _(" (use \"git add <file>...\" to update what will be committed)"));
@@ -223,7 +223,7 @@ static void wt_status_print_other_header(struct wt_status *s,
223223
{
224224
const char *c = color(WT_STATUS_HEADER, s);
225225
status_printf_ln(s, c, "%s:", what);
226-
if (!advice_status_hints)
226+
if (!s->hints)
227227
return;
228228
status_printf_ln(s, c, _(" (use \"git %s <file>...\" to include in what will be committed)"), how);
229229
status_printf_ln(s, c, "");
@@ -801,13 +801,13 @@ static void show_merge_in_progress(struct wt_status *s,
801801
{
802802
if (has_unmerged(s)) {
803803
status_printf_ln(s, color, _("You have unmerged paths."));
804-
if (advice_status_hints)
804+
if (s->hints)
805805
status_printf_ln(s, color,
806806
_(" (fix conflicts and run \"git commit\")"));
807807
} else {
808808
status_printf_ln(s, color,
809809
_("All conflicts fixed but you are still merging."));
810-
if (advice_status_hints)
810+
if (s->hints)
811811
status_printf_ln(s, color,
812812
_(" (use \"git commit\" to conclude merge)"));
813813
}
@@ -823,7 +823,7 @@ static void show_am_in_progress(struct wt_status *s,
823823
if (state->am_empty_patch)
824824
status_printf_ln(s, color,
825825
_("The current patch is empty."));
826-
if (advice_status_hints) {
826+
if (s->hints) {
827827
if (!state->am_empty_patch)
828828
status_printf_ln(s, color,
829829
_(" (fix conflicts and then run \"git am --continue\")"));
@@ -896,7 +896,7 @@ static void show_rebase_in_progress(struct wt_status *s,
896896
else
897897
status_printf_ln(s, color,
898898
_("You are currently rebasing."));
899-
if (advice_status_hints) {
899+
if (s->hints) {
900900
status_printf_ln(s, color,
901901
_(" (fix conflicts and then run \"git rebase --continue\")"));
902902
status_printf_ln(s, color,
@@ -913,7 +913,7 @@ static void show_rebase_in_progress(struct wt_status *s,
913913
else
914914
status_printf_ln(s, color,
915915
_("You are currently rebasing."));
916-
if (advice_status_hints)
916+
if (s->hints)
917917
status_printf_ln(s, color,
918918
_(" (all conflicts fixed: run \"git rebase --continue\")"));
919919
} else if (split_commit_in_progress(s)) {
@@ -925,7 +925,7 @@ static void show_rebase_in_progress(struct wt_status *s,
925925
else
926926
status_printf_ln(s, color,
927927
_("You are currently splitting a commit during a rebase."));
928-
if (advice_status_hints)
928+
if (s->hints)
929929
status_printf_ln(s, color,
930930
_(" (Once your working directory is clean, run \"git rebase --continue\")"));
931931
} else {
@@ -937,7 +937,7 @@ static void show_rebase_in_progress(struct wt_status *s,
937937
else
938938
status_printf_ln(s, color,
939939
_("You are currently editing a commit during a rebase."));
940-
if (advice_status_hints && !s->amend) {
940+
if (s->hints && !s->amend) {
941941
status_printf_ln(s, color,
942942
_(" (use \"git commit --amend\" to amend the current commit)"));
943943
status_printf_ln(s, color,
@@ -952,7 +952,7 @@ static void show_cherry_pick_in_progress(struct wt_status *s,
952952
const char *color)
953953
{
954954
status_printf_ln(s, color, _("You are currently cherry-picking."));
955-
if (advice_status_hints) {
955+
if (s->hints) {
956956
if (has_unmerged(s))
957957
status_printf_ln(s, color,
958958
_(" (fix conflicts and run \"git cherry-pick --continue\")"));
@@ -971,7 +971,7 @@ static void show_revert_in_progress(struct wt_status *s,
971971
{
972972
status_printf_ln(s, color, _("You are currently reverting commit %s."),
973973
find_unique_abbrev(state->revert_head_sha1, DEFAULT_ABBREV));
974-
if (advice_status_hints) {
974+
if (s->hints) {
975975
if (has_unmerged(s))
976976
status_printf_ln(s, color,
977977
_(" (fix conflicts and run \"git revert --continue\")"));
@@ -995,7 +995,7 @@ static void show_bisect_in_progress(struct wt_status *s,
995995
else
996996
status_printf_ln(s, color,
997997
_("You are currently bisecting."));
998-
if (advice_status_hints)
998+
if (s->hints)
999999
status_printf_ln(s, color,
10001000
_(" (use \"git bisect reset\" to get back to the original branch)"));
10011001
wt_status_print_trailer(s);
@@ -1233,7 +1233,7 @@ void wt_status_print(struct wt_status *s)
12331233
}
12341234
} else if (s->commitable)
12351235
status_printf_ln(s, GIT_COLOR_NORMAL, _("Untracked files not listed%s"),
1236-
advice_status_hints
1236+
s->hints
12371237
? _(" (use -u option to show untracked files)") : "");
12381238

12391239
if (s->verbose)
@@ -1244,25 +1244,25 @@ void wt_status_print(struct wt_status *s)
12441244
else if (s->nowarn)
12451245
; /* nothing */
12461246
else if (s->workdir_dirty) {
1247-
if (advice_status_hints)
1247+
if (s->hints)
12481248
printf(_("no changes added to commit "
12491249
"(use \"git add\" and/or \"git commit -a\")\n"));
12501250
else
12511251
printf(_("no changes added to commit\n"));
12521252
} else if (s->untracked.nr) {
1253-
if (advice_status_hints)
1253+
if (s->hints)
12541254
printf(_("nothing added to commit but untracked files "
12551255
"present (use \"git add\" to track)\n"));
12561256
else
12571257
printf(_("nothing added to commit but untracked files present\n"));
12581258
} else if (s->is_initial) {
1259-
if (advice_status_hints)
1259+
if (s->hints)
12601260
printf(_("nothing to commit (create/copy files "
12611261
"and use \"git add\" to track)\n"));
12621262
else
12631263
printf(_("nothing to commit\n"));
12641264
} else if (!s->show_untracked_files) {
1265-
if (advice_status_hints)
1265+
if (s->hints)
12661266
printf(_("nothing to commit (use -u to show untracked files)\n"));
12671267
else
12681268
printf(_("nothing to commit\n"));

wt-status.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ struct wt_status {
5959
unsigned colopts;
6060
int null_termination;
6161
int show_branch;
62+
int hints;
6263

6364
/* These are computed during processing of the individual sections */
6465
int commitable;

0 commit comments

Comments
 (0)