diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index bf58c3bac8f..19b3d36d159 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3429,6 +3429,7 @@ sub git_log {
 }
 
 sub git_commit {
+	$hash ||= $hash_base || "HEAD";
 	my %co = parse_commit($hash);
 	if (!%co) {
 		die_error(undef, "Unknown commit object");
@@ -3706,6 +3707,7 @@ sub git_blobdiff_plain {
 
 sub git_commitdiff {
 	my $format = shift || 'html';
+	$hash ||= $hash_base || "HEAD";
 	my %co = parse_commit($hash);
 	if (!%co) {
 		die_error(undef, "Unknown commit object");