aboutsummaryrefslogtreecommitdiff
path: root/bin/safegit
blob: b5c92c07f3f25d9fa5222297292554a92c60350b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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 "$@"