threads / discuss / 12858

Apply patch on server w/o git

Subject: Apply patch on server w/o git

## tl;dr

7 messages between Mar 25, 2008 and Mar 29, 2008.

replies: 6people: 4as markdown or json

Joe Fiorini· Mar 25, 2008, 18:25 UTC · lore

I am trying to generate a diff patch on my local dev box. I want to upload this patch to a server (running Windows Server 2008) and apply it to my staging code. The catch is: I cannot install git on the server to accept the patch. Therefore, I would like to use a generic patching tool (such as patch from the GnuWin32 tools). I tried generating a unified diff with the following command:

git diff -U > diff.patch
and then tried to apply it using:
patch -u -i ..\other_dir\diff.patch
and I got the error:

"patch unexpectedly ends in middle of line" ... "Only garbage was found in the patch input"

It might be a problem with how I'm using patch, and if so, forgive me. If not, then how can I generate a generic diff format from git so I can do what I want?

Thanks all! Joe Fiorini

Bryan Donlan· Mar 25, 2008, 18:41 UTC · re: Joe Fiorini · lore

Re: Apply patch on server w/o git

On Tue, Mar 25, 2008 at 2:25 PM, Joe Fiorini <joe@faithfulgeek.org> wrote:
Show 24 quoted lines
> I am trying to generate a diff patch on my local dev box.  I want to
>  upload this patch to a server (running Windows Server 2008) and apply
>  it to my staging code.  The catch is: I cannot install git on the
>  server to accept the patch.  Therefore, I would like to use a generic
>  patching tool (such as patch from the GnuWin32 tools).  I tried
>  generating a unified diff with the following command:
>
>  git diff -U > diff.patch
>
>  and then tried to apply it using:
>
>  patch -u -i ..\other_dir\diff.patch
>
>  and I got the error:
>
>  "patch unexpectedly ends in middle of line" ... "Only garbage was
>  found in the patch input"
>
>  It might be a problem with how I'm using patch, and if so, forgive
>  me.  If not, then how can I generate a generic diff format from git so
>  I can do what I want?
>
>  Thanks all!
>  Joe Fiorini

Just a guess, but the gnuwin32 tools might not like unix line endings. Try opening and re-saving in wordpad (or vim :set ff=dos, or $insert your favorite method here).

Joe Fiorini· Mar 25, 2008, 19:23 UTC · re: Bryan Donlan · lore

Re: Apply patch on server w/o git

I just tried it and no luck.  Anyone have any other ideas?
-Joe
On Mar 25, 2008, at 2:41 PM, Bryan Donlan wrote:
Show 31 quoted lines
> On Tue, Mar 25, 2008 at 2:25 PM, Joe Fiorini <joe@faithfulgeek.org>  
> wrote:
>> I am trying to generate a diff patch on my local dev box.  I want to
>> upload this patch to a server (running Windows Server 2008) and apply
>> it to my staging code.  The catch is: I cannot install git on the
>> server to accept the patch.  Therefore, I would like to use a generic
>> patching tool (such as patch from the GnuWin32 tools).  I tried
>> generating a unified diff with the following command:
>>
>> git diff -U > diff.patch
>>
>> and then tried to apply it using:
>>
>> patch -u -i ..\other_dir\diff.patch
>>
>> and I got the error:
>>
>> "patch unexpectedly ends in middle of line" ... "Only garbage was
>> found in the patch input"
>>
>> It might be a problem with how I'm using patch, and if so, forgive
>> me.  If not, then how can I generate a generic diff format from git  
>> so
>> I can do what I want?
>>
>> Thanks all!
>> Joe Fiorini
>
> Just a guess, but the gnuwin32 tools might not like unix line endings.
> Try opening and re-saving in wordpad (or vim :set ff=dos, or $insert
> your favorite method here).
Jan Hudec· Mar 25, 2008, 19:46 UTC · re: Bryan Donlan · lore

Re: Apply patch on server w/o git

On Tue, Mar 25, 2008 at 14:41:04 -0400, Bryan Donlan wrote:
> Just a guess, but the gnuwin32 tools might not like unix line endings.
> Try opening and re-saving in wordpad (or vim :set ff=dos, or $insert
> your favorite method here).
That won't actually work! The problem is, that:
 - The headers (+++/---/@@ lines) should have dos line endings (but does not
   matter too much).
 - The bodies must have the same line endings the actual code does.

Question is, what the code has (it could have been transfered by some method that converted the line-endings or something).

Also trying to patch with ignoring whitespace could work (I believe I did that the other way 'round -- applying windowsy newline-damaged patch on unix). And if it does not, it's not the newlines problem.

-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
Robin Rosenberg· Mar 25, 2008, 19:57 UTC · re: Joe Fiorini · lore

Re: Apply patch on server w/o git

Den Tuesday 25 March 2008 19.25.58 skrev Joe Fiorini:
Show 12 quoted lines
> I am trying to generate a diff patch on my local dev box.  I want to
> upload this patch to a server (running Windows Server 2008) and apply
> it to my staging code.  The catch is: I cannot install git on the
> server to accept the patch.  Therefore, I would like to use a generic
> patching tool (such as patch from the GnuWin32 tools).  I tried
> generating a unified diff with the following command:
>
> git diff -U > diff.patch
>
> and then tried to apply it using:
>
> patch -u -i ..\other_dir\diff.patch

You can try git-apply instead of patch. It is a bit smarter (and not outsmarting itself either).

-- robin
Joe Fiorini· Mar 26, 2008, 03:03 UTC · re: Robin Rosenberg · lore

Re: Apply patch on server w/o git

Thanks for all your replies. Unfortunately, I cannot use git apply because I will not have access to git on the server where I'm doing the patch. I will try Jan's suggestion of ignoring whitespace.

-Joe
On Mar 25, 2008, at 3:57 PM, Robin Rosenberg wrote:
Show 22 quoted lines
> Den Tuesday 25 March 2008 19.25.58 skrev Joe Fiorini:
>> I am trying to generate a diff patch on my local dev box.  I want to
>> upload this patch to a server (running Windows Server 2008) and apply
>> it to my staging code.  The catch is: I cannot install git on the
>> server to accept the patch.  Therefore, I would like to use a generic
>> patching tool (such as patch from the GnuWin32 tools).  I tried
>> generating a unified diff with the following command:
>>
>> git diff -U > diff.patch
>>
>> and then tried to apply it using:
>>
>> patch -u -i ..\other_dir\diff.patch
>
> You can try git-apply instead of patch. It is a bit smarter (and not
> outsmarting itself either).
>
> -- robin
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jan Hudec· Mar 29, 2008, 18:46 UTC · re: Joe Fiorini · lore

Re: Apply patch on server w/o git

On Tue, Mar 25, 2008 at 23:03:58 -0400, Joe Fiorini wrote:
> Thanks for all your replies.  Unfortunately, I cannot use git apply  
> because I will not have access to git on the server where I'm doing the 
> patch.  I will try Jan's suggestion of ignoring whitespace.

By the way, why *can't* you use git there? There is win32 build of git (http://code.google.com/p/msysgit/) and if you can't get the repository over (but if you can get anything there, you should be able to get bundles there too), you can still use git-apply, since it can work without a repository as a pure patch replacement.

-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>

← back to recent threads