git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aaron Schrab <aaron@schrab.com>
To: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: A couple errors dealing with uninitialized submodules
Date: Thu, 20 Oct 2016 19:29:15 -0400	[thread overview]
Message-ID: <20161020232915.GB3667@pug.qqx.org> (raw)

I was working with a fresh clone of a repository where I'd forgotten 
that one of the directories was setup as a submodule, so I hadn't 
initialized it.

I tried to add a symlink to a location outside the repository and this 
failed with an assertion (exact text in comment below). When looking 
into that I realized that the directory was meant to be a submodule and 
decided to try to change that.  So I tried to remove the submodule, and 
got an error (misleadingly) saying that couldn't be done because it uses 
a .git directory.

I first noticed this with git 2.9.3 from Debian unstable, but I also see 
it building from v2.10.1-502-g6598894 fetched from master recently.

The following script replicates both of these issues. These could both 
be classified as "don't do that", although at lease the assertion is 
quite ugly.

--- >8 ----
#!/bin/sh -e

directory=$(mktemp -d)
echo "Using directory '$directory'"
cd $directory
git init --quiet orig
(
  cd orig
  # Using a random, small repository for the submodule.
  git submodule --quiet add https://github.com/diepm/vim-rest-console.git sub
  git commit -m init >/dev/null
)
git clone --quiet orig dup
cd dup

(
  cd sub
  ln -s /tmp/dont_care
  # Next command aborts with
  # git: pathspec.c:317: prefix_pathspec: Assertion `item->nowildcard_len <= item->len && item->prefix <= item->len' failed.`
  git add . || : expected to fail
)

rm -f .git/index.lock
# Next command fails with error wrongly saying that the submodule uses a .git
# directory.  I believe that the real problem is that the uninitialized
# submodule has content.
git rm sub

             reply	other threads:[~2016-10-20 23:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-20 23:29 Aaron Schrab [this message]
2016-10-20 23:51 ` A couple errors dealing with uninitialized submodules Stefan Beller

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

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

  git send-email \
    --in-reply-to=20161020232915.GB3667@pug.qqx.org \
    --to=aaron@schrab.com \
    --cc=git@vger.kernel.org \
    /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.
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 NNTP newsgroup(s).