dim: Disallow remote branch deletions with 'dim push'
An inadvertent 'dim push -d' can delete remote branches. Disallow such remote branch deletions.
v2: s/
Signed-off-by: Ashutosh Dixit ashutosh.dixit@intel.com
Merge request reports
Activity
This one's old, fell between the cracks...
The first problem is,
"$*" == *"-d"*
maches anything that has-d
in it. Including, say,--dry-run
, but happily (likely by coincidence) also--delete
. How thorough or accurate do we want this to be?Perhaps check for any extra options being passed to
git push
, and prompt for confirmation?I recently had this issue when performing a
dim push-branch drm-misc-next -d
.$ ../maintainer-tools/dim push-branch drm-misc-next -d remote: GitLab: You are not allowed to delete protected branches from this project. Only a project maintainer or owner can delete a protected branch. To ssh://gitlab.freedesktop.org/drm/misc/kernel.git ! [remote rejected] drm-misc-next (pre-receive hook declined) error: failed to push some refs to 'ssh://gitlab.freedesktop.org/drm/misc/kernel.git'
How about using
if [[ " $* " == [[:space:]]-d[[:space:]] ]]
?Here's an alternative idea: Just do not pass
"$@"
togit
by default. At all.Add a new
dim
parameter--passthrough-args
or similar, and require that to pass the rest of the params togit
or other shell commands. Warn if"$@"
is present without the parameter.This avoids accidents in the common cases, and enables full flexibility when required. And avoids the complexity of trying to parse "dangerous"
git
parameters.@adixit, do you plan to work on Jani's suggestion?