summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rwxr-xr-xinclude/git.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/git.sh b/include/git.sh
new file mode 100755
index 00000000..f7026765
--- /dev/null
+++ b/include/git.sh
@@ -0,0 +1,21 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
+
+git_am_patches()
+{
+ sdir="${1}" # assumed to be absolute path
+ patchdir="${2}" # ditto
+ _fail="${3}"
+ (
+ cd "${sdir}" || \
+ "${_fail}" "apply_patches: !cd \"${sdir}\""
+ for patch in "${patchdir}/"*; do
+ [ -L "${patch}" ] && continue
+ [ -f "${patch}" ] || continue
+ if ! git am "${patch}"; then
+ git am --abort || "${_fail}" "${sdir}: !git am --abort"
+ "${_fail}" "!git am ${patch} -> ${sdir}"
+ fi
+ done
+ )
+}