git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/5] git-submodule summary
@ 2008-03-11 13:52 Ping Yin
  2008-03-11 13:52 ` [PATCH v5 1/5] git-submodule summary: code framework Ping Yin
  0 siblings, 1 reply; 14+ messages in thread
From: Ping Yin @ 2008-03-11 13:52 UTC (permalink / raw)
  To: gitster; +Cc: git

Relative to v3 series, this series has following changes:

- Improve and fix 'show commit summary' patch
  * Remove --left-right when showing summary for modified modules
  * Remove '%h' from "--pretty=format:" for added/deleted/typechanged
    modules
  * Also compute sha1 for blob when blob has sha1 0{40}
- Merge commit log and document patch from junio
- Add test

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v5 1/5] git-submodule summary: code framework
  2008-03-11 13:52 [PATCH v5 0/5] git-submodule summary Ping Yin
@ 2008-03-11 13:52 ` Ping Yin
  2008-03-11 13:52   ` [PATCH v5 2/5] git-submodule summary: show commit summary Ping Yin
  0 siblings, 1 reply; 14+ messages in thread
From: Ping Yin @ 2008-03-11 13:52 UTC (permalink / raw)
  To: gitster; +Cc: git, Ping Yin

These patches teach git-submodule a new subcommand 'summary' to show
commit summary of checked out submodules between a given super project
commit (defaults to HEAD) and working tree (or index, when --cached is
given).

This patch just introduces the framework to find submodules which have
summary to show. A submodule will have summary if it falls into these
cases:

  - type 'M': modified and checked out    (1)
  - type 'A': added and checked out       (2)
  - type 'D': deleted
  - type 'T': typechanged (blob <-> submodule)

Notes:

  1. There may be modified but not checked out cases. In the case of a
     merge conflict, even if the submodule is not checked out, there may
	 be still a diff between index and HEAD on the submodule entry
	 (i.e. modified). The summary will not be show for such a submodule.
  2. A similar explanation applies to the added but not checked out case.

Signed-off-by: Ping Yin <pkufranky@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-submodule.sh |   61 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 56 insertions(+), 5 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 7171cb6..b70ae40 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 2007 Lars Hjemli
 
-USAGE='[--quiet] [--cached] [add <repo> [-b branch]|status|init|update] [--] [<path>...]'
+USAGE='[--quiet] [--cached] [add <repo> [-b branch]|status|init|update|summary [<commit>]] [--] [<path>...]'
 OPTIONS_SPEC=
 . git-sh-setup
 require_work_tree
@@ -330,7 +330,58 @@ set_name_rev () {
 	) )
 	test -z "$revname" || revname=" ($revname)"
 }
+#
+# Show commit summary for submodules in index or working tree
+#
+# If '--cached' is given, show summary between index and given commit,
+# or between working tree and given commit
+#
+# $@ = [commit (default 'HEAD'),] requested paths (default all)
+#
+cmd_summary() {
+	# parse $args after "submodule ... summary".
+	while test $# -ne 0
+	do
+		case "$1" in
+		--cached)
+			cached="$1"
+			;;
+		--)
+			shift
+			break
+			;;
+		-*)
+			usage
+			;;
+		*)
+			break
+			;;
+		esac
+		shift
+	done
 
+	if rev=$(git rev-parse --verify "$1^0" 2>/dev/null)
+	then
+		head=$rev
+		shift
+	else
+		head=HEAD
+	fi
+
+	cd_to_toplevel
+	# Get modified modules cared by user
+	modules=$(git diff-index $cached --raw $head -- "$@" |
+		grep -e '^:160000' -e '^:[0-7]* 160000' |
+		while read mod_src mod_dst sha1_src sha1_dst status name
+		do
+			# Always show modules deleted or type-changed (blob<->module)
+			test $status = D -o $status = T && echo "$name" && continue
+			# Also show added or modified modules which are checked out
+			GIT_DIR="$name/.git" git-rev-parse --git-dir >/dev/null 2>&1 &&
+			echo "$name"
+		done
+	)
+}
 #
 # List all submodules, prefixed with:
 #  - submodule not initialized
@@ -401,7 +452,7 @@ cmd_status()
 while test $# != 0 && test -z "$command"
 do
 	case "$1" in
-	add | init | update | status)
+	add | init | update | status | summary)
 		command=$1
 		;;
 	-q|--quiet)
@@ -416,7 +467,7 @@ do
 		branch="$2"; shift
 		;;
 	--cached)
-		cached=1
+		cached="$1"
 		;;
 	--)
 		break
@@ -440,8 +491,8 @@ then
 	usage
 fi
 
-# "--cached" is accepted only by "status"
-if test -n "$cached" && test "$command" != status
+# "--cached" is accepted only by "status" and "summary"
+if test -n "$cached" && test "$command" != status -a "$command" != summary
 then
 	usage
 fi
-- 
1.5.4.3.347.g5314c

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v5 2/5] git-submodule summary: show commit summary
  2008-03-11 13:52 ` [PATCH v5 1/5] git-submodule summary: code framework Ping Yin
