From cea88fa827c00ef13c51c81b0e60c74019591ba3 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 1 Jan 2024 16:42:35 +0000 Subject: git.sh: simplify submodule handling in git_prep u-boot doesn't use submodules, so there's no point in checking for it. now we can do with just one call to the git submodule command, for simplicity also, general code cleanup in this file (minor code formatting improvements) Signed-off-by: Leah Rowe --- include/git.sh | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) (limited to 'include/git.sh') diff --git a/include/git.sh b/include/git.sh index d30e90de..10e63dd6 100755 --- a/include/git.sh +++ b/include/git.sh @@ -42,16 +42,12 @@ fetch_config() load_target_config() { - [ -f "${cfgsdir}/${1}/target.cfg" ] || \ - err "${_xm} check: target.cfg does not exist" + [ -f "$cfgsdir/$1/target.cfg" ] || err "$1: target.cfg missing" [ -f "${cfgsdir}/${1}/seen" ] && \ err "${_xm} check: infinite loop in tree definitions" - . "${cfgsdir}/${1}/target.cfg" || \ - err "load_target_config ${cfgsdir}/${1}: cannot load config" - - touch "${cfgsdir}/${1}/seen" || \ - err "load_config $cfgsdir/$1: !mk seen" + . "$cfgsdir/$1/target.cfg" || err "load_target_config !$cfgsdir/$1" + touch "$cfgsdir/$1/seen" || err "load_config $cfgsdir/$1: !mk seen" } prepare_new_tree() @@ -101,25 +97,18 @@ git_prep() _patchdir="$1" _loc="$2" - git -C "$tmpgit" reset --hard $rev || \ - err "!git -C $_patchdir reset $rev" + git -C "$tmpgit" reset --hard $rev || err "git -C $_loc: !reset $rev" git_am_patches "$tmpgit" "$_patchdir" || err "!am $_loc $_patchdir" - [ "$project" != "coreboot" ] && [ "$project" != "u-boot" ] && \ - git_submodule_update "$tmpgit" - [ $# -gt 2 ] && git_submodule_update "$tmpgit" + if [ "$project" != "coreboot" ] || [ $# -gt 2 ]; then + [ ! -f "$tmpgit/.gitmodules" ] || git -C "$tmpgit" submodule \ + update --init --checkout || err "git_prep $_loc: !submod" + fi [ "$_loc" = "${_loc%/*}" ] || x_ mkdir -p "${_loc%/*}" mv "$tmpgit" "$_loc" || err "git_prep: !mv $tmpgit $_loc" } -git_submodule_update() -{ - [ ! -f "${1}/.gitmodules" ] || \ - git -C "${1}" submodule update --init --checkout || \ - err "git_sub ${1}: can't download submodules"; return 0 -} - git_am_patches() { for _patch in "$2/"*; do -- cgit v1.2.1