summaryrefslogtreecommitdiff
path: root/wt-status.c
diff options
context:
space:
mode:
authorJens Lehmann <Jens.Lehmann@web.de>2010-06-25 14:56:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-06-25 18:30:25 (GMT)
commit46a958b3daa1da336683ec82d7f321d0f51b39c8 (patch)
treecc5b3a42bdd09d3f86e6f0b5f34d1f143729b35c /wt-status.c
parent18076502cb282482f3cd75d766e1478cc3fccc29 (diff)
downloadgit-46a958b3daa1da336683ec82d7f321d0f51b39c8.zip
git-46a958b3daa1da336683ec82d7f321d0f51b39c8.tar.gz
git-46a958b3daa1da336683ec82d7f321d0f51b39c8.tar.bz2
Add the option "--ignore-submodules" to "git status"
In some use cases it is not desirable that "git status" considers submodules that only contain untracked content as dirty. This may happen e.g. when the submodule is not under the developers control and not all build generated files have been added to .gitignore by the upstream developers. Using the "untracked" parameter for the "--ignore-submodules" option disables checking for untracked content and lets git diff report them as changed only when they have new commits or modified content. Sometimes it is not wanted to have submodules show up as changed when they just contain changes to their work tree (this was the behavior before 1.7.0). An example for that are scripts which just want to check for submodule commits while ignoring any changes to the work tree. Also users having large submodules known not to change might want to use this option, as the - sometimes substantial - time it takes to scan the submodule work tree(s) is saved when using the "dirty" parameter. And if you want to ignore any changes to submodules, you can now do that by using this option without parameters or with "all" (when the config option status.submodulesummary is set, using "all" will also suppress the output of the submodule summary). A new function handle_ignore_submodules_arg() is introduced to parse this option new to "git status" in a single location, as "git diff" already knew it. 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.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/wt-status.c b/wt-status.c
index 8ca59a2..894d66f 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -9,6 +9,7 @@
#include "quote.h"
#include "run-command.h"
#include "remote.h"
+#include "submodule.h"
static char default_wt_status_colors[][COLOR_MAXLEN] = {
GIT_COLOR_NORMAL, /* WT_STATUS_HEADER */
@@ -306,6 +307,8 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)
DIFF_OPT_SET(&rev.diffopt, DIRTY_SUBMODULES);
if (!s->show_untracked_files)
DIFF_OPT_SET(&rev.diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);
+ if (s->ignore_submodule_arg)
+ handle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);
rev.diffopt.format_callback = wt_status_collect_changed_cb;
rev.diffopt.format_callback_data = s;
rev.prune_data = s->pathspec;
@@ -322,6 +325,9 @@ 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);
+ if (s->ignore_submodule_arg)
+ handle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);
+
rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
rev.diffopt.format_callback = wt_status_collect_updated_cb;
rev.diffopt.format_callback_data = s;
@@ -618,7 +624,9 @@ 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) {
+ if (s->submodule_summary &&
+ (!s->ignore_submodule_arg ||
+ strcmp(s->ignore_submodule_arg, "all"))) {
wt_status_print_submodule_summary(s, 0); /* staged */
wt_status_print_submodule_summary(s, 1); /* unstaged */
}