@ 2008-03-11 13:52   ` Ping Yin
  2008-03-11 13:52     ` [PATCH v5 3/5] git-submodule summary: limit summary size Ping Yin
                       ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Ping Yin @ 2008-03-11 13:52 UTC (permalink / raw)
  To: gitster; +Cc: git, Ping Yin

This patch does the hard work to show submodule commit summary.

For a modified submodule, a series of commits will be shown with
the following command:

    git log --pretty='format:%m %s' \
        --first-parent sha1_src...sha1_dst

where the sha1_src is from the given super project commit and the
sha1_dst is from the index or working tree (switched by --cached).

For a deleted, added, or typechanged (blob<->submodule) submodule,
only one single newest commit from the existing end (for example,
src end for submodule deleted or type changed from submodule to blob)
will be shown.

If the src/dst sha1 for a submodule is missing in the submodule
directory, a warning will be issued except in two cases where the
submodule directory is deleted (type 'D') or typechanged to blob
(one case of type 'T').

In the title line for a submodule, the src/dst sha1 and the number
of commits (--first-parent) between the two commits will be shown.

The following example demonstrates most cases.

    Example: commit summary for modified submodules sm1-sm5.
    --------------------------------------------
    $ git submodule summary
    * sm1 354cd45...3f751e5 (4):
      < one line message for C
      < one line message for B
      > one line message for D
      > one line message for E

    * sm2 5c8bfb5...000000 (3):
      < one line message for F

    * sm3 354cd45...3f751e5:
      Warn: sm3 doesn't contain commit 354cd45

    * sm4 354cd34(submodule)-> 235efa(blob) (1):
      < one line message for G

    * sm5 354cd34(blob)-> 235efa(submodule) (5):
      > one line message for H

    --------------------------------------------

Signed-off-by: Ping Yin <pkufranky@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-submodule.sh |   96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 96 insertions(+), 0 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index b70ae40..b90e132 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -381,6 +381,102 @@ cmd_summary() {
 			echo "$name"
 		done
 	)
