diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Add `max-patch-count` to bound the patch view
Diffstat (limited to '')
-rw-r--r--source/cgit.c3
-rw-r--r--source/cgit.h1
-rw-r--r--source/ui-patch.c5
3 files changed, 9 insertions, 0 deletions
diff --git a/source/cgit.c b/source/cgit.c
index f83d15d..5af2232 100644
--- a/source/cgit.c
+++ b/source/cgit.c
@@ -269,6 +269,8 @@ static void config_cb(const char *name, const char *value)
ctx.cfg.max_repo_count = INT_MAX;
} else if (!strcmp(name, "max-commit-count"))
ctx.cfg.max_commit_count = atoi(value);
+ else if (!strcmp(name, "max-patch-count"))
+ ctx.cfg.max_patch_count = atoi(value);
else if (!strcmp(name, "project-list"))
ctx.cfg.project_list = strdup_first_line(expand_macros(value));
else if (!strcmp(name, "scan-path"))
@@ -422,6 +424,7 @@ static void prepare_context(void)
ctx.cfg.enable_git_config = 0;
ctx.cfg.max_repo_count = 50;
ctx.cfg.max_commit_count = 50;
+ ctx.cfg.max_patch_count = 50;
ctx.cfg.max_diff_files = 200; /* larger commits render stat only */
ctx.cfg.max_diff_lines = 1000; /* larger file diffs link out */
ctx.cfg.max_msg_len = 80;
diff --git a/source/cgit.h b/source/cgit.h
index aaf90f8..b7caaf5 100644
--- a/source/cgit.h
+++ b/source/cgit.h
@@ -250,6 +250,7 @@ struct cgit_config {
int max_atom_items;
int max_repo_count;
int max_commit_count;
+ int max_patch_count;
int max_diff_files;
int max_diff_lines;
int max_msg_len;
diff --git a/source/ui-patch.c b/source/ui-patch.c
index 9395769..6d8a8ad 100644
--- a/source/ui-patch.c
+++ b/source/ui-patch.c
@@ -91,6 +91,11 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
if (prefix)
rev.diffopt.stat_sep = fmt("(limited to '%s')\n\n", prefix);
setup_revisions(rev_argc, rev_argv, &rev, NULL);
+ // A single commit resolves to a parent..commit range, so this only
+ // bounds an explicit id/id2 range and keeps one request from
+ // emitting a patch for the entire history.
+ if (ctx.cfg.max_patch_count > 0)
+ rev.max_count = ctx.cfg.max_patch_count;
prepare_revision_walk(&rev);
while ((commit = get_revision(&rev)) != NULL) {