From: Jonathan Nieder <jrnieder@gmail.com>
To: Thadeus Fleming <thadeus.j.fleming@gmail.com>
Cc: git@vger.kernel.org, Stefan Beller <sbeller@google.com>
Subject: Re: git submodule add fails when using both --branch and --depth
Date: Mon, 2 Oct 2017 15:08:45 -0700 [thread overview]
Message-ID: <20171002220844.GQ19555@aiede.mtv.corp.google.com> (raw)
In-Reply-To: <CAA4Wa2sVddG_SS70Dy_womGLKW0ipAjsxR4g+yjMKscjErRjvQ@mail.gmail.com>
Hi,
Thadeus Fleming wrote:
> I'm running git 2.14.2 on Ubuntu 16.04.
>
> Compare the behavior of
>
>> git clone --branch pu --depth 1 https://github.com/git/git git-pu
>
> which clones only the latest commit of the pu branch and
Yes.
>> mkdir tmp && cd tmp && git init
>> git submodule add --branch pu --depth 1 https://github.com/git/git \
> git-pu
>
> which gives the error
>
> fatal: 'origin/pu' is not a commit and a branch 'pu' cannot be created from it
> Unable to checkout submodule 'git-pu'
As a side note (you are using "git submodule add --depth", not "git
submodule update --depth"), I suspect that "submodule update --depth"
may not always do what people expect.
With add --depth, I agree with your expectation and after your fix
everything should work fine. But with update --depth, consider the
following sequence of steps:
1. I create a repository "super" with submodule "sub" and publish
both.
2. I make a couple commits to "sub" and a commit to "super" making
use of those changes and want to publish them.
3. I use "git push --recurse-submodules" to publish my commits to
"sub" and "super":
a. First it pushes to "sub".
b. Then it pushes to "super".
Between steps 3(a) and 3(b), a person can still "git clone
--recurse-submodules" the "super" repository. The repository "super"
does not have my change yet and "sub" does, but that is not a problem,
since commands like "git checkout --recurse-submodules" and "git
submodule update" know to check out the commit *before* my change in
the submodule.
But between steps 3(a) and 3(b), "git submodule update --depth=1"
would not work. It would fetch the submodule with depth 1 and then
try to check out a commit that is deeper in history.
So I think there's more thinking needed there.
That's all a tangent to your report about add --depth, though.
Thanks,
Jonathan
prev parent reply other threads:[~2017-10-02 22:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-30 17:20 git submodule add fails when using both --branch and --depth Thadeus Fleming
2017-10-02 19:55 ` Stefan Beller
2017-10-02 22:08 ` Jonathan Nieder [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=20171002220844.GQ19555@aiede.mtv.corp.google.com \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=sbeller@google.com \
--cc=thadeus.j.fleming@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).