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

Re: [bug-patch] [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)

From
AGAndreas Gruenbacher <agruen@suse.de>
Date
Sep 3, 2010, 22:58 UTC
Message-ID
<201009040058.18028.agruen@suse.de>
In-Reply-To
<20100903184351.GC2341@burratino>
Hi,
On Friday 03 September 2010 20:43:51 Jonathan Nieder wrote:
Show 25 quoted lines
> Uwe Kleine-König wrote:
> > On Fri, Sep 03, 2010 at 07:18:43PM +0900, Magnus Damm wrote:
> 
> >> Using --dry-run is fine, but omitting dry-run gives me:
> >> 
> >> ...
> >> patching file arch/arm/common/clkdev.c
> >> patching file arch/sh/include/asm/clkdev.h
> >> Hunk #1 FAILED at 1.
> >> Hunk #2 FAILED at 11.
> >> 2 out of 2 hunks FAILED -- saving rejects to file
> >> arch/sh/include/asm/clkdev.h.rej
> >> 
> >> I guess this is caused by the last "renaming" hunk, see below.
> 
> Yep, I can reproduce this.  Patch applies with "git apply",
> "patch --dry-run -p1" accepts it, "patch -p1" fails.
> 
>  $ patch --version | head -1
>  GNU patch 2.6.1.85-423d
>  $ cd ~/src/linux-2.6
>  $ git checkout 2bfc96a12
>  $ git clean -fd
>  $ wget http://download.gmane.org/gmane.linux.ports.sh.devel/8747/8748
> [...]

something pretty bizarre is going on here. The wget output modifies the same file twice, but both patches to this file have the same source sha1 (5645f35):

Show 5 quoted lines
> diff --git a/arch/sh/include/asm/clkdev.h b/arch/sh/include/asm/clkdev.h
> dissimilarity index 69%
> index 5645f35..6ba9186 100644
> --- a/arch/sh/include/asm/clkdev.h
> +++ b/arch/sh/include/asm/clkdev.h
Show 5 quoted lines
> diff --git a/arch/sh/include/asm/clkdev.h b/include/linux/clkdev.h
> similarity index 85%
> rename from arch/sh/include/asm/clkdev.h
> rename to include/linux/clkdev.h
> index 5645f35..457bcb0 100644
So "git apply" and "patch --dry-run" seem to work only by accident.
How was this patch generated: with git itself?

The fact that "patch --dry-run" may not work for patches that modify the same file twice is a known defect. I don't know how to solve this in a reasonably elegant way. Luckily the problem only triggers when people are doing something "strange" such as concatenating patches.

Andreas
Previous: Matthieu MoyNext: Jonathan Nieder
Message 13 of 16 in “Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c”
  1. Uwe Kleine-KönigSep 3, 2010
  2. [BUG?] rename patch accepted with --dry-run, rejected without (Re: [PATCH V3] arm & sh: factorised duplicated clkdev.c)Jonathan Nieder, Sep 3, 2010
  3. Russell King - ARM LinuxSep 3, 2010
  4. Uwe Kleine-KönigSep 3, 2010
  5. Andreas SchwabSep 3, 2010
  6. Russell King - ARM LinuxSep 4, 2010
  7. Andreas GruenbacherSep 4, 2010
  8. Russell King - ARM LinuxSep 4, 2010
  9. Andreas GruenbacherSep 4, 2010
  10. Russell King - ARM LinuxSep 4, 2010
  11. Andreas GruenbacherSep 4, 2010
  12. Matthieu MoySep 3, 2010
  13. Andreas GruenbacherSep 3, 2010
  14. Jonathan NiederSep 3, 2010
  15. Andreas GruenbacherSep 4, 2010
  16. Jean-Christophe PLAGNIOL-VILLARDSep 4, 2010

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.