Skip to contentSkip to conversation

gitweb: Fix git_blame

PATCH In review Aneesh Kumar K.V 3 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitweb: Fix git_blame

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

---
 gitweb/gitweb.perl |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
gitweb/gitweb.perl +6 -4
index 0984e85..57ffa25 100755
@@ -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);
Signature · 1 line
1.4.2.rc1.g83e1-dirty
#1 lore raw

PATCH 1/1 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."

---
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(-)
gitweb/gitweb.perl +8 -5
index 57ffa25..06bdb0e 100755
@@ -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
Signature · 1 line
1.4.1.1
#2 lore raw

Re: [PATCH] gitweb: gitweb_check_feature always return list

Quoted 3 lines · Jakub Narebski

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?

#3 lore raw

Re: [PATCH] gitweb: gitweb_check_feature always return list

Quoted 6 lines · Junio C Hamano
Quoted 3 lines · Jakub Narebski

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.

Quoted 6 lines

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.

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
#4 lore raw

Re: [PATCH] gitweb: gitweb_check_feature always return list

<opublikowany i wysłany>

Quoted 10 lines · Jakub Narebski
Quoted 8 lines · Junio C Hamano
Quoted 3 lines · Jakub Narebski

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.

Quoted 7 lines
Quoted 4 lines
      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.

Signature · 8 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git



-- 
VGER BF report: U 0.499824