dim: Don't run stuff that needs dim setup
PATCH 1/2 dim: Don't run stuff that needs dim setup
Yet another case where something fell off - we can't compute dim_branches before setup is done, so shovel it somewhere where that's not the case.
v2: Also fixup bash completion.
--- bash_completion | 9 +++++++-- dim | 12 ++++++------ 2 files changed, 13 insertions(+), 8 deletions(-)
bash_completion +7 -2
@@ -12,8 +12,13 @@ dim () _dim () { local cur cmds opts i - local nightly_branches=`(source ~/linux/drm-intel-rerere/nightly.conf ; echo $nightly_branches) | \ - xargs -n 1 echo | grep '^origin' | sed -e 's/^origin\///'` + + if [ -f ~/linux/drm-intel-rerere/nightly.conf ] ; then + local nightly_branches=`(source ~/linux/drm-intel-rerere/nightly.conf ; echo $nightly_branches) | \ + xargs -n 1 echo | grep '^origin' | sed -e 's/^origin\///'` + else + local nightly_branches="" + fi local upstream_branches="origin/master airlied/drm-next airlied/drm-fixes" cmds="setup nightly-forget update-branches"
dim +6 -6
@@ -150,14 +150,14 @@ if [ "$subcommand" != "setup" -a "$subcommand" != "help" ]; then exit 1 fi done -fi -# -# Internal configuration that depends on a sane setup. -# + # + # Internal configuration that depends on a sane setup. + # -dim_branches=`(source $DIM_PREFIX/drm-intel-rerere/nightly.conf ; echo $nightly_branches) | \ - xargs -n 1 echo | grep '^origin' | sed -e 's/^origin\///'` + dim_branches=`(source $DIM_PREFIX/drm-intel-rerere/nightly.conf ; echo $nightly_branches) | \ + xargs -n 1 echo | grep '^origin' | sed -e 's/^origin\///'` +fi # get message id from file # $1 = file
Signature · 6 lines
2.5.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 dim: Add success notice to setup
Also add a few output lines in between for progress.
--- dim | 5 +++++ 1 file changed, 5 insertions(+)
dim +5 -0
@@ -618,6 +618,7 @@ function setup_dim fi cd .. + echo "Setting up maintainer-tools ..." if [ ! -d maintainer-tools ]; then git clone --reference=$DIM_PREFIX/$DIM_DRM_INTEL/.git $drm_intel_ssh maintainer-tools fi
@@ -630,6 +631,7 @@ function setup_dim fi cd .. + echo "Setting up drm-intel-rerere ..." if [ ! -d drm-intel-rerere ]; then git clone --reference=$DIM_PREFIX/$DIM_DRM_INTEL/.git $drm_intel_ssh drm-intel-rerere fi
@@ -642,6 +644,7 @@ function setup_dim fi cd .. + echo "Setting up drm-intel-nightly ..." if [ ! -d drm-intel-nightly ]; then git clone --reference=$DIM_PREFIX/$DIM_DRM_INTEL/.git $drm_intel_ssh drm-intel-nightly fi
@@ -668,6 +671,8 @@ function setup_dim else git remote add driver-core-upstream $driver_core_upstream_git fi + + echo "dim setup successfully completed!" } function assert_branch
Signature · 6 lines
2.5.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/1 dim: Don't run stuff that needs dim setup
In reply to Daniel VetterYet another case where something fell off - we can't compute dim_branches before setup is done, so handle the commands that don't need setup first.
---
this is on top of the man page extraction patch
--- dim | 84 +++++++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 45 insertions(+), 39 deletions(-)
dim +45 -39
@@ -139,26 +139,6 @@ else shift fi -# -# Sanity checks. -# - -if [ "$subcommand" != "setup" -a "$subcommand" != "help" ]; 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" - exit 1 - fi - done -fi - -# -# Internal configuration that depends on a sane setup. -# - -dim_branches=`(source $DIM_PREFIX/drm-intel-rerere/nightly.conf ; echo $nightly_branches) | \ - xargs -n 1 echo | grep '^origin' | sed -e 's/^origin\///'` - # get message id from file # $1 = file message_get_id ()
@@ -684,10 +664,53 @@ function assert_branch fi } +# +# Handle subcommands that must work without a sane setup. +# case "$subcommand" in setup) setup_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 + ;; +esac + +# +# Sanity checks. +# +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" + exit 1 + fi +done + +# +# Internal configuration that depends on a sane setup. +# +dim_branches=`(source $DIM_PREFIX/drm-intel-rerere/nightly.conf ; echo $nightly_branches) | \ + xargs -n 1 echo | grep '^origin' | sed -e 's/^origin\///'` + + +case "$subcommand" in nightly-forget) cd $DIM_PREFIX/drm-intel-nightly git fetch origin >& /dev/null
@@ -964,24 +987,7 @@ case "$subcommand" in 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 - 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 + *) + echo "Unknown command '$subcommand'. Try 'dim help'." ;; esac
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 3 lines · Jani Nikula
Yet another case where something fell off - we can't compute
dim_branchesbefore setup is done, so handle the commands that don't need setup first.
This should've had an explanation saying that I'd prefer this kind of approach, to reduce the special casing all around.
Other than that, there was really nothing wrong with your patch either.
BR,
Jani.
Quoted 130 lines
Reported-by Tvrtko Ursulin <[email protected]>Signed-off-by Jani Nikula <[email protected]>---
this is on top of the man page extraction patch
--- dim | 84 +++++++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 45 insertions(+), 39 deletions(-)dim +45
-39@@ -139,26 +139,6 @@ else shift fi -# -# Sanity checks. -# - -if [ "$subcommand" != "setup" -a "$subcommand" != "help" ]; 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" - exit 1 - fi - done -fi - -# -# Internal configuration that depends on a sane setup. -# - -dim_branches=`(source $DIM_PREFIX/drm-intel-rerere/nightly.conf ; echo $nightly_branches) | \ - xargs -n 1 echo | grep '^origin' | sed -e 's/^origin\///'` - # get message id from file # $1 = file message_get_id ()@@ -684,10 +664,53 @@ function assert_branch fi } +# +# Handle subcommands that must work without a sane setup. +# case "$subcommand" in setup) setup_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 + ;; +esac + +# +# Sanity checks. +# +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" + exit 1 + fi +done + +# +# Internal configuration that depends on a sane setup. +# +dim_branches=`(source $DIM_PREFIX/drm-intel-rerere/nightly.conf ; echo $nightly_branches) | \ + xargs -n 1 echo | grep '^origin' | sed -e 's/^origin\///'` + + +case "$subcommand" in nightly-forget) cd $DIM_PREFIX/drm-intel-nightly git fetch origin >& /dev/null@@ -964,24 +987,7 @@ case "$subcommand" in 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 - 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 + *) + echo "Unknown command '$subcommand'. Try 'dim help'." ;; esacSignature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx