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

Re: How can I download a git commit as a diff patch?

From
Jakub Narebski <jnareb@gmail.com>
Date
Sep 30, 2009, 20:10 UTC
Message-ID
<m3tyyk9ost.fsf@localhost.localdomain>
In-Reply-To
<20090930213809.71c2a8e8@varda>
Alejandro Riveira Fernández    <ariveira@gmail.com> writes:
Show 18 quoted lines
> El Wed, 30 Sep 2009 15:00:14 -0400
> 
>  CCing git@vger.kernel.org ??
> 
> lsorense@csclub.uwaterloo.ca (Lennart Sorensen) escribió:
> 
>> On Wed, Sep 30, 2009 at 08:55:00AM -0700, Randy Dunlap wrote:
>>> On Wed, 30 Sep 2009 10:44:10 -0500 Andy wrote:
>>> 
>>>> I just want to down a particular git commit as a patch, not a git commit or
>>>> anything.  Yes, I can see the diffs on the web, but unless I am missing
>>>> something all are in unless html formats for me.  And cut and past from the
>>>> web page does not help either because some lines get mangled.  Is there some
>>>> site, or git itself, that would allow be to get the git commit as a simple
>>>> patch?
>>> 
>>> Look at the commitdiff using the web interface, then click on "raw" near
>>> the upper left corner.

Or better yet, if given installation of gitweb supports it, on the 'patch' link just on the right of 'raw' view. Such patch can be applied better by git-am (but both should work for GNU patch or git-apply).

Show 26 quoted lines
>> 
>> Of course some git diff's are not in a format that patch will like as
>> far as I can tell.
>> 
>> For example commit 6cdee2f96a97f6da26bd3759c3f8823332fbb438 which has
>> stuff like:
>> diff --cc drivers/net/ixp2000/ixpdev.c
>> index 588b44d,92fb823..1272434
>> --- a/drivers/net/ixp2000/ixpdev.c
>> +++ b/drivers/net/ixp2000/ixpdev.c
>> @@@ -67,9 -68,9 +68,9 @@@ static int ixpdev_xmit(struct sk_buff *
>>         ip->tx_queue_entries++;
>>         if (ip->tx_queue_entries == TX_BUF_COUNT_PER_CHAN)
>>                 netif_stop_queue(dev);
>> -       local_irq_enable();
>> +       local_irq_restore(flags);
>> 
>>  -      return 0;
>>  +      return NETDEV_TX_OK;
>>   }
>> 
>> 
>> 
>> Ehm, what does that mean?  patch doesn't like it.
>> 
>> Do git merges cause weird diffs?

Yes, by default for merges the 'commitdiff' view (and the 'raw' version, i.e. 'commitdiff_plain' view) shows **combined** diff of changes brought by merge (see git-diff manpage for details on this format).

For merge commit you have to choose which of parents you want to have diff from. Go to 'commit' view, there in the header would be two or more parents. Click on the 'diff' link beside chosen parent, check if it is the diff you want to get, and then click on 'patch' (or 'raw') link.

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: Alejandro Riveira FernándezNext: Lennart Sorensen
Message 2 of 5 in “Re: How can I download a git commit as a diff patch?”
  1. Alejandro Riveira FernándezSep 30, 2009
  2. Jakub NarebskiSep 30, 2009
  3. Lennart SorensenSep 30, 2009
  4. Jakub NarebskiSep 30, 2009
  5. Lennart SorensenSep 30, 2009

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.