@@ -255,7 +255,46 @@ set_name_rev () {
) )
test -z "$revname" || revname=" ($revname)"
}
+#
+# Show commit summary for submodules in index or working tree relative to the given commit
+#
+# If '--cached' is given, show summary between index and given commit,
+# or between working tree and given commit
+#
+# @ = [head counting commits from (default 'HEAD'),] requested paths (default to all)
+#
+modules_summary()
+{
+ cache_option=${cached:+--cached}
+
+ if rev=$(git rev-parse --verify "$1^0" 2>/dev/null)
+ then
+ head=$rev
+ shift
+ else
+ head=HEAD
+ fi
+ cwd=$(pwd)
+ cd_to_toplevel
+
+ # get modified modules which have been checked out (i.e. cared by user)
+ modules=$(git diff $cache_option --raw $head -- "$@" |
+ grep '^:160000\|:000000 160000' |
+ while read mod_src mod_dst sha1_src sha1_dst status name
+ do
+ test $status=D && echo "$name" && continue
+ GIT_DIR="$name/.git" git-rev-parse --git-dir >/dev/null 2>&1 &&
+ echo "$name"
+ done
+ )
+
+ # TODO: quote module names containing space or tab
+ test -n "$modules" &&
+ echo "# Submodules modified: "$modules &&
+ echo "#"
+ cd "$cwd"
+}
#
# List all submodules, prefixed with:
# - submodule not initialized@@ -345,17 +387,20 @@ case "$add,$branch" in
;;
esac
-case "$add,$init,$update,$status,$cached" in
-1,,,,)
+case "$add,$init,$update,$summary,$status,$cached" in
+1,,,,,)
module_add "$@"
;;
-,1,,,)
+,1,,,,)
modules_init "$@"
;;
-,,1,,)
+,,1,,,)
modules_update "$@"
;;
-,,,*,*)
+,,,1,,*)
+ modules_summary "$@"
+ ;;
+,,,,*,*)
modules_list "$@"
;;
*)