diff --git a/dim b/dim index c41d16fc868e5cb7bcb3d8606080ef273ec40619..f7747177c7cc07b97c46d6d64477c36842e57a1c 100755 --- a/dim +++ b/dim @@ -175,10 +175,15 @@ function pause echo } +ASK_USER_ASSUME_YES= function ask_user { local prompt="$* (y/N) " + if [ $ASK_USER_ASSUME_YES -eq 1 ]; then + return 0 + fi + read -n 1 -rsp "$prompt" echo if [[ $REPLY =~ ^[Yy]$ ]]; then @@ -227,7 +232,9 @@ function url_to_remote # url [url ...] url=$1 remote=${url%.git} remote=${remote##*/} - read -r -i "$remote" -e -p "Enter a name to auto-add this remote, leave blank to abort: " remote + if [ $ASK_USER_ASSUME_YES -ne 1 ]; then + read -r -i "$remote" -e -p "Enter a name to auto-add this remote, leave blank to abort: " remote + fi if [[ -z "$remote" ]]; then echoerr "Please set it up yourself using:" echoerr " $ git remote add <name> $url" @@ -2310,10 +2317,32 @@ function setup_aux_checkout # name url directory cd - > /dev/null } -function dim_setup +function parse_opt_dim_setup # options +{ + local OPTS arg + + OPTS=$(getopt --option y --long yes -n 'dim setup' -- "$@") + + eval set -- "$OPTS" + + while true; do + case "$1" in + -y|--yes) + ASK_USER_ASSUME_YES=1 + shift + ;; + --) + shift; break ;; + esac + done +} + +function dim_setup # options { local remote drm_tip_ssh linux_upstream_git + parse_opt_dim_setup "$@" + drm_tip_ssh=ssh://git.freedesktop.org/git/drm-tip linux_upstream_git=git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git diff --git a/dim.rst b/dim.rst index 7ef8ab0a57ea00de082b04e7bae72d0dad286c51..ede150fa02bb7cd2b684ad437ae3a77edd10e930 100644 --- a/dim.rst +++ b/dim.rst @@ -110,10 +110,16 @@ forward in its entirety. COMMANDS FOR COMMITTERS AND MAINTAINERS ======================================= -setup *prefix* --------------- +setup [options] +--------------- Setup git maintainer branches in the given prefix. +Available options: + +-y|--yes + Assume "yes" to all prompts or default values so + it can be executed non-attended + update-branches --------------- Updates all maintainer branches. Useful to synchronize all branches when other