RFE: download patch between arbitrary revisions

Lukas Fleischer cgit at cryptocrack.de
Thu Jun 13 23:58:10 CEST 2013

On Mon, Jun 03, 2013 at 07:49:53PM +0100, John Keeping wrote:
> On Sun, Jun 02, 2013 at 09:19:11PM -0400, Konstantin Ryabitsev wrote:
> > There is currently a way to render a diff between two arbitrary objects,
> > e.g.:
> > 
> > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/diff/?id=v3.10-rc4&id2=v3.10-rc3
> > 
> > However, there doesn't appear to be a way to download a patch in the
> > same way -- it will only make patch against id's parent. E.g.:
> > 
> > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/patch/?id=v3.10-rc4&id2=v3.10-rc3
> > 
> > Any way we can make the behaviour of patch match that of diff?
> I had a quick look at this and changing the patch output is really easy,
> but the top of the output is now completely wrong since it displays the
> message from the "id" commit.  I'm not sure what to do about this;
> clearly it is useful to be able to get the patch output between two
> arbitrary points in a raw format (not HTML) but I don't know what to do
> about the commit message and headers.  Perhaps we can do something like:
>     if "id2" is specified:
>         print shortlog output
>     else:
>         do what we currently do
> but I don't know how much code would be needed for that.

Well, the problem, obviously, is that we are currently using
git-format-patch(1)-style patches for single commits. There are three
possible solutions that come into my mind: 

1. Use a plain diff for multiple patches (like `git diff HEAD~10..`).

2. Create a patch for a squash commit (like `git merge --squash`
   followed by `git format-patch`). Basically what John suggested above.

3. Create a bunch of `git am` compatible patches (like `git format-patch
   --stdout HEAD~10..`).

I personally think that it might be best to create a new parameter (or
an entirely new URL) to switch between creating plain diffs (see 1) and
git-format-patch(1)-like patches (see 3). That way, we would be able to
provide both patches that mirror exactly what is in the repos and simple
patches that summarize a couple of commits.

> Here's the patch in case anyone wants to try it (slightly bigger than
> strictly necessary because I renamed hex -> new_rev for consistency with
> cgit_print_diff):
> [...]

More information about the CGit mailing list