Skip to contentSkip to conversation

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

DISCUSSION Andy 5 participants 8 messages Sep 30, 2009 Network drivers

lore
Share & tools
lore

Andy

author
#0 lore raw

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?

Thanks,

Andy

#1 lore raw
Quoted 6 lines · 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.

---
~Randy

#2 lore raw
Quoted 11 lines · Randy Dunlap
Quoted 6 lines · 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.

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:

drivers/net/ixp2000/ixpdev.c +0 -0
diff --cc drivers/net/ixp2000/ixpdev.c
index 588b44d,92fb823..1272434
@@@ -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?

Signature · 1 line
Len Sorensen
#3 lore raw

El Wed, 30 Sep 2009 15:00:14 -0400

CCing [email protected] ??

Quoted 39 lines · [email protected] (Lennart Sorensen) escribió:
Quoted 11 lines · Randy Dunlap
Quoted 6 lines · 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.

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:

drivers/net/ixp2000/ixpdev.c +1 -1
diff --cc drivers/net/ixp2000/ixpdev.c
index 588b44d,92fb823..1272434
@@@ -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?

#4 lore raw
Quoted 18 lines · Alejandro Riveira Fernández

El Wed, 30 Sep 2009 15:00:14 -0400

CCing [email protected] ??

Quoted 12 lines · [email protected] (Lennart Sorensen) escribió:
Quoted 11 lines · Randy Dunlap
Quoted 6 lines · 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).

Quoted 23 lines
Quoted 23 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:

drivers/net/ixp2000/ixpdev.c +1 -1
diff --cc drivers/net/ixp2000/ixpdev.c
index 588b44d,92fb823..1272434
@@@ -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;
  }
Quoted 3 lines
Quoted 3 lines

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.

Signature · 3 lines
Jakub Narebski
Poland
ShadeHawk on #git
#5 lore raw
Quoted 10 lines · Jakub Narebski

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).

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).

Quoted 5 lines

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.

Is there a git command to show me a diff I can use with patch if I want to select a given patch as long as I can tell it which tree I want to follow? I don't care to use gitweb if I can do it with the command line git.

git show obviously shows the git combined diff format, at least by default.

Or is the idea of trying to use the diff from the merge commit just silly in the first place?

Signature · 1 line
Len Sorensen
#6 lore raw
Quoted 18 lines · Lennart Sorensen
Quoted 10 lines · Jakub Narebski

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).

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).

Quoted 5 lines

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.

Quoted 3 lines

Is there a git command to show me a diff I can use with patch if I want to select a given patch as long as I can tell it which tree I want to follow? I don't care to use gitweb if I can do it with the command line git.

You can specify parent explicitely: "git diff <rev>^1 <rev>" for diff to first parent, e.g. "git diff HEAD^ HEAD".

Quoted 5 lines

git show obviously shows the git combined diff format, at least by default.

Or is the idea of trying to use the diff from the merge commit just silly in the first place?

Just so you know that this single diff is not enough to redo a merge. It is only partial information.

BTW. there is also "git diff-tree -m <rev>") to show diff to *all* parents at once:

-m By default, git-diff-tree --stdin does not show differences for
merge commits. With this flag, it shows differences to that commit from all of its parents. See also -c.

Signature · 2 lines
Jakub Narebski
Poland
#7 lore raw
Quoted 5 lines · Jakub Narebski

You can specify parent explicitely: "git diff <rev>^1 <rev>" for diff to first parent, e.g. "git diff HEAD^ HEAD".

Just so you know that this single diff is not enough to redo a merge. It is only partial information.

Yes certainly in some cases. Often you can pick specific patches and a few patches they depend on to try and fix something, but for bigger changes it doesn't work. I am actually surprised it has been this long before I ever saw one of these combined diff's. I must have been lucky so far.

Quoted 6 lines

BTW. there is also "git diff-tree -m <rev>") to show diff to *all* parents at once:

-m By default, git-diff-tree --stdin does not show differences for
merge commits. With this flag, it shows differences to that commit from all of its parents. See also -c.

I will have to try that one out.

Signature · 1 line
Len Sorensen