+
+	test -n "$modules" &&
+	git diff-index $cached --raw $head -- $modules |
+	grep -e '^:160000' -e '^:[0-7]* 160000' |
+	cut -c2- |
+	while read mod_src mod_dst sha1_src sha1_dst status name
+	do
+		if test -z "$cached" &&
+			test $sha1_dst = 0000000000000000000000000000000000000000
+		then
+			case "$mod_dst" in
+				160000)
+				sha1_dst=$(GIT_DIR="$name/.git" git rev-parse HEAD)
+				;;
+				100644)
+				sha1_dst=$(git hash-object $name)
+				;;
+			esac
+		fi
+		missing_src=
+		missing_dst=
+
+		test $mod_src = 160000 &&
+		! GIT_DIR="$name/.git" git-rev-parse --verify $sha1_src^0 >/dev/null 2>&1 &&
+		missing_src=t
+
+		test $mod_dst = 160000 &&
+		! GIT_DIR="$name/.git" git-rev-parse --verify $sha1_dst^0 >/dev/null 2>&1 &&
+		missing_dst=t
+
+		total_commits=
+		case "$missing_src,$missing_dst" in
+		t,)
+			errmsg="  Warn: $name doesn't contain commit $sha1_src"
+			;;
+		,t)
+			errmsg="  Warn: $name doesn't contain commit $sha1_dst"
+			;;
+		t,t)
+			errmsg="  Warn: $name doesn't contain commits $sha1_src and $sha1_dst"
+			;;
+		*)
+			errmsg=
+			total_commits=$(
+			if test $mod_src = 160000 -a $mod_dst = 160000
+			then
+				range="$sha1_src...$sha1_dst"
+			elif test $mod_src = 160000
+			then
+				range=$sha1_src
+			else
+				range=$sha1_dst
+			fi
+			GIT_DIR="$name/.git" \
+			git log --pretty=oneline --first-parent $range | wc -l
+			)
+			total_commits=" ($total_commits)"
+			;;
+		esac
+
+		sha1_abbr_src=$(echo $sha1_src | cut -c1-7)
+		sha1_abbr_dst=$(echo $sha1_dst | cut -c1-7)
+		if test $status = T
+		then
+			if test $mod_dst = 160000
+			then
+				echo "* $name $sha1_abbr_src(blob)->$sha1_abbr_dst(submodule)$total_commits:"
+			else
+				echo "* $name $sha1_abbr_src(submodule)->$sha1_abbr_dst(blob)$total_commits:"
+			fi
+		else
+			echo "* $name $sha1_abbr_src...$sha1_abbr_dst$total_commits:"
+		fi
+		if test -n "$errmsg"
+		then
+			# Don't give error msg for modification whose dst is not submodule
+			# i.e. deleted or changed to blob
+			test $mod_dst = 160000 && echo "$errmsg"
+		else
+			if test $mod_src = 160000 -a $mod_dst = 160000
+			then
+				GIT_DIR="$name/.git" \
+				git log --pretty='format:  %m %s' \
+				--first-parent $sha1_src...$sha1_dst
+			elif test $mod_dst = 160000
+			then
+				GIT_DIR="$name/.git" \
+				git log --pretty='format:  > %s' -1 $sha1_dst
+			else
+				GIT_DIR="$name/.git" \
+				git log --pretty='format:  < %s' -1 $sha1_src
+			fi
+			echo
+		fi
+		echo
+	done
 }
 #
 # List all submodules, prefixed with:
-- 
1.5.4.3.347.g5314c

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v5 3/5] git-submodule summary: limit summary size
  2008-03-11 13:52   ` [PATCH v5 2/5] git-submodule summary: show commit summary Ping Yin
@ 2008-03-11 13:52     ` Ping Yin
  2008-03-11 13:52       ` [PATCH v5 4/5] git-submodule summary: documentation Ping Yin
  2008-03-12  2:08     ` [PATCH v5 2/5] git-submodule summary: show commit summary Ping Yin
                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 14+ messages in thread
From: Ping Yin @ 2008-03-11 13:52 UTC (permalink / raw)
  To: gitster; +Cc: git, Ping Yin

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v5 4/5] git-submodule summary: documentation
  2008-03-11 13:52     ` [PATCH v5 3/5] git-submodule summary: limit summary size Ping Yin
@ 2008-03-11 13:52       ` Ping Yin
  2008-03-11 13:52         ` [PATCH v5 5/5] git-submodule summary: test Ping Yin
  0 siblings, 1 reply; 14+ messages in thread
From: Ping Yin @ 2008-03-11 13:52 UTC (permalink / raw)
  To: gitster; +Cc: git, Ping Yin

Signed-off-by: Ping Yin <pkufranky@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/git-submodule.txt |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index b4d0160..41f9f63 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -12,6 +12,7 @@ SYNOPSIS
 'git-submodule' [--quiet] add [-b branch] [--] <repository> [<path>]
 'git-submodule' [--quiet] status [--cached] [--] [<path>...]
 'git-submodule' [--quiet] [init|update] [--] [<path>...]
+'git-submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]
 
 
 COMMANDS
@@ -47,6 +48,11 @@ update::
 	checkout the commit specified in the index of the containing repository.
 	This will make the submodules HEAD be detached.
 
+summary::
+	Show commit summary between the given commit (defaults to HEAD) and
+	working tree/index. For a submodule in question, a series of commits
+	in the submodule between the given super project commit and the
+	index or working tree (switched by --cached) are shown.
 
 OPTIONS
 -------
@@ -57,9 +63,16 @@ OPTIONS
 	Branch of repository to add as submodule.
 
 --cached::
-	Display the SHA-1 stored in the index, not the SHA-1 of the currently
-	checked out submodule commit. This option is only valid for the
-	status command.
+	This option is only valid for status and summary commands.  These
+	commands typically use the commit found in the submodule HEAD, but
+	with this option, the commit stored in the index is used instead.
+
+-n, --summary-limit::
+	This option is only valid for the summary command.
+	Limit the summary size (number of commits shown in total).
+	Giving 0 will disable the summary; a negative number means unlimted
+	(the default). This limit only applies to modified submodules. The
+	size is always limited to 1 for added/deleted/typechanged submodules.
 
 <path>::
 	Path to submodule(s). When specified this will restrict the command
-- 
1.5.4.3.347.g5314c

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v5 5/5] git-submodule summary: test
  2008-03-11 13:52       ` [PATCH v5 4/5] git-submodule summary: documentation Ping Yin
