All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] am -3: recover the diagnostic messages for corrupt patches
@ 2010-04-14 20:33 Junio C Hamano
  2010-04-15  3:28 ` Stephen Boyd
  0 siblings, 1 reply; 2+ messages in thread
From: Junio C Hamano @ 2010-04-14 20:33 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: git

"git am -3" first tries to apply the patch without any extra trick, and
applies it to a synthesized tree for 3-way merge after the first attempt
fails.  "git apply" exits with status 1 for a patch that is well-formed
but is not applicable (and it dies on other errors with non-zereo, non-1
status) and has an optimization to fall back to the 3-way merge only in
the case.

An earlier patch 3ddd170 (am: suppress apply errors when using 3-way,
2009-06-16) squelched diagnostic messages from the first attempt, not to
be shown to the end user.  This worked reasonably well if the reason the
first application failed was because the patch was made against a wrong
version.

When the patch is corrupt (e.g. line-wrapped or leading whitespaces got
dropped), however, because the second patch application is not even
attempted, the error message from the first application is never shown
and is forever lost.  This message is necessary to locate where the patch
is corrupt and fix it up.

We could fix this issue by reverting 3dd170, or keeping the error message
to somewhere and showing it, but because this is an error codepath, the
easiest is to disable the optimization.  The second patch application is
attempted even when the input is corrupt, and it will notice, diagnose,
and stop with an error message.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-am.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-am.sh b/git-am.sh
index e26c54a..4e0e406 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -534,7 +534,7 @@ do
 		;;
 	esac
 
-	if test $apply_status = 1 && test "$threeway" = t
+	if test $apply_status != 0 && test "$threeway" = t
 	then
 		if (fall_back_3way)
 		then
-- 
1.7.1.rc1.252.gce30c

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] am -3: recover the diagnostic messages for corrupt patches
  2010-04-14 20:33 [PATCH] am -3: recover the diagnostic messages for corrupt patches Junio C Hamano
@ 2010-04-15  3:28 ` Stephen Boyd
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2010-04-15  3:28 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On 04/14/2010 01:33 PM, Junio C Hamano wrote:
[...]
> We could fix this issue by reverting 3dd170, or keeping the error message
> to somewhere and showing it, but because this is an error codepath, the
> easiest is to disable the optimization.  The second patch application is
> attempted even when the input is corrupt, and it will notice, diagnose,
> and stop with an error message.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Looks fine to me. Two invocations on an error path where user
intervention is most likely required shouldn't be too bad like you say.

This reminds me, a while ago I looked into pushing 3way into git-apply
(that was a GSoC project suggestion). We could introduce an internal
"I'm attempting a 3way if this fails" option for git-apply and then it
could be smart and output the errors if the patch is malformed.
Otherwise it would be silent like it should be on 3way apply for the
first time failures. Obviously this will have to happen for 3way to be
pushed into git-apply at all.

Sounds a little too smart to me though (this is the stupid content
tracker after all) so let's just do what you have ;-)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-15  3:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-14 20:33 [PATCH] am -3: recover the diagnostic messages for corrupt patches Junio C Hamano
2010-04-15  3:28 ` Stephen Boyd

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.