update-subtree.sh 722 B

1234567891011121314151617181920212223242526
  1. #!/bin/bash
  2. set -e
  3. if [ "$(git rev-parse --show-prefix)" != "" ]; then
  4. echo "Must be in root of git repo!"
  5. exit
  6. fi
  7. if [ "${1}" = "" ]; then
  8. echo "Usage: <path>"
  9. exit
  10. fi
  11. path="${1}"
  12. while read -u $remote repo branch subdir; do
  13. if [ "${repo:0:1}" = "#" ]; then
  14. continue
  15. fi
  16. if [ "${subdir}" = "/" ]; then
  17. exec {capture}>&1
  18. result="$(git subtree pull -P "${path}" "${repo}" "${branch}" -m "Merge ${path} from ${repo}" 2>&1 | tee /proc/self/fd/$capture)"
  19. bash .utils/.check-merge.sh "${path}" "${repo}" "${result}"
  20. else
  21. bash .utils/.subtree-subdir-helper.sh "${path}" "${repo}" "${branch}" "${subdir}" merge
  22. fi
  23. done {remote}< "${path}/.gitsubtree"