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 4, 2009, 17:50 UTC
Message-ID
<4A7874CC.9050702@lsrfire.ath.cx>
In-Reply-To
<9b18b3110908020719h79cf4872p9f284346cd6a185b@mail.gmail.com>
demerphq schrieb:
Show 15 quoted lines
> One solution is to do the work in a process specific temporary
> directory with the correct name and then add it that way.
> 
> A slightly nicer approach is create the file in a common working
> directory with a temporary name and then have it added to the archive
> with a different name. This is actually the approach I used by
> exploiting the the --transform option to tar. So while it might appear
> my request is a YAGNI it is actually a IADNI (I Already Did Need It).
> 
> Even nicer and cleaner of course would be support something like
> "--add-file -=.patch"  with the "-" meaning "read from STDIN", which
> then means temporary files can be avoided, assuming one only needs to
> add a single file to the archive. This is particularly nice if the
> content of  the file can be generated from the output of something
> like git-describe or git rev-parse or any generic tool.

This case (single file in archive, contents from stdin) could be handled by another option, e.g. named --add-stdin <name_in_archive>, without resorting to multi-valued option parameters.

Also, if a file can be generated using a --pretty=format: string, then you can let git-archive expand a checked-in template by setting the attribute export-subst. This works for multiple files, but doesn't if you need git-describe style output (yet).

> So IMO actually this functionality would be very useful, and isnt so
> weird when you think of it in context of generating snapshots for a
> "git aware" build process.

No doubt about it. The question is: how to expose such functionality? Perhaps all that is needed for your purposes is a format place-holder for git-describe output?

(git itself needs more: in addition to the files "version" and "git.spec", which could benefit from such a place-holder, it adds the generated "configure" script and "git-gui/version" to the tarball.)

René
Previous: demerphqNext: Jeff Epler
Message 12 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.