summaryrefslogtreecommitdiff
path: root/include/git.sh
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-09-25 12:17:02 +0100
committerLeah Rowe <leah@libreboot.org>2023-09-25 12:21:23 +0100
commit81d073d5a193f2a07ca8efbb1a337a69c1c6d778 (patch)
treecdd09f636a674e7eb94f194d0fea7af6e9a596d5 /include/git.sh
parenteae173ec134809966cd962c1a3c0333583306a11 (diff)
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>
Diffstat (limited to 'include/git.sh')
-rwxr-xr-xinclude/git.sh14
1 files changed, 14 insertions, 0 deletions
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 <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