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

[PATCH 2/2] difftool: handle uninitialized variable on empty diff

From
Tim Henigan <tim.henigan@gmail.com>
Date
Jun 28, 2012, 19:39 UTC
Message-ID
<1340912395-16990-2-git-send-email-tim.henigan@gmail.com>
In-Reply-To
<1340912395-16990-1-git-send-email-tim.henigan@gmail.com>

When 'difftool --dir-diff' finds no changes, it results in an uninitialized variable warning.

Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
---
 git-difftool.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/git-difftool.perl b/git-difftool.perl
index 679a56d..c94557d 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -117,7 +117,7 @@ sub setup_dir_diff
 	# by Git->repository->command*.
 	my $diffrepo = Git->repository(Repository => $repo_path, WorkingCopy => $workdir);
 	my $diffrtn = $diffrepo->command_oneline('diff', '--raw', '--no-abbrev', '-z', @ARGV);
-	exit(0) if (length($diffrtn) == 0);
+	exit(0) if ((not defined($diffrtn)) or (length($diffrtn) == 0));
 
 	# Setup temp directories
 	my $tmpdir = tempdir('git-diffall.XXXXX', CLEANUP => 1, TMPDIR => 1);
-- 
1.7.11.1.134.gda62046
Previous: Tim HeniganNext: Junio C Hamano
Message 2 of 8 in “difftool: only copy back files modified during directory diff”
  1. 1/2 difftool: only copy back files modified during directory diffTim Henigan, Jun 28, 2012
  2. 2/2 difftool: handle uninitialized variable on empty diffTim Henigan, Jun 28, 2012
  3. Junio C HamanoJun 28, 2012
  4. Junio C HamanoJun 28, 2012
  5. David AguilarJul 19, 2012
  6. difftool: only copy back files modified during directory diffDavid Aguilar, Jul 19, 2012
  7. Junio C HamanoJul 19, 2012
  8. David AguilarJul 21, 2012

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.