Hello, Here's a quick patch to git-r3.eclass for review. It fixes handling of repositories where submodules were partially removed -- they're still listed in .gitmodules but the path was 'git rm'-ed. In this case, vanilla git ignores the submodule, and the patch causes the eclass to do that too.
Relevant bug: https://bugs.gentoo.org/show_bug.cgi?id=551100 Patch attached. -- Best regards, Michał Górny <http://dev.gentoo.org/~mgorny/>
Index: git-r3.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v
retrieving revision 1.49
diff -u -B -r1.49 git-r3.eclass
--- git-r3.eclass 22 Jun 2015 08:39:36 -0000 1.49
+++ git-r3.eclass 26 Jun 2015 20:39:05 -0000
@@ -710,16 +710,23 @@
local subname=${submodules[0]}
local url=${submodules[1]}
local path=${submodules[2]}
- local commit=$(git rev-parse "${local_ref}:${path}")
- if [[ ! ${commit} ]]; then
- die "Unable to get commit id for submodule
${subname}"
- fi
+ # use only submodules for which path does exist
+ # (this is in par with 'git submodule'), bug #551100
+ # note: git cat-file does not work for submodules
+ if [[ $(git ls-tree -d "${local_ref}" "${path}") ]]
+ then
+ local commit=$(git rev-parse
"${local_ref}:${path}" || die)
+
+ if [[ ! ${commit} ]]; then
+ die "Unable to get commit id for
submodule ${subname}"
+ fi
- local subrepos
- _git-r3_set_subrepos "${url}" "${repos[@]}"
+ local subrepos
+ _git-r3_set_subrepos "${url}" "${repos[@]}"
- git-r3_fetch "${subrepos[*]}" "${commit}"
"${local_id}/${subname}"
+ git-r3_fetch "${subrepos[*]}" "${commit}"
"${local_id}/${subname}"
+ fi
submodules=( "${submodules[@]:3}" ) # shift
done
@@ -849,11 +856,16 @@
local subname=${submodules[0]}
local url=${submodules[1]}
local path=${submodules[2]}
- local subrepos
- _git-r3_set_subrepos "${url}" "${repos[@]}"
- git-r3_checkout "${subrepos[*]}" "${out_dir}/${path}" \
- "${local_id}/${subname}"
+ # use only submodules for which path does exist
+ # (this is in par with 'git submodule'), bug #551100
+ if [[ -d ${out_dir}/${path} ]]; then
+ local subrepos
+ _git-r3_set_subrepos "${url}" "${repos[@]}"
+
+ git-r3_checkout "${subrepos[*]}"
"${out_dir}/${path}" \
+ "${local_id}/${subname}"
+ fi
submodules=( "${submodules[@]:3}" ) # shift
done
pgpcC8JtzjPsH.pgp
Description: OpenPGP digital signature
