update-subtree.sh 969 B

12345678910111213141516171819202122232425262728293031
  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 repo branch subdir; do
  13. if [ "${repo:0:1}" = "#" ]; then
  14. continue
  15. fi
  16. exec 69>&1
  17. if [ "${subdir}" = "/" ]; then
  18. result="$(git subtree pull -P "${path}" "${repo}" "${branch}" -m "Merge ${path} from ${repo}" 2>&1 | tee /proc/self/fd/69)"
  19. else
  20. result="$(bash .utils/subtree-subdir-helper.sh "${path}" "${repo}" "${branch}" "${subdir}" merge 2>&1 | tee /proc/self/fd/69)"
  21. fi
  22. if grep "Automatic merge failed; fix conflicts and then commit the result." <<< "$result" > /dev/null; then
  23. echo "Waiting for current index to be resolved..."
  24. while ! git diff --quiet || ! git diff --cached --quiet || ! git merge HEAD &> /dev/null; do
  25. sleep 1
  26. done
  27. fi
  28. done < "${path}/.gitsubtree"