Subject: patch file problem

Original Post unpush's Avatar

unpush

24 Oct, 2009 12:32 PM

I could download the patch file like this,
http://support.github.com/discussions/feature-requests/429-download...

but sometimes failed to patch.
I think that linefeed code was translated from CRLF to LF.
Also, there was no linefeed code at the end of the patch file. Only null code was there in stead.

  1. Support Staff 2 Posted by Tekkub on 24 Oct, 2009 08:17 PM

    Tekkub's Avatar

    What link are you trying to download?

  2. 3 Posted by unpush on 28 Oct, 2009 04:41 AM

    unpush's Avatar

    A case of translated linefeed code

    The link below is the site to download diff files.
    http://github.com/unpush/vimperator-plugins/commit/123376dd2d48de2f...

    "123376d" is a child of "1209016".

    $ git show --format=raw 123376d
    commit 123376dd2d48de2fd593a1e17331a23e0bc98415
    tree e7b0839cb9f3634df1043a80645ff919ac1ef288
    parent 12090164749b4071ff7c3953736166572df3d0d5
    

    To checkout the parent, and try to patch.

    $ git checkout 1209016
    $ wget 'http://github.com/unpush/vimperator-plugins/commit/123376dd2d48de2fd593a1e17331a23e0bc98415.diff'
    $ patch -p1 < 123376dd2d48de2fd593a1e17331a23e0bc98415.diff
    patching file reading.js
    Hunk #1 FAILED at 4.
    Hunk #2 FAILED at 43.
    Hunk #3 FAILED at 139.
    patch unexpectedly ends in middle of line
    Hunk #4 FAILED at 178.
    4 out of 4 hunks FAILED -- saving rejects to file reading.js.rej
    

    The "reading.js" uses CRLF linefeed code, but the diff file is translated to LF code.

    A case of broken hunk

    Refer to the above edit.
    http://github.com/unpush/p2-php/commit/a53f83190a841fa9cce57322548a...

    "a53f831" is a child of "017519d".

    $ git show --format=raw a53f83190a841fa9cce57322548adbea3e9f913a
    commit a53f83190a841fa9cce57322548adbea3e9f913a
    tree 571d917f9aa32e8206bfa324df8bcc0c8d78df4a
    parent 017519db10493494259abdcd24e47e63415188a3
    
    $ git checkout 017519d
    $ wget 'http://github.com/unpush/p2-php/commit/a53f83190a841fa9cce57322548adbea3e9f913a.diff'
    $ patch -p1 < a53f83190a841fa9cce57322548adbea3e9f913a.diff
    patching file lib/showthreadk.class.php
    missing header for unified diff at line 22 of patch
    can't find file to patch at input line 22
    Perhaps you used the wrong -p or --strip option?
    The text leading up to this was:
    --------------------------
    |
    --------------------------
    File to patch:
    

    I think there is an unnecessary LF code between first hunk and second hunk in the diff file.

  3. Support Staff 4 Posted by Tekkub on 28 Oct, 2009 11:32 PM

    Tekkub's Avatar

    Ah yes, git can be very picky about line endings. Are you on windows or not? At any rate, you should probably set autocrlf in the git config. If you're on windows, you want "true", if you're on mac or linux, you should use "input". We've got a guide to help with lineending issues also.

  4. 5 Posted by unpush on 02 Nov, 2009 02:58 PM

    unpush's Avatar

    Thank you for your quick response. I'm on linux. I normally DO NOT set the "autocrlf", and never had any problem with line endings.

    After reading your advice, I tried to set "autocrlf" and used "input", but there was no improvement. Also, I prefer not to convert line endings by git. Furthermore, I would like to control linefeed code depending on different occasion.

    I have been using a diff file from git on my linux without any problem. However, I have been unable to make the diff file downloaded from the github work. Therefore, I truly believe that there might be some problems with the diff file form the github. It would be great if you could determine and solve the issue.

    Thank you,

    Diff file from github does not work.

    $ git checkout 1209016
    $ patch -p1 < 123376dd2d48de2fd593a1e17331a23e0bc98415.diff
    patching file reading.js
    Hunk #1 FAILED at 4.
    Hunk #2 FAILED at 43.
    Hunk #3 FAILED at 139.
    patch unexpectedly ends in middle of line
    Hunk #4 FAILED at 178.
    4 out of 4 hunks FAILED -- saving rejects to file reading.js.rej
    

    Diff file from linux's local git have no problem.

    $ git reset --hard HEAD
    $ git diff 1209016..123376d > test.diff
    $ patch -p1 < test.diff
    patching file reading.js
    $
    
  5. Support Staff 6 Posted by Tekkub on 03 Nov, 2009 12:48 AM

    Tekkub's Avatar

    Try using .patch in the URL instead. It appears there is a difference between the two URLs, patch being a fully formed git patch, diff being just a simple diff.

  6. 7 Posted by unpush on 03 Nov, 2009 09:18 PM

    unpush's Avatar

    Great!
    Thank you for your quick answer and the resolution of the all of the problems!

Comments are currently closed for this discussion. You can start a new one.

Recent Discussions

25 Nov, 2009 05:57 AM
25 Nov, 2009 01:41 AM
25 Nov, 2009 01:27 AM
24 Nov, 2009 10:56 PM
24 Nov, 2009 10:54 PM