From: Krzysztof Opasiak <k.opasiak@samsung.com>
To: git@vger.kernel.org
Cc: cedric.ollivier@orange.com, DEBEAU Eric IMT/OLN <eric.debeau@orange.com>
Subject: [BUG] Recursive submodules fails to track branch correctly if . is used
Date: Tue, 16 Jul 2019 23:49:43 +0200 [thread overview]
Message-ID: <08844c07-5192-0645-9bfc-62e1b16e39a8@samsung.com> (raw)
In-Reply-To: CGME20190716214945eucas1p299e23651b7bc1738d0c3bf2d227d4e46@eucas1p2.samsung.com
Dear git community,
I'd like to report you a potential bug in git submodule implementation.
* Problem statement
According to doc a special value of "." can be used as a branch name to
track. This means that git should trace the same branch as is currently
in use in superproject. This works perfectly fine as long as you don't
try to add superproject (SUP1) with such configuration as a submodule to
another superproject (SUP2). The nesting structure would look like this:
SUP2
- SUP1
- SUB_PROJECT
If you try to do this you won't be able to execute any of the following
commands:
$ git clone --recursive SUP2
$ git clone SUP2 & git submodule update --init --recursive --remote
$ git submodule update --init --recursive --remote
as every time you will get an error message similar to this one:
fatal: Submodule (SUB_PROJECT) branch configured to inherit branch from
superproject, but the superproject is not on any branch
fatal: Needed a single revision
Unable to find current origin/ revision in submodule path 'SUB_PROJECT'
* Initial investigation results
The error message comes from remote_submodule_branch():1938 in
submodule--helper.c and it is generated called from SUP1 dir (due to
--recursive flag). Actually this function behaves correctly. If you go
to SUP1 dir and check the branch info you will notice that the repo is
in detached head state.
* Probable root cause
The root cause is that the traced branch information is never propagated
to the submodules. All the submodules are always initialized in a
detached head state and there is no way to change this behavior nor to
propagate the traced branch information to submodules.
* Workaround script
I managed to workaround this bug by dropping the recursive option and
after the top level project has been cloned I go through every
submodule, set local branch to point to current head and then just do
git checkout and I do this recursively in all modules. After this I'm
able to successfully execute:
$ git submodule update --rebase --recursive --remote
The script (to be executed in SUP2 right after clone):
#!/bin/bash
function prepare_submodules {
git submodule update --init
local SUBMODULE_LIST=`git submodule--helper status | awk '{print $2}'`
while read -r submod; do
local PARENT_DIR=`pwd`
local BRANCH=`git submodule--helper remote-branch ${submod}`
cd ${submod}
git branch -f ${BRANCH} HEAD;
git checkout ${BRANCH}
if [ ! -z "`git submodule status`" ]; then
prepare_submodules;
fi
cd ${PARENT_DIR}
done <<< "$SUBMODULE_LIST"
}
prepare_submodules
Best regards,
--
Krzysztof Opasiak
Samsung R&D Institute Poland
Samsung Electronics
parent reply other threads:[~2019-07-16 21:49 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <CGME20190716214945eucas1p299e23651b7bc1738d0c3bf2d227d4e46@eucas1p2.samsung.com>]
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=08844c07-5192-0645-9bfc-62e1b16e39a8@samsung.com \
--to=k.opasiak@samsung.com \
--cc=cedric.ollivier@orange.com \
--cc=eric.debeau@orange.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.
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).