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

Re: What's cooking in git.git (Nov 2010, #03; Wed, 24)

From
Jakub Narebski <jnareb@gmail.com>
Date
Dec 3, 2010, 14:12 UTC
Message-ID
<201012031512.45793.jnareb@gmail.com>
In-Reply-To
<201012031406.55854.trast@student.ethz.ch>
On Fri, 3 Dec 2010, Thomas Rast wrote:
Show 23 quoted lines
> Jakub Narebski wrote:
> > Could you add 'exit' just after second test in 
> > t/t9502-gitweb-standalone-parse-output.sh test script, or running it
> > with `--immediate' option, and show us the results (after 'cd t') of
> > 
> >   $ file "trash directory.t9502-gitweb-standalone-parse-output/gitweb.body"
> >   should be:
> > 
> >     trash directory.t9502-gitweb-standalone-parse-output/gitweb.body: tar archive
> 
> Well, you're onto something...
> 
>   trash directory.t9502-gitweb-standalone-parse-output$ file *
>   file_list:          empty
>   foo:                ASCII text
>   gitweb.body:        empty
>   gitweb_config.perl: perl script text executable
>   gitweb.headers:     ASCII text, with CRLF line terminators
>   gitweb.log:         empty
>   gitweb.output:      ASCII text, with CRLF line terminators
>   GLOB(0xdf18fc0):    tar archive
> 
> Huh.  Seems something got confused about what to use as a filename?

Hmmm... let me examine 17b15d4 (gitweb: File based caching layer (from git.kernel.org), 2010-11-01)

Ah, I see. It looks like I forgot to update git_blob_plain and git_snapshot when I was modifying original patch by J.H. (which didn't pass test suite for other reasons) to have test for $caching_enabled outside cache_fetch().

Could you try if the following patch applied on top of 17b15d4 fixes it for you? If it does, I'll resend fixed series (yet again, I'm sorry Junio).

It is not most elegant solution.
Sidenote: 
  open BINOUT, '>', \$fullhashbinpath
should open in-memory file, and not be equivalent to
  open BINOUT, '>', "\$fullhashbinpath"
Hmmm... in the case of !$caching_enabled, $fullhasbinpath is *STDOUT.
BTW replacing 
  open BINOUT, '>', \$fullhashbinpath
with
  open BINOUT, '>&STDOUT'
or
  open BINOUT, '>&', \$fullhashbinpath
could be simpler, alternate solution.
-- 8< -- 8< --
diff --git i/gitweb/gitweb.perl w/gitweb/gitweb.perl
index abaeec6..3d787c1 100755
--- i/gitweb/gitweb.perl
+++ w/gitweb/gitweb.perl
@@ -5648,13 +5648,14 @@ sub git_blob_plain {
 	local $/ = undef;
 	if ($caching_enabled) {
 		open BINOUT, '>', $fullhashbinpath or die_error(500, "Could not open bin dump file");
-	}else{
-		open BINOUT, '>', \$fullhashbinpath or die_error(500, "Could not open bin dump file");
+		binmode BINOUT, ':raw';
+		print BINOUT <$fd>;
+		close BINOUT;
+	} else {
+		binmode STDOUT, ':raw';
+		print <$fd>;
+		binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
 	}
-	binmode BINOUT, ':raw';
-	print BINOUT <$fd>;
-	binmode BINOUT, ':utf8'; # as set at the beginning of gitweb.cgi
-	close BINOUT;
 	close $fd;
 }
 
@@ -5941,13 +5942,14 @@ sub git_snapshot {
 		or die_error(500, "Execute git-archive failed");
 	if ($caching_enabled) {
 		open BINOUT, '>', $fullhashbinpath or die_error(500, "Could not open bin dump file");
-	}else{
-		open BINOUT, '>', \$fullhashbinpath or die_error(500, "Could not open bin dump file");
+		binmode BINOUT, ':raw';
+		print BINOUT <$fd>;
+		close BINOUT;
+	} else {
+		binmode STDOUT, ':raw';
+		print <$fd>;
+		binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
 	}
-	binmode BINOUT, ':raw';
-	print BINOUT <$fd>;
-	binmode BINOUT, ':utf8'; # as set at the beginning of gitweb.cgi
-	close BINOUT;
 	close $fd;
 }
 

-- >8 -- >8 -- 
-- 
Jakub Narebski
Poland
Previous: Thomas RastNext: Thomas Rast
Message 22 of 23 in “What's cooking in git.git (Nov 2010, #03; Wed, 24)”
  1. Junio C HamanoNov 25, 2010
  2. Jiang XinNov 25, 2010
  3. Ævar Arnfjörð BjarmasonNov 25, 2010
  4. Erik Faye-LundNov 25, 2010
  5. Ævar Arnfjörð BjarmasonNov 25, 2010
  6. Erik Faye-LundNov 25, 2010
  7. Erik Faye-LundNov 25, 2010
  8. Erik Faye-LundNov 25, 2010
  9. Erik Faye-LundNov 25, 2010
  10. Ævar Arnfjörð BjarmasonNov 25, 2010
  11. Erik Faye-LundNov 25, 2010
  12. Ævar Arnfjörð BjarmasonNov 25, 2010
  13. Erik Faye-LundNov 25, 2010
  14. Ævar Arnfjörð BjarmasonNov 26, 2010
  15. Johannes SixtNov 25, 2010
  16. Jakub NarebskiNov 25, 2010
  17. Thomas RastDec 3, 2010
  18. Jakub NarebskiDec 3, 2010
  19. Thomas RastDec 3, 2010
  20. Jakub NarebskiDec 3, 2010
  21. Thomas RastDec 3, 2010
  22. Jakub NarebskiDec 3, 2010
  23. Thomas RastDec 3, 2010

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.