dim: function based subcommand handling
v2 cover dim: function based subcommand handling
This is v2 of [1], with Daniel's concern regarding aliases addressed. It's much better now.
Patches 1-11 and 15-31 are mostly just mechanical renames or code movement. They explode the series so big, but I think they're easier to look at this way.
The real changes are in patches 12-14 and 32-33.
All in all this should make dim more maintainable. It's getting pretty big for a shell script.
BR,
Jani.
[1] http://mid.gmane.org/[email protected]
Jani Nikula (33):
dim: rename dim_push to dim_push_branch
dim: rename dim_apply to dim_apply_branch
dim: rename dim_co to dim_checkout
dim: rename dim_shell_checkpatch to shell_checkpatch
dim: rename dim_checkpatch to checkpatch_commit
dim: rename dim_checkrange to dim_checkpatch
dim: rename setup_dim to dim_setup
dim: rename create_workdir to dim_create_workdir
dim: rename update_nightly to dim_rebuild_nightly
dim: rename magic_patch to dim_magic_patch
dim: move dim_pull_request parameter check to the function
dim: separate handling of aliases
dim: handle subcommands through functions
dim: add alias command to list aliases
dim: abstract dim_nightly_forget
dim: abstract dim_update_branches
dim: abstract dim_for_each_workdirs
dim: abstract dim_push_*
dim: abstract dim_checkout callers
dim: abstract dim apply* subcommands
dim: abstract dim_magic_rebase_resolve
dim: abstract dim_cat_to_fixup
dim: abstract dim_tc
dim: abstract dim_fixes
dim: abstract dim_cherry_pick
dim: abstract dim_pull_request_*
dim: abstract dim_update_next
dim: abstract dim_tag_next
dim: abstract dim_{create,remove}_branch
dim: abstract dim_checker
dim: abstract dim_help
dim: show usage instead of the man page on unknown subcommands
dim: add -h option for usage, imrove output on unknown options
dim | 738 +++++++++++++++++++++++++++++++++++----------------------------- dim.rst | 5 + 2 files changed, 415 insertions(+), 328 deletions(-)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 1/33 dim: rename dim_push to dim_push_branch
Rename to match the subcommand name. Move error checking to the function too.
--- dim | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
dim +10 -9
@@ -349,8 +349,13 @@ function update_nightly # push branch $1, rebuild nightly. the rest of the arguments are passed to git # push. -function dim_push +function dim_push_branch { + if [[ "x$1" = "x" ]]; then + echo "usage: $0 $subcommand branch" + exit 1 + fi + branch=$1 shift
@@ -773,20 +778,16 @@ case "$subcommand" in cat > `cat .fixup_file_path` ;; push-branch) - if [[ "x$1" = "x" ]]; then - echo "usage: $0 $subcommand branch" - exit 1 - fi - dim_push "$@" + dim_push_branch "$@" ;; push-queued|pq) - dim_push drm-intel-next-queued "$@" + dim_push_branch drm-intel-next-queued "$@" ;; push-next-fixes|pnf) - dim_push drm-intel-next-fixes "$@" + dim_push_branch drm-intel-next-fixes "$@" ;; push-fixes|pf) - dim_push drm-intel-fixes "$@" + dim_push_branch drm-intel-fixes "$@" ;; checkout|co) if [[ "x$1" = "x" ]]; then
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 2/33 dim: rename dim_apply to dim_apply_branch
In reply to Jani NikulaRename to match the subcommand name.
--- dim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
dim +5 -5
@@ -369,7 +369,7 @@ function dim_push_branch # ensure we're on branch $1, and apply patches. the rest of the arguments are # passed to git am. -function dim_apply +function dim_apply_branch { local branch=$1 shift
@@ -806,16 +806,16 @@ case "$subcommand" in dim_co drm-intel-next-fixes ;; apply-branch|ab|sob) - dim_apply "$@" + dim_apply_branch "$@" ;; apply-queued|aq) - dim_apply drm-intel-next-queued "$@" + dim_apply_branch drm-intel-next-queued "$@" ;; apply-fixes|af) - dim_apply drm-intel-fixes "$@" + dim_apply_branch drm-intel-fixes "$@" ;; apply-next-fixes|anf) - dim_apply drm-intel-next-fixes "$@" + dim_apply_branch drm-intel-next-fixes "$@" ;; apply-resolved|ar) make -j 20 && git add -u && git am --resolved
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 3/33 dim: rename dim_co to dim_checkout
In reply to Jani NikulaRename to match the (long) subcommand name. Move error checking to the function too.
--- dim | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
dim +12 -11
@@ -440,8 +440,13 @@ function dim_cd cd $path } -function dim_co +function dim_checkout { + if [[ "x$1" = "x" ]]; then + echo "usage: $0 $subcommand branch" + exit 1 + fi + dim_cd $1 if ! git branch | grep $1 > /dev/null ; then git checkout -t $DIM_DRM_INTEL_REMOTE/$1
@@ -744,14 +749,14 @@ case "$subcommand" in check_repo_clean $DIM_PREFIX/$DIM_DRM_INTEL Kernel for branch in $dim_branches ; do - dim_co $branch + dim_checkout $branch if git diff --quiet $DIM_DRM_INTEL_REMOTE/$branch; then $DRY git rebase else $DRY git rebase -i fi done - dim_co drm-intel-next + dim_checkout drm-intel-next $DRY git reset --hard $DIM_DRM_INTEL_REMOTE/drm-intel-next # TODO: Restore -nightly merge state from the rerere-cache # branch
@@ -790,20 +795,16 @@ case "$subcommand" in dim_push_branch drm-intel-fixes "$@" ;; checkout|co) - if [[ "x$1" = "x" ]]; then - echo "usage: $0 $subcommand branch" - exit 1 - fi - dim_co "$@" + dim_checkout "$@" ;; conq) - dim_co drm-intel-next-queued + dim_checkout drm-intel-next-queued ;; cof) - dim_co drm-intel-fixes + dim_checkout drm-intel-fixes ;; conf) - dim_co drm-intel-next-fixes + dim_checkout drm-intel-next-fixes ;; apply-branch|ab|sob) dim_apply_branch "$@"
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 4/33 dim: rename dim_shell_checkpatch to shell_checkpatch
In reply to Jani NikulaDrop the dim_ prefix as there's no corresponding subcommand.
--- dim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
dim +3 -3
@@ -386,7 +386,7 @@ function dim_apply_branch local message_id=$(message_get_id $file) - dim_shell_checkpatch "cat $file" + shell_checkpatch "cat $file" local commiter_email=$(git config --get user.email) local patch_from=$(grep "From:" "$file" | head -1)
@@ -466,7 +466,7 @@ function check_repo_clean } # $1 is the shell command to display the patch/commit -function dim_shell_checkpatch +function shell_checkpatch { local cmd=$1
@@ -483,7 +483,7 @@ function dim_checkpatch local commit=$1 git --no-pager log --oneline -1 $commit - dim_shell_checkpatch "git show $commit --pretty=email" + shell_checkpatch "git show $commit --pretty=email" } function dim_checkrange
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 5/33 dim: rename dim_checkpatch to checkpatch_commit
In reply to Jani NikulaRename as there's no corresponding subcommand (the check-patch subcommand does a slightly different thing).
--- dim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
dim +3 -3
@@ -478,7 +478,7 @@ function shell_checkpatch } # $1 is the git sha1 to check -function dim_checkpatch +function checkpatch_commit { local commit=$1
@@ -499,7 +499,7 @@ function dim_checkrange fi for commit in $(git rev-list --reverse $range); do - dim_checkpatch $commit || true + checkpatch_commit $commit || true done }
@@ -820,7 +820,7 @@ case "$subcommand" in ;; apply-resolved|ar) make -j 20 && git add -u && git am --resolved - dim_checkpatch HEAD + checkpatch_commit HEAD git commit --amend & ;; apply-igt|ai)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 6/33 dim: rename dim_checkrange to dim_checkpatch
In reply to Jani NikulaRename to match the subcommand. Also add checkpatch subcommand (without the hyphen) to match the spelling of the tool.
--- dim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
dim +3 -3
@@ -486,7 +486,7 @@ function checkpatch_commit shell_checkpatch "git show $commit --pretty=email" } -function dim_checkrange +function dim_checkpatch { local range
@@ -856,8 +856,8 @@ case "$subcommand" in git log -1 $sha1 "--pretty=format:Fixes: %H (\"%s\")%n" | \ sed -e 's/\([0-f]\{12\}\)[0-f]*/\1/' ;; - check-patch|cp) - dim_checkrange $@ + checkpatch|check-patch|cp) + dim_checkpatch $@ ;; cherry-pick) if [[ "x$1" = "x" ]]; then
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 7/33 dim: rename setup_dim to dim_setup
In reply to Jani NikulaRename to match the subcommand.
--- dim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
dim +2 -2
@@ -625,7 +625,7 @@ function dim_pull_request "$addr_drm_maintainer" } -function setup_dim +function dim_setup { if [ ! -d $DIM_PREFIX ]; then echo "please set up your repository directory with:"
@@ -734,7 +734,7 @@ function assert_branch case "$subcommand" in setup) - setup_dim + dim_setup ;; nightly-forget) cd $DIM_PREFIX/drm-intel-nightly
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 8/33 dim: rename create_workdir to dim_create_workdir
In reply to Jani NikulaAdd dim_ prefix to functions corresponding to subcommands.
--- dim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
dim +2 -2
@@ -555,7 +555,7 @@ function prep_pull_mail prep_pull_mail_signature >> ~/tmp/dim-pull-request } -function create_workdir +function dim_create_workdir { cd $DIM_PREFIX local branches
@@ -763,7 +763,7 @@ case "$subcommand" in update_rerere_cache ;; create-workdir) - create_workdir $1 + dim_create_workdir $1 ;; for-each-workdirs|fw) cd $DIM_PREFIX/$DIM_DRM_INTEL
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 9/33 dim: rename update_nightly to dim_rebuild_nightly
In reply to Jani NikulaRename to match the subcommand name.
--- dim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
dim +3 -3
@@ -234,7 +234,7 @@ function update_rerere_cache cd - } -function update_nightly +function dim_rebuild_nightly { local integration_branch=drm-intel-nightly local specfile=`mktemp`
@@ -363,7 +363,7 @@ function dim_push_branch git push $DRY_RUN $DIM_DRM_INTEL_REMOTE $branch "$@" - update_nightly + dim_rebuild_nightly update_linux_next }
@@ -776,7 +776,7 @@ case "$subcommand" in done ;; rebuild-nightly) - update_nightly + dim_rebuild_nightly ;; cat-to-fixup) cd $DIM_PREFIX/drm-intel-nightly
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 10/33 dim: rename magic_patch to dim_magic_patch
In reply to Jani NikulaAdd dim_ prefix to functions corresponding to subcommands.
--- dim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
dim +2 -2
@@ -406,7 +406,7 @@ function dim_apply_branch eval $DRY $DIM_POST_APPLY_ACTION } -function magic_patch +function dim_magic_patch { if [[ "$1" = "-a" ]]; then cd `cat ~/.dim-last-path`
@@ -828,7 +828,7 @@ case "$subcommand" in git am --whitespace=fix -3 -s ;; magic-patch|mp) - magic_patch "$@" + dim_magic_patch "$@" ;; magic-rebase-resolve|mrr) git diff HEAD | patch -p1 -R
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 11/33 dim: move dim_pull_request parameter check to the function
In reply to Jani NikulaMore abstraction is better, also guards against invalid internal use.
--- dim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
dim +5 -4
@@ -591,6 +591,11 @@ function dim_create_workdir # dim_pull_request branch upstream function dim_pull_request { + if [[ "x$1" = "x" || "x$2" = "x" ]]; then + echo "usage: $0 $subcommand branch upstream" + exit 1 + fi + branch=$1 upstream=$2
@@ -874,10 +879,6 @@ case "$subcommand" in $DRY git cherry-pick $1 ;; pull-request) - if [[ "x$1" = "x" || "x$2" = "x" ]]; then - echo "usage: $0 $subcommand branch upstream" - exit 1 - fi dim_pull_request $* ;; pull-request-next)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 12/33 dim: separate handling of aliases
In reply to Jani NikulaAllow specifying dim subcommand aliases using variables of the format dim_alias_<ALIAS>. The value of the variable should be the name of the actual subcommand. The user can specify aliases in the dimrc.
--- dim | 56 ++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 16 deletions(-)
dim +40 -16
@@ -369,6 +369,8 @@ function dim_push_branch # ensure we're on branch $1, and apply patches. the rest of the arguments are # passed to git am. +dim_alias_ab=apply-branch +dim_alias_sob=apply-branch function dim_apply_branch { local branch=$1
@@ -406,6 +408,7 @@ function dim_apply_branch eval $DRY $DIM_POST_APPLY_ACTION } +dim_alias_mp=magic-patch function dim_magic_patch { if [[ "$1" = "-a" ]]; then
@@ -440,6 +443,7 @@ function dim_cd cd $path } +dim_alias_co=checkout function dim_checkout { if [[ "x$1" = "x" ]]; then
@@ -486,6 +490,8 @@ function checkpatch_commit shell_checkpatch "git show $commit --pretty=email" } +dim_alias_check_patch=checkpatch +dim_alias_cp=checkpatch function dim_checkpatch { local range
@@ -737,7 +743,25 @@ function assert_branch fi } -case "$subcommand" in +# dim subcommand aliases +dim_alias_af=apply-fixes +dim_alias_ai=apply-igt +dim_alias_anf=apply-next-fixes +dim_alias_aq=apply-queued +dim_alias_ar=apply-resolved +dim_alias_fw=for-each-workdirs +dim_alias_mrr=magic-rebase-resolve +dim_alias_pf=push-fixes +dim_alias_pnf=push-next-fixes +dim_alias_pq=push-queued +dim_alias_ub=update-branches + +declare -n subcmd=dim_alias_${subcommand//-/_} +if [ -z "$subcmd" ]; then + subcmd="$subcommand" +fi + +case "$subcmd" in setup) dim_setup ;;
@@ -748,7 +772,7 @@ case "$subcommand" in git merge origin/drm-intel-fixes git rerere forget ;; - update-branches|ub) + update-branches) cd $DIM_PREFIX/$DIM_DRM_INTEL git fetch $DIM_DRM_INTEL_REMOTE check_repo_clean $DIM_PREFIX/$DIM_DRM_INTEL Kernel
@@ -770,7 +794,7 @@ case "$subcommand" in create-workdir) dim_create_workdir $1 ;; - for-each-workdirs|fw) + for-each-workdirs) cd $DIM_PREFIX/$DIM_DRM_INTEL $@ for branch in $dim_branches ; do
@@ -790,16 +814,16 @@ case "$subcommand" in push-branch) dim_push_branch "$@" ;; - push-queued|pq) + push-queued) dim_push_branch drm-intel-next-queued "$@" ;; - push-next-fixes|pnf) + push-next-fixes) dim_push_branch drm-intel-next-fixes "$@" ;; - push-fixes|pf) + push-fixes) dim_push_branch drm-intel-fixes "$@" ;; - checkout|co) + checkout) dim_checkout "$@" ;; conq)
@@ -811,31 +835,31 @@ case "$subcommand" in conf) dim_checkout drm-intel-next-fixes ;; - apply-branch|ab|sob) + apply-branch) dim_apply_branch "$@" ;; - apply-queued|aq) + apply-queued) dim_apply_branch drm-intel-next-queued "$@" ;; - apply-fixes|af) + apply-fixes) dim_apply_branch drm-intel-fixes "$@" ;; - apply-next-fixes|anf) + apply-next-fixes) dim_apply_branch drm-intel-next-fixes "$@" ;; - apply-resolved|ar) + apply-resolved) make -j 20 && git add -u && git am --resolved checkpatch_commit HEAD git commit --amend & ;; - apply-igt|ai) + apply-igt) cd ~/xorg/intel-gpu-tools/ git am --whitespace=fix -3 -s ;; - magic-patch|mp) + magic-patch) dim_magic_patch "$@" ;; - magic-rebase-resolve|mrr) + magic-rebase-resolve) git diff HEAD | patch -p1 -R cat .git/rebase-merge/patch | dim mp make -j 20
@@ -861,7 +885,7 @@ case "$subcommand" in git log -1 $sha1 "--pretty=format:Fixes: %H (\"%s\")%n" | \ sed -e 's/\([0-f]\{12\}\)[0-f]*/\1/' ;; - checkpatch|check-patch|cp) + checkpatch) dim_checkpatch $@ ;; cherry-pick)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 13/33 dim: handle subcommands through functions
In reply to Jani NikulaIf there's a dim_ prefixed function matching the subcommand, call it to handle the subcommand without going through the big switch case.
Drop the cases which already match the convention. Once all the cases are converted to functions, the handling of subcommands becomes much cleaner.
This also allows extending of dim by the user via functions declared outside of dim. The current aliases could also be made the user's responsibility to define as the user wishes (the user could define dim_ prefixed functions in the dimrc).
--- dim | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-)
dim +9 -27
@@ -761,10 +761,16 @@ if [ -z "$subcmd" ]; then subcmd="$subcommand" fi +# if there's a function by the subcommand name, call it +subcmd_func=dim_${subcmd//-/_} +if declare -f $subcmd_func >/dev/null; then + $subcmd_func "$@" + exit 0 +fi + +# XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case +# into an else branch in the above check for functions. case "$subcmd" in - setup) - dim_setup - ;; nightly-forget) cd $DIM_PREFIX/drm-intel-nightly git fetch origin >& /dev/null
@@ -791,9 +797,6 @@ case "$subcmd" in # branch update_rerere_cache ;; - create-workdir) - dim_create_workdir $1 - ;; for-each-workdirs) cd $DIM_PREFIX/$DIM_DRM_INTEL $@
@@ -804,16 +807,10 @@ case "$subcmd" in fi done ;; - rebuild-nightly) - dim_rebuild_nightly - ;; cat-to-fixup) cd $DIM_PREFIX/drm-intel-nightly cat > `cat .fixup_file_path` ;; - push-branch) - dim_push_branch "$@" - ;; push-queued) dim_push_branch drm-intel-next-queued "$@" ;;
@@ -823,9 +820,6 @@ case "$subcmd" in push-fixes) dim_push_branch drm-intel-fixes "$@" ;; - checkout) - dim_checkout "$@" - ;; conq) dim_checkout drm-intel-next-queued ;;
@@ -835,9 +829,6 @@ case "$subcmd" in conf) dim_checkout drm-intel-next-fixes ;; - apply-branch) - dim_apply_branch "$@" - ;; apply-queued) dim_apply_branch drm-intel-next-queued "$@" ;;
@@ -856,9 +847,6 @@ case "$subcmd" in cd ~/xorg/intel-gpu-tools/ git am --whitespace=fix -3 -s ;; - magic-patch) - dim_magic_patch "$@" - ;; magic-rebase-resolve) git diff HEAD | patch -p1 -R cat .git/rebase-merge/patch | dim mp
@@ -885,9 +873,6 @@ case "$subcmd" in git log -1 $sha1 "--pretty=format:Fixes: %H (\"%s\")%n" | \ sed -e 's/\([0-f]\{12\}\)[0-f]*/\1/' ;; - checkpatch) - dim_checkpatch $@ - ;; cherry-pick) if [[ "x$1" = "x" ]]; then echo "usage: $0 $subcommand commit-ish"
@@ -902,9 +887,6 @@ case "$subcmd" in git log --grep=$sha_short --pretty=oneline $sha..$DIM_DRM_INTEL_REMOTE/drm-intel-nightly $DRY git cherry-pick $1 ;; - pull-request) - dim_pull_request $* - ;; pull-request-next) upstream=${1:-$DIM_DRM_UPSTREAM_REMOTE/drm-next} dim_pull_request drm-intel-next $upstream
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 14/33 dim: add alias command to list aliases
In reply to Jani NikulaHelpful convenience.
--- dim | 7 +++++++ dim.rst | 5 +++++ 2 files changed, 12 insertions(+)
dim +7 -0
@@ -743,6 +743,13 @@ function assert_branch fi } +function dim_alias +{ + # use posix mode to omit functions in set output + ( set -o posix; set ) | grep "^dim_alias_[a-zA-Z0-9_]*=" |\ + sed 's/^dim_alias_/\t/;s/=/\t/' +} + # dim subcommand aliases dim_alias_af=apply-fixes dim_alias_ai=apply-igt
dim.rst +5 -0
@@ -273,6 +273,11 @@ for-each-workdir|fw *command* Run the given command in all active workdirs including the main repository under \$DIM_DRM_INTEL. +alias +----- + +List all aliases for the subcommand names. + help ---- Show this help. Install **rst2man(1)** for best results.
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 15/33 dim: abstract dim_nightly_forget
In reply to Jani Nikula--- dim | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
dim +9 -7
@@ -347,6 +347,15 @@ function dim_rebuild_nightly } +function dim_nightly_forget +{ + cd $DIM_PREFIX/drm-intel-nightly + git fetch origin >& /dev/null + git reset --hard origin/drm-intel-next-queued >& /dev/null + git merge origin/drm-intel-fixes + git rerere forget +} + # push branch $1, rebuild nightly. the rest of the arguments are passed to git # push. function dim_push_branch
@@ -778,13 +787,6 @@ fi # XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case # into an else branch in the above check for functions. case "$subcmd" in - nightly-forget) - cd $DIM_PREFIX/drm-intel-nightly - git fetch origin >& /dev/null - git reset --hard origin/drm-intel-next-queued >& /dev/null - git merge origin/drm-intel-fixes - git rerere forget - ;; update-branches) cd $DIM_PREFIX/$DIM_DRM_INTEL git fetch $DIM_DRM_INTEL_REMOTE
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 16/33 dim: abstract dim_update_branches
In reply to Jani Nikula--- dim | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-)
dim +22 -20
@@ -645,6 +645,28 @@ function dim_pull_request "$addr_drm_maintainer" } +dim_alias_ub=update-branches +function dim_update_branches +{ + cd $DIM_PREFIX/$DIM_DRM_INTEL + git fetch $DIM_DRM_INTEL_REMOTE + check_repo_clean $DIM_PREFIX/$DIM_DRM_INTEL Kernel + + for branch in $dim_branches ; do + dim_checkout $branch + if git diff --quiet $DIM_DRM_INTEL_REMOTE/$branch; then + $DRY git rebase + else + $DRY git rebase -i + fi + done + dim_checkout drm-intel-next + $DRY git reset --hard $DIM_DRM_INTEL_REMOTE/drm-intel-next + # TODO: Restore -nightly merge state from the rerere-cache + # branch + update_rerere_cache +} + function dim_setup { if [ ! -d $DIM_PREFIX ]; then
@@ -770,7 +792,6 @@ dim_alias_mrr=magic-rebase-resolve dim_alias_pf=push-fixes dim_alias_pnf=push-next-fixes dim_alias_pq=push-queued -dim_alias_ub=update-branches declare -n subcmd=dim_alias_${subcommand//-/_} if [ -z "$subcmd" ]; then
@@ -787,25 +808,6 @@ fi # XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case # into an else branch in the above check for functions. case "$subcmd" in - update-branches) - cd $DIM_PREFIX/$DIM_DRM_INTEL - git fetch $DIM_DRM_INTEL_REMOTE - check_repo_clean $DIM_PREFIX/$DIM_DRM_INTEL Kernel - - for branch in $dim_branches ; do - dim_checkout $branch - if git diff --quiet $DIM_DRM_INTEL_REMOTE/$branch; then - $DRY git rebase - else - $DRY git rebase -i - fi - done - dim_checkout drm-intel-next - $DRY git reset --hard $DIM_DRM_INTEL_REMOTE/drm-intel-next - # TODO: Restore -nightly merge state from the rerere-cache - # branch - update_rerere_cache - ;; for-each-workdirs) cd $DIM_PREFIX/$DIM_DRM_INTEL $@
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 17/33 dim: abstract dim_for_each_workdirs
In reply to Jani Nikula--- dim | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
dim +13 -11
@@ -603,6 +603,19 @@ function dim_create_workdir done } +dim_alias_fw=for-each-workdirs +function dim_for_each_workdirs +{ + cd $DIM_PREFIX/$DIM_DRM_INTEL + $@ + for branch in $dim_branches ; do + if [[ -d $DIM_PREFIX/$branch ]] ; then + cd $DIM_PREFIX/$branch + $@ + fi + done +} + # dim_pull_request branch upstream function dim_pull_request {
@@ -787,7 +800,6 @@ dim_alias_ai=apply-igt dim_alias_anf=apply-next-fixes dim_alias_aq=apply-queued dim_alias_ar=apply-resolved -dim_alias_fw=for-each-workdirs dim_alias_mrr=magic-rebase-resolve dim_alias_pf=push-fixes dim_alias_pnf=push-next-fixes
@@ -808,16 +820,6 @@ fi # XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case # into an else branch in the above check for functions. case "$subcmd" in - for-each-workdirs) - cd $DIM_PREFIX/$DIM_DRM_INTEL - $@ - for branch in $dim_branches ; do - if [[ -d $DIM_PREFIX/$branch ]] ; then - cd $DIM_PREFIX/$branch - $@ - fi - done - ;; cat-to-fixup) cd $DIM_PREFIX/drm-intel-nightly cat > `cat .fixup_file_path`
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 18/33 dim: abstract dim_push_*
In reply to Jani Nikula--- dim | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
dim +18 -12
@@ -376,6 +376,24 @@ function dim_push_branch update_linux_next } +dim_alias_pq=push-queued +function dim_push_queued +{ + dim_push_branch drm-intel-next-queued "$@" +} + +dim_alias_pnf=push-next-fixes +function dim_push_next_fixes +{ + dim_push_branch drm-intel-next-fixes "$@" +} + +dim_alias_pf=push-fixes +function dim_push_fixes +{ + dim_push_branch drm-intel-fixes "$@" +} + # ensure we're on branch $1, and apply patches. the rest of the arguments are # passed to git am. dim_alias_ab=apply-branch
@@ -801,9 +819,6 @@ dim_alias_anf=apply-next-fixes dim_alias_aq=apply-queued dim_alias_ar=apply-resolved dim_alias_mrr=magic-rebase-resolve -dim_alias_pf=push-fixes -dim_alias_pnf=push-next-fixes -dim_alias_pq=push-queued declare -n subcmd=dim_alias_${subcommand//-/_} if [ -z "$subcmd" ]; then
@@ -824,15 +839,6 @@ case "$subcmd" in cd $DIM_PREFIX/drm-intel-nightly cat > `cat .fixup_file_path` ;; - push-queued) - dim_push_branch drm-intel-next-queued "$@" - ;; - push-next-fixes) - dim_push_branch drm-intel-next-fixes "$@" - ;; - push-fixes) - dim_push_branch drm-intel-fixes "$@" - ;; conq) dim_checkout drm-intel-next-queued ;;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 19/33 dim: abstract dim_checkout callers
In reply to Jani Nikula--- dim | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
dim +15 -9
@@ -486,6 +486,21 @@ function dim_checkout fi } +function dim_conq +{ + dim_checkout drm-intel-next-queued "$@" +} + +function dim_coq +{ + dim_checkout drm-intel-fixes "$@" +} + +function dim_conf +{ + dim_checkout drm-intel-next-fixes "$@" +} + function check_repo_clean { cd $1
@@ -839,15 +854,6 @@ case "$subcmd" in cd $DIM_PREFIX/drm-intel-nightly cat > `cat .fixup_file_path` ;; - conq) - dim_checkout drm-intel-next-queued - ;; - cof) - dim_checkout drm-intel-fixes - ;; - conf) - dim_checkout drm-intel-next-fixes - ;; apply-queued) dim_apply_branch drm-intel-next-queued "$@" ;;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 20/33 dim: abstract dim apply* subcommands
In reply to Jani Nikula--- dim | 56 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 23 deletions(-)
dim +33 -23
@@ -435,6 +435,39 @@ function dim_apply_branch eval $DRY $DIM_POST_APPLY_ACTION } +dim_alias_aq=apply-queued +function dim_apply_queued +{ + dim_apply_branch drm-intel-next-queued "$@" +} + +dim_alias_af=apply-fixes +function dim_apply_fixes +{ + dim_apply_branch drm-intel-fixes "$@" +} + +dim_alias_anf=apply-next-fixes +function dim_apply_next_fixes +{ + dim_apply_branch drm-intel-next-fixes "$@" +} + +dim_alias_ar=apply-resolved +function dim_apply_resolved +{ + make -j 20 && git add -u && git am --resolved + checkpatch_commit HEAD + git commit --amend & +} + +dim_alias_ai=apply-igt +function dim_apply_igt +{ + cd ~/xorg/intel-gpu-tools/ + git am --whitespace=fix -3 -s +} + dim_alias_mp=magic-patch function dim_magic_patch {
@@ -828,11 +861,6 @@ function dim_alias } # dim subcommand aliases -dim_alias_af=apply-fixes -dim_alias_ai=apply-igt -dim_alias_anf=apply-next-fixes -dim_alias_aq=apply-queued -dim_alias_ar=apply-resolved dim_alias_mrr=magic-rebase-resolve declare -n subcmd=dim_alias_${subcommand//-/_}
@@ -854,24 +882,6 @@ case "$subcmd" in cd $DIM_PREFIX/drm-intel-nightly cat > `cat .fixup_file_path` ;; - apply-queued) - dim_apply_branch drm-intel-next-queued "$@" - ;; - apply-fixes) - dim_apply_branch drm-intel-fixes "$@" - ;; - apply-next-fixes) - dim_apply_branch drm-intel-next-fixes "$@" - ;; - apply-resolved) - make -j 20 && git add -u && git am --resolved - checkpatch_commit HEAD - git commit --amend & - ;; - apply-igt) - cd ~/xorg/intel-gpu-tools/ - git am --whitespace=fix -3 -s - ;; magic-rebase-resolve) git diff HEAD | patch -p1 -R cat .git/rebase-merge/patch | dim mp
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 21/33 dim: abstract dim_magic_rebase_resolve
In reply to Jani Nikula--- dim | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
dim +10 -9
@@ -461,6 +461,16 @@ function dim_apply_resolved git commit --amend & } +dim_alias_mrr=magic-rebase-resolve +function dim_magic_rebase_resolve +{ + git diff HEAD | patch -p1 -R + cat .git/rebase-merge/patch | dim mp + make -j 20 + git add -u + git rebase --continue +} + dim_alias_ai=apply-igt function dim_apply_igt {
@@ -861,8 +871,6 @@ function dim_alias } # dim subcommand aliases -dim_alias_mrr=magic-rebase-resolve - declare -n subcmd=dim_alias_${subcommand//-/_} if [ -z "$subcmd" ]; then subcmd="$subcommand"
@@ -882,13 +890,6 @@ case "$subcmd" in cd $DIM_PREFIX/drm-intel-nightly cat > `cat .fixup_file_path` ;; - magic-rebase-resolve) - git diff HEAD | patch -p1 -R - cat .git/rebase-merge/patch | dim mp - make -j 20 - git add -u - git rebase --continue - ;; tc) cd $DIM_PREFIX/$DIM_DRM_INTEL tag=$(git tag --contains $1 | grep ^v | sort -V | head -n 1)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 22/33 dim: abstract dim_cat_to_fixup
In reply to Jani Nikula--- dim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
dim +6 -4
@@ -870,6 +870,12 @@ function dim_alias sed 's/^dim_alias_/\t/;s/=/\t/' } +function dim_cat_to_fixup +{ + cd $DIM_PREFIX/drm-intel-nightly + cat > `cat .fixup_file_path` +} + # dim subcommand aliases declare -n subcmd=dim_alias_${subcommand//-/_} if [ -z "$subcmd" ]; then
@@ -886,10 +892,6 @@ fi # XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case # into an else branch in the above check for functions. case "$subcmd" in - cat-to-fixup) - cd $DIM_PREFIX/drm-intel-nightly - cat > `cat .fixup_file_path` - ;; tc) cd $DIM_PREFIX/$DIM_DRM_INTEL tag=$(git tag --contains $1 | grep ^v | sort -V | head -n 1)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 23/33 dim: abstract dim_tc
In reply to Jani Nikula--- dim | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
dim +16 -14
@@ -876,6 +876,22 @@ function dim_cat_to_fixup cat > `cat .fixup_file_path` } +function dim_tc +{ + cd $DIM_PREFIX/$DIM_DRM_INTEL + tag=$(git tag --contains $1 | grep ^v | sort -V | head -n 1) + if [[ -n "$tag" ]]; then + echo "$tag" + else + # not in a tagged release, show upstream branches + git branch -r --contains $1 \ + $DIM_DRM_INTEL_REMOTE/* \ + $DIM_DRM_UPSTREAM_REMOTE/drm-next \ + $DIM_DRM_UPSTREAM_REMOTE/drm-fixes \ + origin/master | sed 's/^ *//' + fi +} + # dim subcommand aliases declare -n subcmd=dim_alias_${subcommand//-/_} if [ -z "$subcmd" ]; then
@@ -892,20 +908,6 @@ fi # XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case # into an else branch in the above check for functions. case "$subcmd" in - tc) - cd $DIM_PREFIX/$DIM_DRM_INTEL - tag=$(git tag --contains $1 | grep ^v | sort -V | head -n 1) - if [[ -n "$tag" ]]; then - echo "$tag" - else - # not in a tagged release, show upstream branches - git branch -r --contains $1 \ - $DIM_DRM_INTEL_REMOTE/* \ - $DIM_DRM_UPSTREAM_REMOTE/drm-next \ - $DIM_DRM_UPSTREAM_REMOTE/drm-fixes \ - origin/master | sed 's/^ *//' - fi - ;; fixes) sha1=$1 git log -1 $sha1 "--pretty=format:Fixes: %H (\"%s\")%n" | \
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 24/33 dim: abstract dim_fixes
In reply to Jani Nikula--- dim | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
dim +7 -5
@@ -892,6 +892,13 @@ function dim_tc fi } +function dim_fixes +{ + sha1=$1 + git log -1 $sha1 "--pretty=format:Fixes: %H (\"%s\")%n" | \ + sed -e 's/\([0-f]\{12\}\)[0-f]*/\1/' +} + # dim subcommand aliases declare -n subcmd=dim_alias_${subcommand//-/_} if [ -z "$subcmd" ]; then
@@ -908,11 +915,6 @@ fi # XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case # into an else branch in the above check for functions. case "$subcmd" in - fixes) - sha1=$1 - git log -1 $sha1 "--pretty=format:Fixes: %H (\"%s\")%n" | \ - sed -e 's/\([0-f]\{12\}\)[0-f]*/\1/' - ;; cherry-pick) if [[ "x$1" = "x" ]]; then echo "usage: $0 $subcommand commit-ish"
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 25/33 dim: abstract dim_cherry_pick
In reply to Jani Nikula--- dim | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
dim +16 -14
@@ -453,6 +453,22 @@ function dim_apply_next_fixes dim_apply_branch drm-intel-next-fixes "$@" } +function dim_cherry_pick +{ + if [[ "x$1" = "x" ]]; then + echo "usage: $0 $subcommand commit-ish" + exit 1 + fi + sha=`git rev-parse $1` + sha_short=${sha:0:8} + + # need latest -nightly + git fetch $DIM_DRM_INTEL_REMOTE + echo Possible fixup patches for your cherry-pick: + git log --grep=$sha_short --pretty=oneline $sha..$DIM_DRM_INTEL_REMOTE/drm-intel-nightly + $DRY git cherry-pick $1 +} + dim_alias_ar=apply-resolved function dim_apply_resolved {
@@ -915,20 +931,6 @@ fi # XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case # into an else branch in the above check for functions. case "$subcmd" in - cherry-pick) - if [[ "x$1" = "x" ]]; then - echo "usage: $0 $subcommand commit-ish" - exit 1 - fi - sha=`git rev-parse $1` - sha_short=${sha:0:8} - - # need latest -nightly - git fetch $DIM_DRM_INTEL_REMOTE - echo Possible fixup patches for your cherry-pick: - git log --grep=$sha_short --pretty=oneline $sha..$DIM_DRM_INTEL_REMOTE/drm-intel-nightly - $DRY git cherry-pick $1 - ;; pull-request-next) upstream=${1:-$DIM_DRM_UPSTREAM_REMOTE/drm-next} dim_pull_request drm-intel-next $upstream
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 26/33 dim: abstract dim_pull_request_*
In reply to Jani Nikula--- dim | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
dim +18 -12
@@ -750,6 +750,24 @@ function dim_pull_request "$addr_drm_maintainer" } +function dim_pull_request_next +{ + upstream=${1:-$DIM_DRM_UPSTREAM_REMOTE/drm-next} + dim_pull_request drm-intel-next $upstream +} + +function dim_pull_request_fixes +{ + upstream=${1:-origin/master} + dim_pull_request drm-intel-fixes $upstream +} + +function dim_pull_request_next_fixes +{ + upstream=${1:-$DIM_DRM_UPSTREAM_REMOTE/drm-next} + dim_pull_request drm-intel-next-fixes $upstream +} + dim_alias_ub=update-branches function dim_update_branches {
@@ -931,18 +949,6 @@ fi # XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case # into an else branch in the above check for functions. case "$subcmd" in - pull-request-next) - upstream=${1:-$DIM_DRM_UPSTREAM_REMOTE/drm-next} - dim_pull_request drm-intel-next $upstream - ;; - pull-request-fixes) - upstream=${1:-origin/master} - dim_pull_request drm-intel-fixes $upstream - ;; - pull-request-next-fixes) - upstream=${1:-$DIM_DRM_UPSTREAM_REMOTE/drm-next} - dim_pull_request drm-intel-next-fixes $upstream - ;; update-next) assert_branch drm-intel-next-queued
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 27/33 dim: abstract dim_update_next
In reply to Jani Nikula--- dim | 126 +++++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 64 insertions(+), 62 deletions(-)
dim +64 -62
@@ -708,6 +708,70 @@ function dim_for_each_workdirs done } +function dim_update_next +{ + assert_branch drm-intel-next-queued + + git pull --ff-only + + if ! git branch --merged $DIM_DRM_INTEL_REMOTE/drm-intel-nightly | grep drm-intel-fixes &> /dev/null ; then + echo "drm-intel-fixes not merged into -nigthly, please update!" + exit 2 + fi + if ! git branch --merged $DIM_DRM_INTEL_REMOTE/drm-intel-nightly | grep drm-intel-next-queued &> /dev/null ; then + echo "drm-intel-next-queued not merged into -nigthly, please update!" + exit 2 + fi + + driver_date=`date +%Y%m%d` + $DRY sed -i -e "s/^#define DRIVER_DATE.*\"[0-9]*\"$/#define DRIVER_DATE\t\t\"$driver_date\"/" \ + drivers/gpu/drm/i915/i915_drv.h + $DRY git add drivers/gpu/drm/i915/i915_drv.h + echo -e "drm/i915: Update DRIVER_DATE to $driver_date\n\nSigned-off-by: Daniel Vetter <[email protected]>" | \ + git commit -s -F - + + gitk drm-intel-next-queued ^$DIM_DRM_UPSTREAM_REMOTE/drm-next & + + # try to push dinq first in case someone raced + dim push-queued + + git push $DRY_RUN $DIM_DRM_INTEL_REMOTE drm-intel-next-queued:drm-intel-next + tag=drm-intel-next-$today + $DRY git tag -f -a $tag $DIM_DRM_INTEL_REMOTE/drm-intel-next + git push $DRY_RUN -f $DIM_DRM_INTEL_REMOTE $tag + + echo "Updating -testing to latest -nightly" + git push $DRY_RUN $DIM_DRM_INTEL_REMOTE +$DIM_DRM_INTEL_REMOTE/drm-intel-nightly:drm-intel-testing + $DRY git tag -f drm-intel-testing-$today $DIM_DRM_INTEL_REMOTE/drm-intel-testing + $DRY git push -f $DIM_DRM_INTEL_REMOTE drm-intel-testing-$today + + cat > ~/tmp/test-request <<-HERE + Hi all, + + New -testing cycle with cool stuff: + HERE + obj=`git rev-parse $tag` + if [[ `git cat-file -t $obj` == "tag" ]] ; then + git cat-file -p $obj | tail -n+6 >> ~/tmp/test-request + else + echo "<tag doesn't contain a changelog overview, fix this>" >> ~/tmp/test-request + fi + cat >> ~/tmp/test-request <<-HERE + + Happy testing! + + Cheers, Daniel + HERE + + $DRY $DIM_MUA -s "Updated drm-intel-testing" \ + -i ~/tmp/test-request \ + -c "$addr_intel_gfx" \ + -c "$addr_intel_gfx_maintainer1" \ + -c "$addr_intel_gfx_maintainer2" \ + "$addr_intel_qa1" \ + "$addr_intel_qa2" +} + # dim_pull_request branch upstream function dim_pull_request {
@@ -949,68 +1013,6 @@ fi # XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case # into an else branch in the above check for functions. case "$subcmd" in - update-next) - assert_branch drm-intel-next-queued - - git pull --ff-only - - if ! git branch --merged $DIM_DRM_INTEL_REMOTE/drm-intel-nightly | grep drm-intel-fixes &> /dev/null ; then - echo "drm-intel-fixes not merged into -nigthly, please update!" - exit 2 - fi - if ! git branch --merged $DIM_DRM_INTEL_REMOTE/drm-intel-nightly | grep drm-intel-next-queued &> /dev/null ; then - echo "drm-intel-next-queued not merged into -nigthly, please update!" - exit 2 - fi - - driver_date=`date +%Y%m%d` - $DRY sed -i -e "s/^#define DRIVER_DATE.*\"[0-9]*\"$/#define DRIVER_DATE\t\t\"$driver_date\"/" \ - drivers/gpu/drm/i915/i915_drv.h - $DRY git add drivers/gpu/drm/i915/i915_drv.h - echo -e "drm/i915: Update DRIVER_DATE to $driver_date\n\nSigned-off-by: Daniel Vetter <[email protected]>" | \ - git commit -s -F - - - gitk drm-intel-next-queued ^$DIM_DRM_UPSTREAM_REMOTE/drm-next & - - # try to push dinq first in case someone raced - dim push-queued - - git push $DRY_RUN $DIM_DRM_INTEL_REMOTE drm-intel-next-queued:drm-intel-next - tag=drm-intel-next-$today - $DRY git tag -f -a $tag $DIM_DRM_INTEL_REMOTE/drm-intel-next - git push $DRY_RUN -f $DIM_DRM_INTEL_REMOTE $tag - - echo "Updating -testing to latest -nightly" - git push $DRY_RUN $DIM_DRM_INTEL_REMOTE +$DIM_DRM_INTEL_REMOTE/drm-intel-nightly:drm-intel-testing - $DRY git tag -f drm-intel-testing-$today $DIM_DRM_INTEL_REMOTE/drm-intel-testing - $DRY git push -f $DIM_DRM_INTEL_REMOTE drm-intel-testing-$today - - cat > ~/tmp/test-request <<-HERE - Hi all, - - New -testing cycle with cool stuff: - HERE - obj=`git rev-parse $tag` - if [[ `git cat-file -t $obj` == "tag" ]] ; then - git cat-file -p $obj | tail -n+6 >> ~/tmp/test-request - else - echo "<tag doesn't contain a changelog overview, fix this>" >> ~/tmp/test-request - fi - cat >> ~/tmp/test-request <<-HERE - - Happy testing! - - Cheers, Daniel - HERE - - $DRY $DIM_MUA -s "Updated drm-intel-testing" \ - -i ~/tmp/test-request \ - -c "$addr_intel_gfx" \ - -c "$addr_intel_gfx_maintainer1" \ - -c "$addr_intel_gfx_maintainer2" \ - "$addr_intel_qa1" \ - "$addr_intel_qa2" - ;; tag-next) cd $DIM_PREFIX/$DIM_DRM_INTEL git fetch $DIM_DRM_INTEL_REMOTE
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 28/33 dim: abstract dim_tag_next
In reply to Jani Nikula--- dim | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-)
dim +18 -16
@@ -772,6 +772,24 @@ function dim_update_next "$addr_intel_qa2" } +function dim_tag_next +{ + cd $DIM_PREFIX/$DIM_DRM_INTEL + git fetch $DIM_DRM_INTEL_REMOTE + + if [ $(git rev-parse drm-intel-next) == $(git rev-parse drm-intel-next@{u}) ] ; then + echo "Tagging current drm-intel-next" + + tag=drm-intel-next-$today + $DRY git tag -f $tag $DIM_DRM_INTEL_REMOTE/drm-intel-next + git push $DRY_RUN -f $DIM_DRM_INTEL_REMOTE $tag + else + echo "drm-intel-next not up-to-date, aborting" + exit + fi + +} + # dim_pull_request branch upstream function dim_pull_request {
@@ -1013,22 +1031,6 @@ fi # XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case # into an else branch in the above check for functions. case "$subcmd" in - tag-next) - cd $DIM_PREFIX/$DIM_DRM_INTEL - git fetch $DIM_DRM_INTEL_REMOTE - - if [ $(git rev-parse drm-intel-next) == $(git rev-parse drm-intel-next@{u}) ] ; then - echo "Tagging current drm-intel-next" - - tag=drm-intel-next-$today - $DRY git tag -f $tag $DIM_DRM_INTEL_REMOTE/drm-intel-next - git push $DRY_RUN -f $DIM_DRM_INTEL_REMOTE $tag - else - echo "drm-intel-next not up-to-date, aborting" - exit - fi - - ;; create-branch) if [[ "x$1" = "x" ]]; then echo "usage: $0 $subcommand branch [commit-ish]"
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 29/33 dim: abstract dim_{create, remove}_branch
In reply to Jani Nikula--- dim | 100 +++++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 52 insertions(+), 48 deletions(-)
dim +52 -48
@@ -515,6 +515,58 @@ function dim_magic_patch done } +function dim_create_branch +{ + if [[ "x$1" = "x" ]]; then + echo "usage: $0 $subcommand branch [commit-ish]" + exit 1 + fi + branch=$1 + if [[ "x$2" = "x" ]]; then + start=HEAD + else + start=$2 + fi + + cd $DIM_PREFIX/$DIM_DRM_INTEL + + $DRY git branch $branch $start + git push $DRY_RUN $DIM_DRM_INTEL_REMOTE +$branch --set-upstream + cd $DIM_PREFIX/drm-intel-rerere + $DRY echo "nightly_branches=\"\$nightly_branches origin/$branch\"" \ + >> nightly.conf + $DRY git add nightly.conf + $DRY git commit --quiet -m "Adding $branch to -nightly" +} + +function dim_remove_branch +{ + if [[ "x$1" = "x" ]]; then + echo "usage: $0 $subcommand branch" + exit 1 + fi + branch=$1 + + cd $DIM_PREFIX/$DIM_DRM_INTEL + + if ! $DRY git branch -d $branch ; then + warn_or_fail "Can't remove $branch in working repo" + fi + + if [[ -d $DIM_PREFIX/$branch ]] ; then + rm -R $DIM_PREFIX/$branch + fi + + cd $DIM_PREFIX/drm-intel-nightly + git push $DRY_RUN origin --delete $branch + $DRY git fetch origin --prune + cd $DIM_PREFIX/drm-intel-rerere + full_branch="origin/$branch" + $DRY sed -e "/${full_branch//\//\\\/}/d" -i nightly.conf + $DRY git add nightly.conf + $DRY git commit --quiet -m "Deleted $branch and removed from -nightly" +} + function dim_cd { local path
@@ -1031,54 +1083,6 @@ fi # XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case # into an else branch in the above check for functions. case "$subcmd" in - create-branch) - if [[ "x$1" = "x" ]]; then - echo "usage: $0 $subcommand branch [commit-ish]" - exit 1 - fi - branch=$1 - if [[ "x$2" = "x" ]]; then - start=HEAD - else - start=$2 - fi - - cd $DIM_PREFIX/$DIM_DRM_INTEL - - $DRY git branch $branch $start - git push $DRY_RUN $DIM_DRM_INTEL_REMOTE +$branch --set-upstream - cd $DIM_PREFIX/drm-intel-rerere - $DRY echo "nightly_branches=\"\$nightly_branches origin/$branch\"" \ - >> nightly.conf - $DRY git add nightly.conf - $DRY git commit --quiet -m "Adding $branch to -nightly" - ;; - remove-branch) - if [[ "x$1" = "x" ]]; then - echo "usage: $0 $subcommand branch" - exit 1 - fi - branch=$1 - - cd $DIM_PREFIX/$DIM_DRM_INTEL - - if ! $DRY git branch -d $branch ; then - warn_or_fail "Can't remove $branch in working repo" - fi - - if [[ -d $DIM_PREFIX/$branch ]] ; then - rm -R $DIM_PREFIX/$branch - fi - - cd $DIM_PREFIX/drm-intel-nightly - git push $DRY_RUN origin --delete $branch - $DRY git fetch origin --prune - cd $DIM_PREFIX/drm-intel-rerere - full_branch="origin/$branch" - $DRY sed -e "/${full_branch//\//\\\/}/d" -i nightly.conf - $DRY git add nightly.conf - $DRY git commit --quiet -m "Deleted $branch and removed from -nightly" - ;; checker) rm drivers/gpu/drm/i915/*.o &> /dev/null || true rm drivers/gpu/drm/i915/*.ko &> /dev/null || true
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 30/33 dim: abstract dim_checker
In reply to Jani Nikula--- dim | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
dim +7 -5
@@ -662,6 +662,13 @@ function dim_checkpatch done } +function dim_checker +{ + rm drivers/gpu/drm/i915/*.o &> /dev/null || true + rm drivers/gpu/drm/i915/*.ko &> /dev/null || true + make C=1 drivers/gpu/drm/i915/i915.ko +} + function prep_pull_mail_greetings { if [ -r $DIM_TEMPLATE_HELLO ]; then
@@ -1083,11 +1090,6 @@ fi # XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case # into an else branch in the above check for functions. case "$subcmd" in - checker) - rm drivers/gpu/drm/i915/*.o &> /dev/null || true - rm drivers/gpu/drm/i915/*.ko &> /dev/null || true - make C=1 drivers/gpu/drm/i915/i915.ko - ;; help|*) manpage=$DIM_PREFIX/maintainer-tools/dim.rst if [ ! -e "$manpage" ]; then
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 31/33 dim: abstract dim_help
In reply to Jani Nikuladim help being the last subcommand handled by the switch case, obliterate it as well, finishing the job we set out to do. Now all subcommands are handled via dim_ prefixed functions.
--- dim | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-)
dim +24 -26
@@ -1074,6 +1074,28 @@ function dim_fixes sed -e 's/\([0-f]\{12\}\)[0-f]*/\1/' } +function dim_help +{ + manpage=$DIM_PREFIX/maintainer-tools/dim.rst + if [ ! -e "$manpage" ]; then + manpage=$(dirname $(readlink -f $0))/dim.rst + if [ ! -e "$manpage" ]; then + echo "Can't find the man page. See http://cgit.freedesktop.org/drm-intel/tree/dim.rst?h=maintainer-tools" + exit 1 + fi + fi + + if hash rst2man 2>/dev/null; then + renderer=rst2man + pager="man -l -" + else + renderer=cat + pager=${PAGER:-cat} + fi + + $renderer < $manpage | $pager +} + # dim subcommand aliases declare -n subcmd=dim_alias_${subcommand//-/_} if [ -z "$subcmd" ]; then
@@ -1084,30 +1106,6 @@ fi subcmd_func=dim_${subcmd//-/_} if declare -f $subcmd_func >/dev/null; then $subcmd_func "$@" - exit 0 +else + dim_help fi - -# XXX: abscract each case to a dim_ prefixed function, and turn the help|*) case -# into an else branch in the above check for functions. -case "$subcmd" in - help|*) - manpage=$DIM_PREFIX/maintainer-tools/dim.rst - if [ ! -e "$manpage" ]; then - manpage=$(dirname $(readlink -f $0))/dim.rst - if [ ! -e "$manpage" ]; then - echo "Can't find the man page. See http://cgit.freedesktop.org/drm-intel/tree/dim.rst?h=maintainer-tools" - exit 1 - fi - fi - - if hash rst2man 2>/dev/null; then - renderer=rst2man - pager="man -l -" - else - renderer=cat - pager=${PAGER:-cat} - fi - - $renderer < $manpage | $pager - ;; -esac
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 32/33 dim: show usage instead of the man page on unknown subcommands
In reply to Jani NikulaI find displaying the man page on every typo a bit distracting. Now that we can list all the supported subcommands (by way of listing all the dim_ prefixed functions), add usage to show quick help. Also make it a subcommand of its own.
--- dim | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
dim +14 -3
@@ -139,7 +139,7 @@ shift `expr $OPTIND - 1` # first positional argument is the subcommand if [ "$#" = "0" ]; then - subcommand="help" + subcommand="usage" else subcommand="$1" shift
@@ -149,7 +149,7 @@ fi # Sanity checks. # -if [ "$subcommand" != "setup" -a "$subcommand" != "help" ]; then +if [ "$subcommand" != "setup" -a "$subcommand" != "help" -a "$subcommand" != "usage" ]; then for d in $DIM_PREFIX $DIM_PREFIX/$DIM_DRM_INTEL $DIM_PREFIX/drm-intel-rerere $DIM_PREFIX/drm-intel-nightly; do if [ ! -d $d ]; then echo "$d is missing, please check your configuration and/or run dim setup"
@@ -1096,6 +1096,16 @@ function dim_help $renderer < $manpage | $pager } +function dim_usage +{ + echo "usage: $0 [OPTIONS] SUBCOMMAND [ARGUMENTS]" + echo + echo "The available subcommands are:" + declare -F | grep -o " dim_[a-zA-Z_]*" | sed 's/^ dim_/\t/' + echo + echo "See '$0 help' for more information." +} + # dim subcommand aliases declare -n subcmd=dim_alias_${subcommand//-/_} if [ -z "$subcmd" ]; then
@@ -1107,5 +1117,6 @@ subcmd_func=dim_${subcmd//-/_} if declare -f $subcmd_func >/dev/null; then $subcmd_func "$@" else - dim_help + echo "$0: '$subcommand' is not a dim command." >&2 + dim_usage fi
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 33/33 dim: add -h option for usage, imrove output on unknown options
In reply to Jani NikulaShow usage also with the -h option, and improve output on unknown options.
--- dim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
dim +7 -3
@@ -107,6 +107,7 @@ DRY_RUN= INTERACTIVE= DRY= FORCE= +HELP= function warn_or_fail {
@@ -118,7 +119,7 @@ function warn_or_fail fi } -while getopts dfi opt; do +while getopts hdfi opt; do case "$opt" in d) DRY_RUN=--dry-run
@@ -130,15 +131,18 @@ while getopts dfi opt; do i) INTERACTIVE='eval read -rsp "Press any key to continue..." -n1 key2; echo' ;; + h) + HELP=1 + ;; *) - echo "Try 'dim help' for more information. $opt" + echo "See '$0 help' for more information." >&2 exit esac done shift `expr $OPTIND - 1` # first positional argument is the subcommand -if [ "$#" = "0" ]; then +if [ -n "$HELP" -o "$#" = "0" ]; then subcommand="usage" else subcommand="$1"
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 11 lines · Jani Nikula
This is v2 of [1], with Daniel's concern regarding aliases addressed. It's much better now.
Patches 1-11 and 15-31 are mostly just mechanical renames or code movement. They explode the series so big, but I think they're easier to look at this way.
The real changes are in patches 12-14 and 32-33.
All in all this should make dim more maintainable. It's getting pretty big for a shell script.
Pushed the lot with Daniel's IRC ack. Fixed one small typo on the way.
Please report any odd behaviour; it's possible I've screwed up something...
BR,
Jani.
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx