From: Junio C Hamano Date: Sun, 07 Mar 2010 05:41:14 GMT Subject: Re: [PATCH] git status: Show detailed dirty status of submodules in long format Message-ID: <7vtyssadtx.fsf@alter.siamese.dyndns.org> In-Reply-To: <4B90EB19.2070300@web.de> Jens Lehmann writes: > # Changed but not updated: > # (use "git add ..." to update what will be committed) > # (use "git checkout -- ..." to discard changes in working directory) > # (commit or discard the untracked or modified content in submodules) Can we do this additional line only when there is a submodule involved in the changes? The whole point of "collect first and then print" is so that we can compute things like "has_deleted" before starting to emit any output to intelligently give an appropriate advice message, and it feels silly to say submodules to users who don't even use any submodule. I have a suspicion that the majority of users may not even know nor care what a submodule is. > I am not so proud of DIFF_FORMAT_DIRTY_SUBMODULES, the new flag i > introduced to tell run_diff_files() it should gather the information > needed even if we don't want patch output. It isn't a "format" per se, > but i couldn't come up with a better way to do this. Opinions? It indeed does sound like DIFF_OPT_* than DIFF_FORMAT_*. In any case, we probably would want to have a small helper function that encapsulates this part that appear twice: changed = ce_match_stat(ce, &st, ce_option); if (S_ISGITLINK(ce->ce_mode) && !DIFF_OPT_TST(&revs->diffopt, IGNORE_SUBMODULES) && (!changed || (revs->diffopt.output_format & DIFF_FORMAT_PATCH) || (revs->diffopt.output_format & DIFF_FORMAT_DIRTY_SUBMODULES))) { dirty_submodule = is_submodule_modified(ce->name); if (dirty_submodule) changed = 1; } to something like changed = match_stat_with_submodule(&revs->diffopt, ce, &st, ce_option, &dirty_submodule); and the implementation of match_stat_with_submodule() a bit more heavily commented so that people will know what it is for.