From 3eef7f37f293e804560e1a7f3a76a46e707f4775 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Fri, 7 Jun 2024 14:40:59 +0100 Subject: [PATCH] git.sh: simplify submodule handling there were stragglers remaining, from when we used to actually run "git submodule update", but this was removed. clean up the submodule functions and merge them together. Signed-off-by: Leah Rowe --- include/git.sh | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/include/git.sh b/include/git.sh index 4d2e9c07..c723fec0 100755 --- a/include/git.sh +++ b/include/git.sh @@ -117,7 +117,6 @@ prep_submodules() while read -r msrcdir; do fetch_submodule "$msrcdir" - patch_submodule "$msrcdir" done < "$tmpdir/modules" } @@ -129,22 +128,16 @@ fetch_submodule() [ ! -f "$mcfgdir/module.cfg" ] || . "$mcfgdir/module.cfg" || \ $err "! . $mcfgdir/module.cfg" - [ -n "$subrepo" ] || [ -n "$subrepo_bkup" ] || return 0 - [ -n "$subrev" ] || $err "$1, $mdir: subrev not defined" + [ -z "$subrepo" ] && [ -z "$subrepo_bkup" ] && return 0 + + for mvar in subrepo subrepo_bkup subrev; do + eval "[ -n \"\$$mvar\" ] || $err \"$1, $mdir: $mvar unset\"" + done rm -Rf "$tmpgit/$1" || $err "!rm '$mdir' '$1'" - for mod in "$subrepo" "$subrepo_bkup"; do - [ -z "$mod" ] && continue - git clone "$mod" "$tmpgit/$1" || rm -Rf "$tmpgit/$1" \ - || $err "!rm $mod $project $cfgdir $1" - [ -d "$tmpgit/$1" ] && break - done - [ -d "$tmpgit/$1" ] || $err "!clone $mod $project $mcfgdir $1" -} - -patch_submodule() -{ - [ -z "$subrev" ] || git -C "$tmpgit/$1" reset --hard "$subrev" || \ + git clone $subrepo "$tmpgit/$1" || git clone $subrepo_bkup \ + "$tmpgit/$1" || $err "clone_project: could not download $project" + git -C "$tmpgit/$1" reset --hard "$subrev" || \ $err "$mdir $1: cannot reset git revision" git_am_patches "$tmpgit/$1" "$mdir/${1##*/}/patches"