aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorAndrew Robbins <contact@andrewrobbins.info>2019-03-18 22:17:45 -0400
committerAndrew Robbins <contact@andrewrobbins.info>2019-03-18 22:18:30 -0400
commit4a493108d1aefe3151096c3b22234d0c8cf893d9 (patch)
tree397ec0c98fa814f8105c1038dac2a984337ab4cc /libs
parentf3426c1e431a6cdf2c14963a91a219545ca5b1c8 (diff)
downloadlibrebootfr-4a493108d1aefe3151096c3b22234d0c8cf893d9.tar.gz
librebootfr-4a493108d1aefe3151096c3b22234d0c8cf893d9.zip
libs/git: Avoid some redundancies in git_patch()
The subshell, changing directory, and checking out was unecessary considering all of these are done within the functions called by git_patch() git_am() was added in order to mirror the same wrapper style as used by git_apply() and git_commit()
Diffstat (limited to 'libs')
-rwxr-xr-xlibs/git48
1 files changed, 29 insertions, 19 deletions
diff --git a/libs/git b/libs/git
index 104239c1..f5d764ef 100755
--- a/libs/git
+++ b/libs/git
@@ -169,7 +169,7 @@ git_commit() {
)
}
-git_apply() {
+git_am() {
local repository_path=$1
local branch=$2
local patch=$3
@@ -182,50 +182,60 @@ git_apply() {
git checkout "$branch" >/dev/null 2>&1
if git_apply_check "$repository_path" "$branch" "$patch"; then
- git apply --index "$patch"
+ git am "$patch" || git am --abort
fi
)
}
-git_apply_check() {
+git_apply() {
local repository_path=$1
local branch=$2
local patch=$3
(
+ export GIT_COMMITTER_NAME=$GIT_NAME
+ export GIT_COMMITTER_EMAIL=$GIT_EMAIL
+
cd "$repository_path"
git checkout "$branch" >/dev/null 2>&1
- git apply --check "$patch"
+ if git_apply_check "$repository_path" "$branch" "$patch"; then
+ git apply --index "$patch"
+ fi
)
}
-git_patch() {
+git_apply_check() {
local repository_path=$1
local branch=$2
local patch=$3
(
- export GIT_COMMITTER_NAME=$GIT_NAME
- export GIT_COMMITTER_EMAIL=$GIT_EMAIL
-
cd "$repository_path"
git checkout "$branch" >/dev/null 2>&1
- case $patch in
- *.patch)
- git am "$patch" || git am --abort
- ;;
- *.diff)
- git_apply "$repository_path" "$branch" "$patch" &&
- git_commit "$repository_path" "Applied ${patch##*/}"
- ;;
- *)
- ;;
- esac
+ git apply --check "$patch"
)
}
+git_patch() {
+ local repository_path=$1
+ local branch=$2
+ local patch=$3
+
+ case $patch in
+ *.patch)
+ git_am "$repository_path" "$branch" "$patch"
+ ;;
+ *.diff)
+ git_apply "$repository_path" "$branch" "$patch" &&
+ git_commit "$repository_path" "Applied ${patch##*/}"
+ ;;
+ *)
+ ;;
+ esac
+}
+
git_revision() {
local repository_path=$1