threads / patch / 4587

patchgitweb: Start search from HEAD

Subject: [PATCH] gitweb: Start search from HEAD

## tl;dr

3 messages between Jun 20, 2006 and Jun 20, 2006. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Timo Hirvonen· Jun 20, 2006, 12:25 UTC · lore

Starting search from whatever the current "h" parameter points to is wrong. Sometimes it doesn't give all the expected results or may even fail if h points to an object which is not a commit.

Signed-off-by: Timo Hirvonen <tihirvon@gmail.com>
---
 This patch is against the "next" branch.
 gitweb/gitweb.cgi |   11 +----------
 1 files changed, 1 insertions(+), 10 deletions(-)
Show changes to gitweb/gitweb.cgi +1 −10
diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi
index 78e6dd0..3ad23a3 100755
--- a/gitweb/gitweb.cgi
+++ b/gitweb/gitweb.cgi
@@ -292,14 +292,7 @@ EOF
 		if (!defined $searchtext) {
 			$searchtext = "";
 		}
-		my $search_hash;
-		if (defined $hash) {
-			$search_hash = $hash;
-		} else {
-			$search_hash  = "HEAD";
-		}
 		$cgi->param("a", "search");
-		$cgi->param("h", $search_hash);
 		print $cgi->startform(-method => "get", -action => $my_uri) .
 		      "<div class=\"search\">\n" .
 		      $cgi->hidden(-name => "p") . "\n" .
@@ -2328,9 +2321,7 @@ sub git_search {
 	if (!defined $searchtext) {
 		die_error("", "Text field empty.");
 	}
-	if (!defined $hash) {
-		$hash = git_read_head($project);
-	}
+	$hash = "HEAD";
 	my %co = git_read_commit($hash);
 	if (!%co) {
 		die_error(undef, "Unknown commit object.");
-- 
1.4.0.gd281
Junio C Hamano· Jun 20, 2006, 12:31 UTC · re: Timo Hirvonen · lore

Re: [PATCH] gitweb: Start search from HEAD

Timo Hirvonen <tihirvon@gmail.com> writes:
> Starting search from whatever the current "h" parameter points to is
> wrong.  Sometimes it doesn't give all the expected results or may even
> fail if h points to an object which is not a commit.

If h is not a commit, perhaps, but wouldn't you expect it to find things from "next" branch if "h" points at it?

Timo Hirvonen· Jun 20, 2006, 13:41 UTC · re: Junio C Hamano · lore

[PATCH] gitweb: Use $hash_base as $search_hash if possible

$hash (h parameter) does not always point to a commit. Use $hash_base as $search_hash when it is defined.

Signed-off-by: Timo Hirvonen <tihirvon@gmail.com>
---
  Junio C Hamano <junkio@cox.net> wrote:
  
  > Timo Hirvonen <tihirvon@gmail.com> writes:
  > 
  > > Starting search from whatever the current "h" parameter points to is
  > > wrong.  Sometimes it doesn't give all the expected results or may even
  > > fail if h points to an object which is not a commit.
  > 
  > If h is not a commit, perhaps, but wouldn't you expect it to
  > find things from "next" branch if "h" points at it?
  I did not change it to start search from tip of the branch. The
  current behavior is somewhat confusing but at least it is consistent
  with rest of gitweb.  For example clicking shortlog link from commit
  view shows the current commit at top of the list, not tip of the
  current branch.
 gitweb/gitweb.cgi |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
Show changes to gitweb/gitweb.cgi +3 −1
diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi
index 78e6dd0..7318512 100755
--- a/gitweb/gitweb.cgi
+++ b/gitweb/gitweb.cgi
@@ -293,7 +293,9 @@ EOF
 			$searchtext = "";
 		}
 		my $search_hash;
-		if (defined $hash) {
+		if (defined $hash_base) {
+			$search_hash = $hash_base;
+		} elsif (defined $hash) {
 			$search_hash = $hash;
 		} else {
 			$search_hash  = "HEAD";
-- 
1.4.0.gd281

← back to recent threads