Skip to content

Commit b4980c6

Browse files
committed
Merge branch 'mm/commit-template-squelch-advice-messages'
From the commit log template, remove irrelevant "advice" messages that are shared with "git status" output. * mm/commit-template-squelch-advice-messages: commit: disable status hints when writing to COMMIT_EDITMSG wt-status: turn advice_status_hints into a field of wt_status commit: factor status configuration is a helper function
2 parents 9a86b89 + ea9882b commit b4980c6

File tree

3 files changed

+37
-27
lines changed

3 files changed

+37
-27
lines changed

builtin/commit.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ static void determine_whence(struct wt_status *s)
164164
s->whence = whence;
165165
}
166166

167+
static void status_init_config(struct wt_status *s, config_fn_t fn)
168+
{
169+
wt_status_prepare(s);
170+
gitmodules_config();
171+
git_config(fn, s);
172+
determine_whence(s);
173+
s->hints = advice_status_hints; /* must come after git_config() */
174+
}
175+
167176
static void rollback_index_files(void)
168177
{
169178
switch (commit_style) {
@@ -700,6 +709,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
700709
old_display_comment_prefix = s->display_comment_prefix;
701710
s->display_comment_prefix = 1;
702711

712+
/*
713+
* Most hints are counter-productive when the commit has
714+
* already started.
715+
*/
716+
s->hints = 0;
717+
703718
if (clean_message_contents)
704719
stripspace(&sb, 0);
705720

@@ -1260,10 +1275,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
12601275
if (argc == 2 && !strcmp(argv[1], "-h"))
12611276
usage_with_options(builtin_status_usage, builtin_status_options);
12621277

1263-
wt_status_prepare(&s);
1264-
gitmodules_config();
1265-
git_config(git_status_config, &s);
1266-
determine_whence(&s);
1278+
status_init_config(&s, git_status_config);
12671279
argc = parse_options(argc, argv, prefix,
12681280
builtin_status_options,
12691281
builtin_status_usage, 0);
@@ -1505,11 +1517,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
15051517
if (argc == 2 && !strcmp(argv[1], "-h"))
15061518
usage_with_options(builtin_commit_usage, builtin_commit_options);
15071519

1508-
wt_status_prepare(&s);
1509-
gitmodules_config();
1510-
git_config(git_commit_config, &s);
1520+
status_init_config(&s, git_commit_config);
15111521
status_format = STATUS_FORMAT_NONE; /* Ignore status.short */
1512-
determine_whence(&s);
15131522
s.colopts = 0;
15141523

15151524
if (get_sha1("HEAD", sha1))

wt-status.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static void wt_status_print_unmerged_header(struct wt_status *s)
165165
}
166166
}
167167

168-
if (!advice_status_hints)
168+
if (!s->hints)
169169
return;
170170
if (s->whence != FROM_COMMIT)
171171
;
@@ -192,7 +192,7 @@ static void wt_status_print_cached_header(struct wt_status *s)
192192
const char *c = color(WT_STATUS_HEADER, s);
193193

