update-subtree.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233
  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 "MERGE_MSG: Merge ${path} from ${repo}"
  24. echo "Waiting for current index to be resolved..."
  25. notify-send -a Git -i git "Subtree merge failed" "Resolve current index to continue" &> /dev/null | true
  26. while ! git diff --quiet || ! git diff --cached --quiet || ! git merge HEAD &> /dev/null; do
  27. sleep 1
  28. done
  29. fi
  30. done < "${path}/.gitsubtree"