@ 2008-03-11 13:52         ` Ping Yin
  0 siblings, 0 replies; 14+ messages in thread
From: Ping Yin @ 2008-03-11 13:52 UTC (permalink / raw)
  To: gitster; +Cc: git, Ping Yin

Signed-off-by: Ping Yin <pkufranky@gmail.com>
---
 t/t7401-submodule-summary.sh |  195 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 195 insertions(+), 0 deletions(-)
 create mode 100755 t/t7401-submodule-summary.sh

diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh
new file mode 100755
index 0000000..0f3c42a
--- /dev/null
+++ b/t/t7401-submodule-summary.sh
@@ -0,0 +1,195 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Ping Yin
+#
+
+test_description='Summary support for submodules
+
+This test tries to verify the sanity of summary subcommand of git-submodule.
+'
+
+. ./test-lib.sh
+
+add_file () {
+	sm=$1
+	shift
+	owd=$(pwd)
+	cd "$sm"
+	for name; do
+		echo "$name" > "$name" &&
+		git add "$name" &&
+		test_tick &&
+		git commit -m "Add $name"
+	done >/dev/null
+	git rev-parse --verify HEAD | cut -c1-7
+	cd "$owd"
+}
+commit_file () {
+	test_tick &&
+	git commit "$@" -m "Commit $*" >/dev/null
+}
+
+test_create_repo sm1 &&
+add_file . foo
+
+head1=$(add_file sm1 foo1 foo2)
+
+test_expect_success 'added submodule' "
+	git add sm1 &&
+	git submodule summary >actual &&
+	diff actual - <<-EOF
+* sm1 0000000...$head1 (2):
+  > Add foo2
+
+EOF
+"
+
+commit_file sm1 &&
+head2=$(add_file sm1 foo3)
+
+test_expect_success 'modified submodule(forward)' "
+	git submodule summary >actual &&
+	diff actual - <<-EOF
+* sm1 $head1...$head2 (1):
+  > Add foo3
+
+EOF
+"
+
+commit_file sm1 &&
+cd sm1 &&
+git reset --hard HEAD~2 >/dev/null &&
+head3=$(git rev-parse --verify HEAD | cut -c1-7) &&
+cd ..
+
+test_expect_success 'modified submodule(backward)' "
+    git submodule summary >actual &&
+    diff actual - <<-EOF
+* sm1 $head2...$head3 (2):
+  < Add foo3
+  < Add foo2
+
+EOF
+"
+
+head4=$(add_file sm1 foo4 foo5) &&
+head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD)
+test_expect_success 'modified submodule(backward and forward)' "
+    git submodule summary >actual &&
+    diff actual - <<-EOF
+* sm1 $head2...$head4 (4):
+  > Add foo5
+  > Add foo4
+  < Add foo3
+  < Add foo2
+
+EOF
+"
+
+test_expect_success '--summary-limit' "
+    git submodule summary -n 3 >actual &&
+    diff actual - <<-EOF
+* sm1 $head2...$head4 (4):
+  > Add foo5
+  > Add foo4
+  < Add foo3
+
+EOF
+"
+
+commit_file sm1 &&
+mv sm1 sm1-bak &&
+echo sm1 >sm1 &&
+head5=$(git hash-object sm1 | cut -c1-7) &&
+git add sm1 &&
+rm -f sm1 &&
+mv sm1-bak sm1
+
+test_expect_success 'typechanged submodule(submodule->blob), --cached' "
+    git submodule summary --cached >actual &&
+    diff actual - <<-EOF
+* sm1 $head4(submodule)->$head5(blob) (3):
+  < Add foo5
+
+EOF
+"
+
+rm -rf sm1 &&
+git checkout-index sm1
+test_expect_success 'typechanged submodule(submodule->blob)' "
+    git submodule summary >actual &&
+    diff actual - <<-EOF
+* sm1 $head4(submodule)->$head5(blob):
+
+EOF
+"
+
+rm -f sm1 &&
+test_create_repo sm1 &&
+head6=$(add_file sm1 foo6 foo7)
+test_expect_success 'nonexistent commit' "
+    git submodule summary >actual &&
+    diff actual - <<-EOF
+* sm1 $head4...$head6:
+  Warn: sm1 doesn't contain commit $head4_full
+
+EOF
+"
+
+commit_file
+test_expect_success 'typechanged submodule(blob->submodule)' "
+    git submodule summary >actual &&
+    diff actual - <<-EOF
+* sm1 $head5(blob)->$head6(submodule) (2):
+  > Add foo7
+
+EOF
+"
+
+commit_file sm1 &&
+rm -rf sm1
+test_expect_success 'deleted submodule' "
+    git submodule summary >actual &&
+    diff actual - <<-EOF
+* sm1 $head6...0000000:
+
+EOF
+"
+
+test_create_repo sm2 &&
+head7=$(add_file sm2 foo8 foo9) &&
+git add sm2
+
+test_expect_success 'multiple submodules' "
+    git submodule summary >actual &&
+    diff actual - <<-EOF
+* sm1 $head6...0000000:
+
+* sm2 0000000...$head7 (2):
+  > Add foo9
+
+EOF
+"
+
+test_expect_success 'path filter' "
+    git submodule summary sm2 >actual &&
+    diff actual - <<-EOF
+* sm2 0000000...$head7 (2):
+  > Add foo9
+
+EOF
+"
+
+commit_file sm2
+test_expect_success 'given commit' "
+    git submodule summary HEAD^ >actual &&
+    diff actual - <<-EOF
+* sm1 $head6...0000000:
+
+* sm2 0000000...$head7 (2):
+  > Add foo9
+
+EOF
+"
+
+test_done
-- 
1.5.4.3.347.g5314c

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v5 2/5] git-submodule summary: show commit summary
  2008-03-11 13:52   ` [PATCH v5 2/5] git-submodule summary: show commit summary Ping Yin
  2008-03-11 13:52     ` [PATCH v5 3/5] git-submodule summary: limit summary size Ping Yin
@ 2008-03-12  2:08     ` Ping Yin
  2008-03-12  2:12       ` Junio C Hamano
  2008-03-12  4:12     ` Junio C Hamano
  2008-03-12  8:30     ` [PATCH] git-submodule summary: fix that some "wc" flavors produce leading spaces Johannes Sixt
  3 siblings, 1 reply; 14+ messages in thread
From: Ping Yin @ 2008-03-12  2:08 UTC (permalink / raw)
  To: gitster; +Cc: git, Ping Yin

On Tue, Mar 11, 2008 at 9:52 PM, Ping Yin <pkufranky@gmail.com> wrote:
> This patch does the hard work to show submodule commit summary.
>

> +                       case "$mod_dst" in
>  +                               160000)
>  +                               sha1_dst=$(GIT_DIR="$name/.git" git rev-parse HEAD)
>  +                               ;;
>  +                               100644)
>  +                               sha1_dst=$(git hash-object $name)
>  +                               ;;
>  +                       esac

please s/100644/100*/



-- 
Ping Yin

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v5 2/5] git-submodule summary: show commit summary
  2008-03-12  2:08     ` [PATCH v5 2/5] git-submodule summary: show commit summary Ping Yin
