diff options
author | Leah Rowe <leah@libreboot.org> | 2024-01-01 16:42:35 +0000 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2024-01-01 16:47:16 +0000 |
commit | cea88fa827c00ef13c51c81b0e60c74019591ba3 (patch) | |
tree | 1447d0ab9e31198ab77b16acdaaf338f2bc34e2e /include/git.sh | |
parent | 1fcbadb8da52a0ca8924b61a83fa86cc38a1c360 (diff) |
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>
Diffstat (limited to 'include/git.sh')
-rwxr-xr-x | include/git.sh | 27 |
1 files changed, 8 insertions, 19 deletions
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 |