[PATCH 3/3] dim: add safeguards for users pushing too many commits at once

Jani Nikula jani.nikula at intel.com
Mon Jan 14 15:23:15 UTC 2019


In most cases, even when pushing long series, it's better to push
commits in moderately sized batches. One functional reason is resolving
potential drm-tip conflicts in smaller and more isolated units, which is
easier to resolve, and is less likely to need a new massive conflict
resolution later.

Ask the user for confirmation when they're trying to push more than
(arbitrarily chosen) 10 patches in one go. This also acts as a safeguard
for pushing more than the user intended.

Obviously maintainers will also face the question when pushing merges or
rebases, but there's no harm in that. They also need to be sure this is
what they mean.

Signed-off-by: Jani Nikula <jani.nikula at intel.com>
---
 dim | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/dim b/dim
index ac100f07a7e4..64d2bf147647 100755
--- a/dim
+++ b/dim
@@ -892,7 +892,7 @@ function checkpatch_commit_push_range
 # push.
 function dim_push_branch
 {
-	local branch remote
+	local branch remote count
 
 	branch=${1:?$usage}
 	shift
@@ -903,6 +903,16 @@ function dim_push_branch
 
 	checkpatch_commit_push_range 1 "$branch@{u}..$branch" --first-parent
 
+	# Apart from maintainers pushing merges or rebases, most patches should
+	# be pushed in small batches.
+	count=$(git rev-list --count "$branch@{u}..$branch")
+	if [[ $count -gt 10 ]]; then
+		if ! ask_user "Pushing $count commits. Are you sure?"; then
+			echoerr "NOTE: Branch not pushed."
+			return 1
+		fi
+	fi
+
 	git push $DRY_RUN $remote $branch "$@"
 
 	update_linux_next $branch drm-intel-next-queued drm-intel-next-fixes drm-intel-fixes
-- 
2.20.1



More information about the dim-tools mailing list