From: john at keeping.me.uk (John Keeping)
Subject: RFE: download patch between arbitrary revisions
Date: Mon, 3 Jun 2013 19:49:53 +0100 [thread overview]
Message-ID: <20130603184953.GK1072@serenity.lan> (raw)
In-Reply-To: <51ABEF0F.3030909@kernel.org>
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.
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):
-- >8 --
diff --git a/cmd.c b/cmd.c
index abe8e46..7e8b168 100644
--- a/cmd.c
+++ b/cmd.c
@@ -93,7 +93,7 @@ static void repolist_fn(struct cgit_context *ctx)
static void patch_fn(struct cgit_context *ctx)
{
- cgit_print_patch(ctx->qry.sha1, ctx->qry.path);
+ cgit_print_patch(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path);
}
static void plain_fn(struct cgit_context *ctx)
diff --git a/ui-patch.c b/ui-patch.c
index fbb92cc..ff8ee34 100644
--- a/ui-patch.c
+++ b/ui-patch.c
@@ -83,28 +83,30 @@ static void filepair_cb(struct diff_filepair *pair)
html("Binary files differ\n");
}
-void cgit_print_patch(char *hex, const char *prefix)
+void cgit_print_patch(const char *new_rev, const char *old_rev, const char *prefix)
{
struct commit *commit;
struct commitinfo *info;
unsigned char sha1[20], old_sha1[20];
char *patchname;
- if (!hex)
- hex = ctx.qry.head;
+ if (!new_rev)
+ new_rev = ctx.qry.head;
- if (get_sha1(hex, sha1)) {
- cgit_print_error("Bad object id: %s", hex);
+ if (get_sha1(new_rev, sha1)) {
+ cgit_print_error("Bad object id: %s", new_rev);
return;
}
commit = lookup_commit_reference(sha1);
if (!commit) {
- cgit_print_error("Bad commit reference: %s", hex);
+ cgit_print_error("Bad commit reference: %s", new_rev);
return;
}
info = cgit_parse_commit(commit);
- if (commit->parents && commit->parents->item)
+ if (old_rev)
+ get_sha1(old_rev, old_sha1);
+ else if (commit->parents && commit->parents->item)
hashcpy(old_sha1, commit->parents->item->object.sha1);
else
hashclr(old_sha1);
diff --git a/ui-patch.h b/ui-patch.h
index 1641cea..e833042 100644
--- a/ui-patch.h
+++ b/ui-patch.h
@@ -1,6 +1,6 @@
#ifndef UI_PATCH_H
#define UI_PATCH_H
-extern void cgit_print_patch(char *hex, const char *prefix);
+extern void cgit_print_patch(const char *new_rev, const char *old_rev, const char *prefix);
#endif /* UI_PATCH_H */
next prev parent reply other threads:[~2013-06-03 18:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-03 1:19 mricon
2013-06-03 18:49 ` john [this message]
2013-06-13 21:58 ` cgit
2013-06-13 22:21 ` john
2013-06-16 7:56 ` cgit
2013-06-16 10:11 ` john
2013-06-16 19:18 ` cgit
2013-08-06 19:23 ` mricon
2013-08-06 21:40 ` cgit
2013-08-12 19:05 ` Jason
2013-08-14 8:56 ` cgit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130603184953.GK1072@serenity.lan \
--to=cgit@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).