git-submodule summary: limit summary size
This patch teaches git-submodule an option '--summary-limit|-n <number>' to limit number of commits in total for the summary of each submodule in the modified case (only a single commit is shown in other cases). Giving 0 will disable the summary; a negative number means unlimted, which is the default. Signed-off-by: Ping Yin <pkufranky@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ping Yin committed
Mar 11, 2008 at 21:52 UTC
f2dc06a344257df7b9307fc8453af7342409b610
1 file changed
+19
-2
git-submodule.sh
+19
-2
@@ -4,7 +4,9 @@
4
#
5
# Copyright (c) 2007 Lars Hjemli
6
7
-USAGE='[--quiet] [--cached] [add <repo> [-b branch]|status|init|update|summary [<commit>]] [--] [<path>...]'
7
+USAGE="[--quiet] [--cached] \
8
+[add <repo> [-b branch]|status|init|update|summary [-n|--summary-limit <n>] [<commit>]] \
9
+[--] [<path>...]"
10
OPTIONS_SPEC=
11
. git-sh-setup
12
require_work_tree
@@ -329,6 +331,8 @@ set_name_rev () {
331
# $@ = [commit (default 'HEAD'),] requested paths (default all)
332
#
333
cmd_summary() {
334
+ summary_limit=-1
335
+
336
# parse $args after "submodule ... summary".
337
while test $# -ne 0
338
do
@@ -336,6 +340,15 @@ cmd_summary() {
340
--cached)
341
cached="$1"
342
;;
343
+ -n|--summary-limit)
344
+ if summary_limit=$(($2 + 0)) 2>/dev/null && test "$summary_limit" = "$2"
345
+ then
346
+ :
347
+ else
348
+ usage
349
+ fi
350
+ shift
351
+ ;;
352
--)
353
shift
354
break
@@ -350,6 +363,8 @@ cmd_summary() {
363
shift
364
done
365
366
+ test $summary_limit = 0 && return
367
+
368
if rev=$(git rev-parse --verify "$1^0" 2>/dev/null)
369
then
370
head=$rev
@@ -458,8 +473,10 @@ cmd_summary() {
473
else
474
if test $mod_src = 160000 -a $mod_dst = 160000
475
then
476
+ limit=
477
+ test $summary_limit -gt 0 && limit="-$summary_limit"
478
GIT_DIR="$name/.git" \
462
- git log --pretty='format: %m %s' \
479
+ git log $limit --pretty='format: %m %s' \
480
--first-parent $sha1_src...$sha1_dst
481
elif test $mod_dst = 160000
482
then