git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v5 3/5] git-submodule summary: limit summary size

From
Ping Yin <pkufranky@gmail.com>
Date
Mar 11, 2008, 13:52 UTC
Message-ID
<1205243539-797-4-git-send-email-pkufranky@gmail.com>
In-Reply-To
<1205243539-797-3-git-send-email-pkufranky@gmail.com>

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>
---
 git-submodule.sh |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index b90e132..3f76b15 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -4,7 +4,9 @@
 #
 # Copyright (c) 2007 Lars Hjemli
 
-USAGE='[--quiet] [--cached] [add <repo> [-b branch]|status|init|update|summary [<commit>]] [--] [<path>...]'
+USAGE="[--quiet] [--cached] \
+[add <repo> [-b branch]|status|init|update|summary [-n|--summary-limit <n>] [<commit>]] \
+[--] [<path>...]"
 OPTIONS_SPEC=
 . git-sh-setup
 require_work_tree
@@ -339,6 +341,8 @@ set_name_rev () {
 # $@ = [commit (default 'HEAD'),] requested paths (default all)
 #
 cmd_summary() {
+	summary_limit=-1
+
 	# parse $args after "submodule ... summary".
 	while test $# -ne 0
 	do
@@ -346,6 +350,15 @@ cmd_summary() {
 		--cached)
 			cached="$1"
 			;;
+		-n|--summary-limit)
+			if summary_limit=$(($2 + 0)) 2>/dev/null && test "$summary_limit" = "$2"
+			then
+				:
+			else
+				usage
+			fi
+			shift
+			;;
 		--)
 			shift
 			break
@@ -360,6 +373,8 @@ cmd_summary() {
 		shift
 	done
 
+	test $summary_limit = 0 && return
+
 	if rev=$(git rev-parse --verify "$1^0" 2>/dev/null)
 	then
 		head=$rev
@@ -462,8 +477,10 @@ cmd_summary() {
 		else
 			if test $mod_src = 160000 -a $mod_dst = 160000
 			then
+				limit=
+				test $summary_limit -gt 0 && limit="-$summary_limit"
 				GIT_DIR="$name/.git" \
-				git log --pretty='format:  %m %s' \
+				git log $limit --pretty='format:  %m %s' \
 				--first-parent $sha1_src...$sha1_dst
 			elif test $mod_dst = 160000
 			then
-- 
1.5.4.3.347.g5314c
Previous: Ping YinNext: Ping Yin
Message 4 of 14 in “git-submodule summary”
  1. 0/5 git-submodule summaryPing Yin, Mar 11, 2008
  2. 1/5 git-submodule summary: code frameworkPing Yin, Mar 11, 2008
  3. 2/5 git-submodule summary: show commit summaryPing Yin, Mar 11, 2008
  4. 3/5 git-submodule summary: limit summary sizePing Yin, Mar 11, 2008
  5. 4/5 git-submodule summary: documentationPing Yin, Mar 11, 2008
  6. 5/5 git-submodule summary: testPing Yin, Mar 11, 2008
  7. Ping YinMar 12, 2008
  8. Junio C HamanoMar 12, 2008
  9. Ping YinMar 12, 2008
  10. Junio C HamanoMar 12, 2008
  11. Ping YinMar 12, 2008
  12. Junio C HamanoMar 12, 2008
  13. Ping YinMar 12, 2008
  14. git-submodule summary: fix that some "wc" flavors produce leading spacesJohannes Sixt, Mar 12, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.