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 <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Matthieu Moy committed Sep 12, 2013 at 12:50 UTC 6a964f57e52bb25d9233ff6d38c82a16f21f60aa
3 files changed +21 -19
builtin/commit.c
+1
@@ -169,6 +169,7 @@ static void status_init_config(struct wt_status *s, config_fn_t fn)
169 gitmodules_config();
170 git_config(fn, s);
171 determine_whence(s);
172 + s->hints = advice_status_hints; /* must come after git_config() */
173 }
174
175 static void rollback_index_files(void)
wt-status.c
+19 -19
@@ -160,7 +160,7 @@ static void wt_status_print_unmerged_header(struct wt_status *s)
160 }
161 }
162
163 - if (!advice_status_hints)
163 + if (!s->hints)
164 return;
165 if (s->whence != FROM_COMMIT)
166 ;
@@ -187,7 +187,7 @@ static void wt_status_print_cached_header(struct wt_status *s)
187 const char *c = color(WT_STATUS_HEADER, s);
188
189 status_printf_ln(s, c, _("Changes to be committed:"));
190 - if (!advice_status_hints)
190 + if (!s->hints)
191 return;
192 if (s->whence != FROM_COMMIT)
193 ; /* NEEDSWORK: use "git reset --unresolve"??? */
@@ -205,7 +205,7 @@ static void wt_status_print_dirty_header(struct wt_status *s,
205 const char *c = color(WT_STATUS_HEADER, s);
206
207 status_printf_ln(s, c, _("Changes not staged for commit:"));
208 - if (!advice_status_hints)
208 + if (!s->hints)
209 return;
210 if (!has_deleted)
211 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,
223 {
224 const char *c = color(WT_STATUS_HEADER, s);
225 status_printf_ln(s, c, "%s:", what);
226 - if (!advice_status_hints)
226 + if (!s->hints)
227 return;
228 status_printf_ln(s, c, _(" (use \"git %s <file>...\" to include in what will be committed)"), how);
229 status_printf_ln(s, c, "");
@@ -801,13 +801,13 @@ static void show_merge_in_progress(struct wt_status *s,
801 {
802 if (has_unmerged(s)) {
803 status_printf_ln(s, color, _("You have unmerged paths."));
804 - if (advice_status_hints)
804 + if (s->hints)
805 status_printf_ln(s, color,
806 _(" (fix conflicts and run \"git commit\")"));
807 } else {
808 status_printf_ln(s, color,
809 _("All conflicts fixed but you are still merging."));
810 - if (advice_status_hints)
810 + if (s->hints)
811 status_printf_ln(s, color,
812 _(" (use \"git commit\" to conclude merge)"));
813 }
@@ -823,7 +823,7 @@ static void show_am_in_progress(struct wt_status *s,
823 if (state->am_empty_patch)
824 status_printf_ln(s, color,
825 _("The current patch is empty."));
826 - if (advice_status_hints) {
826 + if (s->hints) {
827 if (!state->am_empty_patch)
828 status_printf_ln(s, color,
829 _(" (fix conflicts and then run \"git am --continue\")"));
@@ -896,7 +896,7 @@ static void show_rebase_in_progress(struct wt_status *s,
896 else
897 status_printf_ln(s, color,
898 _("You are currently rebasing."));
899 - if (advice_status_hints) {
899 + if (s->hints) {
900 status_printf_ln(s, color,
901 _(" (fix conflicts and then run \"git rebase --continue\")"));
902 status_printf_ln(s, color,
@@ -913,7 +913,7 @@ static void show_rebase_in_progress(struct wt_status *s,
913 else
914 status_printf_ln(s, color,
915 _("You are currently rebasing."));
916 - if (advice_status_hints)
916 + if (s->hints)
917 status_printf_ln(s, color,
918 _(" (all conflicts fixed: run \"git rebase --continue\")"));
919 } else if (split_commit_in_progress(s)) {
@@ -925,7 +925,7 @@ static void show_rebase_in_progress(struct wt_status *s,
925 else
926 status_printf_ln(s, color,
927 _("You are currently splitting a commit during a rebase."));
928 - if (advice_status_hints)
928 + if (s->hints)
929 status_printf_ln(s, color,
930 _(" (Once your working directory is clean, run \"git rebase --continue\")"));
931 } else {
@@ -937,7 +937,7 @@ static void show_rebase_in_progress(struct wt_status *s,
937 else
938 status_printf_ln(s, color,
939 _("You are currently editing a commit during a rebase."));
940 - if (advice_status_hints && !s->amend) {
940 + if (s->hints && !s->amend) {
941 status_printf_ln(s, color,
942 _(" (use \"git commit --amend\" to amend the current commit)"));
943 status_printf_ln(s, color,
@@ -952,7 +952,7 @@ static void show_cherry_pick_in_progress(struct wt_status *s,
952 const char *color)
953 {
954 status_printf_ln(s, color, _("You are currently cherry-picking."));
955 - if (advice_status_hints) {
955 + if (s->hints) {
956 if (has_unmerged(s))
957 status_printf_ln(s, color,
958 _(" (fix conflicts and run \"git cherry-pick --continue\")"));
@@ -971,7 +971,7 @@ static void show_revert_in_progress(struct wt_status *s,
971 {
972 status_printf_ln(s, color, _("You are currently reverting commit %s."),
973 find_unique_abbrev(state->revert_head_sha1, DEFAULT_ABBREV));
974 - if (advice_status_hints) {
974 + if (s->hints) {
975 if (has_unmerged(s))
976 status_printf_ln(s, color,
977 _(" (fix conflicts and run \"git revert --continue\")"));
@@ -995,7 +995,7 @@ static void show_bisect_in_progress(struct wt_status *s,
995 else
996 status_printf_ln(s, color,
997 _("You are currently bisecting."));
998 - if (advice_status_hints)
998 + if (s->hints)
999 status_printf_ln(s, color,
1000 _(" (use \"git bisect reset\" to get back to the original branch)"));
1001 wt_status_print_trailer(s);
@@ -1233,7 +1233,7 @@ void wt_status_print(struct wt_status *s)
1233 }
1234 } else if (s->commitable)
1235 status_printf_ln(s, GIT_COLOR_NORMAL, _("Untracked files not listed%s"),
1236 - advice_status_hints
1236 + s->hints
1237 ? _(" (use -u option to show untracked files)") : "");
1238
1239 if (s->verbose)
@@ -1244,25 +1244,25 @@ void wt_status_print(struct wt_status *s)
1244 else if (s->nowarn)
1245 ; /* nothing */
1246 else if (s->workdir_dirty) {
1247 - if (advice_status_hints)
1247 + if (s->hints)
1248 printf(_("no changes added to commit "
1249 "(use \"git add\" and/or \"git commit -a\")\n"));
1250 else
1251 printf(_("no changes added to commit\n"));
1252 } else if (s->untracked.nr) {
1253 - if (advice_status_hints)
1253 + if (s->hints)
1254 printf(_("nothing added to commit but untracked files "
1255 "present (use \"git add\" to track)\n"));
1256 else
1257 printf(_("nothing added to commit but untracked files present\n"));
1258 } else if (s->is_initial) {
1259 - if (advice_status_hints)
1259 + if (s->hints)
1260 printf(_("nothing to commit (create/copy files "
1261 "and use \"git add\" to track)\n"));
1262 else
1263 printf(_("nothing to commit\n"));
1264 } else if (!s->show_untracked_files) {
1265 - if (advice_status_hints)
1265 + if (s->hints)
1266 printf(_("nothing to commit (use -u to show untracked files)\n"));
1267 else
1268 printf(_("nothing to commit\n"));
wt-status.h
+1
@@ -59,6 +59,7 @@ struct wt_status {
59 unsigned colopts;
60 int null_termination;
61 int show_branch;
62 + int hints;
63
64 /* These are computed during processing of the individual sections */
65 int commitable;