{"thread":{"id":"43599","subject":"Re: [PATCH/RFC] gitweb: Default to $hash_base or HEAD for $hash in \"commit\" and \"commitdiff\" views","startedAt":"2006-11-08T22:11:34Z","lastAt":"2006-11-09T00:09:30Z","messageCount":4,"participants":["Junio C Hamano","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"297497","messageId":"200611082311.35161.jnareb@gmail.com","threadId":"43599","inReplyTo":null,"subject":"[PATCH/RFC] gitweb: Default to $hash_base or HEAD for $hash in \"commit\" and \"commitdiff\" views","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-11-08T22:11:34Z","receivedAt":"2006-11-08T22:11:34Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Set $hash parameter to $hash_base || \"HEAD\" if it is not set (if it is\nnot true to be more exact). This allows [hand-edited] URLs with 'action'\n\"commit\" or \"commitdiff\" but without 'hash' parameter.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nRFC because I want to ask if we should default to HEAD if hash is not\nprovided for commit and commitdiff views, or should we error out with\nmore reasonable error message.\n\n gitweb/gitweb.perl |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 3118cb0..8313517 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3391,6 +3391,7 @@ sub git_log {\n }\n \n sub git_commit {\n+\t$hash ||= $hash_base || \"HEAD\";\n \tmy %co = parse_commit($hash);\n \tif (!%co) {\n \t\tdie_error(undef, \"Unknown commit object\");\n@@ -3668,6 +3669,7 @@ sub git_blobdiff_plain {\n \n sub git_commitdiff {\n \tmy $format = shift || 'html';\n+\t$hash ||= $hash_base || \"HEAD\";\n \tmy %co = parse_commit($hash);\n \tif (!%co) {\n \t\tdie_error(undef, \"Unknown commit object\");\n-- \n1.4.3.4\n"},{"id":"298626","messageId":"7vvelpr34d.fsf@assigned-by-dhcp.cox.net","threadId":"43599","inReplyTo":"200611082311.35161.jnareb@gmail.com","subject":"Re: [PATCH/RFC] gitweb: Default to $hash_base or HEAD for $hash in \"commit\" and \"commitdiff\" views","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-11-08T22:21:38Z","receivedAt":"2006-11-08T22:21:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Set $hash parameter to $hash_base || \"HEAD\" if it is not set (if it is\n> not true to be more exact). This allows [hand-edited] URLs with 'action'\n> \"commit\" or \"commitdiff\" but without 'hash' parameter.\n>\n> Signed-off-by: Jakub Narebski <jnareb@gmail.com>\n> ---\n> RFC because I want to ask if we should default to HEAD if hash is not\n> provided for commit and commitdiff views, or should we error out with\n> more reasonable error message.\n\nProbably the latter; the user might be hand-crafting a URL\n(maybe learned a commit object name from mailing list and\ncutting and pasting) and mispasted the long hexadecimal string.\nSilently giving HEAD may leave the user confused than \"oops, we\ndo not see that commit object\".\n"},{"id":"297913","messageId":"200611082335.28296.jnareb@gmail.com","threadId":"43599","inReplyTo":"7vvelpr34d.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH/RFC] gitweb: Default to $hash_base or HEAD for $hash in \"commit\" and \"commitdiff\" views","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-11-08T22:35:27Z","receivedAt":"2006-11-08T22:35:27Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n>> Set $hash parameter to $hash_base || \"HEAD\" if it is not set (if it is\n>> not true to be more exact). This allows [hand-edited] URLs with 'action'\n>> \"commit\" or \"commitdiff\" but without 'hash' parameter.\n>>\n>> Signed-off-by: Jakub Narebski <jnareb@gmail.com>\n>> ---\n>> RFC because I want to ask if we should default to HEAD if hash is not\n>> provided for commit and commitdiff views, or should we error out with\n>> more reasonable error message.\n> \n> Probably the latter; the user might be hand-crafting a URL\n> (maybe learned a commit object name from mailing list and\n> cutting and pasting) and mispasted the long hexadecimal string.\n> Silently giving HEAD may leave the user confused than \"oops, we\n> do not see that commit object\".\n \nNo, if there is 'h' (hash) parameter provided, then gitweb tries\nto use this. HEAD is used _only_ if nether hash, nor hash_base\nare provided, i.e. for URL like below\n\n  URL?p=project.git;a=commit\n\ni.e. without neither 'h' nor 'hb'.\n\n\nBut if it is (it being defaulting to HEAD, _like git_) wrong solution,\nstill it would be better to show 'commit not provided' error instead of\ncurrent 'bad commit' error.\n-- \nJakub Narebski\n"},{"id":"295800","messageId":"7vejsdqy4l.fsf@assigned-by-dhcp.cox.net","threadId":"43599","inReplyTo":"200611082335.28296.jnareb@gmail.com","subject":"Re: [PATCH/RFC] gitweb: Default to $hash_base or HEAD for $hash in \"commit\" and \"commitdiff\" views","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-11-09T00:09:30Z","receivedAt":"2006-11-09T00:09:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n>> Probably the latter; the user might be hand-crafting a URL\n>> (maybe learned a commit object name from mailing list and\n>> cutting and pasting) and mispasted the long hexadecimal string.\n>> Silently giving HEAD may leave the user confused than \"oops, we\n>> do not see that commit object\".\n>  \n> No, if there is 'h' (hash) parameter provided, then gitweb tries\n> to use this. HEAD is used _only_ if nether hash, nor hash_base\n> are provided, i.e. for URL like below\n>\n>   URL?p=project.git;a=commit\n>\n> i.e. without neither 'h' nor 'hb'.\n\nAh, that one I agree it makes sense to use HEAD.  Also I am all\nfor giving a more readable error message.\n"}]}