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

Re: Adding files to a git-archive when it is generated, and whats the best way to find out what branch a commit is on?

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Aug 2, 2009, 13:52 UTC
Message-ID
<4A759A21.7070806@lsrfire.ath.cx>
In-Reply-To
<9b18b3110907310304w261ee30bw8c06c6a65e936e6e@mail.gmail.com>
demerphq schrieb:
Show 31 quoted lines
> 2009/7/30 René Scharfe <rene.scharfe@lsrfire.ath.cx>:
>> demerphq schrieb:
>>> So then git also would benefit from support in git-archive for adding
>>> arbitrary files to the archive during generation?
>> Yes, and this has come up before.
>>
>> How about the following?  It's missing documentation and a test case,
>> but you could try
>>
>>        $ git archive --add-file extra HEAD >HEAD+extra.tar
>>
>> or
>>
>>        $ git archive --prefix=a/ --add-file extra --prefix=b/ HEAD >ba.tar
>>
>> Only the file name part (after the last slash) of the extra file is used,
>> together with the prefix, to form the path of the archive entry.
>>
>> Opening the extra files when parsing the command line arguments and closing
>> them after they have been written into the archive is a bit iffy, but it's
>> impractical to report open errors after parts of the archive have already
>> been created.
> 
> I havent managed to try it out yet but this is pretty much exactly
> what I was looking for. Only thought I had was that it might be nice
> to be able to specify what name the file should be added as so that
> you can add files to subpaths deeper than the root/root prefix of the
> tar. However for /my/ particular purposes that is unnecessary, it only
> occurs to me as a nice to have. But if you were inclined to think
> about extending it I was thinking an argument notation like --add-file
> foo:bar/baz/bop might be useful.

With the patch as-is, you can make a file named bop appear as bar/baz/bop in the archive (by using a prefix of bar/baz/), but not as foo. I wonder how often one needs to rename a file while adding it to the archive -- or indeed if this is needed at all. Being lazy, I'd wait for such a case to appear before supporting it with a double-valued command line argument.

René
Previous: demerphqNext: demerphq
Message 10 of 14 in “Adding files to a git-archive when it is generated, and whats the best way to find out what branch a commit is on?”
  1. demerphqJul 29, 2009
  2. Avery PennarunJul 29, 2009
  3. Santi BéjarJul 29, 2009
  4. demerphqJul 29, 2009
  5. Santi BéjarJul 29, 2009
  6. demerphqJul 29, 2009
  7. Santi BéjarJul 29, 2009
  8. René ScharfeJul 30, 2009
  9. demerphqJul 31, 2009
  10. René ScharfeAug 2, 2009
  11. demerphqAug 2, 2009
  12. René ScharfeAug 4, 2009
  13. Jeff EplerJul 29, 2009
  14. demerphqJul 31, 2009

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.