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 <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2024-01-01 16:42:35 +00:00
parent 1fcbadb8da
commit cea88fa827
+8 -19
View File
@@ -42,16 +42,12 @@ fetch_config()
load_target_config() load_target_config()
{ {
[ -f "${cfgsdir}/${1}/target.cfg" ] || \ [ -f "$cfgsdir/$1/target.cfg" ] || err "$1: target.cfg missing"
err "${_xm} check: target.cfg does not exist"
[ -f "${cfgsdir}/${1}/seen" ] && \ [ -f "${cfgsdir}/${1}/seen" ] && \
err "${_xm} check: infinite loop in tree definitions" err "${_xm} check: infinite loop in tree definitions"
. "${cfgsdir}/${1}/target.cfg" || \ . "$cfgsdir/$1/target.cfg" || err "load_target_config !$cfgsdir/$1"
err "load_target_config ${cfgsdir}/${1}: cannot load config" touch "$cfgsdir/$1/seen" || err "load_config $cfgsdir/$1: !mk seen"
touch "${cfgsdir}/${1}/seen" || \
err "load_config $cfgsdir/$1: !mk seen"
} }
prepare_new_tree() prepare_new_tree()
@@ -101,25 +97,18 @@ git_prep()
_patchdir="$1" _patchdir="$1"
_loc="$2" _loc="$2"
git -C "$tmpgit" reset --hard $rev || \ git -C "$tmpgit" reset --hard $rev || err "git -C $_loc: !reset $rev"
err "!git -C $_patchdir reset $rev"
git_am_patches "$tmpgit" "$_patchdir" || err "!am $_loc $_patchdir" git_am_patches "$tmpgit" "$_patchdir" || err "!am $_loc $_patchdir"
[ "$project" != "coreboot" ] && [ "$project" != "u-boot" ] && \ if [ "$project" != "coreboot" ] || [ $# -gt 2 ]; then
git_submodule_update "$tmpgit" [ ! -f "$tmpgit/.gitmodules" ] || git -C "$tmpgit" submodule \
[ $# -gt 2 ] && git_submodule_update "$tmpgit" update --init --checkout || err "git_prep $_loc: !submod"
fi
[ "$_loc" = "${_loc%/*}" ] || x_ mkdir -p "${_loc%/*}" [ "$_loc" = "${_loc%/*}" ] || x_ mkdir -p "${_loc%/*}"
mv "$tmpgit" "$_loc" || err "git_prep: !mv $tmpgit $_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() git_am_patches()
{ {
for _patch in "$2/"*; do for _patch in "$2/"*; do