git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] git-am: indicate where a failed patch is to be found.

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 13, 2012, 19:58 UTC
Message-ID
<7vipdr8mch.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1342194690-31578-1-git-send-email-paul.gortmaker@windriver.com>
Paul Gortmaker <paul.gortmaker@windriver.com> writes:
Show 7 quoted lines
> If git am fails to apply something, the end user may need
> to know where to find the patch.  This is normally known for
> a single patch, but if the user is processing a mbox with
> many patches, they may not have a single broken out patch
> handy.  So, provide a helpful hint as to where they can
> find the patch to do some sort of manual fixup, if we
> are processing a mbox with more than one patch in it.

I would rather see this done even for a single patch mbox. The patch that was fed to "git apply" by "git am" and failed to apply is that one, not the one in the mbox you gave "git am". The latter may be ungrokkable with GNU patch or "git apply", if the original was sent in Quoted-Printable and such MIME funnies, which is the whole point of having a separate file there for "git am", instead of feeding the original.

I am not sure if we should limit $patch_format to mbox, but I think showing this unconditionally regardless of mbox/stgit/hg will teach the user only one location to remember, so perhaps like this?

 Documentation/config.txt | 3 +++
 git-am.sh                | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 0e1168c..b1f0a75 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -143,6 +143,9 @@ advice.*::
 		Advice shown when you used linkgit:git-checkout[1] to
 		move to the detach HEAD state, to instruct how to create
 		a local branch after the fact.
+	amWorkDir::
+		Advice that shows the location of the patch file when
+		linkgit:git-am[1] fails to apply it.
 --
 
 core.fileMode::
diff --git a/git-am.sh b/git-am.sh
index dc48f87..f1ae932 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -834,9 +834,9 @@ did you forget to use 'git add'?"
 	if test $apply_status != 0
 	then
 		eval_gettextln 'Patch failed at $msgnum $FIRSTLINE'
-		if test $patch_format = mbox && test "$last" -ne "1"
+		if test "$(git config --bool advice.amworkdir)" != false
 		then
-			eval_gettextln "You can find the copy of the patch that failed here:
+			eval_gettextln "The copy of the patch that failed is found in:
    $dotest/patch"
 		fi
 		stop_here_user_resolve $this
Previous: Paul GortmakerNext: Paul Gortmaker
Message 11 of 16 in “git-am: indicate where a failed patch is to be found.”
  1. git-am: indicate where a failed patch is to be found.Paul Gortmaker, Jul 12, 2012
  2. Junio C HamanoJul 12, 2012
  3. Paul GortmakerJul 12, 2012
  4. Junio C HamanoJul 12, 2012
  5. Paul GortmakerJul 12, 2012
  6. Junio C HamanoJul 12, 2012
  7. Paul GortmakerJul 13, 2012
  8. Junio C HamanoJul 13, 2012
  9. Junio C HamanoJul 12, 2012
  10. git-am: indicate where a failed patch is to be found.Paul Gortmaker, Jul 13, 2012
  11. Junio C HamanoJul 13, 2012
  12. Paul GortmakerJul 13, 2012
  13. Junio C HamanoJul 13, 2012
  14. Re: git-am: indicate where a failed patch is to be found.Nicolas Sebrecht, Jul 12, 2012
  15. Junio C HamanoJul 12, 2012
  16. Jeff KingJul 12, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.