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 functionmaint
						commit
						b4980c63ac
					
				|  | @ -164,6 +164,15 @@ static void determine_whence(struct wt_status *s) | ||||||
| 		s->whence = whence; | 		s->whence = whence; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static void status_init_config(struct wt_status *s, config_fn_t fn) | ||||||
|  | { | ||||||
|  | 	wt_status_prepare(s); | ||||||
|  | 	gitmodules_config(); | ||||||
|  | 	git_config(fn, s); | ||||||
|  | 	determine_whence(s); | ||||||
|  | 	s->hints = advice_status_hints; /* must come after git_config() */ | ||||||
|  | } | ||||||
|  |  | ||||||
| static void rollback_index_files(void) | static void rollback_index_files(void) | ||||||
| { | { | ||||||
| 	switch (commit_style) { | 	switch (commit_style) { | ||||||
|  | @ -700,6 +709,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix, | ||||||
| 	old_display_comment_prefix = s->display_comment_prefix; | 	old_display_comment_prefix = s->display_comment_prefix; | ||||||
| 	s->display_comment_prefix = 1; | 	s->display_comment_prefix = 1; | ||||||
|  |  | ||||||
|  | 	/* | ||||||
|  | 	 * Most hints are counter-productive when the commit has | ||||||
|  | 	 * already started. | ||||||
|  | 	 */ | ||||||
|  | 	s->hints = 0; | ||||||
|  |  | ||||||
| 	if (clean_message_contents) | 	if (clean_message_contents) | ||||||
| 		stripspace(&sb, 0); | 		stripspace(&sb, 0); | ||||||
|  |  | ||||||
|  | @ -1260,10 +1275,7 @@ int cmd_status(int argc, const char **argv, const char *prefix) | ||||||
| 	if (argc == 2 && !strcmp(argv[1], "-h")) | 	if (argc == 2 && !strcmp(argv[1], "-h")) | ||||||
| 		usage_with_options(builtin_status_usage, builtin_status_options); | 		usage_with_options(builtin_status_usage, builtin_status_options); | ||||||
|  |  | ||||||
| 	wt_status_prepare(&s); | 	status_init_config(&s, git_status_config); | ||||||
| 	gitmodules_config(); |  | ||||||
| 	git_config(git_status_config, &s); |  | ||||||
| 	determine_whence(&s); |  | ||||||
| 	argc = parse_options(argc, argv, prefix, | 	argc = parse_options(argc, argv, prefix, | ||||||
| 			     builtin_status_options, | 			     builtin_status_options, | ||||||
| 			     builtin_status_usage, 0); | 			     builtin_status_usage, 0); | ||||||
|  | @ -1505,11 +1517,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix) | ||||||
| 	if (argc == 2 && !strcmp(argv[1], "-h")) | 	if (argc == 2 && !strcmp(argv[1], "-h")) | ||||||
| 		usage_with_options(builtin_commit_usage, builtin_commit_options); | 		usage_with_options(builtin_commit_usage, builtin_commit_options); | ||||||
|  |  | ||||||
| 	wt_status_prepare(&s); | 	status_init_config(&s, git_commit_config); | ||||||
| 	gitmodules_config(); |  | ||||||
| 	git_config(git_commit_config, &s); |  | ||||||
| 	status_format = STATUS_FORMAT_NONE; /* Ignore status.short */ | 	status_format = STATUS_FORMAT_NONE; /* Ignore status.short */ | ||||||
| 	determine_whence(&s); |  | ||||||
| 	s.colopts = 0; | 	s.colopts = 0; | ||||||
|  |  | ||||||
| 	if (get_sha1("HEAD", sha1)) | 	if (get_sha1("HEAD", sha1)) | ||||||
|  |  | ||||||
							
								
								
									
										38
									
								
								wt-status.c
								
								
								
								
							
							
						
						
									
										38
									
								
								wt-status.c
								
								
								
								
							|  | @ -165,7 +165,7 @@ static void wt_status_print_unmerged_header(struct wt_status *s) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (!advice_status_hints) | 	if (!s->hints) | ||||||
| 		return; | 		return; | ||||||
| 	if (s->whence != FROM_COMMIT) | 	if (s->whence != FROM_COMMIT) | ||||||
| 		; | 		; | ||||||
|  | @ -192,7 +192,7 @@ static void wt_status_print_cached_header(struct wt_status *s) | ||||||
| 	const char *c = color(WT_STATUS_HEADER, s); | 	const char *c = color(WT_STATUS_HEADER, s); | ||||||
|  |  | ||||||
| 	status_printf_ln(s, c, _("Changes to be committed:")); | 	status_printf_ln(s, c, _("Changes to be committed:")); | ||||||
| 	if (!advice_status_hints) | 	if (!s->hints) | ||||||
| 		return; | 		return; | ||||||
| 	if (s->whence != FROM_COMMIT) | 	if (s->whence != FROM_COMMIT) | ||||||
| 		; /* NEEDSWORK: use "git reset --unresolve"??? */ | 		; /* NEEDSWORK: use "git reset --unresolve"??? */ | ||||||
|  | @ -210,7 +210,7 @@ static void wt_status_print_dirty_header(struct wt_status *s, | ||||||
| 	const char *c = color(WT_STATUS_HEADER, s); | 	const char *c = color(WT_STATUS_HEADER, s); | ||||||
|  |  | ||||||
| 	status_printf_ln(s, c, _("Changes not staged for commit:")); | 	status_printf_ln(s, c, _("Changes not staged for commit:")); | ||||||
| 	if (!advice_status_hints) | 	if (!s->hints) | ||||||
| 		return; | 		return; | ||||||
| 	if (!has_deleted) | 	if (!has_deleted) | ||||||
| 		status_printf_ln(s, c, _("  (use \"git add <file>...\" to update what will be committed)")); | 		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, | ||||||
| { | { | ||||||
| 	const char *c = color(WT_STATUS_HEADER, s); | 	const char *c = color(WT_STATUS_HEADER, s); | ||||||
| 	status_printf_ln(s, c, "%s:", what); | 	status_printf_ln(s, c, "%s:", what); | ||||||
| 	if (!advice_status_hints) | 	if (!s->hints) | ||||||
| 		return; | 		return; | ||||||
| 	status_printf_ln(s, c, _("  (use \"git %s <file>...\" to include in what will be committed)"), how); | 	status_printf_ln(s, c, _("  (use \"git %s <file>...\" to include in what will be committed)"), how); | ||||||
| 	status_printf_ln(s, c, ""); | 	status_printf_ln(s, c, ""); | ||||||
|  | @ -846,13 +846,13 @@ static void show_merge_in_progress(struct wt_status *s, | ||||||
| { | { | ||||||
| 	if (has_unmerged(s)) { | 	if (has_unmerged(s)) { | ||||||
| 		status_printf_ln(s, color, _("You have unmerged paths.")); | 		status_printf_ln(s, color, _("You have unmerged paths.")); | ||||||
| 		if (advice_status_hints) | 		if (s->hints) | ||||||
| 			status_printf_ln(s, color, | 			status_printf_ln(s, color, | ||||||
| 				_("  (fix conflicts and run \"git commit\")")); | 				_("  (fix conflicts and run \"git commit\")")); | ||||||
| 	} else { | 	} else { | ||||||
| 		status_printf_ln(s, color, | 		status_printf_ln(s, color, | ||||||
| 			_("All conflicts fixed but you are still merging.")); | 			_("All conflicts fixed but you are still merging.")); | ||||||
| 		if (advice_status_hints) | 		if (s->hints) | ||||||
| 			status_printf_ln(s, color, | 			status_printf_ln(s, color, | ||||||
| 				_("  (use \"git commit\" to conclude merge)")); | 				_("  (use \"git commit\" to conclude merge)")); | ||||||
| 	} | 	} | ||||||
|  | @ -868,7 +868,7 @@ static void show_am_in_progress(struct wt_status *s, | ||||||
| 	if (state->am_empty_patch) | 	if (state->am_empty_patch) | ||||||
| 		status_printf_ln(s, color, | 		status_printf_ln(s, color, | ||||||
| 			_("The current patch is empty.")); | 			_("The current patch is empty.")); | ||||||
| 	if (advice_status_hints) { | 	if (s->hints) { | ||||||
| 		if (!state->am_empty_patch) | 		if (!state->am_empty_patch) | ||||||
| 			status_printf_ln(s, color, | 			status_printf_ln(s, color, | ||||||
| 				_("  (fix conflicts and then run \"git am --continue\")")); | 				_("  (fix conflicts and then run \"git am --continue\")")); | ||||||
|  | @ -941,7 +941,7 @@ static void show_rebase_in_progress(struct wt_status *s, | ||||||
| 		else | 		else | ||||||
| 			status_printf_ln(s, color, | 			status_printf_ln(s, color, | ||||||
| 					 _("You are currently rebasing.")); | 					 _("You are currently rebasing.")); | ||||||
| 		if (advice_status_hints) { | 		if (s->hints) { | ||||||
| 			status_printf_ln(s, color, | 			status_printf_ln(s, color, | ||||||
| 				_("  (fix conflicts and then run \"git rebase --continue\")")); | 				_("  (fix conflicts and then run \"git rebase --continue\")")); | ||||||
| 			status_printf_ln(s, color, | 			status_printf_ln(s, color, | ||||||
|  | @ -958,7 +958,7 @@ static void show_rebase_in_progress(struct wt_status *s, | ||||||
| 		else | 		else | ||||||
| 			status_printf_ln(s, color, | 			status_printf_ln(s, color, | ||||||
| 					 _("You are currently rebasing.")); | 					 _("You are currently rebasing.")); | ||||||
| 		if (advice_status_hints) | 		if (s->hints) | ||||||
| 			status_printf_ln(s, color, | 			status_printf_ln(s, color, | ||||||
| 				_("  (all conflicts fixed: run \"git rebase --continue\")")); | 				_("  (all conflicts fixed: run \"git rebase --continue\")")); | ||||||
| 	} else if (split_commit_in_progress(s)) { | 	} else if (split_commit_in_progress(s)) { | ||||||
|  | @ -970,7 +970,7 @@ static void show_rebase_in_progress(struct wt_status *s, | ||||||
| 		else | 		else | ||||||
| 			status_printf_ln(s, color, | 			status_printf_ln(s, color, | ||||||
| 					 _("You are currently splitting a commit during a rebase.")); | 					 _("You are currently splitting a commit during a rebase.")); | ||||||
| 		if (advice_status_hints) | 		if (s->hints) | ||||||
| 			status_printf_ln(s, color, | 			status_printf_ln(s, color, | ||||||
| 				_("  (Once your working directory is clean, run \"git rebase --continue\")")); | 				_("  (Once your working directory is clean, run \"git rebase --continue\")")); | ||||||
| 	} else { | 	} else { | ||||||
|  | @ -982,7 +982,7 @@ static void show_rebase_in_progress(struct wt_status *s, | ||||||
| 		else | 		else | ||||||
| 			status_printf_ln(s, color, | 			status_printf_ln(s, color, | ||||||
| 					 _("You are currently editing a commit during a rebase.")); | 					 _("You are currently editing a commit during a rebase.")); | ||||||
| 		if (advice_status_hints && !s->amend) { | 		if (s->hints && !s->amend) { | ||||||
| 			status_printf_ln(s, color, | 			status_printf_ln(s, color, | ||||||
| 				_("  (use \"git commit --amend\" to amend the current commit)")); | 				_("  (use \"git commit --amend\" to amend the current commit)")); | ||||||
| 			status_printf_ln(s, color, | 			status_printf_ln(s, color, | ||||||
|  | @ -997,7 +997,7 @@ static void show_cherry_pick_in_progress(struct wt_status *s, | ||||||
| 					const char *color) | 					const char *color) | ||||||
| { | { | ||||||
| 	status_printf_ln(s, color, _("You are currently cherry-picking.")); | 	status_printf_ln(s, color, _("You are currently cherry-picking.")); | ||||||
| 	if (advice_status_hints) { | 	if (s->hints) { | ||||||
| 		if (has_unmerged(s)) | 		if (has_unmerged(s)) | ||||||
| 			status_printf_ln(s, color, | 			status_printf_ln(s, color, | ||||||
| 				_("  (fix conflicts and run \"git cherry-pick --continue\")")); | 				_("  (fix conflicts and run \"git cherry-pick --continue\")")); | ||||||
|  | @ -1016,7 +1016,7 @@ static void show_revert_in_progress(struct wt_status *s, | ||||||
| { | { | ||||||
| 	status_printf_ln(s, color, _("You are currently reverting commit %s."), | 	status_printf_ln(s, color, _("You are currently reverting commit %s."), | ||||||
| 			 find_unique_abbrev(state->revert_head_sha1, DEFAULT_ABBREV)); | 			 find_unique_abbrev(state->revert_head_sha1, DEFAULT_ABBREV)); | ||||||
| 	if (advice_status_hints) { | 	if (s->hints) { | ||||||
| 		if (has_unmerged(s)) | 		if (has_unmerged(s)) | ||||||
| 			status_printf_ln(s, color, | 			status_printf_ln(s, color, | ||||||
| 				_("  (fix conflicts and run \"git revert --continue\")")); | 				_("  (fix conflicts and run \"git revert --continue\")")); | ||||||
|  | @ -1040,7 +1040,7 @@ static void show_bisect_in_progress(struct wt_status *s, | ||||||
| 	else | 	else | ||||||
| 		status_printf_ln(s, color, | 		status_printf_ln(s, color, | ||||||
| 				 _("You are currently bisecting.")); | 				 _("You are currently bisecting.")); | ||||||
| 	if (advice_status_hints) | 	if (s->hints) | ||||||
| 		status_printf_ln(s, color, | 		status_printf_ln(s, color, | ||||||
| 			_("  (use \"git bisect reset\" to get back to the original branch)")); | 			_("  (use \"git bisect reset\" to get back to the original branch)")); | ||||||
| 	wt_status_print_trailer(s); | 	wt_status_print_trailer(s); | ||||||
|  | @ -1278,7 +1278,7 @@ void wt_status_print(struct wt_status *s) | ||||||
| 		} | 		} | ||||||
| 	} else if (s->commitable) | 	} else if (s->commitable) | ||||||
| 		status_printf_ln(s, GIT_COLOR_NORMAL, _("Untracked files not listed%s"), | 		status_printf_ln(s, GIT_COLOR_NORMAL, _("Untracked files not listed%s"), | ||||||
| 			advice_status_hints | 			s->hints | ||||||
| 			? _(" (use -u option to show untracked files)") : ""); | 			? _(" (use -u option to show untracked files)") : ""); | ||||||
|  |  | ||||||
| 	if (s->verbose) | 	if (s->verbose) | ||||||
|  | @ -1289,25 +1289,25 @@ void wt_status_print(struct wt_status *s) | ||||||
| 		else if (s->nowarn) | 		else if (s->nowarn) | ||||||
| 			; /* nothing */ | 			; /* nothing */ | ||||||
| 		else if (s->workdir_dirty) { | 		else if (s->workdir_dirty) { | ||||||
| 			if (advice_status_hints) | 			if (s->hints) | ||||||
| 				printf(_("no changes added to commit " | 				printf(_("no changes added to commit " | ||||||
| 					 "(use \"git add\" and/or \"git commit -a\")\n")); | 					 "(use \"git add\" and/or \"git commit -a\")\n")); | ||||||
| 			else | 			else | ||||||
| 				printf(_("no changes added to commit\n")); | 				printf(_("no changes added to commit\n")); | ||||||
| 		} else if (s->untracked.nr) { | 		} else if (s->untracked.nr) { | ||||||
| 			if (advice_status_hints) | 			if (s->hints) | ||||||
| 				printf(_("nothing added to commit but untracked files " | 				printf(_("nothing added to commit but untracked files " | ||||||
| 					 "present (use \"git add\" to track)\n")); | 					 "present (use \"git add\" to track)\n")); | ||||||
| 			else | 			else | ||||||
| 				printf(_("nothing added to commit but untracked files present\n")); | 				printf(_("nothing added to commit but untracked files present\n")); | ||||||
| 		} else if (s->is_initial) { | 		} else if (s->is_initial) { | ||||||
| 			if (advice_status_hints) | 			if (s->hints) | ||||||
| 				printf(_("nothing to commit (create/copy files " | 				printf(_("nothing to commit (create/copy files " | ||||||
| 					 "and use \"git add\" to track)\n")); | 					 "and use \"git add\" to track)\n")); | ||||||
| 			else | 			else | ||||||
| 				printf(_("nothing to commit\n")); | 				printf(_("nothing to commit\n")); | ||||||
| 		} else if (!s->show_untracked_files) { | 		} else if (!s->show_untracked_files) { | ||||||
| 			if (advice_status_hints) | 			if (s->hints) | ||||||
| 				printf(_("nothing to commit (use -u to show untracked files)\n")); | 				printf(_("nothing to commit (use -u to show untracked files)\n")); | ||||||
| 			else | 			else | ||||||
| 				printf(_("nothing to commit\n")); | 				printf(_("nothing to commit\n")); | ||||||
|  |  | ||||||
|  | @ -60,6 +60,7 @@ struct wt_status { | ||||||
| 	unsigned colopts; | 	unsigned colopts; | ||||||
| 	int null_termination; | 	int null_termination; | ||||||
| 	int show_branch; | 	int show_branch; | ||||||
|  | 	int hints; | ||||||
|  |  | ||||||
| 	/* These are computed during processing of the individual sections */ | 	/* These are computed during processing of the individual sections */ | ||||||
| 	int commitable; | 	int commitable; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Junio C Hamano
						Junio C Hamano