Skip to contentSkip to conversation

gitweb: Fix "Use of uninitialized value" warning in git_feed

PATCH In review Jakub Narebski 2 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitweb: Fix "Use of uninitialized value" warning in git_feed

Initial (root) commit has no parents, and $co{'parent'} is undefined. Use '--root' for initial commit.

This fixes "Use of uninitialized value in open at gitweb/gitweb.perl line 4925." warning.

---
 gitweb/gitweb.perl |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +2 -1
index fa8cc02..091cf9c 100755
@@ -4923,7 +4923,8 @@ XML
 
 		# get list of changed files
 		open my $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
-			$co{'parent'}, $co{'id'}, "--", (defined $file_name ? $file_name : ())
+			$co{'parent'} || "--root",
+			$co{'id'}, "--", (defined $file_name ? $file_name : ())
 			or next;
 		my @difftree = map { chomp; $_ } <$fd>;
 		close $fd
Signature · 1 line
1.5.1.4
#1 lore raw
Quoted 16 lines · Jakub Narebski

Initial (root) commit has no parents, and $co{'parent'} is undefined. Use '--root' for initial commit.

This fixes "Use of uninitialized value in open at gitweb/gitweb.perl line 4925." warning.

---
 gitweb/gitweb.perl |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +0 -0
index fa8cc02..091cf9c 100755

gitweb/gitweb.perl XML · line 4930

Quoted 9 lines
gitweb/gitweb.perl +2 -1
@@ -4923,7 +4923,8 @@ XML
 
 		# get list of changed files
 		open my $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
-			$co{'parent'}, $co{'id'}, "--", (defined $file_name ? $file_name : ())
+			$co{'parent'} || "--root",
+			$co{'id'}, "--", (defined $file_name ? $file_name : ())
 			or next;
 		my @difftree = map { chomp; $_ } <$fd>;
 		close $fd

I do not think you would need to make --root conditional...

#2 lore raw
Quoted 7 lines · Junio C Hamano
Quoted 5 lines · Jakub Narebski

Initial (root) commit has no parents, and $co{'parent'} is undefined. Use '--root' for initial commit.

This fixes "Use of uninitialized value in open at gitweb/gitweb.perl line 4925." warning.

[...]

Quoted 4 lines
Quoted 4 lines
gitweb/gitweb.perl +0 -0
@@ -4923,7 +4923,8 @@ XML
 
Quoted 10 lines

gitweb/gitweb.perl XML · line 4930

Quoted 8 lines
gitweb/gitweb.perl +2 -1
 		# get list of changed files
 		open my $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
-			$co{'parent'}, $co{'id'}, "--", (defined $file_name ? $file_name : ())
+			$co{'parent'} || "--root",
+			$co{'id'}, "--", (defined $file_name ? $file_name : ())
 			or next;
 		my @difftree = map { chomp; $_ } <$fd>;
 		close $fd

I do not think you would need to make --root conditional...

I need at last make $co{'parent'} conditional, i.e. at least "$co{'parent'} || ()" or equivalent (e.g. like for $file_name). I cannot omit $co{'parent'} because parents might be rewritten; feeds accept now path limiting. So why not this way?

Signature · 2 lines
Jakub Narebski
Poland
#3 lore raw
Quoted 24 lines · Jakub Narebski
Quoted 7 lines · Junio C Hamano
Quoted 5 lines · Jakub Narebski

Initial (root) commit has no parents, and $co{'parent'} is undefined. Use '--root' for initial commit.

This fixes "Use of uninitialized value in open at gitweb/gitweb.perl line 4925." warning.

[...]

Quoted 4 lines
Quoted 4 lines
gitweb/gitweb.perl +0 -0
@@ -4923,7 +4923,8 @@ XML
 
Quoted 10 lines

gitweb/gitweb.perl XML · line 4930

Quoted 8 lines
gitweb/gitweb.perl +2 -1
 		# get list of changed files
 		open my $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
-			$co{'parent'}, $co{'id'}, "--", (defined $file_name ? $file_name : ())
+			$co{'parent'} || "--root",
+			$co{'id'}, "--", (defined $file_name ? $file_name : ())
 			or next;
 		my @difftree = map { chomp; $_ } <$fd>;
 		close $fd

I do not think you would need to make --root conditional...

Quoted 4 lines

I need at last make $co{'parent'} conditional, i.e. at least "$co{'parent'} || ()" or equivalent (e.g. like for $file_name). I cannot omit $co{'parent'} because parents might be rewritten; feeds accept now path limiting. So why not this way?

Ah, clever (buuuuuuut misleading) ;-)