update-subtree.sh 817 B

123456789101112131415161718192021
  1. #!/bin/bash
  2. set -e
  3. path="${GIT_PREFIX%/}"
  4. while read repo branch subdir; do
  5. if [ "${repo:0:1}" = "#" ]; then
  6. continue
  7. fi
  8. exec 69>&1
  9. if [ "${subdir}" = "/" ]; then
  10. result="$(git subtree pull -P "${path}" "${repo}" "${branch}" -m "Merge ${path} from ${repo}" 2>&1 | tee /proc/self/fd/69)"
  11. else
  12. result="$(bash .utils/subtree-subdir-helper.sh "${path}" "${repo}" "${branch}" "${subdir}" merge 2>&1 | tee /proc/self/fd/69)"
  13. fi
  14. if grep "Automatic merge failed; fix conflicts and then commit the result." <<< "$result" > /dev/null; then
  15. echo "Waiting for current index to be resolved..."
  16. while ! git diff --quiet || ! git diff --cached --quiet || ! git merge HEAD &> /dev/null; do
  17. sleep 1
  18. done
  19. fi
  20. done < "${GIT_PREFIX}.gitsubtree"