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

[PATCH 1/4] difftool: silence uninitialized variable warning

From
David Aguilar <davvid@gmail.com>
Date
Feb 16, 2013, 05:47 UTC
Message-ID
<1360993666-81308-1-git-send-email-davvid@gmail.com>

Git::config() returns `undef` when given keys that do not exist. Check that the $guitool value is defined to prevent a noisy "Use of uninitialized variable $guitool in length" warning.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
 git-difftool.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/git-difftool.perl b/git-difftool.perl
index 0a90de4..12231fb 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -336,7 +336,7 @@ sub main
 	}
 	if ($opts{gui}) {
 		my $guitool = Git::config('diff.guitool');
-		if (length($guitool) > 0) {
+		if (defined($guitool) && length($guitool) > 0) {
 			$ENV{GIT_DIFF_TOOL} = $guitool;
 		}
 	}
-- 
1.8.1.3.623.g622c8fc
Next: David Aguilar
Message 1 of 7 in “difftool: silence uninitialized variable warning”
  1. 1/4 difftool: silence uninitialized variable warningDavid Aguilar, Feb 16, 2013
  2. 2/4 t7800: Update copyright noticeDavid Aguilar, Feb 16, 2013
  3. 3/4 t7800: modernize testsDavid Aguilar, Feb 16, 2013
  4. 4/4 t7800: "defaults" is no longer a builtin tool nameDavid Aguilar, Feb 16, 2013
  5. Jonathan NiederFeb 17, 2013
  6. Jonathan NiederFeb 17, 2013
  7. David AguilarFeb 16, 2013

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.