You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Commit: always allow. --amend is normal pre-push; post-push
230
+
# amend is gated by the push rule below. --no-edit is allowed
231
+
# (useful for amend flows the operator explicitly chose).
199
232
commit)
233
+
exec git "$@"
234
+
;;
235
+
# Merge: refuse when current branch is master/main. Operator
236
+
# uses session-merge flow or bare git with explicit approval.
237
+
merge)
238
+
local_CUR=$(git rev-parse --abbrev-ref HEAD 2>/dev/null ||echo"")
239
+
if [ "$local_CUR"="master" ] || [ "$local_CUR"="main" ];then
240
+
die "git merge: refusing to merge into '$local_CUR'. Use 'session-merge <branch>' for the merge-to-main approval flow, or switch off master/main first."
241
+
fi
242
+
exec git "$@"
243
+
;;
244
+
# Push: refuse if (a) current branch is master/main, (b) any
245
+
# argv token targets master/main via any refspec form, or
246
+
# (c) the remote argument is 'upstream'. Force-push flags are
247
+
# allowed on feature branches by design.
248
+
push)
249
+
local_CUR=$(git rev-parse --abbrev-ref HEAD 2>/dev/null ||echo"")
250
+
if [ "$local_CUR"="master" ] || [ "$local_CUR"="main" ];then
251
+
die "git push: refusing to push while on '$local_CUR' (implicit target). Switch to a feature branch first, or use session-merge for the merge-to-main approval flow."
252
+
fi
253
+
local_SAW_REMOTE=0
254
+
local_REMOTE=""
255
+
forargin"$@";do
256
+
case"$arg"in
257
+
push|-*) ;; # subcommand or flag
258
+
*)
259
+
if [ "$local_SAW_REMOTE"= 0 ];then
260
+
local_REMOTE="$arg"
261
+
local_SAW_REMOTE=1
262
+
fi
263
+
;;
264
+
esac
265
+
done
266
+
if [ "$local_REMOTE"="upstream" ];then
267
+
die "git push upstream ...: refusing to push to the upstream remote. This script never pushes upstream. Use origin for your own fork."
268
+
fi
200
269
forargin"$@";do
201
270
case"$arg"in
202
-
--amend|--no-edit)
203
-
die "git commit $arg: not allowed (would rewrite a published commit). Create a new commit instead."
0 commit comments