diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-04-19 16:29:03 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-04-19 16:30:50 -0700 |
commit | 54d251a68cee30840f2a6a732b655e874d83f884 (patch) | |
tree | 40da24b1eec2fdcba0598fa84d07f3307bb3ad7f /bin/git-pull-safe | |
parent | 43be0ce2d6721f7d5a90babf0e7ae7e0921f3170 (diff) | |
download | dotfiles-54d251a68cee30840f2a6a732b655e874d83f884.tar.gz |
git-pull-safe: don't do anything when branch contains its upstream
In such a case `git merge-ff` will fail but git-pull-safe should not.
Diffstat (limited to 'bin/git-pull-safe')
-rwxr-xr-x | bin/git-pull-safe | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/bin/git-pull-safe b/bin/git-pull-safe index 32a61b56..874c67e2 100755 --- a/bin/git-pull-safe +++ b/bin/git-pull-safe @@ -31,11 +31,14 @@ git fetch --all --tags --prune for branch in $branches; do remote="$(branch_remote $branch 2>/dev/null || true)" if [ "$(branch_prefix $branch)" != "dgit" ] && [ "$remote" != "" ]; then - # if the branch cannot be fast-forwarded, git-merge-ff will - # exit non-zero, so myrepos will report that the update - # failed, so user intervention is required # echo "I: attempting to fast-forward local branch $branch" - git merge-ff "$branch" + if ! git branch --contains "$branch@{upstream}" \ + | grep -qE " $branch$"; then + # if the branch cannot be fast-forwarded, git-merge-ff + # will exit non-zero, so myrepos will report that the + # update failed, so user intervention is required + git merge-ff "$branch" + fi fi done |