diff mbox series

dim: Disallow remote branch deletions with 'dim push'

Message ID 20230602035010.1517899-1-ashutosh.dixit@intel.com (mailing list archive)
State New, archived
Headers show
Series dim: Disallow remote branch deletions with 'dim push' | expand

Commit Message

Dixit, Ashutosh June 2, 2023, 3:50 a.m. UTC
An inadvertent 'dim push -d' can delete remote branches. Disallow such
remote branch deletions.

Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
 dim | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Jani Nikula June 2, 2023, 10:16 a.m. UTC | #1
On Thu, 01 Jun 2023, Ashutosh Dixit <ashutosh.dixit@intel.com> wrote:
> An inadvertent 'dim push -d' can delete remote branches. Disallow such
> remote branch deletions.

Please see https://drm.pages.freedesktop.org/maintainer-tools/CONTRIBUTING.html

>
> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> ---
>  dim | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/dim b/dim
> index 126568e..e5899e6 100755
> --- a/dim
> +++ b/dim
> @@ -1029,6 +1029,12 @@ function dim_push_branch
>  		fi
>  	fi
>  
> +	# Disallow remote branch deletions, say with 'dim push -d'
> +	if [[ "$@" == *"-d"* ]]; then
> +		echoerr "Attempt to delete remote branch, aborting."
> +		return 1
> +	fi

I'm working on adding a server side git pre-receive hook to tackle this
too, but I guess there's no harm in adding this. The choice of -d for
dry run was unfortunate, and this helps with the 'dim -d foo' vs 'dim
foo -d' mistake.

BR,
Jani.


> +
>  	git_push $remote $branch "$@"
>  
>  	update_linux_next $branch drm-intel-next drm-intel-next-fixes drm-intel-fixes
Dixit, Ashutosh June 2, 2023, 8:54 p.m. UTC | #2
On Fri, 02 Jun 2023 03:16:20 -0700, Jani Nikula wrote:
>
> On Thu, 01 Jun 2023, Ashutosh Dixit <ashutosh.dixit@intel.com> wrote:
> > An inadvertent 'dim push -d' can delete remote branches. Disallow such
> > remote branch deletions.
>
> Please see https://drm.pages.freedesktop.org/maintainer-tools/CONTRIBUTING.html
>
> >
> > Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> > ---
> >  dim | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/dim b/dim
> > index 126568e..e5899e6 100755
> > --- a/dim
> > +++ b/dim
> > @@ -1029,6 +1029,12 @@ function dim_push_branch
> >		fi
> >	fi
> >
> > +	# Disallow remote branch deletions, say with 'dim push -d'
> > +	if [[ "$@" == *"-d"* ]]; then
> > +		echoerr "Attempt to delete remote branch, aborting."
> > +		return 1
> > +	fi
>
> I'm working on adding a server side git pre-receive hook to tackle this
> too, but I guess there's no harm in adding this. The choice of -d for
> dry run was unfortunate, and this helps with the 'dim -d foo' vs 'dim
> foo -d' mistake.

Yup, understood. I thought I'd just send out the patch anyway in case it
was useful.

I have created a merge request for the patch here:

https://gitlab.freedesktop.org/drm/maintainer-tools/-/merge_requests/21

Thanks.
--
Ashutosh

> > +
> >	git_push $remote $branch "$@"
> >
> >	update_linux_next $branch drm-intel-next drm-intel-next-fixes drm-intel-fixes
>
> --
> Jani Nikula, Intel Open Source Graphics Center
diff mbox series

Patch

diff --git a/dim b/dim
index 126568e..e5899e6 100755
--- a/dim
+++ b/dim
@@ -1029,6 +1029,12 @@  function dim_push_branch
 		fi
 	fi
 
+	# Disallow remote branch deletions, say with 'dim push -d'
+	if [[ "$@" == *"-d"* ]]; then
+		echoerr "Attempt to delete remote branch, aborting."
+		return 1
+	fi
+
 	git_push $remote $branch "$@"
 
 	update_linux_next $branch drm-intel-next drm-intel-next-fixes drm-intel-fixes