Jens Lehmann <Jens.Lehmann@xxxxxx> writes: > I was planning a cleanup patch anyway to get rid of the test for > DIFF_FORMAT_PATCH by setting DIFF_OPT_DIRTY_SUBMODULES at the appropriate > call sites and then only test for DIFF_OPT_DIRTY_SUBMODULES here. Putting > the duplicated code into a new function is a good idea, so I'll do that > in the cleanup patch, o.k.? Sounds sensible, thanks. > diff --git a/wt-status.c b/wt-status.c > index 5807fc3..c028afd 100644 > --- a/wt-status.c > +++ b/wt-status.c > @@ -153,6 +157,21 @@ static void wt_status_print_change_data(struct wt_status *s, > one_name = d->head_path; > break; > case WT_STATUS_CHANGED: > + if (d->new_submodule_commits || d->dirty_submodule) { > + const char *sep = ""; > + strbuf_addstr(&extra, " ("); > + if (d->new_submodule_commits) { > + strbuf_addf(&extra, "new commits"); > + sep = ", "; > + } > + if (d->dirty_submodule & DIRTY_SUBMODULE_MODIFIED) { > + strbuf_addf(&extra, "%smodified content", sep); > + sep = ", "; > + } > + if (d->dirty_submodule & DIRTY_SUBMODULE_UNTRACKED) > + strbuf_addf(&extra, "%suntracked content",sep); > + strbuf_addch(&extra, ')'); > + } This may be easier to read and maintain if you always added ", " at each step, and then backed up by two places before closing the thing with ')', without doing the sep = ", " in the middle. > @@ -189,6 +208,10 @@ static void wt_status_print_change_data(struct wt_status *s, > default: > die("bug: unhandled diff status %c", status); > } > + if (extra.len) { > + color_fprintf(s->fp, color(WT_STATUS_HEADER, s), extra.buf); > + strbuf_release(&extra); > + } This needs to be touched up as: color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "%s", extra.buf); just in case we may start adding some more free strings in extra.buf later. Also we tell the compiler that the third parameter to the function quacks like printf format string, and get a warning for passing an arbitrary string extra.buf to it. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html