提交 d0f64dd4 编写于 作者: P Ping Yin 提交者: Junio C Hamano

git-submodule summary: --for-status option

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: NPing Yin <pkufranky@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 f43e2fd4
...@@ -342,6 +342,7 @@ set_name_rev () { ...@@ -342,6 +342,7 @@ set_name_rev () {
# #
cmd_summary() { cmd_summary() {
summary_limit=-1 summary_limit=-1
for_status=
# parse $args after "submodule ... summary". # parse $args after "submodule ... summary".
while test $# -ne 0 while test $# -ne 0
...@@ -350,6 +351,9 @@ cmd_summary() { ...@@ -350,6 +351,9 @@ cmd_summary() {
--cached) --cached)
cached="$1" cached="$1"
;; ;;
--for-status)
for_status="$1"
;;
-n|--summary-limit) -n|--summary-limit)
if summary_limit=$(($2 + 0)) 2>/dev/null && test "$summary_limit" = "$2" if summary_limit=$(($2 + 0)) 2>/dev/null && test "$summary_limit" = "$2"
then then
...@@ -397,7 +401,8 @@ cmd_summary() { ...@@ -397,7 +401,8 @@ cmd_summary() {
done done
) )
test -n "$modules" && test -z "$modules" && return
git diff-index $cached --raw $head -- $modules | git diff-index $cached --raw $head -- $modules |
grep -e '^:160000' -e '^:[0-7]* 160000' | grep -e '^:160000' -e '^:[0-7]* 160000' |
cut -c2- | cut -c2- |
...@@ -499,7 +504,14 @@ cmd_summary() { ...@@ -499,7 +504,14 @@ cmd_summary() {
echo echo
fi fi
echo echo
done done |
if test -n "$for_status"; then
echo "# Modified submodules:"
echo "#"
sed -e 's|^|# |' -e 's|^# $|#|'
else
cat
fi
} }
# #
# List all submodules, prefixed with: # List all submodules, prefixed with:
......
...@@ -192,4 +192,17 @@ test_expect_success 'given commit' " ...@@ -192,4 +192,17 @@ test_expect_success 'given commit' "
EOF EOF
" "
test_expect_success '--for-status' "
git submodule summary --for-status HEAD^ >actual &&
test_cmp actual - <<EOF
# Modified submodules:
#
# * sm1 $head6...0000000:
#
# * sm2 0000000...$head7 (2):
# > Add foo9
#
EOF
"
test_done test_done
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册