gitweb: Start search from HEAD
PATCH 1/1 gitweb: Start search from HEAD
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.
---
This patch is against the "next" branch.
gitweb/gitweb.cgi | 11 +---------- 1 files changed, 1 insertions(+), 10 deletions(-)
gitweb/gitweb.cgi +1 -10
@@ -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.");
Signature · 1 line
1.4.0.gd281
Quoted 3 lines · Timo Hirvonen
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?
PATCH 1/1 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.
---
Quoted 8 lines · Junio C Hamano
Quoted 3 lines · Timo Hirvonen
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(-)
gitweb/gitweb.cgi +3 -1
@@ -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";
Signature · 1 line
1.4.0.gd281