Re: [RFC] Clone repositories recursive with depth 1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 11, 2015 at 11:19 AM, Stefan Beller <sbeller@xxxxxxxxxx> wrote:
> On Wed, Nov 11, 2015 at 6:09 AM, Lars Schneider
> <larsxschneider@xxxxxxxxx> wrote:
>> Hi,
>>
>> I have a clean build machine and I want to clone my source code to this machine while transferring only the minimal necessary amount of data. Therefore I use this command:
>>
>> git clone --recursive --depth 1 --single-branch <url>
>
> That *should* work, actually.
> However looking at the code it does not.
>
> citing from builtin/clone.c:
>
>     static struct option builtin_clone_options[] = {
>         ...
>         OPT_BOOL(0, "recursive", &option_recursive,
>            N_("initialize submodules in the clone")),
>         OPT_BOOL(0, "recurse-submodules", &option_recursive,
>           N_("initialize submodules in the clone")),
>         ...
>     };
>     ...
>     static const char *argv_submodule[] = {
>         "submodule", "update", "--init", "--recursive", NULL
>     };
>
>     if (!err && option_recursive)
>         err = run_command_v_opt(argv_submodule, RUN_GIT_CMD);
>
> So the --depth argument is not passed on, although "git submodule update"
> definitely supports --depth.
>
> In an upcoming series (next version of origin/sb/submodule-parallel-update),
> this will slightly change, such it will be even easier to add the
> depth argument in
> there as we construct the argument list in code instead of hard coding
> argv_submodule.
>
> This may require some discussion whether you expect --depth to be recursed.
> (What if you only want a top level shallow thing?, What if you want to have only
> submodules shallow? What is the user expectation here?)
>
>>
>> Apparently this does not clone the submodules with "--depth 1" (using Git 2.4.9). As a workaround I tried:
>>
>> git clone --depth 1 --single-branch <url>
>> cd <repo-name>
>> git submodule update --init --recursive --depth 1
>>

The workaround works with the origin/master version for me.

Notice the other email thread, which suggests to include --remote into the
call to  git submodule update depending on a branch config option being
present in the .gitmodules file.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]