Skip to contentSkip to conversation

dim: pass git directory via parameter in dim cite, don't cd

PATCH In review Jani Nikula 1 participant 4 messages Jan 14, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 dim: pass git directory via parameter in dim cite, don't cd

Make dim_cite safer to use within dim.

---
 dim | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
dim +2 -3
index b2fddff1010c..9aac817be567 100755
@@ -2275,9 +2275,8 @@ function dim_cite
 
 	sha1=${1:?$usage}
 
-	cd $DIM_PREFIX/$DIM_REPO
-
-	git log -1 $sha1 "--pretty=format:%H (\"%s\")%n" | \
+	git --git-dir="$DIM_PREFIX/$DIM_REPO/.git" log -1 $sha1 \
+	    "--pretty=format:%H (\"%s\")%n" | \
 		sed -e 's/\([0-f]\{12\}\)[0-f]*/\1/'
 }
 
Signature · 6 lines
2.20.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

PATCH 2/3 dim: improve error messages in push branch checks

Use dim_cite() to produce pretty commit message references. Unify and improve error messages while at it.

---
 dim | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
dim +11 -7
index 9aac817be567..ac100f07a7e4 100755
@@ -805,12 +805,14 @@ function dim_rebuild_tip
 # additional patch checks before pushing, e.g. for r-b tags
 function checkpatch_commit_push
 {
-	local sha1 managed_branch rv author committer author_outlook
+	local sha1 managed_branch rv author committer author_outlook cite
 
 	sha1=$1
 	managed_branch=$2
 	rv=0
 
+	cite=$(dim_cite $sha1)
+
 	# use real names for people with many different email addresses
 	author=$(git show -s $sha1 --format="format:%an")
 	committer=$(git show -s $sha1 --format="format:%cn")
@@ -819,26 +821,26 @@ function checkpatch_commit_push
 
 	# check for author sign-off
 	if ! git show -s $sha1 | grep -qi "Signed-off-by:.*\\($author\\|$author_outlook\\)" ; then
-		echoerr "$sha1 is lacking author of sign-off"
+		echoerr "$cite: author Signed-off-by missing."
 		rv=1
 	fi
 
 	# check for committer sign-off
 	if ! git show -s $sha1 | grep -qi "Signed-off-by:.*$committer"  ; then
-		echoerr "$sha1 is lacking committer of sign-off"
+		echoerr "$cite: committer Signed-off-by missing."
 		rv=1
 	fi
 
 	# check for Link tag
 	if [[ "$managed_branch" = "1" ]] && ! git show -s $sha1 | grep -qi 'Link:'  ; then
-		echoerr "$sha1 is lacking of link tag"
+		echoerr "$cite: Link tag missing."
 		rv=1
 	fi
 
 	# check for a-b/r-b tag
 	if ! git show -s $sha1 | grep -qi '\(reviewed\|acked\)\S*-by:' && \
 	   ! [[ "$committer" != "$author" ]]; then
-		echoerr "$sha1 is lacking mandatory review"
+		echoerr "$cite: mandatory review missing."
 		rv=1
 	fi
 
@@ -847,16 +849,18 @@ function checkpatch_commit_push
 
 function checkmerge_commit_push
 {
-	local sha1 managed_branch rv body_text
+	local sha1 managed_branch rv body_text cite
 
 	sha1=$1
 	managed_branch=${2}
 	rv=0
 
+	cite=$(dim_cite $sha1)
+
 	body_text="$(git show $sha1 -s --format="format:%b" | grep -v "^$" | grep -v "^\S*:")"
 
 	if [[ -z "$body_text" ]] ; then
-		echoerr "$sha1 is lacking merge commit justification"
+		echoerr "$cite: merge commit justification missing."
 		rv=1
 	fi
 
Signature · 6 lines
2.20.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#2 lore raw

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

In reply to Jani Nikula

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.

---
 dim | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
dim +11 -1
index ac100f07a7e4..64d2bf147647 100755
@@ -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
Signature · 6 lines
2.20.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#3 lore raw
In reply to Jani Nikula

This series obviously sent to the wrong list. Resubmitted to dim-tools.

Sorry for the noise.

BR,
Jani.

Quoted 22 lines · Jani Nikula

Make dim_cite safer to use within dim.

---
 dim | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
dim +2 -3
index b2fddff1010c..9aac817be567 100755
@@ -2275,9 +2275,8 @@ function dim_cite
 
 	sha1=${1:?$usage}
 
-	cd $DIM_PREFIX/$DIM_REPO
-
-	git log -1 $sha1 "--pretty=format:%H (\"%s\")%n" | \
+	git --git-dir="$DIM_PREFIX/$DIM_REPO/.git" log -1 $sha1 \
+	    "--pretty=format:%H (\"%s\")%n" | \
 		sed -e 's/\([0-f]\{12\}\)[0-f]*/\1/'
 }
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev