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

[PATCH v2 3/3] gitweb/gitweb.perl: don't call S_ISREG() with undef

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Feb 19, 2011, 15:27 UTC
Message-ID
<1298129262-10468-4-git-send-email-avarab@gmail.com>
In-Reply-To
<1298124654-12051-1-git-send-email-avarab@gmail.com>

Change S_ISREG($to_mode_oct) to S_ISREG($from_mode_oct) in the branch that handles from modes, not to modes. This logic appears to have been caused by copy/paste programming by Jakub Narebski in e8e41a93. It would be better to rewrite this code not to be duplicated, but I haven't done so.

This issue caused a failing test on perl 5.13.9, which has a warning that turned this up:

     gitweb.perl: Use of uninitialized value in subroutine entry at /home/avar/g/git/t/../gitweb/gitweb.perl line 4415.
Which caused the Git test suite to fail on this test:
    ./t9500-gitweb-standalone-no-errors.sh             (Wstat: 256 Tests: 90 Failed: 84)
      Failed tests:  1-8, 10-36, 38-45, 47-48, 50-88
      Non-zero exit status: 1
Reported-by: perl 5.13.9
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 gitweb/gitweb.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index b02372c..1b9369d 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -4412,7 +4412,7 @@ sub git_difftree_body {
 		}
 		if ($diff->{'from_mode'} ne ('0' x 6)) {
 			$from_mode_oct = oct $diff->{'from_mode'};
-			if (S_ISREG($to_mode_oct)) { # only for regular file
+			if (S_ISREG($from_mode_oct)) { # only for regular file
 				$from_mode_str = sprintf("%04o", $from_mode_oct & 0777); # permission bits
 			}
 			$from_file_type = file_type($diff->{'from_mode'});
-- 
1.7.2.3
Previous: Jakub NarebskiNext: Jakub Narebski
Message 14 of 15 in “gitweb/gitweb.perl: remove use of qw(...) as parentheses”
  1. gitweb/gitweb.perl: remove use of qw(...) as parenthesesÆvar Arnfjörð Bjarmason, Feb 19, 2011
  2. 0/3 Fix failure-causing warnings in Gitweb + improve gitweb-lib.shÆvar Arnfjörð Bjarmason, Feb 19, 2011
  3. 1/3 t/gitweb-lib.sh: print to stderr when gitweb_run has errorsÆvar Arnfjörð Bjarmason, Feb 19, 2011
  4. Jakub NarebskiFeb 19, 2011
  5. Ævar Arnfjörð BjarmasonFeb 19, 2011
  6. Jakub NarebskiFeb 19, 2011
  7. Ævar Arnfjörð BjarmasonFeb 19, 2011
  8. Junio C HamanoFeb 21, 2011
  9. 2/3 gitweb/gitweb.perl: remove use of qw(...) as parenthesesÆvar Arnfjörð Bjarmason, Feb 19, 2011
  10. Jakub NarebskiFeb 19, 2011
  11. Jakub NarebskiFeb 19, 2011
  12. Ævar Arnfjörð BjarmasonFeb 19, 2011
  13. Jakub NarebskiFeb 20, 2011
  14. 3/3 gitweb/gitweb.perl: don't call S_ISREG() with undefÆvar Arnfjörð Bjarmason, Feb 19, 2011
  15. Jakub NarebskiFeb 19, 2011

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.