update/project/*: unified git reset handling

With this change, lbmk now also updates submodules on
simple git clones, not just multi-tree clones.

This is OK, because git does not return non-zero status
when git submodule update is ran, where git submodules
are not actually defined.

Signed-off-by: Leah Rowe <leah@libreboot.org>
btrfsvols
Leah Rowe 2023-09-25 12:17:02 +01:00
parent eae173ec13
commit 81d073d5a1
3 changed files with 19 additions and 12 deletions

View File

@ -1,6 +1,20 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
git_reset_rev()
{
sdir="${1}"
_rev="${2}"
_fail="${3}"
(
cd "${sdir}" || "${_fail}" "cannot cd to ${sdir}"
git reset --hard ${_rev} || \
"${_fail}" "cannot git reset ${sdir} <- ${rev}"
git submodule update --init --checkout || \
"${_fail}" "cannot update git modules <- ${sdir}"
)
}
git_am_patches()
{
sdir="${1}" # assumed to be absolute path

View File

@ -79,11 +79,8 @@ clone_project()
git clone ${url} "${tmp_dir}" || git clone ${bkup_url} "${tmp_dir}" || \
fail "clone_project: could not download ${name}"
(
cd "${tmp_dir}" || fail "clone_project: tmpdir not created"
git reset --hard ${revision} || \
fail "clone_project: Cannot reset revision"
)
git_reset_rev "${tmp_dir}" "${revision}" "fail" || \
fail "clone_project ${location}/: cannot reset <- ${revision}"
git_am_patches "${tmp_dir}" "${PWD}/config/${name}/patches" "fail" || \
fail "clone_project ${location}/: cannot apply patches"

View File

@ -143,13 +143,9 @@ prepare_new_tree()
cp -R "${project}/${project}" "${project}/${tree}" || \
err "${project}/${tree}: cannot copy source tree"
(
cd "${project}/${tree}" || err "cannot cd to ${project}/${tree}"
git reset --hard ${rev} || \
err "cannot reset ${project} revision for tree, ${tree}"
git submodule update --init --checkout || \
err "cannot update ${project} submodules for tree, ${tree}"
)
git_reset_rev "${project}/${tree}" "${rev}" "err" || \
err "prepare_new_trees ${project}/${tree}: cannot reset <- ${rev}"
git_am_patches "${PWD}/${project}/${tree}" \
"${PWD}/${cfgsdir}/${tree}/patches" "err" || \
err "prepare_new_trees ${project}/${tree}: cannot apply patches"