git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] difftool: initialize variables for readability

From
David Aguilar <davvid@gmail.com>
Date
May 16, 2016, 18:05 UTC
Message-ID
<20160516180537.22212-1-davvid@gmail.com>

The code always goes into one of the two conditional blocks but make it clear that not doing so is an error condition by setting $ok to 0.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
 git-difftool.perl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/git-difftool.perl b/git-difftool.perl
index 488d14b..8cf0040 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -273,7 +273,7 @@ EOF
 	# temporary file to both the left and right directories to show the
 	# change in the recorded SHA1 for the submodule.
 	for my $path (keys %submodule) {
-		my $ok;
+		my $ok = 0;
 		if (defined($submodule{$path}{left})) {
 			$ok = write_to_file("$ldir/$path",
 				"Subproject commit $submodule{$path}{left}");
@@ -289,7 +289,7 @@ EOF
 	# shows only the link itself, not the contents of the link target.
 	# This loop replicates that behavior.
 	for my $path (keys %symlink) {
-		my $ok;
+		my $ok = 0;
 		if (defined($symlink{$path}{left})) {
 			$ok = write_to_file("$ldir/$path",
 					$symlink{$path}{left});
-- 
2.8.2.404.gdfc6a507
Next: David Aguilar
Message 1 of 3 in “difftool: initialize variables for readability”
  1. 1/2 difftool: initialize variables for readabilityDavid Aguilar, May 16, 2016
  2. 2/2 difftool: handle unmerged files in dir-diff modeDavid Aguilar, May 16, 2016
  3. Junio C HamanoMay 16, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.