git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* [PATCH] git-apply: modify prints to account for --3way changes
@ 2021-04-27  1:13 Jerry Zhang
  2021-04-27  7:46 ` Junio C Hamano
  2021-04-27 19:40 ` [PATCH V2] " Jerry Zhang
  0 siblings, 2 replies; 7+ messages in thread
From: Jerry Zhang @ 2021-04-27  1:13 UTC (permalink / raw)
  To: git, gitster; +Cc: ross, abe, brian.kubisiak, Jerry Zhang

"git apply" specifically calls out when it
is falling back to 3way merge application.
Since the order changed to preferring 3way
and falling back to direct application,
continue that behavior by printing whenever
3way fails and git has to fall back.

Add a --quiet flag to "git apply" so the user
can turn down the verbosity.

Signed-off-by: Jerry Zhang <jerry@skydio.com>
---
 apply.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/apply.c b/apply.c
index 8532b48e4f..2abf2e8a61 100644
--- a/apply.c
+++ b/apply.c
@@ -3572,7 +3572,7 @@ static int try_threeway(struct apply_state *state,
 		 read_blob_object(&buf, &pre_oid, patch->old_mode))
 		return error(_("repository lacks the necessary blob to perform 3-way merge."));
 
-	if (state->apply_verbosity > verbosity_silent)
+	if (state->apply_verbosity > verbosity_silent && patch->direct_to_threeway)
 		fprintf(stderr, _("Performing three-way merge...\n"));
 
 	img = strbuf_detach(&buf, &len);
@@ -3639,6 +3639,10 @@ static int apply_data(struct apply_state *state, struct patch *patch,
 		return -1;
 
 	if (!state->threeway || try_threeway(state, &image, patch, st, ce) < 0) {
+		if (state->apply_verbosity > verbosity_silent &&
+		    state->threeway && !patch->direct_to_threeway)
+			fprintf(stderr, _("Falling back to direct application...\n"));
+
 		/* Note: with --reject, apply_fragments() returns 0 */
 		if (patch->direct_to_threeway || apply_fragments(state, &image, patch) < 0)
 			return -1;
@@ -5050,6 +5054,8 @@ int apply_parse_options(int argc, const char **argv,
 		OPT_BOOL(0, "allow-overlap", &state->allow_overlap,
 			N_("allow overlapping hunks")),
 		OPT__VERBOSE(&state->apply_verbosity, N_("be verbose")),
+		OPT_SET_INT('q', "quiet", &state->apply_verbosity,
+			N_("be quiet"), -1),
 		OPT_BIT(0, "inaccurate-eof", options,
 			N_("tolerate incorrectly detected missing new-line at the end of file"),
 			APPLY_OPT_INACCURATE_EOF),
-- 
@@ -3572,7 +3572,7 @@ static int try_threeway(struct apply_state *state,
 		 read_blob_object(&buf, &pre_oid, patch->old_mode))
 		return error(_("repository lacks the necessary blob to perform 3-way merge."));
 
-	if (state->apply_verbosity > verbosity_silent)
+	if (state->apply_verbosity > verbosity_silent && patch->direct_to_threeway)
 		fprintf(stderr, _("Performing three-way merge...\n"));
 
 	img = strbuf_detach(&buf, &len);
@@ -3639,6 +3639,10 @@ static int apply_data(struct apply_state *state, struct patch *patch,
 		return -1;
 
 	if (!state->threeway || try_threeway(state, &image, patch, st, ce) < 0) {
+		if (state->apply_verbosity > verbosity_silent &&
+		    state->threeway && !patch->direct_to_threeway)
+			fprintf(stderr, _("Falling back to direct application...\n"));
+
 		/* Note: with --reject, apply_fragments() returns 0 */
 		if (patch->direct_to_threeway || apply_fragments(state, &image, patch) < 0)
 			return -1;
@@ -5050,6 +5054,8 @@ int apply_parse_options(int argc, const char **argv,
 		OPT_BOOL(0, "allow-overlap", &state->allow_overlap,
 			N_("allow overlapping hunks")),
 		OPT__VERBOSE(&state->apply_verbosity, N_("be verbose")),
+		OPT_SET_INT('q', "quiet", &state->apply_verbosity,
+			N_("be quiet"), -1),
 		OPT_BIT(0, "inaccurate-eof", options,
 			N_("tolerate incorrectly detected missing new-line at the end of file"),
 			APPLY_OPT_INACCURATE_EOF),
-- 
2.29.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread
1
end of thread, other threads:[~2021-04-29  2:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-27  1:13 [PATCH] git-apply: modify prints to account for --3way changes Jerry Zhang
2021-04-27  7:46 ` Junio C Hamano
2021-04-27 19:40 ` [PATCH V2] " Jerry Zhang
2021-04-28  7:32   ` Junio C Hamano
2021-04-28 18:26     ` Jerry Zhang
2021-04-29  0:58       ` Junio C Hamano
2021-04-29  2:35   ` [PATCH V3] git-apply: adjust messages " Jerry Zhang

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).