summaryrefslogtreecommitdiff
path: root/wt-status.c
diff options
context:
space:
mode:
authorJens Lehmann <Jens.Lehmann@web.de>2014-04-05 18:59:03 +0200
committerJunio C Hamano <gitster@pobox.com>2014-04-07 10:32:20 -0700
commit1d2f393ac9bfb4c20f14d6ead7bb4c56e766ab77 (patch)
treebd4ff693f4c0c0983a7689597b4065d14bee07d0 /wt-status.c
parent5f95c9f850b19b368c43ae399cc831b17a26a5ac (diff)
downloadgit-1d2f393ac9bfb4c20f14d6ead7bb4c56e766ab77.tar.gz
status/commit: show staged submodules regardless of ignore config
Currently setting submodule.<name>.ignore and/or diff.ignoreSubmodules to "all" suppresses all output of submodule changes for the diff family, status and commit. For status and commit this is really confusing, as it even when the user chooses to record a new commit for an ignored submodule by adding it manually this change won't show up under the to-be-committed changes. To add insult to injury, a later "git commit" will error out with "nothing to commit" when only ignored submodules are staged. Fix that by making wt_status always print staged submodule changes, no matter what ignore settings are configured. The only exception is when the user explicitly uses the "--ignore-submodules=all" command line option, in that case the submodule output is still suppressed. This also makes "git commit" work again when only modifications of ignored submodules are staged, as that command uses the "commitable" member of the wt_status struct to determine if staged changes are present. But this only happens when the commit command uses the wt_status* functions to produce status output for human consumption (when forking an editor or with --dry-run), in all other cases (e.g. when run in a script with '-m') another code path is taken which uses index_differs_from() to determine if any changes are staged which still ignores submodules according to their configuration. This will be fixed in a follow-up commit. Change t7508 to reflect this new behavior and add three new tests to show that a single staged submodule configured to be ignored will be committed when the status output is generated and won't be if not. Also update the documentation of the ignore config options accordingly. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
-rw-r--r--wt-status.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/wt-status.c b/wt-status.c
index 4e55810059..ccdf02fc8a 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -486,9 +486,19 @@ static void wt_status_collect_changes_index(struct wt_status *s)
opt.def = s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference;
setup_revisions(0, NULL, &rev, &opt);
+ DIFF_OPT_SET(&rev.diffopt, OVERRIDE_SUBMODULE_CONFIG);
if (s->ignore_submodule_arg) {
- DIFF_OPT_SET(&rev.diffopt, OVERRIDE_SUBMODULE_CONFIG);
handle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);
+ } else {
+ /*
+ * Unless the user did explicitly request a submodule ignore
+ * mode by passing a command line option we do not ignore any
+ * changed submodule SHA-1s when comparing index and HEAD, no
+ * matter what is configured. Otherwise the user won't be
+ * shown any submodules she manually added (and which are
+ * staged to be committed), which would be really confusing.
+ */
+ handle_ignore_submodules_arg(&rev.diffopt, "dirty");
}
rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;