[PATCH] dim: add additional prompts for pushing merges

Jani Nikula jani.nikula at intel.com
Mon Aug 16 06:55:40 UTC 2021


On Wed, 11 Aug 2021, Jani Nikula <jani.nikula at intel.com> wrote:
> It's not exactly trivial to add the smarts to properly check for pushing
> backmerges, rebases, topic branches and subtree branches (such as
> gvt). For a start, prompt the user with hints about what's going on.

I've pushed this with Daniel's and Rodrigo's acks.

It will cause dim to have a new prompt when you're pushing merges, for example:

	Pushing 1 merges and 0 non-merge commits. Merges should only be
	pushed by maintainers. Are you sure? (y/N)

The old prompt warning about pushing lots of commits at a time has been
changed to:

	Pushing 13 commits. Commits should be only be pushed in
	relatively small batches. Are you sure?

You won't get two prompts for the same push.

The main idea remains, warn people about pushing more or something
different than they intend.



BR,
Jani.


>
> Cc: Daniel Vetter <daniel at ffwll.ch>
> Signed-off-by: Jani Nikula <jani.nikula at intel.com>
>
> ---
>
> Untested.
> ---
>  dim | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/dim b/dim
> index 56463eb0c0a6..9fc2d78b8617 100755
> --- a/dim
> +++ b/dim
> @@ -989,7 +989,7 @@ function checkpatch_commit_push_range
>  # push.
>  function dim_push_branch
>  {
> -	local branch remote committer_email count
> +	local branch remote committer_email commit_count merge_count
>  
>  	branch=${1:?$usage}
>  	shift
> @@ -1004,9 +1004,15 @@ function dim_push_branch
>  
>  	# Apart from maintainers pushing merges or rebases, most patches should
>  	# be pushed in small batches.
> -	count=$(git rev-list --count --first-parent "$branch@{u}..$branch")
> -	if [[ $count -gt 10 ]]; then
> -		if ! ask_user "Pushing $count commits. Are you sure?"; then
> +	commit_count=$(git rev-list --count --no-merges --first-parent "$branch@{u}..$branch")
> +	merge_count=$(git rev-list --count --merges --first-parent "$branch@{u}..$branch")
> +	if [[ $merge_count -gt 0 ]]; then
> +		if ! ask_user "Pushing $merge_count merges and $commit_count non-merge commits. Merges should only be pushed by maintainers. Are you sure?"; then
> +			echoerr "NOTE: Branch not pushed."
> +			return 1
> +		fi
> +	elif [[ $commit_count -gt 10 ]]; then
> +		if ! ask_user "Pushing $commit_count commits. Commits should be only be pushed in relatively small batches. Are you sure?"; then
>  			echoerr "NOTE: Branch not pushed."
>  			return 1
>  		fi

-- 
Jani Nikula, Intel Open Source Graphics Center


More information about the dim-tools mailing list