git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git submodule add fails when using both --branch and --depth
@ 2017-09-30 17:20 Thadeus Fleming
  2017-10-02 19:55 ` Stefan Beller
  2017-10-02 22:08 ` Jonathan Nieder
  0 siblings, 2 replies; 3+ messages in thread
From: Thadeus Fleming @ 2017-09-30 17:20 UTC (permalink / raw)
  To: git

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

> 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'

Investigating further, there is indeed only one commit in the local repo:

> cd git-pu
> git log --oneline | wc -l
1

But that commit is the head of master.

> git branch -a
* master                                 remotes/origin/master
  remotes/origin/HEAD -> origin/master

This appears to be because git-submodule--helper does not accept a
--branch option. Using the --depth N option causes it to only clone N
commits from the default branch, which generally do not include the
desired branch. Thus, the next step,

git checkout -f -q -B "$branch" "origin/$branch"

fails, and provides the rather confusing error message above.

I'd suggest that git-submodule--helper learn a --branch option
consistent with git clone, and if that is impossible, that
git submodule add rejects the simultaneous use of both the --branch and
--depth options.



--tjf

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-02 22:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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

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).