@ 2008-03-12  2:12       ` Junio C Hamano
  2008-03-12  2:30         ` Ping Yin
  0 siblings, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2008-03-12  2:12 UTC (permalink / raw)
  To: Ping Yin; +Cc: git

"Ping Yin" <pkufranky@gmail.com> writes:

> On Tue, Mar 11, 2008 at 9:52 PM, Ping Yin <pkufranky@gmail.com> wrote:
>> This patch does the hard work to show submodule commit summary.
>>
>
>> +                       case "$mod_dst" in
>>  +                               160000)
>>  +                               sha1_dst=$(GIT_DIR="$name/.git" git rev-parse HEAD)
>>  +                               ;;
>>  +                               100644)
>>  +                               sha1_dst=$(git hash-object $name)
>>  +                               ;;
>>  +                       esac
>
> please s/100644/100*/

How would that help symbolic links?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v5 2/5] git-submodule summary: show commit summary
  2008-03-12  2:12       ` Junio C Hamano
@ 2008-03-12  2:30         ` Ping Yin
  0 siblings, 0 replies; 14+ messages in thread
From: Ping Yin @ 2008-03-12  2:30 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Wed, Mar 12, 2008 at 10:12 AM, Junio C Hamano <gitster@pobox.com> wrote:
>
> "Ping Yin" <pkufranky@gmail.com> writes:
>
>  > On Tue, Mar 11, 2008 at 9:52 PM, Ping Yin <pkufranky@gmail.com> wrote:
>  >> This patch does the hard work to show submodule commit summary.
>  >>
>  >
>  >> +                       case "$mod_dst" in
>  >>  +                               160000)
>  >>  +                               sha1_dst=$(GIT_DIR="$name/.git" git rev-parse HEAD)
>  >>  +                               ;;
>  >>  +                               100644)
>  >>  +                               sha1_dst=$(git hash-object $name)
>  >>  +                               ;;
>  >>  +                       esac
>  >
>  > please s/100644/100*/
>
>  How would that help symbolic links?
>

