From: imyousuf@gmail.com
To: git@vger.kernel.org
Cc: gitster@pobox.com, Imran M Yousuf <imyousuf@smartitengineering.com>
Subject: [PATCH 4/5] Add pre command argument to git submodule recurse subcommand
Date: Sat, 3 May 2008 19:53:32 +0600 [thread overview]
Message-ID: <1209822813-12237-4-git-send-email-imyousuf@gmail.com> (raw)
In-Reply-To: <1209822813-12237-3-git-send-email-imyousuf@gmail.com>
From: Imran M Yousuf <imyousuf@smartitengineering.com>
I usually feel that when typing a command, being able to see some options
come in handy. For example if I can see the available branches before checking
out a branch that would be useful, IOW, if I could do 'git branch' before git
checkout it would be helpful.
It is now possible using the [-p|--pre-command] option. Using this
subcommand command argument one can actually execute another command before
specifying the arguments or the original command getting executed.
git submodule recurse -a -p checkout
it will prompt the user for the pre command until one is satisfied and later
the original command with the custom argument will get executed.
Signed-off-by: Imran M Yousuf <imyousuf@smartitengineering.com>
---
git-submodule.sh | 29 ++++++++++++++++++++++++++++-
1 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 59e58e5..6a85ba6 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] [-a|--customized-argument] <git command> [<args> ...]"
+$0 recurse [-q|--quiet] [-e|--exit-after-error] [-d|--depth <recursion depth>] [-b|--breadth-first] [-a|--customized-argument] [-p|--pre-command] <git command> [<args> ...]"
OPTIONS_SPEC=
. git-sh-setup
require_work_tree
@@ -27,6 +27,7 @@ depth_first=1
on_error=
use_custom_args=
custom_args=
+pre_cmd=
#
# print stuff on stdout unless -q was specified
@@ -587,6 +588,28 @@ cmd_status()
done
}
+# Take command from user and execute it until user wants to discontinue
+do_pre_command()
+{
+ say "Starting pre-comamnd execution!"
+ while :
+ do
+ (
+ printf "Please provide a command: "
+ read pre_command
+ test -z "$pre_command" ||
+ eval "$pre_command"
+ )
+ printf "Press y to continue with another shell command... "
+ read keypress
+ if test "$keypress" != "y" &&
+ test "$keypress" != "Y"
+ then
+ break
+ fi
+ done
+}
+
# Take arguments from user to pass as custom arguments and execute the command
exec_with_custom_args()
{
@@ -674,6 +697,7 @@ 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 "$@"
+ test -n "$pre_cmd" && do_pre_command
say "git submodule recurse $submod_path $*"
if test -n "$use_custom_args"
then
@@ -735,6 +759,9 @@ cmd_recurse() {
-a|--customized-argument)
use_custom_args=1
;;
+ -p|--pre-command)
+ pre_cmd=1
+ ;;
-*)
usage
;;
--
1.5.4.2
next prev parent reply other threads:[~2008-05-03 13:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-03 13:53 [PATCH 1/5] Add Long Usage instead of simple usage imyousuf
2008-05-03 13:53 ` [PATCH 2/5] Add recurse subcommand with basic options imyousuf
2008-05-03 13:53 ` [PATCH 3/5] Add Custom argument input support to git submodule recurse subcommand imyousuf
2008-05-03 13:53 ` imyousuf [this message]
2008-05-03 13:53 ` [PATCH 5/5] Add documentation for the " imyousuf
2008-05-03 14:12 ` [PATCH 1/5] Add Long Usage instead of simple usage Johannes Schindelin
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=1209822813-12237-4-git-send-email-imyousuf@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.