mbox series

[0/1] Fix format detection when archiving remotely

Message ID cover.1539990488.git.steadmon@google.com (mailing list archive)
Headers show
Series Fix format detection when archiving remotely | expand

Message

Josh Steadmon Oct. 19, 2018, 11:19 p.m. UTC
Currently, git-archive does not properly determine the desired archive
format when both --output and --remote are provided, because
run_remote_archiver() does not initialize the archivers prior to calling
archive_format_from_filename(). This results in the remote archiver
always returning a TAR file, regardless of the requested format.

This patch initializes the TAR and ZIP archivers before calling
archive_format_from_filename(), which fixes format detection.

Steps to reproduce:

∫ git version
git version 2.19.1.568.g152ad8e336-goog
∫ cd ~/src/git
∫ git archive --output ~/good.zip HEAD
∫ file ~/good.zip
/home/steadmon/good.zip: Zip archive data, at least v1.0 to extract
∫ git archive --output ~/bad.zip --remote=. HEAD
∫ file ~/bad.zip
/home/steadmon/bad.zip: POSIX tar archive

(apply patch and build)

∫ ./bin-wrappers/git archive --output ~/fixed.zip --remote=. HEAD
∫ file ~/fixed.zip
/home/steadmon/fixed.zip: Zip archive data, at least v1.0 to extract


Josh Steadmon (1):
  archive: init archivers before determining format

 builtin/archive.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Jeff King Oct. 19, 2018, 11:41 p.m. UTC | #1
On Fri, Oct 19, 2018 at 04:19:27PM -0700, steadmon@google.com wrote:

> Currently, git-archive does not properly determine the desired archive
> format when both --output and --remote are provided, because
> run_remote_archiver() does not initialize the archivers prior to calling
> archive_format_from_filename(). This results in the remote archiver
> always returning a TAR file, regardless of the requested format.
> 
> This patch initializes the TAR and ZIP archivers before calling
> archive_format_from_filename(), which fixes format detection.

It seems like some of this content could be in the commit message of the
actual patch.

> Steps to reproduce:
> 
> ∫ git version
> git version 2.19.1.568.g152ad8e336-goog
> ∫ cd ~/src/git
> ∫ git archive --output ~/good.zip HEAD
> ∫ file ~/good.zip
> /home/steadmon/good.zip: Zip archive data, at least v1.0 to extract
> ∫ git archive --output ~/bad.zip --remote=. HEAD
> ∫ file ~/bad.zip
> /home/steadmon/bad.zip: POSIX tar archive

And this could be in a test script in the actual patch. :)

-Peff
Josh Steadmon Oct. 22, 2018, 9:46 p.m. UTC | #2
On 2018.10.19 19:41, Jeff King wrote:
> On Fri, Oct 19, 2018 at 04:19:27PM -0700, steadmon@google.com wrote:
> 
> > Currently, git-archive does not properly determine the desired archive
> > format when both --output and --remote are provided, because
> > run_remote_archiver() does not initialize the archivers prior to calling
> > archive_format_from_filename(). This results in the remote archiver
> > always returning a TAR file, regardless of the requested format.
> > 
> > This patch initializes the TAR and ZIP archivers before calling
> > archive_format_from_filename(), which fixes format detection.
> 
> It seems like some of this content could be in the commit message of the
> actual patch.

Ack. I'll be sending v2 shortly, please let me know if I've missed
anything that should be included.

> > Steps to reproduce:
> > 
> > ∫ git version
> > git version 2.19.1.568.g152ad8e336-goog
> > ∫ cd ~/src/git
> > ∫ git archive --output ~/good.zip HEAD
> > ∫ file ~/good.zip
> > /home/steadmon/good.zip: Zip archive data, at least v1.0 to extract
> > ∫ git archive --output ~/bad.zip --remote=. HEAD
> > ∫ file ~/bad.zip
> > /home/steadmon/bad.zip: POSIX tar archive
> 
> And this could be in a test script in the actual patch. :)

Done.