git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/5] gitweb: Default to $hash_base or HEAD for $hash in "commit" and "commitdiff"

From
Jakub Narebski <jnareb@gmail.com>
Date
Nov 18, 2006, 22:35 UTC
Message-ID
<11638893462704-git-send-email-jnareb@gmail.com>
In-Reply-To
<1163889342877-git-send-email-jnareb@gmail.com>

Set $hash parameter to $hash_base || "HEAD" if it is not set (if it is not true to be more exact). This allows [hand-edited] URLs with 'action' "commit" or "commitdiff" but without 'hash' parameter.

If there is 'h' (hash) parameter provided, then gitweb tries
to use this. HEAD is used _only_ if nether hash, nor hash_base
are provided, i.e. for URL like below
  URL?p=project.git;a=commit
i.e. without neither 'h' nor 'hb'.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index eadaa31..5875ba0 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3450,6 +3450,7 @@ sub git_log {
 }
 
 sub git_commit {
+	$hash ||= $hash_base || "HEAD";
 	my %co = parse_commit($hash);
 	if (!%co) {
 		die_error(undef, "Unknown commit object");
@@ -3727,6 +3728,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");
-- 
1.4.3.4
Previous: Jakub NarebskiNext: Jakub Narebski
Message 6 of 7 in “gitweb: New patchset view corrections and improvements, and few other things”
  1. 0/5 gitweb: New patchset view corrections and improvements, and few other thingsJakub Narebski, Nov 18, 2006
  2. 1/5 gitweb: Protect against possible warning in git_commitdiffJakub Narebski, Nov 18, 2006
  3. Jakub NarebskiNov 18, 2006
  4. 2/5 gitweb: Buffer diff header to deal with split patches + git_patchset_body refactoringJakub Narebski, Nov 18, 2006
  5. 3/5 gitweb: New improved formatting of chunk header in diffJakub Narebski, Nov 18, 2006
  6. 4/5 gitweb: Default to $hash_base or HEAD for $hash in "commit" and "commitdiff"Jakub Narebski, Nov 18, 2006
  7. 5/5 gitweb: Add an option to href() to return full URLJakub Narebski, Nov 18, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.