summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/diff.c2
-rw-r--r--diff-lib.c3
-rw-r--r--diff.h2
-rw-r--r--submodule.c16
-rw-r--r--submodule.h1
-rwxr-xr-xt/t4027-diff-submodule.sh12
-rwxr-xr-xt/t7508-status.sh6
7 files changed, 35 insertions, 7 deletions
diff --git a/builtin/diff.c b/builtin/diff.c
index adb93a9efa..c47614d7c2 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -162,6 +162,8 @@ static int builtin_diff_tree(struct rev_info *revs,
if (argc > 1)
usage(builtin_diff_usage);
+ enforce_no_complete_ignore_submodule(&revs->diffopt);
+
/*
* We saw two trees, ent0 and ent1. If ent1 is uninteresting,
* swap them.
diff --git a/diff-lib.c b/diff-lib.c
index 346cac651d..c5219cb046 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -483,6 +483,9 @@ int run_diff_index(struct rev_info *revs, int cached)
{
struct object_array_entry *ent;
+ if (cached)
+ enforce_no_complete_ignore_submodule(&revs->diffopt);
+
ent = revs->pending.objects;
if (diff_cache(revs, ent->item->sha1, ent->name, cached))
exit(128);
diff --git a/diff.h b/diff.h
index e34232501e..81561b35ed 100644
--- a/diff.h
+++ b/diff.h
@@ -64,7 +64,7 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data)
#define DIFF_OPT_FIND_COPIES_HARDER (1 << 6)
#define DIFF_OPT_FOLLOW_RENAMES (1 << 7)
#define DIFF_OPT_RENAME_EMPTY (1 << 8)
-/* (1 << 9) unused */
+#define DIFF_OPT_NO_IGNORE_SUBMODULE (1 << 9)
#define DIFF_OPT_HAS_CHANGES (1 << 10)
#define DIFF_OPT_QUICK (1 << 11)
#define DIFF_OPT_NO_INDEX (1 << 12)
diff --git a/submodule.c b/submodule.c
index 7d8b000ab4..c28a926daf 100644
--- a/submodule.c
+++ b/submodule.c
@@ -304,6 +304,16 @@ int parse_submodule_config_option(const char *var, const char *value)
return 0;
}
+void enforce_no_complete_ignore_submodule(struct diff_options *diffopt)
+{
+ DIFF_OPT_SET(diffopt, NO_IGNORE_SUBMODULE);
+ if (DIFF_OPT_TST(diffopt, OVERRIDE_SUBMODULE_CONFIG) &&
+ DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES)) {
+ DIFF_OPT_CLR(diffopt, IGNORE_SUBMODULES);
+ DIFF_OPT_SET(diffopt, IGNORE_DIRTY_SUBMODULES);
+ }
+}
+
void handle_ignore_submodules_arg(struct diff_options *diffopt,
const char *arg)
{
@@ -311,9 +321,11 @@ void handle_ignore_submodules_arg(struct diff_options *diffopt,
DIFF_OPT_CLR(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);
DIFF_OPT_CLR(diffopt, IGNORE_DIRTY_SUBMODULES);
- if (!strcmp(arg, "all"))
+ if (!strcmp(arg, "all")) {
+ if (DIFF_OPT_TST(diffopt, NO_IGNORE_SUBMODULE))
+ return;
DIFF_OPT_SET(diffopt, IGNORE_SUBMODULES);
- else if (!strcmp(arg, "untracked"))
+ } else if (!strcmp(arg, "untracked"))
DIFF_OPT_SET(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);
else if (!strcmp(arg, "dirty"))
DIFF_OPT_SET(diffopt, IGNORE_DIRTY_SUBMODULES);
diff --git a/submodule.h b/submodule.h
index c20bb6f862..e067580b57 100644
--- a/submodule.h
+++ b/submodule.h
@@ -21,6 +21,7 @@ int is_ignored_submodule(const char *path);
int submodule_config(const char *var, const char *value, void *cb);
void gitmodules_config(void);
int parse_submodule_config_option(const char *var, const char *value);
+void enforce_no_complete_ignore_submodule(struct diff_options *diffopt);
void handle_ignore_submodules_arg(struct diff_options *diffopt, const char *);
int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);
void show_submodule_summary(FILE *f, const char *path,
diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh
index 518bf9524e..bd84ea7c7f 100755
--- a/t/t4027-diff-submodule.sh
+++ b/t/t4027-diff-submodule.sh
@@ -258,7 +258,9 @@ test_expect_success 'git diff between submodule commits' '
expect_from_to >expect.body $subtip $subprev &&
test_cmp expect.body actual.body &&
git diff --ignore-submodules HEAD^..HEAD >actual &&
- ! test -s actual
+ sed -e "1,/^@@/d" actual >actual.body &&
+ expect_from_to >expect.body $subtip $subprev &&
+ test_cmp expect.body actual.body
'
test_expect_success 'git diff between submodule commits [.git/config]' '
@@ -274,7 +276,9 @@ test_expect_success 'git diff between submodule commits [.git/config]' '
test_cmp expect.body actual.body &&
git config submodule.subname.ignore all &&
git diff HEAD^..HEAD >actual &&
- ! test -s actual &&
+ sed -e "1,/^@@/d" actual >actual.body &&
+ expect_from_to >expect.body $subtip $subprev &&
+ test_cmp expect.body actual.body &&
git diff --ignore-submodules=dirty HEAD^..HEAD >actual &&
sed -e "1,/^@@/d" actual >actual.body &&
expect_from_to >expect.body $subtip $subprev &&
@@ -294,7 +298,9 @@ test_expect_success 'git diff between submodule commits [.gitmodules]' '
test_cmp expect.body actual.body &&
git config -f .gitmodules submodule.subname.ignore all &&
git diff HEAD^..HEAD >actual &&
- ! test -s actual &&
+ sed -e "1,/^@@/d" actual >actual.body &&
+ expect_from_to >expect.body $subtip $subprev &&
+ test_cmp expect.body actual.body &&
git config submodule.subname.ignore dirty &&
git config submodule.subname.path sub &&
git diff HEAD^..HEAD >actual &&
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index c987b5ed65..977295f786 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -1357,6 +1357,11 @@ test_expect_success "status (core.commentchar with two chars with submodule summ
test_expect_success "--ignore-submodules=all suppresses submodule summary" '
cat > expect << EOF &&
On branch master
+Changes to be committed:
+ (use "git reset HEAD <file>..." to unstage)
+
+ modified: sm
+
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
@@ -1374,7 +1379,6 @@ Untracked files:
output
untracked
-no changes added to commit (use "git add" and/or "git commit -a")
EOF
git status --ignore-submodules=all > output &&
test_i18ncmp expect output