git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Fredrik Gustafsson <iveqy@iveqy.com>
To: Lars Schneider <larsxschneider@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [RFC] Clone repositories recursive with depth 1
Date: Sat, 14 Nov 2015 17:25:15 +0100	[thread overview]
Message-ID: <20151114162515.GJ1678@paksenarrion.iveqy.com> (raw)
In-Reply-To: <DE5B8B46-B185-4258-A1C8-07E46072CD5D@gmail.com>

On Wed, Nov 11, 2015 at 03:09:18PM +0100, Lars Schneider wrote:
> 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
> 
> However, this does not work either as I get:
> fatal: reference is not a tree: <correct sha1 of the submodule referenced by the main project>
> Unable to checkout <correct sha1 of the submodule referenced by the main project> in submodule path <submodule path>

This looks like a familiar bug to me. I'm not sure if it's a bug or a
known behaviour. When the depth argument was introduced to submodules a
year (or two) ago there was a know bug. I not sure if it's fixed or
not.

The problem is that git is/was unable to fetch a sha1 but only a branch
or a tag. So fetching a submodule will fetch the HEAD of the submodule
with the requested depth. Then git will try to checkout a sha1 of that
submodule, which may or maynot exists.

Say that you fetch master of a submodule of depth 1 and do a checkout of
a commit that exists. When someonen else has pushed to that submodule,
the commit will not longer be reachable from depth 1 and if someone else
tries to clone with depth 1 it will fail with the same error message as
you got.

The solution to this is to allow git to fetch the sha1 the superproject
points to direct when fetching the submodule.

-- 
Fredrik Gustafsson

phone: +46 733-608274
e-mail: iveqy@iveqy.com
website: http://www.iveqy.com

      parent reply	other threads:[~2015-11-14 16:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-11 14:09 [RFC] Clone repositories recursive with depth 1 Lars Schneider
2015-11-11 19:19 ` Stefan Beller
2015-11-11 20:09   ` Stefan Beller
2015-11-12  9:39     ` Lars Schneider
2015-11-12 23:47       ` Stefan Beller
2015-11-14 16:25 ` Fredrik Gustafsson [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20151114162515.GJ1678@paksenarrion.iveqy.com \
    --to=iveqy@iveqy.com \
    --cc=git@vger.kernel.org \
    --cc=larsxschneider@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).