While we already have a porcelain2 layer for git-status, that is accurate for submodules, users still like the way they are are used to of 'status -s'.
As a submodule has more state than a file potentially, we'll look at all cases: ------ new submodule commits / ----- modified files | / -- untracked files | | / | | | current / proposed reporting 0 0 0 " " " " 0 0 1 " M" " ?" 0 1 0 " M" " m" 0 1 1 " M" " m" 1 0 0 " M" " M" 1 0 1 " M" " M" 1 1 0 " M" " M" 1 1 1 " M" " M" So when there is no new commits in the submodule, we'd want to tell what actually happend to the submodule. The lower case 'm' indicates to the user that there is need to give a --recurse-submodules option for e.g. adding or committing these changes. The " ?" also differentiates an untracked file in the submodule from a regular untracked file. While making these changes, we need to make sure to not break porcelain level 1, which uses the same code as the short printing function. Signed-off-by: Stefan Beller <sbel...@google.com> --- Documentation/git-status.txt | 8 ++++++++ wt-status.c | 15 +++++++++++++-- wt-status.h | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt index ba873657cf..26c8d832cd 100644 --- a/Documentation/git-status.txt +++ b/Documentation/git-status.txt @@ -181,6 +181,12 @@ in which case `XY` are `!!`. ! ! ignored ------------------------------------------------- +Submodules have more state to it, such that it reports instead: + M the submodule has new commits + m the submodule has modified content + ? the submodule has untracked files + + If -b is used the short-format status is preceded by a line ## branchname tracking info @@ -210,6 +216,8 @@ field from the first filename). Third, filenames containing special characters are not specially formatted; no quoting or backslash-escaping is performed. +Any submodule changes are reported as modified `M` instead of `m` or single `?`. + Porcelain Format Version 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/wt-status.c b/wt-status.c index a52d342695..080d97f272 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1664,9 +1664,19 @@ static void wt_shortstatus_status(struct string_list_item *it, color_fprintf(s->fp, color(WT_STATUS_UPDATED, s), "%c", d->index_status); else putchar(' '); - if (d->worktree_status) + if (d->worktree_status) { + if (!s->submodule_porcelain1 && + (d->dirty_submodule || d->new_submodule_commits)) { + /* It is a submodule, and we're not in plumbing mode. */ + if (d->new_submodule_commits) + d->worktree_status = 'M'; + else if (d->dirty_submodule & DIRTY_SUBMODULE_MODIFIED) + d->worktree_status = 'm'; + else if (d->dirty_submodule & DIRTY_SUBMODULE_UNTRACKED) + d->worktree_status = '?'; + } color_fprintf(s->fp, color(WT_STATUS_CHANGED, s), "%c", d->worktree_status); - else + } else putchar(' '); putchar(' '); if (s->null_termination) { @@ -1811,6 +1821,7 @@ static void wt_porcelain_print(struct wt_status *s) s->relative_paths = 0; s->prefix = NULL; s->no_gettext = 1; + s->submodule_porcelain1 = 1; wt_shortstatus_print(s); } diff --git a/wt-status.h b/wt-status.h index 54fec77032..620e4d2ae4 100644 --- a/wt-status.h +++ b/wt-status.h @@ -70,6 +70,7 @@ struct wt_status { int display_comment_prefix; int relative_paths; int submodule_summary; + int submodule_porcelain1; int show_ignored_files; enum untracked_status_type show_untracked_files; const char *ignore_submodule_arg; -- 2.12.0.269.g1a05a5734c.dirty