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

Bug?: git archive exclude pathspec and gitattributes export-ignore

From
DADavid Adam <zanchey@ucc.gu.uwa.edu.au>
Date
Aug 13, 2017, 04:53 UTC
Message-ID
<alpine.DEB.2.11.1708131240360.15538@motsugo.ucc.gu.uwa.edu.au>
Hi all,

I think I have a bug in git (tested 2.11.0 on Debian 8, 2.14.1 on OS X and 2.14.1.145.gb3622a4 on OS X).

Given a repository with an export-ignore directive for a subdirectory in .gitattributes, `git archive` with a pathspec that excludes a different subdirectory produces no output file and git exits with -1 as the return status.

As shown:
   > git init foo && cd foo
   Initialized empty Git repository in /Users/david/src/foo/.git/
   > mkdir a b
   > touch {a,b}/somefile
   > echo "/a export-ignore" >> .gitattributes
   > git add .
   > git commit -m "Initial commit"
   [master (root-commit) 53527a7] Initial commit
    3 files changed, 1 insertion(+)
    create mode 100644 .gitattributes
    create mode 100644 a/somefile
    create mode 100644 b/somefile
   > git archive --verbose master ':(top)' ':(exclude)b*'
   .gitattributes
   > echo $?
   255

If this is intended behaviour, is there any way of achieving the goal of excluding a subdirectory not listed as export-ignore? Using the exclude pathspec ":(exclude)b" produces an empty subdirectory b in the output, which I would like to avoid.

This is a reduced testcase; my goal is to end up with two archives, one containing directory b only, and one containing everything except for directory b - so I can't just add 'b export-ignore' to gitattributes.

Thanks

David Adam zanchey@ucc.gu.uwa.edu.au

Next: René Scharfe
Message 1 of 17 in “Bug?: git archive exclude pathspec and gitattributes export-ignore”
  1. David AdamAug 13, 2017
  2. René ScharfeAug 14, 2017
  3. David AdamAug 15, 2017
  4. René ScharfeAug 19, 2017
  5. 1/4 t5001: add tests for export-ignore attributes and exclude pathspecsRené Scharfe, Aug 19, 2017
  6. 2/4 archive: factor out helper functions for handling attributesRené Scharfe, Aug 19, 2017
  7. 4/4 archive: queue directories for all types of pathspecsRené Scharfe, Aug 19, 2017
  8. René ScharfeAug 19, 2017
  9. René ScharfeAug 19, 2017
  10. Junio C HamanoAug 19, 2017
  11. Jeff KingAug 20, 2017
  12. René ScharfeSep 12, 2017
  13. Jeff KingSep 13, 2017
  14. René ScharfeSep 13, 2017
  15. Stefan BellerAug 21, 2017
  16. Junio C HamanoAug 19, 2017
  17. 3/4 archive: don't queue excluded directoriesRené Scharfe, Aug 19, 2017

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.