I am not familiar with git core code, could you tell me where to find
all file mod for various types?



-- 
Ping Yin

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v5 2/5] git-submodule summary: show commit summary
  2008-03-11 13:52   ` [PATCH v5 2/5] git-submodule summary: show commit summary Ping Yin
  2008-03-11 13:52     ` [PATCH v5 3/5] git-submodule summary: limit summary size Ping Yin
  2008-03-12  2:08     ` [PATCH v5 2/5] git-submodule summary: show commit summary Ping Yin
@ 2008-03-12  4:12     ` Junio C Hamano
  2008-03-12  4:28       ` Ping Yin
  2008-03-12  8:30     ` [PATCH] git-submodule summary: fix that some "wc" flavors produce leading spaces Johannes Sixt
  3 siblings, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2008-03-12  4:12 UTC (permalink / raw)
  To: Ping Yin; +Cc: git

I've squashed a moral equivalent of the following into this patch (I also
re-indented "case...esac").  Will perhaps queue in 'next' and after that
we can incrementally improve on it.

Thanks.

 git-submodule.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index a0ea913..ea23b45 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -400,7 +400,7 @@ cmd_summary() {
 				160000)
 				sha1_dst=$(GIT_DIR="$name/.git" git rev-parse HEAD)
 				;;
-				100644)
+				100644 | 100755 | 120000)
 				sha1_dst=$(git hash-object $name)
 				;;
 			esac

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v5 2/5] git-submodule summary: show commit summary
  2008-03-12  4:12     ` Junio C Hamano
@ 2008-03-12  4:28       ` Ping Yin
  2008-03-12  6:15         ` Junio C Hamano
  0 siblings, 1 reply; 14+ messages in thread
From: Ping Yin @ 2008-03-12  4:28 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Wed, Mar 12, 2008 at 12:12 PM, Junio C Hamano <gitster@pobox.com> wrote:
> --- a/git-submodule.sh
>  +++ b/git-submodule.sh
>  @@ -400,7 +400,7 @@ cmd_summary() {
>
>                                 160000)
>                                 sha1_dst=$(GIT_DIR="$name/.git" git rev-parse HEAD)
>                                 ;;
>  -                               100644)
>  +                               100644 | 100755 | 120000)
>
Are 644 and 755 file permission bit? If it is, how about the other
cases (655, 744 and so on)?



-- 
Ping Yin

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v5 2/5] git-submodule summary: show commit summary
  2008-03-12  4:28       ` Ping Yin
@ 2008-03-12  6:15         ` Junio C Hamano
  2008-03-12  8:27           ` Ping Yin
  0 siblings, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2008-03-12  6:15 UTC (permalink / raw)
  To: Ping Yin; +Cc: Junio C Hamano, git

