* [PATCH (BUGFIX)] gitweb: Fix two 'uninitialized value' varnings in git_tree()
@ 2008-10-02 14:50 Jakub Narebski
2008-10-02 15:02 ` Giuseppe Bilotta
2008-10-02 15:08 ` Petr Baudis
0 siblings, 2 replies; 3+ messages in thread
From: Jakub Narebski @ 2008-10-02 14:50 UTC (permalink / raw)
To: git; +Cc: Jakub Narebski
If we did try to access nonexistent directory or file, which means
that git_get_hash_by_path() returns `undef`, uninitialized $hash
variable was passed to 'open' call. Now we fail early with "404 Not
Found - No such tree" error. (If we try to access something which
does not resolve to tree-ish, for example a file / 'blob' object, the
error will be caught later, as "404 Not Found - Reading tree failed"
error).
If we tried to use 'tree' action without $file_name ('f' parameter)
set, which means either tree given by hash or a top tree (and we
currently cannot distinguish between those two cases), we cannot print
path breadcrumbs with git_print_page_path(). Fix this by moving call
to git_print_page_path() inside conditional.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Those two errors were discovered when creating new basic test for
path_info (following).
I was also thinking about alternate solution of using instead
"$hash_base:$file_name" for $hash, but it caused some errors I didn't
feel like debugging. Current diff is also smaller than mentioned
solution.
BTW. should we use "No such tree" or "No such directory".
gitweb/gitweb.perl | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 18e70a3..bb20ed7 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -4445,6 +4445,7 @@ sub git_tree {
$hash = $hash_base;
}
}
+ die_error(404, "No such tree") unless defined($hash);
$/ = "\0";
open my $fd, "-|", git_cmd(), "ls-tree", '-z', $hash
or die_error(500, "Open git-ls-tree failed");
@@ -4485,8 +4486,8 @@ sub git_tree {
if ($basedir ne '' && substr($basedir, -1) ne '/') {
$basedir .= '/';
}
+ git_print_page_path($file_name, 'tree', $hash_base);
}
- git_print_page_path($file_name, 'tree', $hash_base);
print "<div class=\"page_body\">\n";
print "<table class=\"tree\">\n";
my $alternate = 1;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH (BUGFIX)] gitweb: Fix two 'uninitialized value' varnings in git_tree()
2008-10-02 14:50 [PATCH (BUGFIX)] gitweb: Fix two 'uninitialized value' varnings in git_tree() Jakub Narebski
@ 2008-10-02 15:02 ` Giuseppe Bilotta
2008-10-02 15:08 ` Petr Baudis
1 sibling, 0 replies; 3+ messages in thread
From: Giuseppe Bilotta @ 2008-10-02 15:02 UTC (permalink / raw)
To: git
On Thursday 02 October 2008 16:50, Jakub Narebski wrote:
> gitweb: Fix two 'uninitialized value' varnings in git_tree()
Vat's a varning?
--
Giuseppe "Oblomov" Bilotta
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH (BUGFIX)] gitweb: Fix two 'uninitialized value' varnings in git_tree()
2008-10-02 14:50 [PATCH (BUGFIX)] gitweb: Fix two 'uninitialized value' varnings in git_tree() Jakub Narebski
2008-10-02 15:02 ` Giuseppe Bilotta
@ 2008-10-02 15:08 ` Petr Baudis
1 sibling, 0 replies; 3+ messages in thread
From: Petr Baudis @ 2008-10-02 15:08 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git
On Thu, Oct 02, 2008 at 04:50:04PM +0200, Jakub Narebski wrote:
> If we did try to access nonexistent directory or file, which means
> that git_get_hash_by_path() returns `undef`, uninitialized $hash
> variable was passed to 'open' call. Now we fail early with "404 Not
> Found - No such tree" error. (If we try to access something which
> does not resolve to tree-ish, for example a file / 'blob' object, the
> error will be caught later, as "404 Not Found - Reading tree failed"
> error).
>
> If we tried to use 'tree' action without $file_name ('f' parameter)
> set, which means either tree given by hash or a top tree (and we
> currently cannot distinguish between those two cases), we cannot print
> path breadcrumbs with git_print_page_path(). Fix this by moving call
> to git_print_page_path() inside conditional.
>
> Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Acked-by: Petr Baudis <pasky@suse.cz>
> BTW. should we use "No such tree" or "No such directory".
I prefer the former.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-10-02 15:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-02 14:50 [PATCH (BUGFIX)] gitweb: Fix two 'uninitialized value' varnings in git_tree() Jakub Narebski
2008-10-02 15:02 ` Giuseppe Bilotta
2008-10-02 15:08 ` Petr Baudis
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).