All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Imran M Yousuf" <imyousuf@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, "Imran M Yousuf" <imyousuf@smartitengineering.com>
Subject: Re: [PATCH] git-submodule.sh: Add Custom argument input support to git submodule recurse subcommand
Date: Mon, 5 May 2008 15:07:56 +0600	[thread overview]
Message-ID: <7bfdc29a0805050207i7978043u6084cf328be4bec4@mail.gmail.com> (raw)
In-Reply-To: <1209977051-25896-3-git-send-email-imyousuf@gmail.com>

Sorry for the inconvenience, but please ignore this patch as it was
not generated with -n and version number :(.

- best regards,

Imran


On Mon, May 5, 2008 at 2:44 PM,  <imyousuf@gmail.com> wrote:
> From: Imran M Yousuf <imyousuf@smartitengineering.com>
>
>  There is a scenario which has been put forward several times in
>  discussion over the recurse subcommand and it is that commands chould have
>  different arguments for different modules.
>
>  For example, one module could want to checkout 'master', while another might want
>  to checkout 'work'. The [-a|--customized-argument] argument provides platform
>  just for that. Consider the following command and its followup for further info:
>
>         git submodule recurse -a checkout
>
>         Submodule b is not initialized and skipped
>         git submodule recurse a checkout
>         Please provide an argument: master
>         Press y to provide another arg...
>         git checkout master
>         Already on branch "master"
>         Submodule d is not initialized and skipped
>         git submodule recurse . checkout
>         Please provide an argument: master
>         Press y to provide another arg...
>         git checkout master
>         Already on branch "master"
>
>  This command would also come in handy for diffs and other commands.
>
>  Signed-off-by: Imran M Yousuf <imyousuf@smartitengineering.com>
>  ---
>   git-submodule.sh |   53 +++++++++++++++++++++++++++++++++++++++++++++++++----
>   1 files changed, 49 insertions(+), 4 deletions(-)
>
>  diff --git a/git-submodule.sh b/git-submodule.sh
>  index 8161d51..314652d 100755
>  --- a/git-submodule.sh
>  +++ b/git-submodule.sh
>  @@ -12,7 +12,7 @@ LONG_USAGE="$0 add [-q|--quiet] [-b|--branch branch] <repository> [<path>]
>   $0 [status] [-q|--quiet] [-c|--cached] [--] [<path>...]
>   $0 init|update [-q|--quiet] [--] [<path>...]
>   $0 summary [--cached] [-n|--summary-limit <n>] [<commit>]
>  -$0 recurse [-q|--quiet] [-e|--exit-after-error] [-d|--depth <recursion depth>] [-b|--breadth-first] <git command> [<args> ...]"
>  +$0 recurse [-q|--quiet] [-e|--exit-after-error] [-d|--depth <recursion depth>] [-b|--breadth-first] [-a|--customized-argument] <git command> [<args> ...]"
>   OPTIONS_SPEC=
>   . git-sh-setup
>   require_work_tree
>  @@ -25,6 +25,8 @@ depth=0
>   current_depth=0
>   depth_first=1
>   on_error=
>  +use_custom_args=
>  +custom_args=
>
>   #
>   # print stuff on stdout unless -q was specified
>  @@ -585,6 +587,40 @@ cmd_status()
>         done
>   }
>
>  +# Take arguments from user to pass as custom arguments and execute the command
>  +exec_with_custom_args()
>  +{
>  +       input=
>  +       arg_index=0
>  +       eval_str="set "
>  +       while test $# -gt 0
>  +       do
>  +               arg_index=$(($arg_index + 1))
>  +               var='$'"$arg_index"
>  +               input="$1"
>  +               eval_str="$eval_str $var \"$input\""
>  +               shift
>  +       done
>  +       while :
>  +       do
>  +               arg_index=$(($arg_index + 1))
>  +               printf "Please provide an argument: "
>  +               read input
>  +               var='$'"$arg_index"
>  +               eval_str="$eval_str $var \"$input\""
>  +               printf "Press y to provide another arg... "
>  +               read keypress
>  +               if test "$keypress" != "y" &&
>  +                       test "$keypress" != "Y"
>  +               then
>  +                       break
>  +               fi
>  +       done
>  +       eval $eval_str
>  +       say "$*"
>  +       "$@"
>  +}
>  +
>   # Check whether the submodule is initialized or not
>   initialize_sub_module()
>   {
>  @@ -637,10 +673,16 @@ traverse_module()
>                 # If depth-first is specified in that case submodules are
>                 # are traversed before executing the command on this submodule
>                 test -n "$depth_first" && traverse_submodules "$@"
>  -               # pwd is mentioned in order to enable the ser to distinguish
>  -               # between same name modules, e.g. a/lib and b/lib.
>                 say "git submodule recurse $submod_path $*"
>  -               git "$@"
>  +               if test -n "$use_custom_args"
>  +               then
>  +                       # Execute the commands after taking the arguments
>  +                       # Please note that one input is for one argument
>  +                       # only.
>  +                       exec_with_custom_args git "$@"
>  +               else
>  +                       git "$@"
>  +               fi
>                 # if exit on error is specifed than script will exit if any
>                 # command fails. As there is no transaction there will be
>                 # no rollback either
>  @@ -689,6 +731,9 @@ cmd_recurse() {
>                 -e|--exit-after-error)
>                         on_error=1
>                         ;;
>  +               -a|--customized-argument)
>  +                       use_custom_args=1
>  +                       ;;
>                 -*)
>                         usage
>                         ;;
>  --
>  1.5.4.2
>
>



-- 
Imran M Yousuf
Entrepreneur & Software Engineer
Smart IT Engineering
Dhaka, Bangladesh
Email: imran@smartitengineering.com
Mobile: +880-1711402557

  parent reply	other threads:[~2008-05-05  9:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-05  8:44 [PATCH] git-submodule.sh: Add Long Usage instead of simple usage imyousuf
2008-05-05  8:44 ` [PATCH] git-submodule.sh: Add recurse subcommand with basic options imyousuf
2008-05-05  8:44   ` [PATCH] git-submodule.sh: Add Custom argument input support to git submodule recurse subcommand imyousuf
2008-05-05  8:44     ` [PATCH] git-submodule.sh: Add pre command argument " imyousuf
2008-05-05  8:44       ` [PATCH] Documentation/git-submodule.txt: Add documentation for the " imyousuf
2008-05-05  9:07         ` Imran M Yousuf
2008-05-05  9:07       ` [PATCH] git-submodule.sh: Add pre command argument to git submodule " Imran M Yousuf
2008-05-05  9:07     ` Imran M Yousuf [this message]
2008-05-05  9:08   ` [PATCH] git-submodule.sh: Add recurse subcommand with basic options Imran M Yousuf
2008-05-05  9:07 ` [PATCH] git-submodule.sh: Add Long Usage instead of simple usage Imran M Yousuf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7bfdc29a0805050207i7978043u6084cf328be4bec4@mail.gmail.com \
    --to=imyousuf@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=imyousuf@smartitengineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.