summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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"
}
#