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>
9020vga
Leah Rowe 2024-01-01 16:42:35 +00:00
parent 1fcbadb8da
commit cea88fa827
1 changed files with 8 additions and 19 deletions

View File

@ -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