threads / discuss / 39096

git-archive ignores submodules

Subject: git-archive ignores submodules

## tl;dr

7 messages between Apr 16, 2015 and Apr 20, 2015.

replies: 6people: 5as markdown or json

Pedro Rodrigues· Apr 16, 2015, 17:35 UTC · lore

I've been using git-archive as my main way of deploying to production servers, but today I've come across a git repo with submodules and found out that git archive has no option to include submodules on the output archive.

This simply makes git-archive unusable on this scenario.
-- 
Pedro Rodrigues
+244 917 774 823
+351 969 042 335
Mail: prodrigues1990@gmail.com
Fredrik Gustafsson· Apr 16, 2015, 17:56 UTC · re: Pedro Rodrigues · lore

Re: git-archive ignores submodules

On Thu, Apr 16, 2015 at 06:35:38PM +0100, Pedro Rodrigues wrote:
> I've been using git-archive as my main way of deploying to production
> servers, but today I've come across a git repo with submodules and
> found out that git archive has no option to include submodules on the
> output archive.

As far as I know this is an known limitation that's just waiting for someone to solve. Thanks for bringing attention to it.

> This simply makes git-archive unusable on this scenario.

Not completely. There's a simple workaround. Combine git submodule foreach with git archive and make an archive for each submodule.

Not as simple as if git archive --recurse-submodule would have been implementet, but hopefully it can make things work for you at the moment.

-- 
Fredrik Gustafsson

phone: +46 733-608274
e-mail: iveqy@iveqy.com
website: http://www.iveqy.com
Pedro Rodrigues· Apr 16, 2015, 18:09 UTC · re: Fredrik Gustafsson · lore

Re: git-archive ignores submodules

Good to know about git submodule foreach.
Simpler yet, I'm using:
zip -r ../project.zip . -x *.git*

Which essentially does the same thing I would need from git-archive --recurse-submodule, zip everything excluding .git folders. Still would be better to use git itself.

2015-04-16 18:56 GMT+01:00 Fredrik Gustafsson <iveqy@iveqy.com>:
Show 24 quoted lines
> On Thu, Apr 16, 2015 at 06:35:38PM +0100, Pedro Rodrigues wrote:
>> I've been using git-archive as my main way of deploying to production
>> servers, but today I've come across a git repo with submodules and
>> found out that git archive has no option to include submodules on the
>> output archive.
>
> As far as I know this is an known limitation that's just waiting for
> someone to solve. Thanks for bringing attention to it.
>
>> This simply makes git-archive unusable on this scenario.
>
> Not completely. There's a simple workaround. Combine git submodule
> foreach with git archive and make an archive for each submodule.
>
> Not as simple as if git archive --recurse-submodule would have been
> implementet, but hopefully it can make things work for you at the
> moment.
>
> --
> Fredrik Gustafsson
>
> phone: +46 733-608274
> e-mail: iveqy@iveqy.com
> website: http://www.iveqy.com
-- 
Pedro Rodrigues
+244 917 774 823
+351 969 042 335
Mail: prodrigues1990@gmail.com
Jens Lehmann· Apr 16, 2015, 19:03 UTC · re: Pedro Rodrigues · lore

Re: git-archive ignores submodules

Am 16.04.2015 um 20:09 schrieb Pedro Rodrigues:
Show 9 quoted lines
> Good to know about git submodule foreach.
>
> Simpler yet, I'm using:
>
> zip -r ../project.zip . -x *.git*
>
> Which essentially does the same thing I would need from git-archive
> --recurse-submodule, zip everything excluding .git folders. Still
> would be better to use git itself.
Yes.
Show 9 quoted lines
> 2015-04-16 18:56 GMT+01:00 Fredrik Gustafsson <iveqy@iveqy.com>:
>> On Thu, Apr 16, 2015 at 06:35:38PM +0100, Pedro Rodrigues wrote:
>>> I've been using git-archive as my main way of deploying to production
>>> servers, but today I've come across a git repo with submodules and
>>> found out that git archive has no option to include submodules on the
>>> output archive.
>>
>> As far as I know this is an known limitation that's just waiting for
>> someone to solve. Thanks for bringing attention to it.

I just rebased a patch Lars Hjemli posted in 2009 (which I kept in my GitHub repo to resurrect it when I find the time) to current master:

https://github.com/jlehmann/git-submod-enhancements/commits/archive--submodules

See gmane/$107030 for its original posting. Apart from renaming the '--submodule' option to '--recurse-submodules' and solving a merge conflict I didn't change anything. Not sure why it wasn't accepted back then, I'll have to read that thread more closely ...

If people are interested I could try to polish it and resubmit it. It would be great if Pedro could test that it does what he expects.

Pedro Rodrigues· Apr 16, 2015, 19:59 UTC · re: Jens Lehmann · lore

Re: git-archive ignores submodules

I sure can. Just send me an ID I can pull and test in here (not really into C, so this the least I can contribute).

Although, my expectations are very simple, I just expect(ed) the exact same git-archive command to be run on submodule(s), and have an output on a single zip|tar|whatever file.

Not completely off topic, but for consistency consider that: git-clone supports --recursive and --recurse-submodules, which do the same thing. git-pull and git-push only support --recurse-submodules.

Chris Packham· Apr 20, 2015, 08:51 UTC · re: Pedro Rodrigues · lore

Re: git-archive ignores submodules

On Fri, Apr 17, 2015 at 7:59 AM, Pedro Rodrigues <prodrigues1990@gmail.com> wrote: <snip>

> Not completely off topic, but for consistency consider that:
> git-clone supports --recursive and --recurse-submodules, which do the
> same thing.
> git-pull and git-push only support --recurse-submodules.

It took a while to get the terminology sorted but the eventual agreement[1] was "--recurse-submodules" was the best generally applicable flag for all commands. For backwards compatibility some commands that already had "--recursive" as an option have retained it

-- [1] - http://article.gmane.org/gmane.comp.version-control.git/160634

Kevin Daudt· Apr 19, 2015, 16:19 UTC · re: Jens Lehmann · lore

Re: git-archive ignores submodules

On Thu, Apr 16, 2015 at 09:03:10PM +0200, Jens Lehmann wrote:
> Am 16.04.2015 um 20:09 schrieb Pedro Rodrigues:
> 
> If people are interested I could try to polish it and resubmit it.
> It would be great if Pedro could test that it does what he expects.
I'm certainly interested.

← back to recent threads