Skip to content

Commit

Permalink
Rollback if git-pull fails, both merge and rebase style
Browse files Browse the repository at this point in the history
    It would be inconvenient if live symlinked files will stop
    working due to git-merge conflict markers added to those files,
    so if pull fails we make sure display a message and rollback
    files to a pre-pull state
  • Loading branch information
antontsv committed Aug 15, 2016
1 parent 96a8379 commit d72bdcf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/commands/pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ function pull {

local git_out
git_out=$(cd "$repo"; git pull 2>&1)
[[ $? == 0 ]] || err $EX_SOFTWARE "Unable to pull $repo. Git says:" "$git_out"
if [ $? -ne 0 ];then
# try to reset bad merge, to get to a clean state:
$(cd "$repo"; git reset --merge 1>/dev/null 2>&1)
# abort any rebase if pull has been overriden to do a rebase:
$(cd "$repo"; git rebase --abort 1>/dev/null 2>&1)
err $EX_SOFTWARE "Unable to pull $repo. Git says:" "$git_out"
fi;

version_compare $GIT_VERSION 1.6.5
if [[ $? != 2 ]]; then
Expand Down

0 comments on commit d72bdcf

Please sign in to comment.