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