Skip to content

Commit

Permalink
git status: Show uncommitted submodule changes too when enabled
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jens Lehmann authored and Junio C Hamano committed Jan 17, 2010
1 parent 8e08b41 commit f17a5d3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
6 changes: 5 additions & 1 deletion git-submodule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,11 @@ cmd_summary() {
echo
done |
if test -n "$for_status"; then
echo "# Modified submodules:"
if [ -n "$files" ]; then
echo "# Submodules changed but not updated:"
else
echo "# Submodule changes to be committed:"
fi
echo "#"
sed -e 's|^|# |' -e 's|^# $|#|'
else
Expand Down
2 changes: 1 addition & 1 deletion t/t7401-submodule-summary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ EOF
test_expect_success '--for-status' "
git submodule summary --for-status HEAD^ >actual &&
test_cmp actual - <<EOF
# Modified submodules:
# Submodule changes to be committed:
#
# * sm1 $head6...0000000:
#
Expand Down
4 changes: 2 additions & 2 deletions t/t7508-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ cat >expect <<EOF
#
# modified: dir1/modified
#
# Modified submodules:
# Submodule changes to be committed:
#
# * sm 0000000...$head (1):
# > Add foo
Expand Down Expand Up @@ -672,7 +672,7 @@ cat >expect <<EOF
#
# modified: dir1/modified
#
# Modified submodules:
# Submodule changes to be committed:
#
# * sm 0000000...$head (1):
# > Add foo
Expand Down
12 changes: 7 additions & 5 deletions wt-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ static void wt_status_print_changed(struct wt_status *s)
wt_status_print_trailer(s);
}

static void wt_status_print_submodule_summary(struct wt_status *s)
static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitted)
{
struct child_process sm_summary;
char summary_limit[64];
Expand All @@ -468,11 +468,11 @@ static void wt_status_print_submodule_summary(struct wt_status *s)
const char *argv[] = {
"submodule",
"summary",
"--cached",
uncommitted ? "--files" : "--cached",
"--for-status",
"--summary-limit",
summary_limit,
s->amend ? "HEAD^" : "HEAD",
uncommitted ? NULL : (s->amend ? "HEAD^" : "HEAD"),
NULL
};

Expand Down Expand Up @@ -580,8 +580,10 @@ void wt_status_print(struct wt_status *s)
wt_status_print_updated(s);
wt_status_print_unmerged(s);
wt_status_print_changed(s);
if (s->submodule_summary)
wt_status_print_submodule_summary(s);
if (s->submodule_summary) {
wt_status_print_submodule_summary(s, 0); /* staged */
wt_status_print_submodule_summary(s, 1); /* unstaged */
}
if (s->show_untracked_files)
wt_status_print_untracked(s);
else if (s->commitable)
Expand Down

0 comments on commit f17a5d3

Please sign in to comment.