diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/safegit | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/bin/safegit b/bin/safegit new file mode 100755 index 0000000..b5c92c0 --- /dev/null +++ b/bin/safegit @@ -0,0 +1,28 @@ +#!/bin/zsh + +set -o errexit +set -o nounset +set -o pipefail +if [[ "${TRACE-0}" == "1" ]]; then + set -o xtrace +fi + +local isforce=0 +local ispush=0 +for arg in "$@"; do + if [ "$arg" = "-f" ] || [ "$arg" = "--force" ]; then + isforce=1 + fi + + if [ "$arg" = "push" ]; then + ispush=1 + fi + + if [ "$ispush" = 1 ] && [ "$isforce" = 1 ]; then + echo "use \`--force-with-lease\` instead so you don't cause race conflicts in the repo" + return 1 + fi +done + +git "$@" + |
