Skip to contentSkip to conversation

dim: Disallow remote branch deletions with 'dim push'

PATCH In review Ashutosh Dixit 3 participants 4 messages Jun 2, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dim: Disallow remote branch deletions with 'dim push'

An inadvertent 'dim push -d' can delete remote branches. Disallow such remote branch deletions.

---
 dim | 6 ++++++
 1 file changed, 6 insertions(+)
dim +6 -0
index 126568e..e5899e6 100755
@@ -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
Signature · 1 line
2.38.0
#1 lore raw

[Intel-gfx] ✗ Fi.CI.BUILD: failure for dim: Disallow remote branch deletions with 'dim push'

== Series Details ==

== Series Details ==

Series: dim: Disallow remote branch deletions with 'dim push'
URL : https://patchwork.freedesktop.org/series/118744/
State : failure

== Summary ==

Error: patch https://patchwork.freedesktop.org/api/1.0/series/118744/revisions/1/mbox/ not applied
Applying: dim: Disallow remote branch deletions with 'dim push'
error: sha1 information is lacking or useless (dim).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 dim: Disallow remote branch deletions with 'dim push'
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Build failed, no error log produced

#2 lore raw
In reply to Ashutosh Dixit
Quoted 2 lines · Ashutosh Dixit

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

Quoted 11 lines
---
 dim | 6 ++++++
 1 file changed, 6 insertions(+)
dim +0 -0
index 126568e..e5899e6 100755

dim function dim_push_branch · line 1036

Quoted 8 lines
dim +5 -0
@@ -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.

Quoted 4 lines
dim +1 -0
+
 	git_push $remote $branch "$@"
 
 	update_linux_next $branch drm-intel-next drm-intel-next-fixes drm-intel-fixes
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
#3 lore raw
Quoted 21 lines · Jani Nikula
Quoted 2 lines · Ashutosh Dixit

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

Quoted 14 lines
---
 dim | 6 ++++++
 1 file changed, 6 insertions(+)
dim +0 -0
index 126568e..e5899e6 100755
@@ -1029,6 +1029,12 @@ function dim_push_branch
 		fi
 	fi
 
Quoted 10 lines

dim function dim_push_branch · line 1036

Quoted 5 lines
dim +5 -0
+	# 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

Quoted 7 lines

dim function dim_push_branch · line 1040

Quoted 4 lines
dim +1 -0
+
 	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