Subject: 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 <[email-masked]>
Date: Tue, 04 Aug 2009 19:50:04 +0200

demerphq schrieb:
> 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é