4
#
5
# Copyright (c) 2007 Lars Hjemli
6
7
-USAGE='[--quiet] [--cached] [add <repo> [-b branch]|status|init|update] [--] [<path>...]'
7
+USAGE='[--quiet] [--cached] [add <repo> [-b branch]|status|init|update|summary [<commit>]] [--] [<path>...]'
8
OPTIONS_SPEC=
9
. git-sh-setup
10
require_work_tree
320
) )
321
test -z "$revname" || revname=" ($revname)"
322
}
323
+#
324
+# Show commit summary for submodules in index or working tree
325
+#
326
+# If '--cached' is given, show summary between index and given commit,
327
+# or between working tree and given commit
328
+#
329
+# $@ = [commit (default 'HEAD'),] requested paths (default all)
330
+#
331
+cmd_summary() {
332
+ # parse $args after "submodule ... summary".
333
+ while test $# -ne 0
334
+ do
335
+ case "$1" in
336
+ --cached)
337
+ cached="$1"
338
+ ;;
339
+ --)
340
+ shift
341
+ break
342
+ ;;
343
+ -*)
344
+ usage
345
+ ;;
346
+ *)
347
+ break
348
+ ;;
349
+ esac
350
+ shift
351
+ done
352
353
+ if rev=$(git rev-parse --verify "$1^0" 2>/dev/null)
354
+ then
355
+ head=$rev
356
+ shift
357
+ else
358
+ head=HEAD
359
+ fi
360
+
361
+ cd_to_toplevel
362
+ # Get modified modules cared by user
363
+ modules=$(git diff-index $cached --raw $head -- "$@" |
364
+ grep -e '^:160000' -e '^:[0-7]* 160000' |
365
+ while read mod_src mod_dst sha1_src sha1_dst status name
366
+ do
367
+ # Always show modules deleted or type-changed (blob<->module)
368
+ test $status = D -o $status = T && echo "$name" && continue
369
+ # Also show added or modified modules which are checked out
370
+ GIT_DIR="$name/.git" git-rev-parse --git-dir >/dev/null 2>&1 &&
371
+ echo "$name"
372
+ done
373
+ )
374
+}
375
#
376
# List all submodules, prefixed with:
377
# - submodule not initialized
442
while test $# != 0 && test -z "$command"
443
do
444
case "$1" in
394
- add | init | update | status)
445
+ add | init | update | status | summary)
446
command=$1
447
;;
448
-q|--quiet)
457
branch="$2"; shift
458
;;
459
--cached)
409
- cached=1
460
+ cached="$1"
461
;;
462
--)
463
break
481
usage
482
fi
483
433
-# "--cached" is accepted only by "status"
434
-if test -n "$cached" && test "$command" != status
484
+# "--cached" is accepted only by "status" and "summary"
485
+if test -n "$cached" && test "$command" != status -a "$command" != summary
486
then
487
usage
488
fi