Commit b723dd96 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Handle divergence after a failed push of auto-commits

parent 5adfee60
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -63,6 +63,26 @@ get_shell()
	echo sh
}

update_worktree()
{
	local upstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{u})
	if [ -z "$upstream" ]; then
		return 0
	fi
	local stash=$(git stash create)
	local original=$(git rev-parse HEAD)
	git reset --hard HEAD
	git fetch origin
	git filter-branch -f --commit-filter '
		if grep -q "Automatically generated"; then
			skip_commit "$@"
		else
			git commit-tree "$@"
		fi' $upstream..HEAD
	git merge --ff-only $upstream || git reset $original
	git stash apply $stash
}

update_submodules()
{
	git submodule sync --recursive
@@ -131,7 +151,7 @@ do_update()
	esac

	(cd ~
		git pull --ff-only origin &&
		update_worktree &&
		update_submodules
	) || return