[Intel-gfx] [PATCH] dim: Add helper command to generate Fixes: lines

Daniel Vetter daniel.vetter at ffwll.ch
Wed Dec 23 04:10:06 PST 2015


Unfortunately a simple git alias doesn't work since the linux kernel
wants a sha1 shortened to 12 characters, and the git commit
prettifying can't do that with e.g. %12h. sed to the rescue.

I'm using this when editing commit messages after applying (:read !dim
fixes sha1 in vim).

Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
---
 bash_completion | 4 ++--
 dim             | 5 +++++
 dim.rst         | 5 +++++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/bash_completion b/bash_completion
index 7f129ca818eb..e44e5fc844b4 100644
--- a/bash_completion
+++ b/bash_completion
@@ -29,7 +29,7 @@ _dim ()
 	cmds="$cmds magic-patch mp cd"
 	cmds="$cmds magic-rebase-resolve mrr"
 	cmds="$cmds apply-igt ai"
-	cmds="$cmds apply-resolved ar tc check-patch cp cherry-pick"
+	cmds="$cmds apply-resolved ar tc fixes check-patch cp cherry-pick"
 	cmds="$cmds pull-request pull-request-fixes pull-request-next pull-request-next-fixes"
 	cmds="$cmds update-next"
 	cmds="$cmds create-branch remove-branch create-workdir for-each-workdirs fw"
@@ -73,7 +73,7 @@ _dim ()
 				COMPREPLY=( $( compgen -o nospace -W "-a" -- $cur ) )
 			fi
 			;;
-		tc)
+		tc|fixes)
 			# FIXME needs a git sha1
 			;;
 		check-patch|cp)
diff --git a/dim b/dim
index 9ecb95053718..c749cebd1187 100755
--- a/dim
+++ b/dim
@@ -839,6 +839,11 @@ case "$subcommand" in
 			    origin/master | sed 's/^ *//'
 		fi
 		;;
+	fixes)
+		sha1=$1
+		git log -1 $sha1 "--pretty=format:Fixes: %H (\"%s\")%n" | \
+			sed -e 's/\([0-f]\{12\}\)[0-f]*/\1/'
+		;;
 	check-patch|cp)
 		dim_checkrange $@
 		;;
diff --git a/dim.rst b/dim.rst
index 567bcb8bb13e..e37d6630aecb 100644
--- a/dim.rst
+++ b/dim.rst
@@ -177,6 +177,11 @@ tc *commit-ish*
 Print the oldest Linux kernel release or -rc tag that contains the supplied
 *commit-ish*, or, if none do, print the upstream branches that contain it.
 
+fixes *commit-ish*
+---------------
+Print the Fixes: line for the supplied *commit-ish* in the linux kernel
+CodingStyle approved format.
+
 check-patch|cp [*commit-ish* [.. *commit-ish*]]
 -----------------------------------------------
 Runs the given commit range commit-ish..commit-ish through the check tools. If
-- 
2.6.4



More information about the Intel-gfx mailing list