git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] gitweb generates wrong links in grep search results (git_search_files)
@ 2012-01-02 13:29 Thomas Perl
  2012-01-04  0:28 ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Perl @ 2012-01-02 13:29 UTC (permalink / raw)
  To: git

Hi,

I think I found a bug in gitweb when grep'ing for text in a branch
different from "master". Here's how to reproduce it:

1. Have a project with a master branch and a branch different from master
2. Start gitweb for that project (e.g. using "git instaweb") and open
it in a web browser
3. Switch to the non-master branch (e.g.
http://127.0.0.1:1234/?p=.git;a=shortlog;h=refs/heads/mynonmasterbranch)
4. In the top right search box, select "grep" in the combo box and
enter a text that only appears in the non-master branch
5. Submit the search by pressing enter, you should be at:
http://127.0.0.1:1234/?p=.git&a=search&h=refs%2Fheads%2Fmynonmasterbranch&st=grep&s=somesearchtext

ACTUAL RESULT
In that list of results, you should now see some files matching the
search - note that the links for the file names and the line numbers
go to e.g. http://127.0.0.1:1234/?p=.git;a=blob;f=somefile.txt for a
file "somefile.txt". The links therefore go to the master branch,
while the search results refer to the non-master branch.

EXPECTED RESULT
The link should (presumably) go to
http://127.0.0.1:1234/?p=.git;a=blob;hb=refs%2Fheads%2Fmynonmasterbranch;f=somefile.txt
so that when the link is clicked, the right file (somefile.txt in
mynonmasterbranch) is shown.

I also investigated a bit in where the problem happens, and nailed it
down to: gitweb/gitweb.perl, sub git_search_files, line 5871 in commit
17b4e93d5b849293e6a3659bbc4075ed8a6e97e2 (current master tip of
https://github.com/gitster/git). I haven't looked at the intrinsics of
the "href" sub, but I believe that it should somehow get the "h"
parameter from the original page and incorporate it into the final
link (as "hb" parameter?) to the file. The same fix that is applied
there then also needs to be applied at line 5891 (same commit, same
file).

No patch, because after several tries, I didn't get it to work, my
Perl foo might not be up to the task, and I believe that someone more
familiar with gitweb's code base might have an easier time to fix
this.

Thanks,
Thomas

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-01-13 19:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-02 13:29 [BUG] gitweb generates wrong links in grep search results (git_search_files) Thomas Perl
2012-01-04  0:28 ` Junio C Hamano
2012-01-04 16:21   ` Jakub Narębski
2012-01-05 20:26     ` [PATCH 1/2] gitweb: Fix file links in "grep" search Jakub Narebski
2012-01-05 20:32       ` [PATCH 2/2] gitweb: Harden "grep" search against filenames with ':' Jakub Narebski
2012-01-13 14:09       ` [PATCH 1/2] gitweb: Fix file links in "grep" search Thomas Perl
2012-01-13 19:18         ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).