1715: Rb breaks Git patches with new files/deleted files

j**@multan****** (Google Code) (Is this you? Claim this profile.)
Feb. 27, 2011
What version are you running?
1.5 beta 2 (dev)

What steps will reproduce the problem?
1. Create a new review request using a patch from a Git repository, which creates a new file. The header of the hunk looks like this:

    diff --git a/foo.py b/foo.py
    new file mode 100644
    index 0000000..e4da686
    --- /dev/null
    +++ b/foo.py
    @@ -0,0 +1 @@
    +Some content

2. Then, download the patch from ReviewBoard, by clicking on the "Download Diff" button. the patch contains the following content:

    diff --git a/foo.py b/foo.py
    --- /dev/null
    +++ b/foo.py
    @@ -0,0 +1 @@
    +Some content

3. Using "git apply" to apply the patch, retrieved from the Reviewboard, on a repository result in the following error:

    $ git apply foo.patch
    error: dev/null: No such file or directory

4. If I manually update the patch file downloaded from the ReviewBoard, adding the two lines which has disappeared, the patch can be applied by git

AFAIR, the same problem occurs when the patch contains files which have been deleted.
#2 mconley
I can also confirm this issue.
#3 cgr***@gmai***** (Google Code) (Is this you? Claim this profile.)
I can also confirm this issue, it applies to the `patch` utility too.

Seems like all patches coming from git get kinda broken.
#4 david
Fixed in master d74b8a4. Thanks!
  • +Fixed
#5 cuj2k.*******@gmai***** (Google Code) (Is this you? Claim this profile.)
Is the fix already included in the latest release? I think it's quite urgent to ship it! (at least KDE's reviewboard still has the bug)

A workaround, to apply a broken patch: instead of git apply my.patch, use:
patch -p1 < my.patch