List for cgit developers and users
 help / color / mirror / Atom feed
* Error when searching for a bogus range
@ 2014-06-10 18:05 mricon
  2014-06-10 20:59 ` john
  0 siblings, 1 reply; 5+ messages in thread
From: mricon @ 2014-06-10 18:05 UTC (permalink / raw)


Hi, all:

cgit-0.10.1-1.el6 (EPEL version)

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.


Best,
-- 
Konstantin Ryabitsev
Senior Systems Administrator
Linux Foundation Collab Projects
Montr?al, Qu?bec

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 538 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20140610/413948bd/attachment.asc>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Error when searching for a bogus range
  2014-06-10 18:05 Error when searching for a bogus range mricon
@ 2014-06-10 20:59 ` john
  2014-06-10 21:07   ` peter
  0 siblings, 1 reply; 5+ messages in thread
From: john @ 2014-06-10 20:59 UTC (permalink / raw)


On Tue, Jun 10, 2014 at 02:05:14PM -0400, Konstantin Ryabitsev wrote:
> cgit-0.10.1-1.el6 (EPEL version)
> 
> 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/

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.

-- >8 --
diff --git a/ui-log.c b/ui-log.c
index 499534c..4cb26bc 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -337,16 +337,16 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
 	else if (commit_sort == 2)
 		argv_array_push(&rev_argv, "--topo-order");
 
-	if (path) {
-		argv_array_push(&rev_argv, "--");
+	argv_array_push(&rev_argv, "--");
+	if (path)
 		argv_array_push(&rev_argv, path);
-	}
 
 	init_revisions(&rev, NULL);
 	rev.abbrev = DEFAULT_ABBREV;
 	rev.commit_format = CMIT_FMT_DEFAULT;
 	rev.verbose_header = 1;
 	rev.show_root_diff = 0;
+	rev.ignore_missing = 1;
 	setup_revisions(rev_argv.argc, rev_argv.argv, &rev, NULL);
 	load_ref_decorations(DECORATE_FULL_REFS);
 	rev.show_decorations = 1;


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Error when searching for a bogus range
  2014-06-10 20:59 ` john
@ 2014-06-10 21:07   ` peter
  2014-06-10 22:41     ` Jason
  0 siblings, 1 reply; 5+ messages in thread
From: peter @ 2014-06-10 21:07 UTC (permalink / raw)


On Tuesday 10 June 2014 21:59:39 John Keeping wrote:
> On Tue, Jun 10, 2014 at 02:05:14PM -0400, Konstantin Ryabitsev wrote:
> > cgit-0.10.1-1.el6 (EPEL version)
> > 
> > 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/
> 
> 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.

The patch looks good to me, it reduces the error to just the "fatal: ..."
message. The error can be reproduced with:

echo scan-path=. > cgitrc
CGIT_CONFIG=cgitrc PATH_INFO=/.git/log/ QUERY_STRING=qt=range\&q=foo ./cgit
(assuming .git/ in $PWD)

The accepted argument is the same as the one passed to `git rev-list`.
Unless you manually check for the possible formats (v3.15~10..v3.15,
v3.13.., ..next, foo...bar, you won't be able to catch the error (as
John noted).

Regards,
Peter

> -- >8 --
> diff --git a/ui-log.c b/ui-log.c
> index 499534c..4cb26bc 100644
> --- a/ui-log.c
> +++ b/ui-log.c
> @@ -337,16 +337,16 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
>  	else if (commit_sort == 2)
>  		argv_array_push(&rev_argv, "--topo-order");
>  
> -	if (path) {
> -		argv_array_push(&rev_argv, "--");
> +	argv_array_push(&rev_argv, "--");
> +	if (path)
>  		argv_array_push(&rev_argv, path);
> -	}
>  
>  	init_revisions(&rev, NULL);
>  	rev.abbrev = DEFAULT_ABBREV;
>  	rev.commit_format = CMIT_FMT_DEFAULT;
>  	rev.verbose_header = 1;
>  	rev.show_root_diff = 0;
> +	rev.ignore_missing = 1;
>  	setup_revisions(rev_argv.argc, rev_argv.argv, &rev, NULL);
>  	load_ref_decorations(DECORATE_FULL_REFS);
>  	rev.show_decorations = 1;


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Error when searching for a bogus range
  2014-06-10 21:07   ` peter
@ 2014-06-10 22:41     ` Jason
  2014-06-28 13:56       ` Jason
  0 siblings, 1 reply; 5+ messages in thread
From: Jason @ 2014-06-10 22:41 UTC (permalink / raw)


Cool. Merges will happen last week in June. Thanks for sending this. Noted
in my list.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20140611/547ac8f4/attachment.html>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Error when searching for a bogus range
  2014-06-10 22:41     ` Jason
@ 2014-06-28 13:56       ` Jason
  0 siblings, 0 replies; 5+ messages in thread
From: Jason @ 2014-06-28 13:56 UTC (permalink / raw)


Thanks John. I've merged this patch here:
http://git.zx2c4.com/cgit/commit/?id=4046e8ef66225928a4f0d2cd71479e401faf7c3b

I'll probably do a release soon that includes this.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20140628/35fbf1db/attachment.html>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-28 13:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-10 18:05 Error when searching for a bogus range mricon
2014-06-10 20:59 ` john
2014-06-10 21:07   ` peter
2014-06-10 22:41     ` Jason
2014-06-28 13:56       ` Jason

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).