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

Re: git archive --format zip utf-8 issues

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 10, 2012, 22:47 UTC
Message-ID
<7vtxwagy9f.fsf@alter.siamese.dyndns.org>
In-Reply-To
<502583F4.8030308@tu-clausthal.de>
Sven Strickroth <sven.strickroth@tu-clausthal.de> writes:
> when I create a git repository, add a file containing utf-8 characters
> or umlauts (like öäü.txt), commit and then export the HEAD revision to a
> zip archive using "git archive --format zip -o 1.zip HEAD", the zip file
> contains incorrect filenames:

My reading of archive-zip.c seems to suggest that we write out whatever pathname you have in the tree, so a pathname encoded in UTF-8 will be literally written out in the resulting zip archive.

Do you know in what encoding the pathnames are _expected_ to be stored in zip archives? Random documentation seems to suggest that there is no standard encoding, e.g. http://docs.python.org/library/zipfile.html says:

    There is no official file name encoding for ZIP files. If you
    have unicode file names, you must convert them to byte strings
    in your desired encoding before passing them to write(). WinZip
    interprets all file names as encoded in CP437, also known as DOS
    Latin.
which may explain it.
It may not be a bad idea for "git archive --format=zip" to
 (1) check if pathname is a correct UTF-8; and
 (2) check if it can be reencoded to latin-1

and if (and only if) both are true, automatically re-encode the path to latin-1.

Of course, "git archive --format=zip --path-reencode=utf8-to-latin1" would be the most generic way to do this.

Previous: Sven StrickrothNext: Sven Strickroth
Message 2 of 21 in “git archive --format zip utf-8 issues”
  1. Sven StrickrothAug 10, 2012
  2. Junio C HamanoAug 10, 2012
  3. Sven StrickrothAug 10, 2012
  4. René ScharfeAug 11, 2012
  5. Junio C HamanoAug 12, 2012
  6. René ScharfeAug 11, 2012
  7. Sven StrickrothAug 11, 2012
  8. Jeff KingAug 30, 2012
  9. René ScharfeSep 4, 2012
  10. Junio C HamanoSep 4, 2012
  11. René ScharfeSep 5, 2012
  12. René ScharfeSep 18, 2012
  13. 1/2 archive-zip: support UTF-8 pathsRené Scharfe, Sep 18, 2012
  14. 2/2 archive-zip: declare creator to be Unix for UTF-8 pathsRené Scharfe, Sep 18, 2012
  15. René ScharfeSep 18, 2012
  16. Junio C HamanoSep 18, 2012
  17. René ScharfeSep 20, 2012
  18. René ScharfeSep 24, 2012
  19. Junio C HamanoSep 24, 2012
  20. 3/2 archive-zip: write extended timestampRené Scharfe, Sep 24, 2012
  21. Junio C HamanoAug 12, 2012

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.