"Ping Yin" <pkufranky@gmail.com> writes:

> On Wed, Mar 12, 2008 at 12:12 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> --- a/git-submodule.sh
>>  +++ b/git-submodule.sh
>>  @@ -400,7 +400,7 @@ cmd_summary() {
>>
>>                                 160000)
>>                                 sha1_dst=$(GIT_DIR="$name/.git" git rev-parse HEAD)
>>                                 ;;
>>  -                               100644)
>>  +                               100644 | 100755 | 120000)
>>
> Are 644 and 755 file permission bit? If it is, how about the other
> cases (655, 744 and so on)?

They never appear, as git tracks only one executable bit, so mode bits for
regular file blobs are canonicalized to either 100755 or 100644.

Don't you ever see 000000 mode bits here?  There is no case arm for that
in the code.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v5 2/5] git-submodule summary: show commit summary
  2008-03-12  6:15         ` Junio C Hamano
@ 2008-03-12  8:27           ` Ping Yin
  0 siblings, 0 replies; 14+ messages in thread
From: Ping Yin @ 2008-03-12  8:27 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Wed, Mar 12, 2008 at 2:15 PM, Junio C Hamano <gitster@pobox.com> wrote:
>
> "Ping Yin" <pkufranky@gmail.com> writes:
>

>
>  They never appear, as git tracks only one executable bit, so mode bits for
>  regular file blobs are canonicalized to either 100755 or 100644.
>
>  Don't you ever see 000000 mode bits here?  There is no case arm for that
>  in the code.
>
000000 mode will appear for added or deleted or unmerged modules. The
deleted/added case has already been handled. However, the unmerged
case is not handled yet which will appear at very low frequency. So
this case can be delayed to handle.


-- 
Ping Yin

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] git-submodule summary: fix that some "wc" flavors produce leading spaces
  2008-03-11 13:52   ` [PATCH v5 2/5] git-submodule summary: show commit summary Ping Yin
                       ` (2 preceding siblings ...)
  2008-03-12  4:12     ` Junio C Hamano
@ 2008-03-12  8:30     ` Johannes Sixt
  3 siblings, 0 replies; 14+ messages in thread
From: Johannes Sixt @ 2008-03-12  8:30 UTC (permalink / raw)
  To: Ping Yin; +Cc: gitster, git

From: Johannes Sixt <johannes.sixt@telecom.at>

We print the number of commits in parentheses, but without this change
we would get an oddly looking line like this:

    * sm1 4c8d358...41fbea9 (      4):

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---

	How portable is this?

	-- Hannes

 git-submodule.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index f7a6ee2..221a4c8 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -462,7 +462,7 @@ cmd_summary() {
 			GIT_DIR="$name/.git" \
 			git log --pretty=oneline --first-parent $range | wc -l
 			)
-			total_commits=" ($total_commits)"
+			total_commits=" ($(($total_commits + 0)))"
 			;;
 		esac

-- 
1.5.4.4.1329.g2c612

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2008-03-12  8:31 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-11 13:52 [PATCH v5 0/5] git-submodule summary Ping Yin
2008-03-11 13:52 ` [PATCH v5 1/5] git-submodule summary: code framework Ping Yin
2008-03-11 13:52   ` [PATCH v5 2/5] git-submodule summary: show commit summary Ping Yin
2008-03-11 13:52     ` [PATCH v5 3/5] git-submodule summary: limit summary size Ping Yin
2008-03-11 13:52       ` [PATCH v5 4/5] git-submodule summary: documentation Ping Yin
2008-03-11 13:52         ` [PATCH v5 5/5] git-submodule summary: test Ping Yin
2008-03-12  2:08     ` [PATCH v5 2/5] git-submodule summary: show commit summary Ping Yin
2008-03-12  2:12       ` Junio C Hamano
2008-03-12  2:30         ` Ping Yin
2008-03-12  4:12     ` Junio C Hamano
2008-03-12  4:28       ` Ping Yin
2008-03-12  6:15         ` Junio C Hamano
2008-03-12  8:27           ` Ping Yin
2008-03-12  8:30     ` [PATCH] git-submodule summary: fix that some "wc" flavors produce leading spaces Johannes Sixt

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