commit 584 B

123456789101112131415161718
  1. #!/bin/bash
  2. extra=("$@")
  3. #FIXME: checking only $1 for --amend when it could be any $N is bad! (doing it in two places also)
  4. if test "$(basename "${0}")" == "commitamend" -o "$1" == "--amend" -o "$1" == "--ammend" -o "$1" == "amend" -o "$1" == "ammend"; then
  5. if git status|grep -E '^Your branch is ahead of .* by [1-9]+ commit[s]?.$' ; then
  6. if test "$1" != "--amend"; then # for ./commitamend other flags here
  7. extra+=("--amend")
  8. fi
  9. else
  10. echo "Can't amend, you've already pushed!" >&2
  11. exit 1
  12. fi
  13. fi
  14. #maybe first:
  15. #git add ./OSes/
  16. git commit -a "${extra[@]}"