google / gitiles

A simple browser for Git repositories.
https://gerrit.googlesource.com/gitiles/
Other
582 stars 174 forks source link

Download original patch as exported by git format-patch #189

Open ao2 opened 5 years ago

ao2 commented 5 years ago

Hi,

while it is possible to download the raw content of files from gitiles somehow (https://github.com/google/gitiles/issues/106#issuecomment-462030196) I see no easy way to download the original committed patch, for example as exported by git format-patch.

Most of the other git repository browsers offer this functionality.

I may download the commit message and the diff separately using format=TEXT and then recompose the commit and try to apply it locally with git am, or I can follow the link to gerrit (when available) and navigate the UI and get to the patch download link there, but all this seems like more work than it should be.

Maybe a format=PATCH option can be added? Or maybe the diff view should include the git commit info for format=TEXT and format=JSON too, like it does for format=HTML? Ideally the output should be in a format compatible with git format-patch/git am.

This issue is specifically about patches, I would not consider it to be a duplicate of other issues which are about files: https://github.com/google/gitiles/issues/7 https://github.com/google/gitiles/issues/99 https://github.com/google/gitiles/issues/106

Thanks, Antonio

ao2 commented 2 years ago

FWIW here is a script that works around the issue by combining the commit message from format=JSON and the diff from format=TEXT and adjusts the date to be accepted by git am: gitiles-format-patch.sh.gz

It can be used like this:

./gitiles-format-patch.sh https://gerrit.googlesource.com/gitiles/+/a7b74f2f3edc61124c8ae73f96dd9ba8455ea524