threads / patch / 5448

patchgitweb: Fix git_blame

Subject: [PATCH] gitweb: Fix git_blame

## tl;dr

6 messages between Sep 1, 2006 and Sep 1, 2006. Diffs are folded; open one to read it.

replies: 5people: 3as markdown or json

Aneesh Kumar K.V· Sep 1, 2006, 03:43 UTC · lore

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(-)
Show changes to gitweb/gitweb.perl +6 −4
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· Sep 1, 2006, 09:07 UTC · re: Aneesh Kumar K.V · lore

Re: [PATCH] gitweb: Fix git_blame

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· Sep 1, 2006, 19:31 UTC · re: Aneesh Kumar K.V · lore

[PATCH] gitweb: gitweb_check_feature always return list

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(-)
Show changes to gitweb/gitweb.perl +8 −5
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· Sep 1, 2006, 19:37 UTC · re: Jakub Narebski · lore

Re: [PATCH] gitweb: gitweb_check_feature always return list

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· Sep 1, 2006, 19:48 UTC · re: Junio C Hamano · lore

Re: [PATCH] gitweb: gitweb_check_feature always return list

Junio C Hamano wrote:
Show 12 quoted lines
> 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· Sep 1, 2006, 20:12 UTC · re: Jakub Narebski · lore

Re: [PATCH] gitweb: gitweb_check_feature always return list

<opublikowany i wysłany>
Jakub Narebski wrote:
Show 17 quoted lines
> 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

← back to recent threads