diff options
| author | Junio C Hamano <gitster@pobox.com> | 2023-06-23 11:21:17 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2023-06-23 11:21:17 -0700 |
| commit | 4ee088deb83e2a4a78ac3882168b3e8fadd4f541 (patch) | |
| tree | 0125def176094b6e47746063746ea99fce0cb715 | |
| parent | Merge branch 'rj/leakfixes' (diff) | |
| parent | diff-lib: honor override_submodule_config flag bit (diff) | |
| download | git-4ee088deb83e2a4a78ac3882168b3e8fadd4f541.tar.gz git-4ee088deb83e2a4a78ac3882168b3e8fadd4f541.zip | |
Merge branch 'js/defeat-ignore-submodules-config-with-explicit-addition'
Even when diff.ignoreSubmodules tells us to ignore submodule
changes, "git commit" with an index that already records changes to
submodules should include the submodule changes in the resulting
commit, but it did not.
* js/defeat-ignore-submodules-config-with-explicit-addition:
diff-lib: honor override_submodule_config flag bit
| -rw-r--r-- | diff-lib.c | 9 | ||||
| -rwxr-xr-x | t/t7406-submodule-update.sh | 23 |
2 files changed, 31 insertions, 1 deletions
diff --git a/diff-lib.c b/diff-lib.c index 60e979dc1b..1918517ebd 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -669,8 +669,15 @@ int index_differs_from(struct repository *r, setup_revisions(0, NULL, &rev, &opt); rev.diffopt.flags.quick = 1; rev.diffopt.flags.exit_with_status = 1; - if (flags) + if (flags) { diff_flags_or(&rev.diffopt.flags, flags); + /* + * Now that flags are merged, honor override_submodule_config + * and ignore_submodules from passed flags. + */ + if (flags->override_submodule_config) + rev.diffopt.flags.ignore_submodules = flags->ignore_submodules; + } rev.diffopt.ita_invisible_in_index = ita_invisible_in_index; run_diff_index(&rev, 1); has_changes = rev.diffopt.flags.has_changes; diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index f094e3d7f3..00651c25cb 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -1179,4 +1179,27 @@ test_expect_success 'submodule update --recursive skip submodules with strategy= test_cmp expect.err actual.err ' +add_submodule_commit_and_validate () { + HASH=$(git rev-parse HEAD) && + git update-index --add --cacheinfo 160000,$HASH,sub && + git commit -m "create submodule" && + echo "160000 commit $HASH sub" >expect && + git ls-tree HEAD -- sub >actual && + test_cmp expect actual +} + +test_expect_success 'commit with staged submodule change' ' + add_submodule_commit_and_validate +' + +test_expect_success 'commit with staged submodule change with ignoreSubmodules dirty' ' + test_config diff.ignoreSubmodules dirty && + add_submodule_commit_and_validate +' + +test_expect_success 'commit with staged submodule change with ignoreSubmodules all' ' + test_config diff.ignoreSubmodules all && + add_submodule_commit_and_validate +' + test_done |
