From 81d073d5a193f2a07ca8efbb1a337a69c1c6d778 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 25 Sep 2023 12:17:02 +0100 Subject: 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 --- include/git.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include/git.sh') diff --git a/include/git.sh b/include/git.sh index 9a48023d..1ad84d11 100755 --- a/include/git.sh +++ b/include/git.sh @@ -1,6 +1,20 @@ # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2023 Leah Rowe +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 -- cgit v1.2.1