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

Re: [BUG] git-am silently applying patches incorrectly

From
Drew Northup <drew.northup@maine.edu>
Date
Mar 4, 2011, 16:17 UTC
Message-ID
<1299255471.22002.15.camel@drew-northup.unet.maine.edu>
In-Reply-To
<4D70EBC3.3010400@colin.guthr.ie>
On Fri, 2011-03-04 at 13:40 +0000, Colin Guthrie wrote:
Show 18 quoted lines
> Hi,
> 
> We recently found a bug in git-am 1.7.4.1 while working on PulseAudio.
> 
> It seems that it mis-applied a patch and did so silently without
> generating any warnings. It is reproducible and has been confirmed on
> different distros.
> 
> I make reference to the bug here:
> http://thread.gmane.org/gmane.comp.audio.pulseaudio.general/8840/focus=8857
> 
> In order to reproduce:
> 
> git clone http://git.0pointer.de/repos/pulseaudio.git
> git co -b misapply 0ce3017b7407ab1c4094f7ce271bb68319a7eba7
> git am 0002-alsa-mixer-add-required-any-and-required-for-enum-op.patch
> 
> (I've attached the patch here for convenience).
Show 21 quoted lines
> For reference, applying the patch manually with patch works fine and
> does not result in an error:
> 
> $ cat 0002-alsa-mixer-add-required-any-and-required-for-enum-op.patch |
> patch -p1
> patching file src/modules/alsa/alsa-mixer.c
> Hunk #1 succeeded at 1121 (offset 103 lines).
> Hunk #2 succeeded at 1325 (offset 103 lines).
> Hunk #3 succeeded at 1356 (offset 103 lines).
> Hunk #4 succeeded at 1613 (offset 103 lines).
> Hunk #5 succeeded at 1640 (offset 103 lines).
> Hunk #6 succeeded at 1913 (offset 103 lines).
> Hunk #7 succeeded at 1997 (offset 105 lines).
> Hunk #8 succeeded at 2242 (offset 106 lines).
> Hunk #9 succeeded at 2261 (offset 106 lines).
> Hunk #10 succeeded at 2312 (offset 106 lines).
> patching file src/modules/alsa/alsa-mixer.h
> Hunk #1 succeeded at 112 (offset 1 line).
> Hunk #2 succeeded at 133 (offset 1 line).
> Hunk #3 succeeded at 169 (offset 1 line).
> patching file src/modules/alsa/mixer/paths/analog-output.conf.common

Did you try removing the first line from the patch mbox file? It seems to work just fine if you do that.

That first line is "removed" from the output of "git format-patch" when you correctly import the mbox file into your mail client's drafts folder as described in the documentation. Then you send the mail created by importing that draft. If you just send the output of "git format-patch" untouched as an attachment you can expect problems.

-- 
-Drew Northup
________________________________________________
"As opposed to vegetable or mineral error?"
-John Pescatore, SANS NewsBites Vol. 12 Num. 59
Previous: Colin GuthrieNext: Colin Guthrie
Message 2 of 34 in “[BUG] git-am silently applying patches incorrectly”
  1. Colin GuthrieMar 4, 2011
  2. Drew NorthupMar 4, 2011
  3. Colin GuthrieMar 4, 2011
  4. Junio C HamanoMar 4, 2011
  5. Junio C HamanoMar 4, 2011
  6. Junio C HamanoMar 4, 2011
  7. Junio C HamanoMar 4, 2011
  8. Linus TorvaldsMar 4, 2011
  9. Junio C HamanoMar 4, 2011
  10. Alexander MiselerMar 4, 2011
  11. Junio C HamanoMar 4, 2011
  12. Colin GuthrieMar 4, 2011
  13. Junio C HamanoMar 4, 2011
  14. Junio C HamanoMar 4, 2011
  15. Colin GuthrieMar 5, 2011
  16. Junio C HamanoMar 6, 2011
  17. Junio C HamanoMar 6, 2011
  18. Jonathan NiederMar 6, 2011
  19. Junio C HamanoMar 6, 2011
  20. Colin GuthrieMar 7, 2011
  21. Alexander MiselerMar 4, 2011
  22. Junio C HamanoMar 5, 2011
  23. Junio C HamanoMar 4, 2011
  24. Drew NorthupMar 4, 2011
  25. 0/2 i18n: add ngettext stubJonathan Nieder, Mar 9, 2011
  26. 1/2 i18n: add stub ngettext implementationJonathan Nieder, Mar 9, 2011
  27. 2/2 i18n: avoid conflict with ngettext from libintlJonathan Nieder, Mar 9, 2011
  28. Junio C HamanoMar 9, 2011
  29. Jonathan NiederMar 9, 2011
  30. Junio C HamanoMar 9, 2011
  31. i18n: add stub Q_() wrapper for ngettextJonathan Nieder, Mar 10, 2011
  32. Junio C HamanoMar 10, 2011
  33. Ævar Arnfjörð BjarmasonMar 10, 2011
  34. Ævar Arnfjörð BjarmasonMar 10, 2011

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.