Allow for creating raw diffs with cgit_print_diff()
This adds a parameter to cgit_print_diff() to create raw diffs, using the same format as `git diff <commit>`. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
This commit is contained in:
förälder
747b035dda
incheckning
9003cc172a
2
cmd.c
2
cmd.c
@ -57,7 +57,7 @@ static void commit_fn(struct cgit_context *ctx)
|
|||||||
|
|
||||||
static void diff_fn(struct cgit_context *ctx)
|
static void diff_fn(struct cgit_context *ctx)
|
||||||
{
|
{
|
||||||
cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path, 1);
|
cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void info_fn(struct cgit_context *ctx)
|
static void info_fn(struct cgit_context *ctx)
|
||||||
|
@ -137,7 +137,7 @@ void cgit_print_commit(char *hex, const char *prefix)
|
|||||||
tmp = sha1_to_hex(commit->parents->item->object.sha1);
|
tmp = sha1_to_hex(commit->parents->item->object.sha1);
|
||||||
else
|
else
|
||||||
tmp = NULL;
|
tmp = NULL;
|
||||||
cgit_print_diff(ctx.qry.sha1, tmp, prefix, 0);
|
cgit_print_diff(ctx.qry.sha1, tmp, prefix, 0, 0);
|
||||||
}
|
}
|
||||||
strbuf_release(¬es);
|
strbuf_release(¬es);
|
||||||
cgit_free_commitinfo(info);
|
cgit_free_commitinfo(info);
|
||||||
|
10
ui-diff.c
10
ui-diff.c
@ -358,7 +358,7 @@ void cgit_print_diff_ctrls()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cgit_print_diff(const char *new_rev, const char *old_rev,
|
void cgit_print_diff(const char *new_rev, const char *old_rev,
|
||||||
const char *prefix, int show_ctrls)
|
const char *prefix, int show_ctrls, int raw)
|
||||||
{
|
{
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
@ -398,6 +398,14 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (raw) {
|
||||||
|
ctx.page.mimetype = "text/plain";
|
||||||
|
cgit_print_http_headers(&ctx);
|
||||||
|
cgit_diff_tree(old_rev_sha1, new_rev_sha1, filepair_cb_raw,
|
||||||
|
prefix, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
use_ssdiff = ctx.qry.has_ssdiff ? ctx.qry.ssdiff : ctx.cfg.ssdiff;
|
use_ssdiff = ctx.qry.has_ssdiff ? ctx.qry.ssdiff : ctx.cfg.ssdiff;
|
||||||
|
|
||||||
if (show_ctrls)
|
if (show_ctrls)
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
extern void cgit_print_diff_ctrls();
|
extern void cgit_print_diff_ctrls();
|
||||||
|
|
||||||
extern void cgit_print_diff(const char *new_hex, const char *old_hex,
|
extern void cgit_print_diff(const char *new_hex, const char *old_hex,
|
||||||
const char *prefix, int show_ctrls);
|
const char *prefix, int show_ctrls, int raw);
|
||||||
|
|
||||||
extern struct diff_filespec *cgit_get_current_old_file(void);
|
extern struct diff_filespec *cgit_get_current_old_file(void);
|
||||||
extern struct diff_filespec *cgit_get_current_new_file(void);
|
extern struct diff_filespec *cgit_get_current_new_file(void);
|
||||||
|
Laddar…
Referens i nytt ärende
Block a user