@matheusbsbs / matheus-bagliano / commits / f17a5d3494
Fork 0

git status: Show uncommitted submodule changes too when enabled

When the configuration variable status.submodulesummary is not 0 or false, "git status" shows the submodule summary of the staged submodule commits. But it did not show the summary of those commits not yet staged in the supermodule, making it hard to see what will not be committed. The output of "submodule summary --for-status" has been changed from "# Modified submodules:" to "# Submodule changes to be committed:" for the already staged changes. "# Submodules changed but not updated:" has been added for changes that will not be committed. This is much clearer and consistent with the output for regular files. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jens Lehmann committed Jan 17, 2010 at 20:42 UTC f17a5d34948363087db94a1cb2c3c715c1ada2d8
4 files changed +15 -9
git-submodule.sh
+5 -1
@@ -688,7 +688,11 @@ cmd_summary() {
688 echo
689 done |
690 if test -n "$for_status"; then
691 - echo "# Modified submodules:"
691 + if [ -n "$files" ]; then
692 + echo "# Submodules changed but not updated:"
693 + else
694 + echo "# Submodule changes to be committed:"
695 + fi
696 echo "#"
697 sed -e 's|^|# |' -e 's|^# $|#|'
698 else
t/t7401-submodule-summary.sh
+1 -1
@@ -213,7 +213,7 @@ EOF
213 test_expect_success '--for-status' "
214 git submodule summary --for-status HEAD^ >actual &&
215 test_cmp actual - <<EOF
216 -# Modified submodules:
216 +# Submodule changes to be committed:
217 #
218 # * sm1 $head6...0000000:
219 #
t/t7508-status.sh
+2 -2
@@ -579,7 +579,7 @@ cat >expect <<EOF
579 #
580 # modified: dir1/modified
581 #
582 -# Modified submodules:
582 +# Submodule changes to be committed:
583 #
584 # * sm 0000000...$head (1):
585 # > Add foo
@@ -672,7 +672,7 @@ cat >expect <<EOF
672 #
673 # modified: dir1/modified
674 #
675 -# Modified submodules:
675 +# Submodule changes to be committed:
676 #
677 # * sm 0000000...$head (1):
678 # > Add foo
wt-status.c
+7 -5
@@ -459,7 +459,7 @@ static void wt_status_print_changed(struct wt_status *s)
459 wt_status_print_trailer(s);
460 }
461
462 -static void wt_status_print_submodule_summary(struct wt_status *s)
462 +static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitted)
463 {
464 struct child_process sm_summary;
465 char summary_limit[64];
@@ -468,11 +468,11 @@ static void wt_status_print_submodule_summary(struct wt_status *s)
468 const char *argv[] = {
469 "submodule",
470 "summary",
471 - "--cached",
471 + uncommitted ? "--files" : "--cached",
472 "--for-status",
473 "--summary-limit",
474 summary_limit,
475 - s->amend ? "HEAD^" : "HEAD",
475 + uncommitted ? NULL : (s->amend ? "HEAD^" : "HEAD"),
476 NULL
477 };
478
@@ -580,8 +580,10 @@ void wt_status_print(struct wt_status *s)
580 wt_status_print_updated(s);
581 wt_status_print_unmerged(s);
582 wt_status_print_changed(s);
583 - if (s->submodule_summary)
584 - wt_status_print_submodule_summary(s);
583 + if (s->submodule_summary) {
584 + wt_status_print_submodule_summary(s, 0); /* staged */
585 + wt_status_print_submodule_summary(s, 1); /* unstaged */
586 + }
587 if (s->show_untracked_files)
588 wt_status_print_untracked(s);
589 else if (s->commitable)