Subject: Re: [PATCH] gitweb: return correct HTTP status codes

From: Lea Wiemann <[email-masked]>
Date: Tue, 17 Jun 2008 16:04:25 +0200

Junio C Hamano wrote:
> It's up to you to work on 'next' or 'master with extra patches'.

Okay; I guess I'll use 'next with extra patches'. ;-)

> [Gitweb's error handling:] isn't it possible for you to unconfuse
> yourself in a slow path and  figure out exactly why it failed?
> 
>         unless (open $fd, '-|', ls-tree $base -- $path) {
>                 # Oh, an error?  why?
>                 if (!object_exists($base)) {  [...]
>                 } elsif (!is_a_treeish($base)) {  [...]

That's possible, but the API I'm writing is designed the other way 
round: First, get the hash & type of $base; if it fails or the type is 
wrong, die accordingly.  Then pass the hash you got into whatever call 
to git, and if that fails, you can quite safely assume that something 
serious went wrong.  (The example above has an additional $path to deal 
with, but you get the idea.)

IOW, the strategy is "don't let the git binaries resolve any object 
names for you", which should make both error handling and caching a lot 
easier.

-- Lea