You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
776 B

  1. #!/bin/sh
  2. set -u
  3. cd "$(dirname "$0")"
  4. branch="$(git branch | sed -n 's/^* \(.*\)$/\1/p;')"
  5. [ -n "$branch" ] || exit
  6. remote=$(git config --get "branch.$branch.remote")
  7. rbranch=$(git config --get "branch.$branch.merge" | sed -e 's|^refs/heads/||')
  8. rurl=$(git config --get "remote.$remote.url")
  9. [ -n "$remote" -a -n "$rbranch" -a -n "$rurl" ] || exit
  10. echo "# $PWD ($branch <- $rurl:$rbranch)"
  11. hash0=$(git rev-parse "$remote/$rbranch")
  12. git fetch "$remote"
  13. hash1=$(git rev-parse "$remote/$rbranch")
  14. [ -n "$hash0" -a -n "$hash1" -a "$hash0" != "$hash1" ] || exit
  15. if [ "$(git ls-files -md)" ]; then
  16. stashed=true
  17. git stash -q
  18. else
  19. stashed=false
  20. fi
  21. git rebase "$remote/$rbranch"
  22. git submodule update --init
  23. if $stashed; then
  24. git stash pop -q
  25. fi
  26. [ $# -eq 0 ] || exec "$@"