summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflu0r1ne <flu0r1ne@flu0r1ne.net>2021-09-18 19:42:41 -0500
committerflu0r1ne <flu0r1ne@flu0r1ne.net>2021-09-18 19:44:43 -0500
commit9d8e731e754d4419b7f529ee938f2d3a23101447 (patch)
treef0d06e2e92cdf926aa17450e76f51fc0ae3acb49
parente7baa3b9cfb27dea951e465eb9f31782718b687e (diff)
downloadgit-update-agent-main.tar.xz
git-update-agent-main.zip
Update to v0.0.7 and autopopHEADv0.0.7main
-rwxr-xr-xgit-update-agent31
1 files changed, 26 insertions, 5 deletions
diff --git a/git-update-agent b/git-update-agent
index 6d1ebdb..e3a56ed 100755
--- a/git-update-agent
+++ b/git-update-agent
@@ -99,6 +99,23 @@ local_branch() {
echo "$branch"
}
+die_manually_pop_stash() {
+die <<_EOF
+Could not pop git stash, must be manually popped to restore state:
+git stash pop
+_EOF
+}
+
+try_stash_pop() {
+ if [ -n "${STASHED}" ] && [ -z "${NO_STASH_POP}" ]; then
+
+ if ! git stash pop &>/dev/null; then
+ die_manually_pop_stash
+ fi
+
+ fi
+}
+
merge() {
local STASHED
@@ -113,6 +130,7 @@ merge() {
local remote_ref
remote_ref="$remote/$remote_branch"
+ trap 'try_stash_pop' EXIT
if [[ -n "$(git status --untracked-files=all --porcelain 2>/dev/null)" ]]; then
# Abort rebase or merge if initiated
@@ -138,9 +156,9 @@ merge() {
--strategy-option=ignore-all-space \
>/dev/null
- if [[ -n "$STASHED" && -z "$NO_STASH_POP" ]]; then
- git stash pop &>/dev/null
- fi
+ trap - EXIT
+
+ try_stash_pop
}
remote() {
@@ -312,7 +330,10 @@ init_repo() {
DEFAULT_BRANCH="main"
- git init &>/dev/null
+ if ! git init &>/dev/null; then
+ die "Could not initalize git repository"
+ fi
+
git config "remote.${remote}.url" "$remote_url"
git config "remote.${remote}.fetch" "+refs/heads/*:refs/remotes/$remote/*"
set_should_track true
@@ -329,7 +350,7 @@ init_repo() {
}
print_version() {
- echo "0.0.6"
+ echo "0.0.7"
}
#