# [PATCH] gitweb: Start search from HEAD

3 messages from 2006-06-20 to 2006-06-20. Participants: Timo Hirvonen, Junio C Hamano.
Thread: https://gitlist.dev/t/4587

## Timo Hirvonen, 2006-06-20 12:25

Subject: [PATCH] gitweb: Start search from HEAD
Message-ID: <20060620152515.23e59396.tihirvon@gmail.com>
URL: https://gitlist.dev/e/20060620152515.23e59396.tihirvon%40gmail.com

```
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(-)

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, 2006-06-20 12:31

Subject: Re: [PATCH] gitweb: Start search from HEAD
Message-ID: <7v64iw80uo.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v64iw80uo.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20060620152515.23e59396.tihirvon@gmail.com>

```
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, 2006-06-20 13:41

Subject: [PATCH] gitweb: Use $hash_base as $search_hash if possible
Message-ID: <20060620164105.7276a45f.tihirvon@gmail.com>
URL: https://gitlist.dev/e/20060620164105.7276a45f.tihirvon%40gmail.com
In-Reply-To: <7v64iw80uo.fsf@assigned-by-dhcp.cox.net>

```
$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(-)

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

```
