git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: demerphq <demerphq@gmail.com>
To: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
Cc: "Santi Béjar" <santi@agolina.net>, Git <git@vger.kernel.org>,
	"Jakub Narebski" <jnareb@gmail.com>
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?
Date: Sun, 2 Aug 2009 16:19:54 +0200	[thread overview]
Message-ID: <9b18b3110908020719h79cf4872p9f284346cd6a185b@mail.gmail.com> (raw)
In-Reply-To: <4A759A21.7070806@lsrfire.ath.cx>

2009/8/2 René Scharfe <rene.scharfe@lsrfire.ath.cx>:
> demerphq schrieb:
>> 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.

Well I was kinda thinking the case of a snapshot generator on
something like gitweb.

In that case you could have multiple processes trying to create the
same snapshot.

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.

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.

Of course this is all very easy for me to say as a back-seat driver. :-)

cheers,
Yves




-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

  reply	other threads:[~2009-08-02 14:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-29  8:15 Adding files to a git-archive when it is generated, and whats the best way to find out what branch a commit is on? demerphq
2009-07-29  8:40 ` Avery Pennarun
2009-07-29  8:41 ` Santi Béjar
2009-07-29  9:21   ` demerphq
2009-07-29  9:33     ` Santi Béjar
2009-07-29  9:51       ` demerphq
2009-07-29 11:13         ` Santi Béjar
2009-07-30 20:33     ` René Scharfe
2009-07-31 10:04       ` demerphq
     [not found]         ` <m3hbwtrpip.fsf@localhost.localdomain>
2009-07-31 13:48           ` demerphq
2009-08-02 13:52         ` René Scharfe
2009-08-02 14:19           ` demerphq [this message]
2009-08-04 17:50             ` René Scharfe
2009-07-29 16:12 ` Jeff Epler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9b18b3110908020719h79cf4872p9f284346cd6a185b@mail.gmail.com \
    --to=demerphq@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jnareb@gmail.com \
    --cc=rene.scharfe@lsrfire.ath.cx \
    --cc=santi@agolina.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).