git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Subject: Re: [PATCH] gitweb: Support for snapshot
Date: Sat, 19 Aug 2006 16:22:42 +0200	[thread overview]
Message-ID: <ec76rd$8qf$1@sea.gmane.org> (raw)
In-Reply-To: 44E71888.30104@gmail.com

Aneesh Kumar K.V wrote:

> I tested this and added some comments. I also fixed some code. 
> I am attaching the full diff. 

Below comments to the patch.

> BTW git-repo-config have the below bug. 
> 
> $ git repo-config --bool --get gitweb.blame
> true
> $ git repo-config --get --bool gitweb.blame
> $
> 
> So i dropped --get from the git_get_project_config

Wouldn't it be better to correct the error in git-repo-config? 
Or (easier) add '--get' last (see comments)?

> +# Feature configuration.

Wouldn't it make it easier to understand code to put %feature hash 
and gitweb_check_feature subroutine _before_ subroutines for specific
features?

> +# These subs are only called when per repository
> +# overrides are allowed.  They take the default options,
> +# inspect the repository and return the values from there if
> +# the repository wants to override the system default.
> +
> +# To enable system wide have in $GITWEB_CONFIG
> +# $feature{'blame'} =  [\&feature_blame, 0, 1];

This enables system wide, but also disables per-project override.
To enable system wide, while allowing for per project disabling
it should read
# $feature{'blame'} = [\&feature_blame, 1, 1]; # overridable, enabled by default

> +# To disbale project wide 

Typo. disbale -> disable.

> +# you should have allow-override enabled in  $GITWEB_CONFIG
Example:
# $feature{'blame'} = [\&feature_blame, 1, 1]; # overridable, enabled by default
or just

$feature{'blame'}->[1] = 1;

(See below for comments on that form)

> +# and in project config   gitweb.blame = 0;
Example:
# $ git repo-config --bool gitweb.blame false

> +# To disable system wide have in $GITWEB_CONFIG
> +# $feature{'snapshot'} =  [\&feature_snapshot, 0, undef, undef, undef];
It would be enough to put:
$feature{'snapshot'} =  [\&feature_snapshot, 0, undef];

> +# You define site-wide feature defaults here; override them with
> +# $GITWEB_CONFIG as necessary.
> +our %feature =
> +(
> +       # feature       => [feature-sub, allow-override, default options...]
> +
> +       'blame'         => [\&feature_blame, 0, 0],
> +       'snapshot'      => [\&feature_snapshot, 0, 'x-gzip', 'gz', 'gzip'],
> +);

By the way, wouldn't it be better to use _hash_ for mixed meaning
than _array_? I.e.

our %feature =
(
       # feature       => {'sub' => feature-sub, 'override' => allow-override, 'default' => default options...]

       'blame'         => {'sub' => \&feature_blame, 'override' => 0, 'default' => 0},
   #or 'blame'         => {'sub' => \&feature_blame, 'override' => 0, 'default' => [ 0 ]},
       'snapshot'      => {'sub' => \&feature_snapshot, 'override' => 0, 'default => [ 'x-gzip', 'gz', 'gzip' ]},
);

Then you could enable override, or change default simplier in
$GITWEB_CONFIG, e.g. $feature{'blame'}{'override'} = 1; instead
of $feature{'blame'}[1] = 1;

By the way, it has more sense to have feature by default 
(i.e. in gitweb.perl) with override enabled if it is set to on.

>  sub git_get_project_config {
[...]
> -       my $val = qx($GIT repo-config --get gitweb.$key);
> +       my @x = ($GIT, 'repo-config');
> +       if (defined $type) { push @x, $type; }
Just add '--get' as the last argument, _after_ type:
  +       push @x, '--get';
> +       push @x, "gitweb.$key";
> +       my $val = qx(@x);
> +       chomp $val;
>         return ($val);
>  }


> -       die_error('403 Permission denied', "Permission denied") if (!git_get_project_config_bool ('blame'));
> +
> +       if (!gitweb_check_feature('blame')) {
> +               die_error(undef, "Permission denied");
> +       }

Why did you drop '403 Permission denied' HTTP return code from call
to die_error? (And not set in other similar cases)?

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

  reply	other threads:[~2006-08-19 14:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-17 15:29 gitweb: Support for snapshot Aneesh Kumar K.V
2006-08-18  5:06 ` [PATCH] " Aneesh Kumar K.V
2006-08-18 19:51   ` Luben Tuikov
2006-08-18 20:05     ` Timo Hirvonen
     [not found]     ` <7v64gp7prk.fsf@assigned-by-dhcp.cox.net>
2006-08-19  8:10       ` Aneesh Kumar
2006-08-19 10:51         ` Junio C Hamano
2006-08-19 11:09           ` Jakub Narebski
2006-08-19 11:13           ` Jakub Narebski
2006-08-19 11:58             ` Aneesh Kumar K.V
2006-08-19 13:56           ` Aneesh Kumar K.V
2006-08-19 14:22             ` Jakub Narebski [this message]
2006-08-19 16:17               ` Aneesh Kumar K.V
2006-08-19 16:26                 ` Aneesh Kumar K.V
2006-08-19 21:49               ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='ec76rd$8qf$1@sea.gmane.org' \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).