diff options
author | John Keeping | 2014-06-28 15:55:06 +0200 |
---|---|---|
committer | Jason A. Donenfeld | 2014-06-28 15:57:02 +0200 |
commit | 4046e8ef66225928a4f0d2cd71479e401faf7c3b (patch) | |
tree | c460eb32a801d2f31b4f3b99b0cfd4107029c64f /ui-log.c | |
parent | 79c985e13c10b498c3ea62f4607c2e2a460c3b10 (diff) | |
download | cgit-4046e8ef66225928a4f0d2cd71479e401faf7c3b.tar.gz cgit-4046e8ef66225928a4f0d2cd71479e401faf7c3b.tar.bz2 cgit-4046e8ef66225928a4f0d2cd71479e401faf7c3b.zip |
ui-log: ignore unhandled arguments
If you search for a bogus range string here:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/log/
Using something like "range" and "qwerty123456", it returns an "Internal
Server Error" and the following in the logs:
> [Tue Jun 10 17:45:32 2014] [error] [client 172.21.1.6] fatal:
> ambiguous argument 'qwerty123456': unknown revision or path not in the
> working tree., referer:
> http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/
> [Tue Jun 10 17:45:32 2014] [error] [client 172.21.1.6] Use '--' to
> separate paths from revisions, like this:, referer:
> http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/
> [Tue Jun 10 17:45:32 2014] [error] [client 172.21.1.6] 'git <command>
> [<revision>...] -- [<file>...]', referer:
> http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/
> [Tue Jun 10 17:45:32 2014] [error] [client 172.21.1.6] Premature end
> of script headers: cgit, referer:
> http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/
The cache will kick in, so if you search for the same string again,
it'll show an empty range, so you have to change the bogus strings each
time.
This is because we just pass the arguments straight to Git's revision
parsing machinery which die()s if it cannot parse an argument, printing
the above to stderr and exiting.
The patch below makes it a bit friendlier by just ignoring unhandled
arguments, but I can't see an easy way to report errors when we can't
parse revision arguments without losing the flexibility of supporting
all of the revision specifiers supported by Git.
Reported-by: Konstantin Ryabitsev <mricon@kernel.org>
Diffstat (limited to 'ui-log.c')
-rw-r--r-- | ui-log.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -337,16 +337,16 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern | |||
337 | else if (commit_sort == 2) | 337 | else if (commit_sort == 2) |
338 | argv_array_push(&rev_argv, "--topo-order"); | 338 | argv_array_push(&rev_argv, "--topo-order"); |
339 | 339 | ||
340 | if (path) { | 340 | argv_array_push(&rev_argv, "--"); |
341 | argv_array_push(&rev_argv, "--"); | 341 | if (path) |
342 | argv_array_push(&rev_argv, path); | 342 | argv_array_push(&rev_argv, path); |
343 | } | ||
344 | 343 | ||
345 | init_revisions(&rev, NULL); | 344 | init_revisions(&rev, NULL); |
346 | rev.abbrev = DEFAULT_ABBREV; | 345 | rev.abbrev = DEFAULT_ABBREV; |
347 | rev.commit_format = CMIT_FMT_DEFAULT; | 346 | rev.commit_format = CMIT_FMT_DEFAULT; |
348 | rev.verbose_header = 1; | 347 | rev.verbose_header = 1; |
349 | rev.show_root_diff = 0; | 348 | rev.show_root_diff = 0; |
349 | rev.ignore_missing = 1; | ||
350 | setup_revisions(rev_argv.argc, rev_argv.argv, &rev, NULL); | 350 | setup_revisions(rev_argv.argc, rev_argv.argv, &rev, NULL); |
351 | load_ref_decorations(DECORATE_FULL_REFS); | 351 | load_ref_decorations(DECORATE_FULL_REFS); |
352 | rev.show_decorations = 1; | 352 | rev.show_decorations = 1; |