Merge branch 'jl/maint-diff-ignore-submodules'
* jl/maint-diff-ignore-submodules: t4027,4041: Use test -s to test for an empty file Add optional parameters to the diff option "--ignore-submodules" git diff: rename test that had a conflicting name
This commit is contained in:
commit
e1165dd144
@ -328,8 +328,14 @@ endif::git-format-patch[]
|
|||||||
--no-ext-diff::
|
--no-ext-diff::
|
||||||
Disallow external diff drivers.
|
Disallow external diff drivers.
|
||||||
|
|
||||||
--ignore-submodules::
|
--ignore-submodules[=<when>]::
|
||||||
Ignore changes to submodules in the diff generation.
|
Ignore changes to submodules in the diff generation. <when> can be
|
||||||
|
either "untracked", "dirty" or "all", which is the default. When
|
||||||
|
"untracked" is used submodules are not considered dirty when they only
|
||||||
|
contain untracked content (but they are still scanned for modified
|
||||||
|
content). Using "dirty" ignores all changes to the work tree of submodules,
|
||||||
|
only changes to the commits stored in the superproject are shown (this was
|
||||||
|
the behavior until 1.7.0). Using "all" hides all changes to submodules.
|
||||||
|
|
||||||
--src-prefix=<prefix>::
|
--src-prefix=<prefix>::
|
||||||
Show the given source prefix instead of "a/".
|
Show the given source prefix instead of "a/".
|
||||||
|
@ -70,6 +70,7 @@ static int match_stat_with_submodule(struct diff_options *diffopt,
|
|||||||
int changed = ce_match_stat(ce, st, ce_option);
|
int changed = ce_match_stat(ce, st, ce_option);
|
||||||
if (S_ISGITLINK(ce->ce_mode)
|
if (S_ISGITLINK(ce->ce_mode)
|
||||||
&& !DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES)
|
&& !DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES)
|
||||||
|
&& !DIFF_OPT_TST(diffopt, IGNORE_DIRTY_SUBMODULES)
|
||||||
&& (!changed || DIFF_OPT_TST(diffopt, DIRTY_SUBMODULES))) {
|
&& (!changed || DIFF_OPT_TST(diffopt, DIRTY_SUBMODULES))) {
|
||||||
*dirty_submodule = is_submodule_modified(ce->name, DIFF_OPT_TST(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES));
|
*dirty_submodule = is_submodule_modified(ce->name, DIFF_OPT_TST(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES));
|
||||||
}
|
}
|
||||||
|
11
diff.c
11
diff.c
@ -3169,7 +3169,16 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
|
|||||||
DIFF_OPT_CLR(options, ALLOW_TEXTCONV);
|
DIFF_OPT_CLR(options, ALLOW_TEXTCONV);
|
||||||
else if (!strcmp(arg, "--ignore-submodules"))
|
else if (!strcmp(arg, "--ignore-submodules"))
|
||||||
DIFF_OPT_SET(options, IGNORE_SUBMODULES);
|
DIFF_OPT_SET(options, IGNORE_SUBMODULES);
|
||||||
else if (!strcmp(arg, "--submodule"))
|
else if (!prefixcmp(arg, "--ignore-submodules=")) {
|
||||||
|
if (!strcmp(arg + 20, "all"))
|
||||||
|
DIFF_OPT_SET(options, IGNORE_SUBMODULES);
|
||||||
|
else if (!strcmp(arg + 20, "untracked"))
|
||||||
|
DIFF_OPT_SET(options, IGNORE_UNTRACKED_IN_SUBMODULES);
|
||||||
|
else if (!strcmp(arg + 20, "dirty"))
|
||||||
|
DIFF_OPT_SET(options, IGNORE_DIRTY_SUBMODULES);
|
||||||
|
else
|
||||||
|
die("bad --ignore-submodules argument: %s", arg + 20);
|
||||||
|
} else if (!strcmp(arg, "--submodule"))
|
||||||
DIFF_OPT_SET(options, SUBMODULE_LOG);
|
DIFF_OPT_SET(options, SUBMODULE_LOG);
|
||||||
else if (!prefixcmp(arg, "--submodule=")) {
|
else if (!prefixcmp(arg, "--submodule=")) {
|
||||||
if (!strcmp(arg + 12, "log"))
|
if (!strcmp(arg + 12, "log"))
|
||||||
|
@ -103,7 +103,15 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)'
|
|||||||
git diff HEAD >actual &&
|
git diff HEAD >actual &&
|
||||||
sed -e "1,/^@@/d" actual >actual.body &&
|
sed -e "1,/^@@/d" actual >actual.body &&
|
||||||
expect_from_to >expect.body $subprev $subprev-dirty &&
|
expect_from_to >expect.body $subprev $subprev-dirty &&
|
||||||
test_cmp expect.body actual.body
|
test_cmp expect.body actual.body &&
|
||||||
|
git diff --ignore-submodules HEAD >actual2 &&
|
||||||
|
! test -s actual2 &&
|
||||||
|
git diff --ignore-submodules=untracked HEAD >actual3 &&
|
||||||
|
sed -e "1,/^@@/d" actual3 >actual3.body &&
|
||||||
|
expect_from_to >expect.body $subprev $subprev-dirty &&
|
||||||
|
test_cmp expect.body actual3.body &&
|
||||||
|
git diff --ignore-submodules=dirty HEAD >actual4 &&
|
||||||
|
! test -s actual4
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'git diff HEAD with dirty submodule (index, refs match)' '
|
test_expect_success 'git diff HEAD with dirty submodule (index, refs match)' '
|
||||||
@ -129,7 +137,13 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'
|
|||||||
git diff HEAD >actual &&
|
git diff HEAD >actual &&
|
||||||
sed -e "1,/^@@/d" actual >actual.body &&
|
sed -e "1,/^@@/d" actual >actual.body &&
|
||||||
expect_from_to >expect.body $subprev $subprev-dirty &&
|
expect_from_to >expect.body $subprev $subprev-dirty &&
|
||||||
test_cmp expect.body actual.body
|
test_cmp expect.body actual.body &&
|
||||||
|
git diff --ignore-submodules=all HEAD >actual2 &&
|
||||||
|
! test -s actual2 &&
|
||||||
|
git diff --ignore-submodules=untracked HEAD >actual3 &&
|
||||||
|
! test -s actual3 &&
|
||||||
|
git diff --ignore-submodules=dirty HEAD >actual4 &&
|
||||||
|
! test -s actual4
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'git diff (empty submodule dir)' '
|
test_expect_success 'git diff (empty submodule dir)' '
|
||||||
|
@ -205,6 +205,21 @@ Submodule sm1 contains untracked content
|
|||||||
EOF
|
EOF
|
||||||
"
|
"
|
||||||
|
|
||||||
|
test_expect_success 'submodule contains untracked content (untracked ignored)' "
|
||||||
|
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
|
||||||
|
! test -s actual
|
||||||
|
"
|
||||||
|
|
||||||
|
test_expect_success 'submodule contains untracked content (dirty ignored)' "
|
||||||
|
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
||||||
|
! test -s actual
|
||||||
|
"
|
||||||
|
|
||||||
|
test_expect_success 'submodule contains untracked content (all ignored)' "
|
||||||
|
git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
|
||||||
|
! test -s actual
|
||||||
|
"
|
||||||
|
|
||||||
test_expect_success 'submodule contains untracked and modifed content' "
|
test_expect_success 'submodule contains untracked and modifed content' "
|
||||||
echo new > sm1/foo6 &&
|
echo new > sm1/foo6 &&
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
@ -214,6 +229,26 @@ Submodule sm1 contains modified content
|
|||||||
EOF
|
EOF
|
||||||
"
|
"
|
||||||
|
|
||||||
|
test_expect_success 'submodule contains untracked and modifed content (untracked ignored)' "
|
||||||
|
echo new > sm1/foo6 &&
|
||||||
|
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
|
||||||
|
diff actual - <<-EOF
|
||||||
|
Submodule sm1 contains modified content
|
||||||
|
EOF
|
||||||
|
"
|
||||||
|
|
||||||
|
test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' "
|
||||||
|
echo new > sm1/foo6 &&
|
||||||
|
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
||||||
|
! test -s actual
|
||||||
|
"
|
||||||
|
|
||||||
|
test_expect_success 'submodule contains untracked and modifed content (all ignored)' "
|
||||||
|
echo new > sm1/foo6 &&
|
||||||
|
git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
|
||||||
|
! test -s actual
|
||||||
|
"
|
||||||
|
|
||||||
test_expect_success 'submodule contains modifed content' "
|
test_expect_success 'submodule contains modifed content' "
|
||||||
rm -f sm1/new-file &&
|
rm -f sm1/new-file &&
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
@ -242,6 +277,27 @@ Submodule sm1 $head6..$head8:
|
|||||||
EOF
|
EOF
|
||||||
"
|
"
|
||||||
|
|
||||||
|
test_expect_success 'modified submodule contains untracked content (untracked ignored)' "
|
||||||
|
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
|
||||||
|
diff actual - <<-EOF
|
||||||
|
Submodule sm1 $head6..$head8:
|
||||||
|
> change
|
||||||
|
EOF
|
||||||
|
"
|
||||||
|
|
||||||
|
test_expect_success 'modified submodule contains untracked content (dirty ignored)' "
|
||||||
|
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
||||||
|
diff actual - <<-EOF
|
||||||
|
Submodule sm1 $head6..$head8:
|
||||||
|
> change
|
||||||
|
EOF
|
||||||
|
"
|
||||||
|
|
||||||
|
test_expect_success 'modified submodule contains untracked content (all ignored)' "
|
||||||
|
git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
|
||||||
|
! test -s actual
|
||||||
|
"
|
||||||
|
|
||||||
test_expect_success 'modified submodule contains untracked and modifed content' "
|
test_expect_success 'modified submodule contains untracked and modifed content' "
|
||||||
echo modification >> sm1/foo6 &&
|
echo modification >> sm1/foo6 &&
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
||||||
@ -253,6 +309,31 @@ Submodule sm1 $head6..$head8:
|
|||||||
EOF
|
EOF
|
||||||
"
|
"
|
||||||
|
|
||||||
|
test_expect_success 'modified submodule contains untracked and modifed content (untracked ignored)' "
|
||||||
|
echo modification >> sm1/foo6 &&
|
||||||
|
git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
|
||||||
|
diff actual - <<-EOF
|
||||||
|
Submodule sm1 contains modified content
|
||||||
|
Submodule sm1 $head6..$head8:
|
||||||
|
> change
|
||||||
|
EOF
|
||||||
|
"
|
||||||
|
|
||||||
|
test_expect_success 'modified submodule contains untracked and modifed content (dirty ignored)' "
|
||||||
|
echo modification >> sm1/foo6 &&
|
||||||
|
git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
|
||||||
|
diff actual - <<-EOF
|
||||||
|
Submodule sm1 $head6..$head8:
|
||||||
|
> change
|
||||||
|
EOF
|
||||||
|
"
|
||||||
|
|
||||||
|
test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' "
|
||||||
|
echo modification >> sm1/foo6 &&
|
||||||
|
git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
|
||||||
|
! test -s actual
|
||||||
|
"
|
||||||
|
|
||||||
test_expect_success 'modified submodule contains modifed content' "
|
test_expect_success 'modified submodule contains modifed content' "
|
||||||
rm -f sm1/new-file &&
|
rm -f sm1/new-file &&
|
||||||
git diff-index -p --submodule=log HEAD >actual &&
|
git diff-index -p --submodule=log HEAD >actual &&
|
Loading…
Reference in New Issue
Block a user