X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=%2Bbin%2Fgit-up;h=c0172a2b6de64956dac3df4f8b576a1ae63752b3;hb=901f0486e49163e44626809ac42a18c6a1dd52bf;hp=06a2c71ff944bf4bc4377f19407e731f4b14882e;hpb=5923f706617b966f114656c78bd60108d4ab1dde;p=~madcoder%2Fdotfiles.git diff --git a/+bin/git-up b/+bin/git-up index 06a2c71..c0172a2 100755 --- a/+bin/git-up +++ b/+bin/git-up @@ -1,5 +1,7 @@ #!/bin/sh +. "$(dirname "$0")/setup.sh" + OPTIONS_SPEC="\ $(basename $0) [options] [ []] -- @@ -8,7 +10,7 @@ r,rebase perform a rebase m,merge perform a merge " SUBDIRECTORY_OK=t -. git-sh-setup +. "$(git --exec-path)/git-sh-setup" require_work_tree lbranch=$(git symbolic-ref HEAD | sed -e s~refs/heads/~~) @@ -52,7 +54,10 @@ case $# in *) usage;; esac -git fetch "${remote}" +git remote update +if git config remote.mob.fetch >/dev/null 2>/dev/null; then + git remote prune mob +fi if test `git rev-list .."${remote}/${branch#refs/heads/}" -- | wc -l` = 0; then echo "Current branch $lbranch is up to date." exit 0 @@ -69,16 +74,20 @@ if test -z "$action"; then esac fi +no_changes () { + git diff-index --quiet --cached HEAD --ignore-submodules -- && + git diff-files --quiet --ignore-submodules +} + unclean= -git rev-parse --verify HEAD > /dev/null && \ - git update-index --refresh && \ - git diff-files --quiet && \ - git diff-index --cached --quiet HEAD -- || unclean=t +no_changes || unclean=t + case "$action" in rebase) test -z "$unclean" || git stash save "git-up stash" git rebase "${remote}/${branch#refs/heads/}" + cd "$(dirname "$(git rev-parse --git-dir)")" && git submodule update --rebase ;; merge) test -z "$unclean" || git stash save "git-up stash" @@ -95,6 +104,6 @@ if test -n "$unclean"; then echo "" echo "run 'git stash apply' when rebase is finished" else - git stash apply + git stash pop fi fi