git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ping Yin <pkufranky@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Ping Yin <pkufranky@gmail.com>
Subject: [PATCH v2 1/4] git-submodule summary: --for-status option
Date: Thu, 13 Mar 2008 21:48:02 +0800	[thread overview]
Message-ID: <1205416085-23431-2-git-send-email-pkufranky@gmail.com> (raw)
In-Reply-To: <1205416085-23431-1-git-send-email-pkufranky@gmail.com>

The --for-status option is mainly used by builtin-status/commit.
It adds 'Modified submodules:' line at top and  '# ' prefix to all
following lines.

Signed-off-by: Ping Yin <pkufranky@gmail.com>
---
 git-submodule.sh             |   17 ++++++++++++++++-
 t/t7401-submodule-summary.sh |   13 +++++++++++++
 2 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 5f1d5ef..4baafba 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -342,6 +342,7 @@ set_name_rev () {
 #
 cmd_summary() {
 	summary_limit=-1
+	for_status=
 
 	# parse $args after "submodule ... summary".
 	while test $# -ne 0
@@ -350,6 +351,9 @@ cmd_summary() {
 		--cached)
 			cached="$1"
 			;;
+		--for-status)
+			for_status="$1"
+			;;
 		-n|--summary-limit)
 			if summary_limit=$(($2 + 0)) 2>/dev/null && test "$summary_limit" = "$2"
 			then
@@ -398,6 +402,12 @@ cmd_summary() {
 	)
 
 	test -n "$modules" &&
+	if test -n "$for_status"; then
+		echo "# Modified submodules:"
+		echo "#"
+	else
+		true
+	fi &&
 	git diff-index $cached --raw $head -- $modules |
 	grep -e '^:160000' -e '^:[0-7]* 160000' |
 	cut -c2- |
@@ -499,7 +509,12 @@ cmd_summary() {
 			echo
 		fi
 		echo
-	done
+	done |
+	if test -n "$for_status"; then
+		sed -e "s|^|# |" -e 's|^# $|#|'
+	else
+		cat
+	fi
 }
 #
 # List all submodules, prefixed with:
diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh
index 0f3c42a..1dbb39d 100755
--- a/t/t7401-submodule-summary.sh
+++ b/t/t7401-submodule-summary.sh
@@ -192,4 +192,17 @@ test_expect_success 'given commit' "
 EOF
 "
 
+test_expect_success '--for-status' "
+    git submodule summary --for-status HEAD^ >actual &&
+    diff actual - <<-EOF
+# Modified submodules:
+#
+# * sm1 $head6...0000000:
+#
+# * sm2 0000000...$head7 (2):
+#   > Add foo9
+#
+EOF
+"
+
 test_done
-- 
1.5.4.3.347.g5314c

  reply	other threads:[~2008-03-13 13:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-13 13:48 builtin-status submodule summary Ping Yin
2008-03-13 13:48 ` Ping Yin [this message]
2008-03-13 13:48   ` [PATCH v2 2/4] builtin-status: submodule summary support Ping Yin
2008-03-13 13:48     ` [PATCH v2 3/4] builtin-status: configurable submodule summary size Ping Yin
2008-03-13 13:48       ` [PATCH v2 4/4] buitin-status: Add tests for submodule summary Ping Yin
2008-03-13 14:21         ` Johannes Sixt
2008-03-13 18:04           ` Junio C Hamano
2008-03-13 18:14             ` Ping Yin
2008-03-13 18:09           ` Ping Yin
2008-03-13 14:15       ` [PATCH v2 3/4] builtin-status: configurable submodule summary size Johannes Sixt
2008-03-13 14:11     ` [PATCH v2 2/4] builtin-status: submodule summary support Johannes Sixt
2008-03-13 18:01       ` Ping Yin
2008-03-14 14:30 ` builtin-status submodule summary Ping Yin
2008-03-14 16:39   ` Junio C Hamano
2008-03-14 17:45     ` Ping Yin

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=1205416085-23431-2-git-send-email-pkufranky@gmail.com \
    --to=pkufranky@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --subject='Re: [PATCH v2 1/4] git-submodule summary: --for-status option' \
    /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

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).