# [PATCH] gitweb: Fix git_blame

6 messages from 2006-09-01 to 2006-09-01. Participants: Aneesh Kumar K.V, Jakub Narebski, Junio C Hamano.
Thread: https://gitlist.dev/t/5448

## Aneesh Kumar K.V, 2006-09-01 03:43

Subject: [PATCH] gitweb: Fix git_blame
Message-ID: <ed8a90$pfn$1@sea.gmane.org>
URL: https://gitlist.dev/e/ed8a90%24pfn%241%40sea.gmane.org

```



Converting the default values to array broke the git blame enable
disable support. Fix the same.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
---
 gitweb/gitweb.perl |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 0984e85..57ffa25 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2251,7 +2251,8 @@ sub git_blame2 {
 	my $fd;
 	my $ftype;
 
-	if (!gitweb_check_feature('blame')) {
+	my ($have_blame) = gitweb_check_feature('blame');
+	if (!$have_blame) {
 		die_error('403 Permission denied', "Permission denied");
 	}
 	die_error('404 Not Found', "File name not defined") if (!$file_name);
@@ -2320,7 +2321,8 @@ HTML
 sub git_blame {
 	my $fd;
 
-	if (!gitweb_check_feature('blame')) {
+	my ($have_blame) = gitweb_check_feature('blame');
+	if (!$have_blame) {
 		die_error('403 Permission denied', "Permission denied");
 	}
 	die_error('404 Not Found', "File name not defined") if (!$file_name);
@@ -2494,7 +2496,7 @@ sub git_blob {
 			die_error(undef, "No file name defined");
 		}
 	}
-	my $have_blame = gitweb_check_feature('blame');
+	my ($have_blame) = gitweb_check_feature('blame');
 	open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
 		or die_error(undef, "Couldn't cat $file_name, $hash");
 	my $mimetype = blob_mimetype($fd, $file_name);
@@ -2570,7 +2572,7 @@ sub git_tree {
 	my $ref = format_ref_marker($refs, $hash_base);
 	git_header_html();
 	my $base = "";
-	my $have_blame = gitweb_check_feature('blame');
+	my ($have_blame) = gitweb_check_feature('blame');
 	if (defined $hash_base && (my %co = parse_commit($hash_base))) {
 		git_print_page_nav('tree','', $hash_base);
 		git_print_header_div('commit', esc_html($co{'title'}) . $ref, $hash_base);
-- 
1.4.2.rc1.g83e1-dirty


```

## Jakub Narebski, 2006-09-01 09:07

Subject: Re: [PATCH] gitweb: Fix git_blame
Message-ID: <ed8t86$cd8$1@sea.gmane.org>
URL: https://gitlist.dev/e/ed8t86%24cd8%241%40sea.gmane.org
In-Reply-To: <ed8a90$pfn$1@sea.gmane.org>

```
Aneesh Kumar wrote:

> Converting the default values to array broke the git blame enable
> disable support. Fix the same.
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>

Hmmm.... git^W got applied (1d3fc68a), but commit message was lost.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```

## Jakub Narebski, 2006-09-01 19:31

Subject: [PATCH] gitweb: gitweb_check_feature always return list
Message-ID: <11571390683018-git-send-email-jnareb@gmail.com>
URL: https://gitlist.dev/e/11571390683018-git-send-email-jnareb%40gmail.com
In-Reply-To: <ed8a90$pfn$1@sea.gmane.org>

```
Modified feature_blame so it returns one-element list and not scalar,
thus making gitweb_check_feature always return list.  Updated comment
to explain that part.

This is continuation of Aneesh Kumar work:
  gitweb: Fix git_blame
"Converting the default values to array broke the git blame enable
 disable support. Fix the same."

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
We could modify %feature hash so the 'default' value could be either
array reference or a scalar instead.

 gitweb/gitweb.perl |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 57ffa25..06bdb0e 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -74,9 +74,12 @@ our %feature = (
 	#
 	# if feature is overridable (it means that allow-override has true value,
 	# then feature-sub will be called with default options as parameters;
-	# return value of feature-sub indicates if to enable specified feature
+	# return value of feature-sub indicates if to enable specified feature,
+	# and is taken to be current parameters of the feature
 	#
-	# use gitweb_check_feature(<feature>) to check if <feature> is enabled
+	# use gitweb_check_feature(<feature>) to check if <feature> is enabled;
+	# to be more exact to get current parameters of <feature>;
+	# gitweb_check_feature(<feature>) returns array (list) of current options
 
 	'blame' => {
 		'sub' => \&feature_blame,
@@ -111,12 +114,12 @@ sub feature_blame {
 	my ($val) = git_get_project_config('blame', '--bool');
 
 	if ($val eq 'true') {
-		return 1;
+		return (1);
 	} elsif ($val eq 'false') {
-		return 0;
+		return (0);
 	}
 
-	return $_[0];
+	return ($_[0]);
 }
 
 # To disable system wide have in $GITWEB_CONFIG
-- 
1.4.1.1

```

## Junio C Hamano, 2006-09-01 19:37

Subject: Re: [PATCH] gitweb: gitweb_check_feature always return list
Message-ID: <7vk64n5qep.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vk64n5qep.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <11571390683018-git-send-email-jnareb@gmail.com>

```
Jakub Narebski <jnareb@gmail.com> writes:

> Modified feature_blame so it returns one-element list and not scalar,
> thus making gitweb_check_feature always return list.  Updated comment
> to explain that part.

I do not understand what you are fixing.

	sub A { return (1); }
        sub B { return 1; }

Don't they quack the same way?

```

## Jakub Narebski, 2006-09-01 19:48

Subject: Re: [PATCH] gitweb: gitweb_check_feature always return list
Message-ID: <eda2q0$la8$1@sea.gmane.org>
URL: https://gitlist.dev/e/eda2q0%24la8%241%40sea.gmane.org
In-Reply-To: <7vk64n5qep.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano wrote:

> Jakub Narebski <jnareb@gmail.com> writes:
> 
>> Modified feature_blame so it returns one-element list and not scalar,
>> thus making gitweb_check_feature always return list.  Updated comment
>> to explain that part.
> 
> I do not understand what you are fixing.
> 
>       sub A { return (1); }
>       sub B { return 1; }
> 
> Don't they quack the same way?

Well, that is just nitpicking. gitweb_check_feature returns list if feature
is not overridable, so I made it that it always returns list.
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```

## Jakub Narebski, 2006-09-01 20:12

Subject: Re: [PATCH] gitweb: gitweb_check_feature always return list
Message-ID: <eda475$ob7$1@sea.gmane.org>
URL: https://gitlist.dev/e/eda475%24ob7%241%40sea.gmane.org
In-Reply-To: <eda2q0$la8$1@sea.gmane.org>

```
<opublikowany i wysłany>

Jakub Narebski wrote:

> Junio C Hamano wrote:
> 
>> Jakub Narebski <jnareb@gmail.com> writes:
>> 
>>> Modified feature_blame so it returns one-element list and not scalar,
>>> thus making gitweb_check_feature always return list.  Updated comment
>>> to explain that part.
>> 
>> I do not understand what you are fixing.
>> 
>>       sub A { return (1); }
>>       sub B { return 1; }
>> 
>> Don't they quack the same way?
> 
> Well, that is just nitpicking. gitweb_check_feature returns list if feature
> is not overridable, so I made it that it always returns list.

Then I'm not sure if Aneesh Kumar patch I replied to is really necessary.
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git



-- 
VGER BF report: U 0.499824

```