194194
status_printf_ln(s, c, _("Changes to be committed:"));
195-
if (!advice_status_hints)
195+
if (!s->hints)
196196
return;
197197
if (s->whence != FROM_COMMIT)
198198
; /* NEEDSWORK: use "git reset --unresolve"??? */
@@ -210,7 +210,7 @@ static void wt_status_print_dirty_header(struct wt_status *s,
210210
const char *c = color(WT_STATUS_HEADER, s);
211211

212212
status_printf_ln(s, c, _("Changes not staged for commit:"));
213-
if (!advice_status_hints)
213+
if (!s->hints)
214214
return;
215215
if (!has_deleted)
216216
status_printf_ln(s, c, _(" (use \"git add <file>...\" to update what will be committed)"));
@@ -228,7 +228,7 @@ static void wt_status_print_other_header(struct wt_status *s,
228228
{
229229
const char *c = color(WT_STATUS_HEADER, s);
230230
status_printf_ln(s, c, "%s:", what);
231-
if (!advice_status_hints)
231+
if (!s->hints)
232232
return;
233233
status_printf_ln(s, c, _(" (use \"git %s <file>...\" to include in what will be committed)"), how);
234234
status_printf_ln(s, c, "");
@@ -846,13 +846,13 @@ static void show_merge_in_progress(struct wt_status *s,
846846
{
847847
if (has_unmerged(s)) {
848848
status_printf_ln(s, color, _("You have unmerged paths."));
849-
if (advice_status_hints)
849+
if (s->hints)
850850
status_printf_ln(s, color,
851851
_(" (fix conflicts and run \"git commit\")"));
852852
} else {
853853
status_printf_ln(s, color,
854854
_("All conflicts fixed but you are still merging."));
855-
if (advice_status_hints)
855+
if (s->hints)
856856
status_printf_ln(s, color,
857857
_(" (use \"git commit\" to conclude merge)"));
858858
}
@@ -868,7 +868,7 @@ static void show_am_in_progress(struct wt_status *s,
868868
if (state->am_empty_patch)
869869
status_printf_ln(s, color,
870870
_("The current patch is empty."));
871-
if (advice_status_hints) {
871+
if (s->hints) {
872872
if (!state->am_empty_patch)
873873
status_printf_ln(s, color,
874874
_(" (fix conflicts and then run \"git am --continue\")"));
@@ -941,7 +941,7 @@ static void show_rebase_in_progress(struct wt_status *s,
941941
else
942942
status_printf_ln(s, color,
943943
_("You are currently rebasing."));
944-
if (advice_status_hints) {
944+
if (s->hints) {
945945
status_printf_ln(s, color,
946946
_(" (fix conflicts and then run \"git rebase --continue\")"));
947947
status_printf_ln(s, color,
@@ -958,7 +958,7 @@ static void show_rebase_in_progress(struct wt_status *s,
958958
else
959959
status_printf_ln(s, color,
960960
_("You are currently rebasing."));
961-
if (advice_status_hints)
961+
if (s->hints)
962962
status_printf_ln(s, color,
963963
_(" (all conflicts fixed: run \"git rebase --continue\")"));
964964
} else if (split_commit_in_progress(s)) {
@@ -970,7 +970,7 @@ static void show_rebase_in_progress(struct wt_status *s,
970970
else
971971
status_printf_ln(s, color,
972972
_("You are currently splitting a commit during a rebase."));
973-
if (advice_status_hints)
973+
if (s->hints)
974974
status_printf_ln(s, color,
975975
_(" (Once your working directory is clean, run \"git rebase --continue\")"));
976976
} else {
@@ -982,7 +982,7 @@ static void show_rebase_in_progress(struct wt_status *s,
982982
else
983983
status_printf_ln(s, color,
984984
_("You are currently editing a commit during a rebase."));
985-
if (advice_status_hints && !s->amend) {
985+
if (s->hints && !s->amend) {
986986
status_printf_ln(s, color,
987987
_(" (use \"git commit --amend\" to amend the current commit)"));
988988
status_printf_ln(s, color,
@@ -997,7 +997,7 @@ static void show_cherry_pick_in_progress(struct wt_status *s,
997997
const char *color)
998998
{
999999
status_printf_ln(s, color, _("You are currently cherry-picking."));
1000-
if (advice_status_hints) {
1000+
if (s->hints) {
10011001
if (has_unmerged(s))
10021002
status_printf_ln(s, color,
10031003
_(" (fix conflicts and run \"git cherry-pick --continue\")"));
@@ -1016,7 +1016,7 @@ static void show_revert_in_progress(struct wt_status *s,
10161016
{
10171017
status_printf_ln(s, color, _("You are currently reverting commit %s."),
10181018
find_unique_abbrev(state->revert_head_sha1, DEFAULT_ABBREV));
1019-
if (advice_status_hints) {
1019+
if (s->hints) {
10201020
if (has_unmerged(s))
10211021
status_printf_ln(s, color,
10221022
_(" (fix conflicts and run \"git revert --continue\")"));
@@ -1040,7 +1040,7 @@ static void show_bisect_in_progress(struct wt_status *s,
10401040
else
10411041
status_printf_ln(s, color,
10421042
_("You are currently bisecting."));
1043-
if (advice_status_hints)
1043+
if (s->hints)
10441044
status_printf_ln(s, color,
10451045
_(" (use \"git bisect reset\" to get back to the original branch)"));
10461046
wt_status_print_trailer(s);
@@ -1278,7 +1278,7 @@ void wt_status_print(struct wt_status *s)
12781278
}
12791279
} else if (s->commitable)
12801280
status_printf_ln(s, GIT_COLOR_NORMAL, _("Untracked files not listed%s"),
1281-
advice_status_hints
1281+
s->hints
12821282
? _(" (use -u option to show untracked files)") : "");
12831283

12841284
if (s->verbose)
@@ -1289,25 +1289,25 @@ void wt_status_print(struct wt_status *s)
12891289
else if (s->nowarn)
12901290
; /* nothing */
12911291
else if (s->workdir_dirty) {
1292-
if (advice_status_hints)
1292+
if (s->hints)
12931293
printf(_("no changes added to commit "
12941294
"(use \"git add\" and/or \"git commit -a\")\n"));
12951295
else
12961296
printf(_("no changes added to commit\n"));
12971297
} else if (s->untracked.nr) {
1298-
if (advice_status_hints)
1298+
if (s->hints)
12991299
printf(_("nothing added to commit but untracked files "
13001300
"present (use \"git add\" to track)\n"));
13011301
else
13021302
printf(_("nothing added to commit but untracked files present\n"));
13031303
} else if (s->is_initial) {
1304-
if (advice_status_hints)
1304+
if (s->hints)
13051305
printf(_("nothing to commit (create/copy files "
13061306
"and use \"git add\" to track)\n"));
13071307
else
13081308
printf(_("nothing to commit\n"));
13091309
} else if (!s->show_untracked_files) {
1310-
if (advice_status_hints)
1310+
if (s->hints)
13111311
printf(_("nothing to commit (use -u to show untracked files)\n"));
13121312
else
13131313
printf(_("nothing to commit\n"));

wt-status.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ struct wt_status {
6060
unsigned colopts;
6161
int null_termination;
6262
int show_branch;
63+
int hints;
6364

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

0 commit comments

Comments
 (0)