/etckeeper/init.d/70vcs-add

http://github.com/brinkman83/bashrc · Shell · 27 lines · 24 code · 1 blank · 2 comment · 8 complexity · ef0c315d37d73a48ca19c238a57b0b0c MD5 · raw file

  1. #!/bin/sh
  2. set -e
  3. if [ "$VCS" = git ]; then
  4. if ! git add .; then
  5. echo "etckeeper warning: git add failed" >&2
  6. fi
  7. elif [ "$VCS" = hg ]; then
  8. if ! hg add .; then
  9. echo "etckeeper warning: hg add failed" >&2
  10. fi
  11. elif [ "$VCS" = bzr ]; then
  12. if ! bzr add .; then
  13. echo "etckeeper warning: bzr add failed" >&2
  14. fi
  15. elif [ "$VCS" = darcs ]; then
  16. # Don't warn if all the files were already added.
  17. rc=0
  18. res=$( darcs add -qr . 2>&1 ) || rc=$?
  19. if test $rc -ne 0; then
  20. if ! test $rc -eq 2 -a "${res%No files were added}" != "$res"; then
  21. printf "%s" "$res"
  22. echo "etckeeper warning: darcs add failed" >&2
  23. fi
  24. fi
  25. unset rc res
  26. fi