From: imyousuf@gmail.com
To: git@vger.kernel.org
Cc: gitster@pobox.com, Imran M Yousuf <imyousuf@smartitengineering.com>
Subject: [PATCH v2 4/5] git-submodule.sh: Add pre command argument to git submodule recurse subcommand
Date: Mon, 5 May 2008 15:09:41 +0600 [thread overview]
Message-ID: <1209978582-5785-4-git-send-email-imyousuf@gmail.com> (raw)
In-Reply-To: <1209978582-5785-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 314652d..dd80850 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()
{
@@ -673,6 +696,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
@@ -734,6 +758,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-05 9:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-05 9:09 [PATCH v2 1/5] git-submodule.sh: Add Long Usage instead of simple usage imyousuf
2008-05-05 9:09 ` [PATCH v2 2/5] git-submodule.sh: Add recurse subcommand with basic options imyousuf
2008-05-05 9:09 ` [PATCH v2 3/5] git-submodule.sh: Add Custom argument input support to git submodule recurse subcommand imyousuf
2008-05-05 9:09 ` imyousuf [this message]
2008-05-05 9:09 ` [PATCH v2 5/5] Documentation/git-submodule.txt: Add documentation for the " imyousuf
2008-05-12 22:43 ` [PATCH v2 3/5] git-submodule.sh: Add Custom argument input support to git submodule " Junio C Hamano
2008-05-18 13:27 ` Johan Herland
2008-05-18 13:36 ` Sverre Rabbelier
2008-05-18 15:32 ` Johannes Schindelin
2008-05-18 15:34 ` Sverre Rabbelier
2008-05-19 3:48 ` Imran M Yousuf
2008-05-12 1:20 ` [PATCH v2 2/5] git-submodule.sh: Add recurse subcommand with basic options Junio C Hamano
2008-05-13 6:40 ` 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=1209978582-5785-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).