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

Re: [PATCH v2] archive: initialize archivers earlier

From
Jeff King <peff@peff.net>
Date
Oct 23, 2018, 00:06 UTC
Message-ID
<20181023000616.GA27393@sigill.intra.peff.net>
In-Reply-To
<20181022235127.GE233961@google.com>
On Mon, Oct 22, 2018 at 04:51:27PM -0700, Josh Steadmon wrote:
Show 17 quoted lines
> > > +test_expect_success GZIP 'git archive with --output and --remote uses expected format' '
> > > +	git archive --output=d5.tgz --remote=. HEAD &&
> > > +	gzip -d -c < d5.tgz > d5.tar &&
> > > +	test_cmp_bin b.tar d5.tar
> > > +'
> > 
> > This nicely tests the more-interesting tgz case. But unfortunately it
> > won't run on machines without the GZIP prerequisite. I'd think that
> > would really be _most_ machines, but is it worth having a separate zip
> > test to cover machines without gzip? I guess that just creates the
> > opposite problem: not everybody has ZIP.
> 
> Added a test to compare the file lists from the .zip file to the
> reference .tar file. I'm not sure if this is the best way to do things,
> but it at least verifies that a .zip is produced. However, it's brittle
> if the output of "zip -sf" changes. Let me know if you have a better
> idea.

I wonder if we could do something more black-box. What we really care about here is not the exact output, but rather that "-o foo.zip" produces the same output as "--format zip". Could we do that without even relying on ZIP?

I think it should follow even for tgz, because we use "-n" for a repeatable output. But there we are relying on an external gzip just to _create_ the file, so we'd still need the GZIP prereq.

Hmm. Looks like we already have a similar test in t5003. So maybe just:
diff --git a/t/t5003-archive-zip.sh b/t/t5003-archive-zip.sh
index 55c7870997..cf19f56924 100755
--- a/t/t5003-archive-zip.sh
+++ b/t/t5003-archive-zip.sh
@@ -158,11 +158,16 @@ test_expect_success 'git archive --format=zip with --output' \
     'git archive --format=zip --output=d2.zip HEAD &&
     test_cmp_bin d.zip d2.zip'
 
-test_expect_success 'git archive with --output, inferring format' '
+test_expect_success 'git archive with --output, inferring format (local)' '
 	git archive --output=d3.zip HEAD &&
 	test_cmp_bin d.zip d3.zip
 '
 
+test_expect_success 'git archive with --output, ferring format (remote)' '
+	git archive --remote=. --output=d4.zip HEAD &&
+	test_cmp_bin d.zip d4.zip
+'
+
 test_expect_success \
     'git archive --format=zip with prefix' \
     'git archive --format=zip --prefix=prefix/ HEAD >e.zip'

which I think exposes the bug and can run everywhere?

-Peff
Previous: Josh SteadmonNext: Josh Steadmon
Message 12 of 20 in “Fix format detection when archiving remotely”
  1. 0/1 Fix format detection when archiving remotelysteadmon@google.com, Oct 19, 2018
  2. 1/1 archive: init archivers before determining formatsteadmon@google.com, Oct 19, 2018
  3. Jeff KingOct 19, 2018
  4. Junio C HamanoOct 22, 2018
  5. Josh SteadmonOct 22, 2018
  6. Jeff KingOct 22, 2018
  7. Jeff KingOct 19, 2018
  8. Josh SteadmonOct 22, 2018
  9. archive: initialize archivers earliersteadmon@google.com, Oct 22, 2018
  10. Jeff KingOct 22, 2018
  11. Josh SteadmonOct 22, 2018
  12. Jeff KingOct 23, 2018
  13. Josh SteadmonOct 23, 2018
  14. archive: initialize archivers earliersteadmon@google.com, Oct 22, 2018
  15. archive: initialize archivers earliersteadmon@google.com, Oct 23, 2018
  16. Junio C HamanoOct 23, 2018
  17. Josh SteadmonOct 25, 2018
  18. archive: initialize archivers earliersteadmon@google.com, Oct 25, 2018
  19. Jeff KingOct 25, 2018
  20. Junio C HamanoOct 26, 2018

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.