{"thread":{"id":"12643","subject":"[PATCH] git-submodule summary: --for-status option","startedAt":"2008-03-12T02:23:47Z","lastAt":"2008-03-12T02:23:47Z","messageCount":1,"participants":["Ping Yin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"71768","messageId":"1205288627-20499-1-git-send-email-pkufranky@gmail.com","threadId":"12643","inReplyTo":null,"subject":"[PATCH] git-submodule summary: --for-status option","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-03-12T02:23:47Z","receivedAt":"2008-03-12T02:23:47Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"The --for-status option is mainly used by builtin-status/commit.\nIt adds 'Modified submodules:' line at top and  '# ' prefix to all\nfollowing lines.\n---\n git-submodule.sh             |   17 ++++++++++++++++-\n t/t7401-submodule-summary.sh |   13 +++++++++++++\n 2 files changed, 29 insertions(+), 1 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex c47b364..da9d5c8 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -342,6 +342,7 @@ set_name_rev () {\n #\n cmd_summary() {\n \tsummary_limit=-1\n+\tfor_status=\n \n \t# parse $args after \"submodule ... summary\".\n \twhile test $# -ne 0\n@@ -350,6 +351,9 @@ cmd_summary() {\n \t\t--cached)\n \t\t\tcached=\"$1\"\n \t\t\t;;\n+\t\t--for-status)\n+\t\t\tfor_status=\"$1\"\n+\t\t\t;;\n \t\t-n|--summary-limit)\n \t\t\tif summary_limit=$(($2 + 0)) 2>/dev/null && test \"$summary_limit\" = \"$2\"\n \t\t\tthen\n@@ -398,6 +402,12 @@ cmd_summary() {\n \t)\n \n \ttest -n \"$modules\" &&\n+\tif test -n \"$for_status\"; then\n+\t\techo \"# Modified submodules:\"\n+\t\techo \"#\"\n+\telse\n+\t\ttrue\n+\tfi &&\n \tgit diff-index $cached --raw $head -- $modules |\n \tgrep -e '^:160000' -e '^:[0-7]* 160000' |\n \tcut -c2- |\n@@ -493,7 +503,12 @@ cmd_summary() {\n \t\t\techo\n \t\tfi\n \t\techo\n-\tdone\n+\tdone |\n+\tif test -n \"$for_status\"; then\n+\t\tsed -e \"s|^|# |\" -e 's|^# $|#|'\n+\telse\n+\t\tcat\n+\tfi\n }\n #\n # List all submodules, prefixed with:\ndiff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh\nindex 0f3c42a..1dbb39d 100755\n--- a/t/t7401-submodule-summary.sh\n+++ b/t/t7401-submodule-summary.sh\n@@ -192,4 +192,17 @@ test_expect_success 'given commit' \"\n EOF\n \"\n \n+test_expect_success '--for-status' \"\n+    git submodule summary --for-status HEAD^ >actual &&\n+    diff actual - <<-EOF\n+# Modified submodules:\n+#\n+# * sm1 $head6...0000000:\n+#\n+# * sm2 0000000...$head7 (2):\n+#   > Add foo9\n+#\n+EOF\n+\"\n+\n test_done\n-- \n1.5.4.3.347.g5314c\n"}]}