aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorAndrew Robbins <contact@andrewrobbins.info>2019-03-18 19:12:49 -0400
committerAndrew Robbins <contact@andrewrobbins.info>2019-03-18 22:18:30 -0400
commitf3426c1e431a6cdf2c14963a91a219545ca5b1c8 (patch)
tree2d02e36bd0521813bb3f912338b6945c1b57bad6 /libs
parent88a7101827ebd8ce2adb0d3d451254614d80904f (diff)
downloadlibrebootfr-f3426c1e431a6cdf2c14963a91a219545ca5b1c8.tar.gz
librebootfr-f3426c1e431a6cdf2c14963a91a219545ca5b1c8.zip
libs/git: Move patching method logic to git_patch()
This simplifies git_project_patch_recursive() and provides a unified method for patching, regardless of the patch format (mailbox or diff). Logic is included for dealing with patching failures due to git_apply_check() not being enough to catch certain edge cases, such as 'git apply --check' returning 0 but a subsequent 'git apply' failing.
Diffstat (limited to 'libs')
-rwxr-xr-xlibs/git21
1 files changed, 13 insertions, 8 deletions
diff --git a/libs/git b/libs/git
index 358d5d1f..104239c1 100755
--- a/libs/git
+++ b/libs/git
@@ -210,9 +210,19 @@ git_patch() {
export GIT_COMMITTER_EMAIL=$GIT_EMAIL
cd "$repository_path"
- git checkout "$branch" 2> /dev/null > /dev/null
+ git checkout "$branch" >/dev/null 2>&1
- git am "$patch" || git am --abort
+ case $patch in
+ *.patch)
+ git am "$patch" || git am --abort
+ ;;
+ *.diff)
+ git_apply "$repository_path" "$branch" "$patch" &&
+ git_commit "$repository_path" "Applied ${patch##*/}"
+ ;;
+ *)
+ ;;
+ esac
)
}
@@ -277,12 +287,7 @@ git_project_patch_recursive() {
fi
for patch in "$patches_path"/[!.]*.@(patch|diff); do
- if [[ ${patch##*.} == patch ]]; then
- git_patch "$repository_path" "$branch" "$patch"
- else
- git_apply "$repository_path" "$branch" "$patch"
- git_commit "$repository_path" "Applied ${patch##*/}"
- fi
+ git_patch "$repository_path" "$branch" "$patch"
done
}