diff options
author | Andrew Robbins <contact@andrewrobbins.info> | 2019-03-18 19:12:49 -0400 |
---|---|---|
committer | Andrew Robbins <contact@andrewrobbins.info> | 2019-03-18 22:18:30 -0400 |
commit | f3426c1e431a6cdf2c14963a91a219545ca5b1c8 (patch) | |
tree | 2d02e36bd0521813bb3f912338b6945c1b57bad6 | |
parent | 88a7101827ebd8ce2adb0d3d451254614d80904f (diff) | |
download | librebootfr-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.
-rwxr-xr-x | libs/git | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -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 } |