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

[PATCH] gitweb: Test if $from_id and $to_id are defined before comparison

From
Jakub Narebski <jnareb@gmail.com>
Date
May 12, 2007, 10:42 UTC
Message-ID
<200705121242.33156.jnareb@gmail.com>
In-Reply-To
<200705120135.30150.jnareb@gmail.com>

Get rid of "Use of uninitialized value in string eq at gitweb/gitweb.perl line 2320" warning caused by the fact that "empty" patches, consisting only of extended git diff header and with patch body empty, such as patch for pure rename, does not have "index" line in extended diff header. For such patches $from_id and $to_id, filled from parsing extended diff header, are undefined. But such patches cannot be continuation patches.

Test if $from_id and $to_id are defined before comparing them with $diffinfo.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This also fixes "Use of uninitialized value ..." error/warning, but this
time it is caused by something else than non-existent object (wrong value
of parameter).
 gitweb/gitweb.perl |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index afa0056..2b39502 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2664,9 +2664,10 @@ sub git_patchset_body {
 		# check if current patch belong to current raw line
 		# and parse raw git-diff line if needed
 		if (defined $diffinfo &&
+		    defined $from_id && defined $to_id &&
 		    from_ids_eq($diffinfo->{'from_id'}, $from_id) &&
 		    $diffinfo->{'to_id'} eq $to_id) {
-			# this is split patch
+			# this is continuation of a split patch
 			print "<div class=\"patch cont\">\n";
 		} else {
 			# advance raw git-diff output if needed
-- 
1.5.1.4
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 7 in “gitweb: Avoid "Use of uninitialized value" errors (written to logs)”
  1. gitweb: Avoid "Use of uninitialized value" errors (written to logs)Jakub Narebski, May 11, 2007
  2. Junio C HamanoMay 12, 2007
  3. gitweb: Check if requested object existsJakub Narebski, May 12, 2007
  4. gitweb: Fix "Use of unitialized value" warnings in empty repositoryJakub Narebski, May 13, 2007
  5. Junio C HamanoMay 13, 2007
  6. gitweb: Test if $from_id and $to_id are defined before comparisonJakub Narebski, May 12, 2007
  7. Junio C HamanoMay 12, 2007

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.