{"thread":{"id":"22261","subject":"[PATCH] git status: Show uncommitted submodule changes too when enabled","startedAt":"2010-01-17T19:42:31Z","lastAt":"2010-01-17T19:42:31Z","messageCount":1,"participants":["Jens Lehmann"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"131962","messageId":"4B536827.4070202@web.de","threadId":"22261","inReplyTo":null,"subject":"[PATCH] git status: Show uncommitted submodule changes too when enabled","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2010-01-17T19:42:31Z","receivedAt":"2010-01-17T19:42:31Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"When the configuration variable status.submodulesummary is not 0 or\nfalse, \"git status\" shows the submodule summary of the staged submodule\ncommits. But it did not show the summary of those commits not yet\nstaged in the supermodule, making it hard to see what will not be\ncommitted.\n\nThe output of \"submodule summary --for-status\" has been changed from\n\"# Modified submodules:\" to \"# Submodule changes to be committed:\" for\nthe already staged changes. \"# Submodules changed but not updated:\" has\nbeen added for changes that will not be committed. This is much clearer\nand consistent with the output for regular files.\n\nSigned-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n---\n\n\nWhile looking for ways to teach \"git status\" how to show dirty\nsubmodules i came across this functionality. I think the output of\nonly the staged submodule changes is not enough, submodule commits\nnot staged in the superproject should be shown too (At the time this\nfunctionality was introduced the \"--files\" option to \"git submodule\nsummary\" was missing, so there was no way to show the unstaged\nsubmodule changes back then).\n\n\n git-submodule.sh             |    6 +++++-\n t/t7401-submodule-summary.sh |    2 +-\n t/t7508-status.sh            |    4 ++--\n wt-status.c                  |   12 +++++++-----\n 4 files changed, 15 insertions(+), 9 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 77d2232..664f217 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -688,7 +688,11 @@ cmd_summary() {\n \t\techo\n \tdone |\n \tif test -n \"$for_status\"; then\n-\t\techo \"# Modified submodules:\"\n+\t\tif [ -n \"$files\" ]; then\n+\t\t\techo \"# Submodules changed but not updated:\"\n+\t\telse\n+\t\t\techo \"# Submodule changes to be committed:\"\n+\t\tfi\n \t\techo \"#\"\n \t\tsed -e 's|^|# |' -e 's|^# $|#|'\n \telse\ndiff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh\nindex 6cc16c3..d3c039f 100755\n--- a/t/t7401-submodule-summary.sh\n+++ b/t/t7401-submodule-summary.sh\n@@ -213,7 +213,7 @@ EOF\n test_expect_success '--for-status' \"\n     git submodule summary --for-status HEAD^ >actual &&\n     test_cmp actual - <<EOF\n-# Modified submodules:\n+# Submodule changes to be committed:\n #\n # * sm1 $head6...0000000:\n #\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex cf67fe3..556d0fa 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -579,7 +579,7 @@ cat >expect <<EOF\n #\n #\tmodified:   dir1/modified\n #\n-# Modified submodules:\n+# Submodule changes to be committed:\n #\n # * sm 0000000...$head (1):\n #   > Add foo\n@@ -672,7 +672,7 @@ cat >expect <<EOF\n #\n #\tmodified:   dir1/modified\n #\n-# Modified submodules:\n+# Submodule changes to be committed:\n #\n # * sm 0000000...$head (1):\n #   > Add foo\ndiff --git a/wt-status.c b/wt-status.c\nindex 65feb29..5807fc3 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -459,7 +459,7 @@ static void wt_status_print_changed(struct wt_status *s)\n \twt_status_print_trailer(s);\n }\n\n-static void wt_status_print_submodule_summary(struct wt_status *s)\n+static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitted)\n {\n \tstruct child_process sm_summary;\n \tchar summary_limit[64];\n@@ -468,11 +468,11 @@ static void wt_status_print_submodule_summary(struct wt_status *s)\n \tconst char *argv[] = {\n \t\t\"submodule\",\n \t\t\"summary\",\n-\t\t\"--cached\",\n+\t\tuncommitted ? \"--files\" : \"--cached\",\n \t\t\"--for-status\",\n \t\t\"--summary-limit\",\n \t\tsummary_limit,\n-\t\ts->amend ? \"HEAD^\" : \"HEAD\",\n+\t\tuncommitted ? NULL : (s->amend ? \"HEAD^\" : \"HEAD\"),\n \t\tNULL\n \t};\n\n@@ -580,8 +580,10 @@ void wt_status_print(struct wt_status *s)\n \twt_status_print_updated(s);\n \twt_status_print_unmerged(s);\n \twt_status_print_changed(s);\n-\tif (s->submodule_summary)\n-\t\twt_status_print_submodule_summary(s);\n+\tif (s->submodule_summary) {\n+\t\twt_status_print_submodule_summary(s, 0);  /* staged */\n+\t\twt_status_print_submodule_summary(s, 1);  /* unstaged */\n+\t}\n \tif (s->show_untracked_files)\n \t\twt_status_print_untracked(s);\n \telse if (s->commitable)\n-- \n1.6.6.327.g4c0c1.dirty\n"}]}