{"thread":{"id":"54429","subject":"[PATCH] diff: do not show submodule with untracked files as \"-dirty\"","startedAt":"2020-10-15T17:08:51Z","lastAt":"2020-12-08T22:28:17Z","messageCount":36,"participants":["Sangeeta via GitGitGadget","Phillip Wood","Sangeeta NB","Sangeeta Jain","Eric Sunshine","Junio C Hamano","Sangeeta","Đoàn Trần Công Danh"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"407630","messageId":"pull.751.git.1602781723670.gitgitgadget@gmail.com","threadId":"54429","inReplyTo":null,"subject":"[PATCH] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-10-15T17:08:43Z","receivedAt":"2020-10-15T17:08:51Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"From: sangu09 <sangunb09@gmail.com>\n\nGit diff reports a submodule directory as -dirty even when there are only untracked files in the submodule directory.\nThis is inconsistent with what `git describe --dirty` says when run in the submodule directory in that state.\n\nSo this patch makes `git diff HEAD` consistent with `git describe --dirty` in case of untracked files. This can be solved by including the \"--ignore-submodules=untracked\" feature in git diff by default. So in order to make this as default behaviour I have added the behaviour of `ignore-submodules` in `repo_diff_setup()` function. Also, to avoid `ignoreSubmodules` in user config being overwritten, I have made a  global variable `diff_ignore_submodule_config` to keep a track whether `handle_ignore_submodules_arg` is called before or not.\n\nSigned-off-by: Sangeeta Jain <sangunb09@gmail.com>\n---\n    [Outreachy] diff: do not show submodule with untracked files as \"-dirty\"\n    \n    Git diff reports a submodule directory as -dirty even when there are\n    only untracked files in the submodule directory. This is inconsistent\n    with what git describe --dirty says when run in the submodule directory\n    in that state.\n    \n    So this patch makes git diff HEAD consistent with git describe --dirty \n    in case of untracked files. This can be solved by including the\n    \"--ignore-submodules=untracked\" feature in git diff by default. So in\n    order to make this as default behaviour I have added the behaviour of \n    ignore-submodules in repo_diff_setup() function. Also, to avoid \n    ignoreSubmodules in user config being overwritten, I have made a global\n    variable diff_ignore_submodule_config to keep a track whether \n    handle_ignore_submodules_arg is called before or not.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-751%2Fsangu09%2Fhandle_untracked-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-751/sangu09/handle_untracked-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/751\n\n diff.c                                       |  1 +\n submodule.c                                  |  2 ++\n t/t3701-add-interactive.sh                   |  2 +-\n t/t4027-diff-submodule.sh                    |  6 ++--\n t/t4041-diff-submodule-option.sh             | 16 ++++-----\n t/t4060-diff-submodule-option-diff-format.sh | 16 ++++-----\n t/t7064-wtstatus-pv2.sh                      |  8 ++---\n t/t7506-status-submodule.sh                  | 38 +++++---------------\n 8 files changed, 36 insertions(+), 53 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 2bb2f8f57e..07d89e3e2b 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4585,6 +4585,7 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)\n \t\tDIFF_XDL_SET(options, INDENT_HEURISTIC);\n \n \toptions->orderfile = diff_order_file_cfg;\n+\toptions->flags.ignore_untracked_in_submodules = 1;\n \n \tif (diff_no_prefix) {\n \t\toptions->a_prefix = options->b_prefix = \"\";\ndiff --git a/submodule.c b/submodule.c\nindex b3bb59f066..762298c010 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -1678,6 +1678,8 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)\n \tstrvec_pushl(&cp.args, \"status\", \"--porcelain=2\", NULL);\n \tif (ignore_untracked)\n \t\tstrvec_push(&cp.args, \"-uno\");\n+\telse\n+        strvec_push (&cp.args, \"--ignore-submodules=none\");\n \n \tprepare_submodule_repo_env(&cp.env_array);\n \tcp.git_cmd = 1;\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex ca04fac417..98e46ad1ae 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -761,7 +761,7 @@ test_expect_success 'setup different kinds of dirty submodules' '\n \t\techo dirty >>initial &&\n \t\t: >untracked\n \t) &&\n-\tgit -C for-submodules diff-files --name-only >actual &&\n+\tgit -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&\n \tcat >expected <<-\\EOF &&\n \tdirty-both-ways\n \tdirty-head\ndiff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\nindex d7145ccca4..7bf2cb9c88 100755\n--- a/t/t4027-diff-submodule.sh\n+++ b/t/t4027-diff-submodule.sh\n@@ -93,7 +93,7 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked)' '\n \t) &&\n \tgit diff HEAD >actual &&\n \tsed -e \"1,/^@@/d\" actual >actual.body &&\n-\texpect_from_to >expect.body $subtip $subprev-dirty &&\n+\texpect_from_to >expect.body $subtip $subprev &&\n \ttest_cmp expect.body actual.body\n '\n \n@@ -168,13 +168,13 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'\n \t\tgit clean -qfdx &&\n \t\t>cruft\n \t) &&\n-\tgit diff HEAD >actual &&\n+\tgit diff --ignore-submodules=none HEAD >actual &&\n \tsed -e \"1,/^@@/d\" actual >actual.body &&\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual.body &&\n \tgit diff --ignore-submodules=all HEAD >actual2 &&\n \ttest_must_be_empty actual2 &&\n-\tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n+\tgit diff HEAD >actual3 &&\n \ttest_must_be_empty actual3 &&\n \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n \ttest_must_be_empty actual4\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex f852136585..bb368b685d 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -262,7 +262,7 @@ test_expect_success 'submodule is up to date' '\n \n test_expect_success 'submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tEOF\n@@ -270,7 +270,7 @@ test_expect_success 'submodule contains untracked content' '\n '\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \ttest_must_be_empty actual\n '\n \n@@ -286,7 +286,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n \n test_expect_success 'submodule contains untracked and modified content' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -296,7 +296,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n \n test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tEOF\n@@ -337,7 +337,7 @@ test_expect_success 'submodule is modified' '\n \n test_expect_success 'modified submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p  --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 $head6..$head8:\n@@ -347,7 +347,7 @@ test_expect_success 'modified submodule contains untracked content' '\n '\n \n test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 $head6..$head8:\n \t  > change\n@@ -371,7 +371,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n \n test_expect_success 'modified submodule contains untracked and modified content' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -383,7 +383,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n \n test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tSubmodule sm1 $head6..$head8:\ndiff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh\nindex fc8229c726..dc7b242697 100755\n--- a/t/t4060-diff-submodule-option-diff-format.sh\n+++ b/t/t4060-diff-submodule-option-diff-format.sh\n@@ -409,7 +409,7 @@ test_expect_success 'submodule is up to date' '\n \n test_expect_success 'submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tEOF\n@@ -417,7 +417,7 @@ test_expect_success 'submodule contains untracked content' '\n '\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \ttest_must_be_empty actual\n '\n \n@@ -433,7 +433,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n \n test_expect_success 'submodule contains untracked and modified content' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -451,7 +451,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n # NOT OK\n test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tdiff --git a/sm1/foo6 b/sm1/foo6\n@@ -512,7 +512,7 @@ test_expect_success 'submodule is modified' '\n \n test_expect_success 'modified submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 $head7..$head8:\n@@ -528,7 +528,7 @@ test_expect_success 'modified submodule contains untracked content' '\n '\n \n test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 $head7..$head8:\n \tdiff --git a/sm1/foo6 b/sm1/foo6\n@@ -564,7 +564,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n \n test_expect_success 'modified submodule contains untracked and modified content' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -583,7 +583,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n \n test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tSubmodule sm1 $head7..$head8:\ndiff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh\nindex 537787e598..200626251e 100755\n--- a/t/t7064-wtstatus-pv2.sh\n+++ b/t/t7064-wtstatus-pv2.sh\n@@ -483,7 +483,7 @@ test_expect_success 'create and add submodule, submodule appears clean (A. S...)\n \t)\n '\n \n-test_expect_success 'untracked changes in added submodule (AM S..U)' '\n+test_expect_success 'untracked changes in added submodule (A. S...))' '\n \t(\tcd super_repo &&\n \t\t## create untracked file in the submodule.\n \t\t(\tcd sub1 &&\n@@ -500,7 +500,7 @@ test_expect_success 'untracked changes in added submodule (AM S..U)' '\n \t\t# branch.upstream origin/master\n \t\t# branch.ab +0 -0\n \t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n-\t\t1 AM S..U 000000 160000 160000 $ZERO_OID $HSUB sub1\n+\t\t1 A. S... 000000 160000 160000 $ZERO_OID $HSUB sub1\n \t\tEOF\n \n \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n@@ -560,7 +560,7 @@ test_expect_success 'staged and unstaged changes in added (AM S.M.)' '\n \t)\n '\n \n-test_expect_success 'staged and untracked changes in added submodule (AM S.MU)' '\n+test_expect_success 'staged and untracked changes in added submodule (AM S.M.)' '\n \t(\tcd super_repo &&\n \t\t(\tcd sub1 &&\n \t\t\t## stage new changes in tracked file.\n@@ -579,7 +579,7 @@ test_expect_success 'staged and untracked changes in added submodule (AM S.MU)'\n \t\t# branch.upstream origin/master\n \t\t# branch.ab +0 -0\n \t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n-\t\t1 AM S.MU 000000 160000 160000 $ZERO_OID $HSUB sub1\n+\t\t1 AM S.M. 000000 160000 160000 $ZERO_OID $HSUB sub1\n \t\tEOF\n \n \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\ndiff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh\nindex 3fcb44767f..b7ff7928fb 100755\n--- a/t/t7506-status-submodule.sh\n+++ b/t/t7506-status-submodule.sh\n@@ -95,7 +95,7 @@ test_expect_success 'status with untracked file in submodule' '\n \t(cd sub && git reset --hard) &&\n \techo \"content\" >sub/new-file &&\n \tgit status >output &&\n-\ttest_i18ngrep \"modified:   sub (untracked content)\" output\n+\ttest_i18ngrep \"^nothing to commit\" output\n '\n \n test_expect_success 'status -uno with untracked file in submodule' '\n@@ -105,23 +105,19 @@ test_expect_success 'status -uno with untracked file in submodule' '\n \n test_expect_success 'status with untracked file in submodule (porcelain)' '\n \tgit status --porcelain >output &&\n-\tdiff output - <<-\\EOF\n-\t M sub\n-\tEOF\n+\ttest_must_be_empty output\n '\n \n test_expect_success 'status with untracked file in submodule (short)' '\n \tgit status --short >output &&\n-\tdiff output - <<-\\EOF\n-\t ? sub\n-\tEOF\n+\ttest_must_be_empty output\n '\n \n test_expect_success 'status with added and untracked file in submodule' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n \tgit status >output &&\n-\ttest_i18ngrep \"modified:   sub (modified content, untracked content)\" output\n+\ttest_i18ngrep \"modified:   sub (modified content)\" output\n '\n \n test_expect_success 'status with added and untracked file in submodule (porcelain)' '\n@@ -169,7 +165,7 @@ test_expect_success 'status with untracked file in modified submodule' '\n \t(cd sub && git reset --hard) &&\n \techo \"content\" >sub/new-file &&\n \tgit status >output &&\n-\ttest_i18ngrep \"modified:   sub (new commits, untracked content)\" output\n+\ttest_i18ngrep \"modified:   sub (new commits)\" output\n '\n \n test_expect_success 'status with untracked file in modified submodule (porcelain)' '\n@@ -183,7 +179,7 @@ test_expect_success 'status with added and untracked file in modified submodule'\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n \tgit status >output &&\n-\ttest_i18ngrep \"modified:   sub (new commits, modified content, untracked content)\" output\n+\ttest_i18ngrep \"modified:   sub (new commits, modified content)\" output\n '\n \n test_expect_success 'status with added and untracked file in modified submodule (porcelain)' '\n@@ -350,30 +346,17 @@ test_expect_success 'setup superproject with untracked file in nested submodule'\n \n test_expect_success 'status with untracked file in nested submodule (porcelain)' '\n \tgit -C super status --porcelain >output &&\n-\tdiff output - <<-\\EOF\n-\t M sub1\n-\t M sub2\n-\t M sub3\n-\tEOF\n+\ttest_must_be_empty output\n '\n \n test_expect_success 'status with untracked file in nested submodule (porcelain=2)' '\n \tgit -C super status --porcelain=2 >output &&\n-\tsanitize_output output &&\n-\tdiff output - <<-\\EOF\n-\t1 .M S..U 160000 160000 160000 HASH HASH sub1\n-\t1 .M S..U 160000 160000 160000 HASH HASH sub2\n-\t1 .M S..U 160000 160000 160000 HASH HASH sub3\n-\tEOF\n+\ttest_must_be_empty output\n '\n \n test_expect_success 'status with untracked file in nested submodule (short)' '\n \tgit -C super status --short >output &&\n-\tdiff output - <<-\\EOF\n-\t ? sub1\n-\t ? sub2\n-\t ? sub3\n-\tEOF\n+\ttest_must_be_empty output\n '\n \n test_expect_success 'setup superproject with modified file in nested submodule' '\n@@ -386,7 +369,6 @@ test_expect_success 'status with added file in nested submodule (porcelain)' '\n \tdiff output - <<-\\EOF\n \t M sub1\n \t M sub2\n-\t M sub3\n \tEOF\n '\n \n@@ -396,7 +378,6 @@ test_expect_success 'status with added file in nested submodule (porcelain=2)' '\n \tdiff output - <<-\\EOF\n \t1 .M S.M. 160000 160000 160000 HASH HASH sub1\n \t1 .M S.M. 160000 160000 160000 HASH HASH sub2\n-\t1 .M S..U 160000 160000 160000 HASH HASH sub3\n \tEOF\n '\n \n@@ -405,7 +386,6 @@ test_expect_success 'status with added file in nested submodule (short)' '\n \tdiff output - <<-\\EOF\n \t m sub1\n \t m sub2\n-\t ? sub3\n \tEOF\n '\n \n\nbase-commit: d98273ba77e1ab9ec755576bc86c716a97bf59d7\n-- \ngitgitgadget\n"},{"id":"407981","messageId":"7af89857-5495-d008-3d8f-09b5fed32775@gmail.com","threadId":"54429","inReplyTo":"pull.751.git.1602781723670.gitgitgadget@gmail.com","subject":"Re: [OUTREACHY][PATCH] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2020-10-20T13:38:50Z","receivedAt":"2020-10-20T13:38:55Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Sangeeta\n\nOn 15/10/2020 18:08, Sangeeta via GitGitGadget wrote:\n> From: sangu09 <sangunb09@gmail.com>\n\nI think we require your full name on the From line to match the \nSigned-off-by line below (c.f. \nhttps://lore.kernel.org/git/xmqqpn5dd5dv.fsf@gitster.c.googlers.com)\n\n> Git diff reports a submodule directory as -dirty even when there are only untracked files in the submodule directory.\n> This is inconsistent with what `git describe --dirty` says when run in the submodule directory in that state.\n\nThat is a good summary of the issue that this change addresses, we \nnormally wrap lines at 72 characters though.\n\n> So this patch makes `git diff HEAD` consistent with `git describe --dirty` in case of untracked files. This can be solved by including the \"--ignore-submodules=untracked\" feature in git diff by default. So in order to make this as default behaviour I have added the behaviour of `ignore-submodules` in `repo_diff_setup()` function.\n\nI think this could be a little more concise\n\nThis patch makes `git diff HEAD` consistent with `git describe --dirty` \nwhen a submodule contains untracked files by making \n`--ignore-submodules=untracked` the default.\n\n> Also, to avoid `ignoreSubmodules` in user config being overwritten, I have made a  global variable >`diff_ignore_submodule_config` to keep a track whether `handle_ignore_submodules_arg` is called before or not.\n\nIt is good that you have thought about this and it is worth mentioning \nin the commit message, however unfortunately that variable does not seem \nto exist in the patch.\n\n> \n> Signed-off-by: Sangeeta Jain <sangunb09@gmail.com>\n> ---\n>      [Outreachy] diff: do not show submodule with untracked files as \"-dirty\"\n>      \n>      Git diff reports a submodule directory as -dirty even when there are\n>      only untracked files in the submodule directory. This is inconsistent\n>      with what git describe --dirty says when run in the submodule directory\n>      in that state.\n>      \n>      So this patch makes git diff HEAD consistent with git describe --dirty\n>      in case of untracked files. This can be solved by including the\n>      \"--ignore-submodules=untracked\" feature in git diff by default. So in\n>      order to make this as default behaviour I have added the behaviour of\n>      ignore-submodules in repo_diff_setup() function. Also, to avoid\n>      ignoreSubmodules in user config being overwritten, I have made a global\n>      variable diff_ignore_submodule_config to keep a track whether\n>      handle_ignore_submodules_arg is called before or not.\n> \n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-751%2Fsangu09%2Fhandle_untracked-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-751/sangu09/handle_untracked-v1\n> Pull-Request: https://github.com/gitgitgadget/git/pull/751\n> \n>   diff.c                                       |  1 +\n>   submodule.c                                  |  2 ++\n>   t/t3701-add-interactive.sh                   |  2 +-\n>   t/t4027-diff-submodule.sh                    |  6 ++--\n>   t/t4041-diff-submodule-option.sh             | 16 ++++-----\n>   t/t4060-diff-submodule-option-diff-format.sh | 16 ++++-----\n>   t/t7064-wtstatus-pv2.sh                      |  8 ++---\n>   t/t7506-status-submodule.sh                  | 38 +++++---------------\n>   8 files changed, 36 insertions(+), 53 deletions(-)\n> \n> diff --git a/diff.c b/diff.c\n> index 2bb2f8f57e..07d89e3e2b 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -4585,6 +4585,7 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)\n>   \t\tDIFF_XDL_SET(options, INDENT_HEURISTIC);\n>   \n>   \toptions->orderfile = diff_order_file_cfg;\n> +\toptions->flags.ignore_untracked_in_submodules = 1;\n\nThis unconditionally overrides diff.ignoreSubmodules, grepping seems to \nshow that we don't have any tests that test a config value of \"none\". \nThere are a few that check \"dirty\" which we should look at to consider \nif they still add value now we've changed the default.\n\n>   \tif (diff_no_prefix) {\n>   \t\toptions->a_prefix = options->b_prefix = \"\";\n> diff --git a/submodule.c b/submodule.c\n> index b3bb59f066..762298c010 100644\n> --- a/submodule.c\n> +++ b/submodule.c\n> @@ -1678,6 +1678,8 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)\n>   \tstrvec_pushl(&cp.args, \"status\", \"--porcelain=2\", NULL);\n>   \tif (ignore_untracked)\n>   \t\tstrvec_push(&cp.args, \"-uno\");\n> +\telse\n> +        strvec_push (&cp.args, \"--ignore-submodules=none\");\n\nWe need to do this a a consequence of changing the default for \n'--ignore-submodules`, we should think what the consequences are for \nother users of `git status` and whether we need to do something similar \nthere if diff.ignoreSubmodules is not set.\n\n>   \tprepare_submodule_repo_env(&cp.env_array);\n>   \tcp.git_cmd = 1;\n> diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\n> index ca04fac417..98e46ad1ae 100755\n> --- a/t/t3701-add-interactive.sh\n> +++ b/t/t3701-add-interactive.sh\n> @@ -761,7 +761,7 @@ test_expect_success 'setup different kinds of dirty submodules' '\n>   \t\techo dirty >>initial &&\n>   \t\t: >untracked\n>   \t) &&\n> -\tgit -C for-submodules diff-files --name-only >actual &&\n> +\tgit -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&\n>   \tcat >expected <<-\\EOF &&\n>   \tdirty-both-ways\n>   \tdirty-head\n> diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\n> index d7145ccca4..7bf2cb9c88 100755\n> --- a/t/t4027-diff-submodule.sh\n> +++ b/t/t4027-diff-submodule.sh\n> @@ -93,7 +93,7 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked)' '\n>   \t) &&\n>   \tgit diff HEAD >actual &&\n>   \tsed -e \"1,/^@@/d\" actual >actual.body &&\n> -\texpect_from_to >expect.body $subtip $subprev-dirty &&\n> +\texpect_from_to >expect.body $subtip $subprev &&\n>   \ttest_cmp expect.body actual.body\n>   '\n>   \n> @@ -168,13 +168,13 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'\n>   \t\tgit clean -qfdx &&\n>   \t\t>cruft\n>   \t) &&\n> -\tgit diff HEAD >actual &&\n> +\tgit diff --ignore-submodules=none HEAD >actual &&\n>   \tsed -e \"1,/^@@/d\" actual >actual.body &&\n>   \texpect_from_to >expect.body $subprev $subprev-dirty &&\n>   \ttest_cmp expect.body actual.body &&\n>   \tgit diff --ignore-submodules=all HEAD >actual2 &&\n>   \ttest_must_be_empty actual2 &&\n> -\tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n> +\tgit diff HEAD >actual3 &&\n\nThis checks the new default which is good\n\n>   \ttest_must_be_empty actual3 &&\n>   \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n>   \ttest_must_be_empty actual4\n> diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\n> index f852136585..bb368b685d 100755\n> --- a/t/t4041-diff-submodule-option.sh\n> +++ b/t/t4041-diff-submodule-option.sh\n> @@ -262,7 +262,7 @@ test_expect_success 'submodule is up to date' '\n>   \n>   test_expect_success 'submodule contains untracked content' '\n>   \techo new > sm1/new-file &&\n> -\tgit diff-index -p --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n>   \tcat >expected <<-EOF &&\n>   \tSubmodule sm1 contains untracked content\n>   \tEOF\n> @@ -270,7 +270,7 @@ test_expect_success 'submodule contains untracked content' '\n>   '\n>   \n>   test_expect_success 'submodule contains untracked content (untracked ignored)' '\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD >actual &&\n>   \ttest_must_be_empty actual\n>   '\n>   \n> @@ -286,7 +286,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n>   \n>   test_expect_success 'submodule contains untracked and modified content' '\n>   \techo new > sm1/foo6 &&\n> -\tgit diff-index -p --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n>   \tcat >expected <<-EOF &&\n>   \tSubmodule sm1 contains untracked content\n>   \tSubmodule sm1 contains modified content\n> @@ -296,7 +296,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n>   \n>   test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n>   \techo new > sm1/foo6 &&\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD >actual &&\n>   \tcat >expected <<-EOF &&\n>   \tSubmodule sm1 contains modified content\n>   \tEOF\n> @@ -337,7 +337,7 @@ test_expect_success 'submodule is modified' '\n>   \n>   test_expect_success 'modified submodule contains untracked content' '\n>   \techo new > sm1/new-file &&\n> -\tgit diff-index -p --submodule=log HEAD >actual &&\n> +\tgit diff-index -p  --ignore-submodules=none --submodule=log HEAD >actual &&\n>   \tcat >expected <<-EOF &&\n>   \tSubmodule sm1 contains untracked content\n>   \tSubmodule sm1 $head6..$head8:\n> @@ -347,7 +347,7 @@ test_expect_success 'modified submodule contains untracked content' '\n>   '\n>   \n>   test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD >actual &&\n>   \tcat >expected <<-EOF &&\n>   \tSubmodule sm1 $head6..$head8:\n>   \t  > change\n> @@ -371,7 +371,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n>   \n>   test_expect_success 'modified submodule contains untracked and modified content' '\n>   \techo modification >> sm1/foo6 &&\n> -\tgit diff-index -p --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n>   \tcat >expected <<-EOF &&\n>   \tSubmodule sm1 contains untracked content\n>   \tSubmodule sm1 contains modified content\n> @@ -383,7 +383,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n>   \n>   test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n>   \techo modification >> sm1/foo6 &&\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD >actual &&\n>   \tcat >expected <<-EOF &&\n>   \tSubmodule sm1 contains modified content\n>   \tSubmodule sm1 $head6..$head8:\n> diff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh\n> index fc8229c726..dc7b242697 100755\n> --- a/t/t4060-diff-submodule-option-diff-format.sh\n> +++ b/t/t4060-diff-submodule-option-diff-format.sh\n> @@ -409,7 +409,7 @@ test_expect_success 'submodule is up to date' '\n>   \n>   test_expect_success 'submodule contains untracked content' '\n>   \techo new > sm1/new-file &&\n> -\tgit diff-index -p --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n>   \tcat >expected <<-EOF &&\n>   \tSubmodule sm1 contains untracked content\n>   \tEOF\n> @@ -417,7 +417,7 @@ test_expect_success 'submodule contains untracked content' '\n>   '\n>   \n>   test_expect_success 'submodule contains untracked content (untracked ignored)' '\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --submodule=diff HEAD >actual &&\n>   \ttest_must_be_empty actual\n>   '\n>   \n> @@ -433,7 +433,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n>   \n>   test_expect_success 'submodule contains untracked and modified content' '\n>   \techo new > sm1/foo6 &&\n> -\tgit diff-index -p --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n>   \tcat >expected <<-EOF &&\n>   \tSubmodule sm1 contains untracked content\n>   \tSubmodule sm1 contains modified content\n> @@ -451,7 +451,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n>   # NOT OK\n>   test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n>   \techo new > sm1/foo6 &&\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --submodule=diff HEAD >actual &&\n>   \tcat >expected <<-EOF &&\n>   \tSubmodule sm1 contains modified content\n>   \tdiff --git a/sm1/foo6 b/sm1/foo6\n> @@ -512,7 +512,7 @@ test_expect_success 'submodule is modified' '\n>   \n>   test_expect_success 'modified submodule contains untracked content' '\n>   \techo new > sm1/new-file &&\n> -\tgit diff-index -p --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n>   \tcat >expected <<-EOF &&\n>   \tSubmodule sm1 contains untracked content\n>   \tSubmodule sm1 $head7..$head8:\n> @@ -528,7 +528,7 @@ test_expect_success 'modified submodule contains untracked content' '\n>   '\n>   \n>   test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --submodule=diff HEAD >actual &&\n>   \tcat >expected <<-EOF &&\n>   \tSubmodule sm1 $head7..$head8:\n>   \tdiff --git a/sm1/foo6 b/sm1/foo6\n> @@ -564,7 +564,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n>   \n>   test_expect_success 'modified submodule contains untracked and modified content' '\n>   \techo modification >> sm1/foo6 &&\n> -\tgit diff-index -p --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n>   \tcat >expected <<-EOF &&\n>   \tSubmodule sm1 contains untracked content\n>   \tSubmodule sm1 contains modified content\n> @@ -583,7 +583,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n>   \n>   test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n>   \techo modification >> sm1/foo6 &&\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --submodule=diff HEAD >actual &&\n>   \tcat >expected <<-EOF &&\n>   \tSubmodule sm1 contains modified content\n>   \tSubmodule sm1 $head7..$head8:\n\nI think all the diff tests look fine and we seem to have a good mix of \ntesting the new default and --ignore-submodules=none\n\n> diff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh\n> index 537787e598..200626251e 100755\n> --- a/t/t7064-wtstatus-pv2.sh\n> +++ b/t/t7064-wtstatus-pv2.sh\n> @@ -483,7 +483,7 @@ test_expect_success 'create and add submodule, submodule appears clean (A. S...)\n>   \t)\n>   '\n>   \n> -test_expect_success 'untracked changes in added submodule (AM S..U)' '\n> +test_expect_success 'untracked changes in added submodule (A. S...))' '\n\ntypo: there's an extra ')'\n\n>   \t(\tcd super_repo &&\n>   \t\t## create untracked file in the submodule.\n>   \t\t(\tcd sub1 &&\n> @@ -500,7 +500,7 @@ test_expect_success 'untracked changes in added submodule (AM S..U)' '\n>   \t\t# branch.upstream origin/master\n>   \t\t# branch.ab +0 -0\n>   \t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n> -\t\t1 AM S..U 000000 160000 160000 $ZERO_OID $HSUB sub1\n> +\t\t1 A. S... 000000 160000 160000 $ZERO_OID $HSUB sub1\n>   \t\tEOF\n>   \n>   \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n> @@ -560,7 +560,7 @@ test_expect_success 'staged and unstaged changes in added (AM S.M.)' '\n>   \t)\n>   '\n>   \n> -test_expect_success 'staged and untracked changes in added submodule (AM S.MU)' '\n> +test_expect_success 'staged and untracked changes in added submodule (AM S.M.)' '\n>   \t(\tcd super_repo &&\n>   \t\t(\tcd sub1 &&\n>   \t\t\t## stage new changes in tracked file.\n> @@ -579,7 +579,7 @@ test_expect_success 'staged and untracked changes in added submodule (AM S.MU)'\n>   \t\t# branch.upstream origin/master\n>   \t\t# branch.ab +0 -0\n>   \t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n> -\t\t1 AM S.MU 000000 160000 160000 $ZERO_OID $HSUB sub1\n> +\t\t1 AM S.M. 000000 160000 160000 $ZERO_OID $HSUB sub1\n>   \t\tEOF\n>\n\nI'm not sure about the changes in this file, maybe we should be testing \nthe new default and --ignore-submodules=none\n\n>   \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n> diff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh\n> index 3fcb44767f..b7ff7928fb 100755\n> --- a/t/t7506-status-submodule.sh\n> +++ b/t/t7506-status-submodule.sh\n> @@ -95,7 +95,7 @@ test_expect_success 'status with untracked file in submodule' '\n>   \t(cd sub && git reset --hard) &&\n>   \techo \"content\" >sub/new-file &&\n>   \tgit status >output &&\n> -\ttest_i18ngrep \"modified:   sub (untracked content)\" output\n> +\ttest_i18ngrep \"^nothing to commit\" output\n>   '\n>   \n>   test_expect_success 'status -uno with untracked file in submodule' '\n> @@ -105,23 +105,19 @@ test_expect_success 'status -uno with untracked file in submodule' '\n>   \n>   test_expect_success 'status with untracked file in submodule (porcelain)' '\n>   \tgit status --porcelain >output &&\n> -\tdiff output - <<-\\EOF\n> -\t M sub\n> -\tEOF\n> +\ttest_must_be_empty output\n>   '\n>   \n>   test_expect_success 'status with untracked file in submodule (short)' '\n>   \tgit status --short >output &&\n> -\tdiff output - <<-\\EOF\n> -\t ? sub\n> -\tEOF\n> +\ttest_must_be_empty output\n>   '\n>   \n>   test_expect_success 'status with added and untracked file in submodule' '\n>   \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n>   \techo \"content\" >sub/new-file &&\n>   \tgit status >output &&\n> -\ttest_i18ngrep \"modified:   sub (modified content, untracked content)\" output\n> +\ttest_i18ngrep \"modified:   sub (modified content)\" output\n>   '\n>   \n>   test_expect_success 'status with added and untracked file in submodule (porcelain)' '\n> @@ -169,7 +165,7 @@ test_expect_success 'status with untracked file in modified submodule' '\n>   \t(cd sub && git reset --hard) &&\n>   \techo \"content\" >sub/new-file &&\n>   \tgit status >output &&\n> -\ttest_i18ngrep \"modified:   sub (new commits, untracked content)\" output\n> +\ttest_i18ngrep \"modified:   sub (new commits)\" output\n>   '\n>   \n>   test_expect_success 'status with untracked file in modified submodule (porcelain)' '\n> @@ -183,7 +179,7 @@ test_expect_success 'status with added and untracked file in modified submodule'\n>   \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n>   \techo \"content\" >sub/new-file &&\n>   \tgit status >output &&\n> -\ttest_i18ngrep \"modified:   sub (new commits, modified content, untracked content)\" output\n> +\ttest_i18ngrep \"modified:   sub (new commits, modified content)\" output\n>   '\n>   \n>   test_expect_success 'status with added and untracked file in modified submodule (porcelain)' '\n> @@ -350,30 +346,17 @@ test_expect_success 'setup superproject with untracked file in nested submodule'\n>   \n>   test_expect_success 'status with untracked file in nested submodule (porcelain)' '\n>   \tgit -C super status --porcelain >output &&\n> -\tdiff output - <<-\\EOF\n> -\t M sub1\n> -\t M sub2\n> -\t M sub3\n> -\tEOF\n> +\ttest_must_be_empty output\n>   '\n>   \n>   test_expect_success 'status with untracked file in nested submodule (porcelain=2)' '\n>   \tgit -C super status --porcelain=2 >output &&\n> -\tsanitize_output output &&\n> -\tdiff output - <<-\\EOF\n> -\t1 .M S..U 160000 160000 160000 HASH HASH sub1\n> -\t1 .M S..U 160000 160000 160000 HASH HASH sub2\n> -\t1 .M S..U 160000 160000 160000 HASH HASH sub3\n> -\tEOF\n> +\ttest_must_be_empty output\n>   '\n>   \n>   test_expect_success 'status with untracked file in nested submodule (short)' '\n>   \tgit -C super status --short >output &&\n> -\tdiff output - <<-\\EOF\n> -\t ? sub1\n> -\t ? sub2\n> -\t ? sub3\n> -\tEOF\n> +\ttest_must_be_empty output\n>   '\n>   \n>   test_expect_success 'setup superproject with modified file in nested submodule' '\n> @@ -386,7 +369,6 @@ test_expect_success 'status with added file in nested submodule (porcelain)' '\n>   \tdiff output - <<-\\EOF\n>   \t M sub1\n>   \t M sub2\n> -\t M sub3\n>   \tEOF\n>   '\n>   \n> @@ -396,7 +378,6 @@ test_expect_success 'status with added file in nested submodule (porcelain=2)' '\n>   \tdiff output - <<-\\EOF\n>   \t1 .M S.M. 160000 160000 160000 HASH HASH sub1\n>   \t1 .M S.M. 160000 160000 160000 HASH HASH sub2\n> -\t1 .M S..U 160000 160000 160000 HASH HASH sub3\n>   \tEOF\n>   '\n>   \n> @@ -405,7 +386,6 @@ test_expect_success 'status with added file in nested submodule (short)' '\n>   \tdiff output - <<-\\EOF\n>   \t m sub1\n>   \t m sub2\n> -\t ? sub3\n>   \tEOF\n>   '\n\nI think we want to keep testing that we get the correct output when \n--ignore-submodules=none as well as maybe adding a couple of new tests \nthat check the default in this file, rather than changing the expected \noutput.\n\nBest Wishes\n\nPhillip\n\n\n> base-commit: d98273ba77e1ab9ec755576bc86c716a97bf59d7\n> \n"},{"id":"407994","messageId":"CAHjREB7Xhga3da9vGyXxJo6MCi9P9CyezzO66Xh2X2+rDFkQjw@mail.gmail.com","threadId":"54429","inReplyTo":"7af89857-5495-d008-3d8f-09b5fed32775@gmail.com","subject":"Re: [OUTREACHY][PATCH] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta NB","fromEmail":"sangunb09@gmail.com","sentAt":"2020-10-20T18:10:42Z","receivedAt":"2020-10-20T18:10:57Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"Hey Phillip,\n\n> I think we require your full name on the From line to match the\n> Signed-off-by line below (c.f.\n> https://lore.kernel.org/git/xmqqpn5dd5dv.fsf@gitster.c.googlers.com)\n\n> That is a good summary of the issue that this change addresses, we\n> normally wrap lines at 72 characters though.\n\nThis was sent by gitgitgadget so I am unable to find how I can\ncustomize it. Can you help me with this? Or else I have set the Travis\nso should I send another patch using send-email?\n\n> This unconditionally overrides diff.ignoreSubmodules, grepping seems to\n> show that we don't have any tests that test a config value of \"none\".\n> There are a few that check \"dirty\" which we should look at to consider\n> if they still add value now we've changed the default.\n\nYes, sorry, noticed it now. I have now added a flag in diff_flags.\nAlso, do I have to add tests that check whether diff.ignoreSubmodules\nis not being overwritten?\n\n\n>       if (diff_no_prefix) {\n>               options->a_prefix = options->b_prefix = \"\";\n> diff --git a/submodule.c b/submodule.c\n> index b3bb59f066..762298c010 100644\n> --- a/submodule.c\n> +++ b/submodule.c\n> @@ -1678,6 +1678,8 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)\n>       strvec_pushl(&cp.args, \"status\", \"--porcelain=2\", NULL);\n>       if (ignore_untracked)\n>               strvec_push(&cp.args, \"-uno\");\n> +     else\n> +        strvec_push (&cp.args, \"--ignore-submodules=none\");\n>\n> We need to do this as a consequence of changing the default for\n> '--ignore-submodules`, we should think what the consequences are for\n> other users of `git status` and whether we need to do something similar\n> there if diff.ignoreSubmodules is not set.\n>\n\nOh okay. I understood what you said. But I couldn't figure out how to\ndo that. As all the tests of status were passing so I don't think\nthere might be any issue with this.\n\n>\n> I think we want to keep testing that we get the correct output when\n> --ignore-submodules=none as well as maybe adding a couple of new tests\n> that check the default in this file, rather than changing the expected\n> output.\n>\n\nThanks, I have added more tests.\n\nThanks and Regards,\nSangeeta\n"},{"id":"408042","messageId":"d9376318-b8dd-3e30-8aa9-255eefe727c4@gmail.com","threadId":"54429","inReplyTo":"CAHjREB7Xhga3da9vGyXxJo6MCi9P9CyezzO66Xh2X2+rDFkQjw@mail.gmail.com","subject":"Re: [OUTREACHY][PATCH] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2020-10-21T11:28:37Z","receivedAt":"2020-10-21T11:28:44Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Sangeeta\n\nOn 20/10/2020 19:10, Sangeeta NB wrote:\n> Hey Phillip,\n> \n>> I think we require your full name on the From line to match the\n>> Signed-off-by line below (c.f.\n>> https://lore.kernel.org/git/xmqqpn5dd5dv.fsf@gitster.c.googlers.com)\n> \n>> That is a good summary of the issue that this change addresses, we\n>> normally wrap lines at 72 characters though.\n> \n> This was sent by gitgitgadget so I am unable to find how I can\n> customize it. Can you help me with this? Or else I have set the Travis\n> so should I send another patch using send-email?\n\nWhen you create the commit message you need to get your editor to wrap \nthe lines with line breaks, how you do this depends on your editor - for \nemacs you can use fill-paragraph, in vim 'gq' you should be able to \ngoogle it for your editor.\n\nIt would be a good idea to add [Outreachy] to the beginning of the \ncommit subject line as well so people can easily find outreachy related \npatches on the list (anything inside [] is removed by `git am` when the \npatch is applied)\n\n>> This unconditionally overrides diff.ignoreSubmodules, grepping seems to\n>> show that we don't have any tests that test a config value of \"none\".\n>> There are a few that check \"dirty\" which we should look at to consider\n>> if they still add value now we've changed the default.\n> \n> Yes, sorry, noticed it now. I have now added a flag in diff_flags.\n> Also, do I have to add tests that check whether diff.ignoreSubmodules\n> is not being overwritten?\n\nI think adding a test that checks diff.ignoreSubmodules=none is \nrespected would be a good idea\n\n> \n>>        if (diff_no_prefix) {\n>>                options->a_prefix = options->b_prefix = \"\";\n>> diff --git a/submodule.c b/submodule.c\n>> index b3bb59f066..762298c010 100644\n>> --- a/submodule.c\n>> +++ b/submodule.c\n>> @@ -1678,6 +1678,8 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)\n>>        strvec_pushl(&cp.args, \"status\", \"--porcelain=2\", NULL);\n>>        if (ignore_untracked)\n>>                strvec_push(&cp.args, \"-uno\");\n>> +     else\n>> +        strvec_push (&cp.args, \"--ignore-submodules=none\");\n>>\n>> We need to do this as a consequence of changing the default for\n>> '--ignore-submodules`, we should think what the consequences are for\n>> other users of `git status` and whether we need to do something similar\n>> there if diff.ignoreSubmodules is not set.\n>>\n> \n> Oh okay. I understood what you said. But I couldn't figure out how to\n> do that.\n\nI'm not sure if we need to do this or not, I was hoping to get some \ninput from the list\n\n> As all the tests of status were passing so I don't think\n> there might be any issue with this.\n\nPossibly, though I think it is more likely that we're not testing \nanything that gets broken by this change.\n\n\nBest Wishes\n\nPhillip\n\n>> I think we want to keep testing that we get the correct output when\n>> --ignore-submodules=none as well as maybe adding a couple of new tests\n>> that check the default in this file, rather than changing the expected\n>> output.\n>>\n> \n> Thanks, I have added more tests.\n> \n> Thanks and Regards,\n> Sangeeta\n> \n"},{"id":"408049","messageId":"20201021131012.20703-1-sangunb09@gmail.com","threadId":"54429","inReplyTo":"pull.751.git.1602781723670.gitgitgadget@gmail.com","subject":"[Outreachy] [PATCH v2] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta Jain","fromEmail":"sangunb09@gmail.com","sentAt":"2020-10-21T13:10:12Z","receivedAt":"2020-10-21T13:10:35Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"Git diff reports a submodule directory as -dirty even when there are\nonly untracked files in the submodule directory.\nThis is inconsistent with what `git describe --dirty` says when run in\nthe submodule directory in that state.\n\nThis patch makes `git diff HEAD` consistent with `git describe --dirty`\nwhen a submodule contains untracked files by making\n`--ignore-submodules=untracked` the default.\n\nAlso, to avoid `ignoreSubmodules` in user config being overwritten,\nI have made added a flag in diff_flags to keep a track whether\n`handle_ignore_submodules_arg` is called before or not.\n\nSigned-off-by: Sangeeta Jain <sangunb09@gmail.com>\n---\n diff.c                                       |   3 +\n diff.h                                       |   1 +\n submodule.c                                  |   3 +\n t/t3701-add-interactive.sh                   |   2 +-\n t/t4027-diff-submodule.sh                    |  15 ++-\n t/t4041-diff-submodule-option.sh             |  16 +--\n t/t4060-diff-submodule-option-diff-format.sh |  16 +--\n t/t7064-wtstatus-pv2.sh                      |  52 ++++++++++\n t/t7506-status-submodule.sh                  | 102 ++++++++++++++++---\n 9 files changed, 178 insertions(+), 32 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 2bb2f8f57e..027462a339 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4585,6 +4585,9 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)\n \t\tDIFF_XDL_SET(options, INDENT_HEURISTIC);\n \n \toptions->orderfile = diff_order_file_cfg;\n+\t\n+\tif(!options->flags.ignore_submodule_set)\n+\t\toptions->flags.ignore_untracked_in_submodules = 1;\n \n \tif (diff_no_prefix) {\n \t\toptions->a_prefix = options->b_prefix = \"\";\ndiff --git a/diff.h b/diff.h\nindex 11de52e9e9..1e18e6b1c3 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -178,6 +178,7 @@ struct diff_flags {\n \tunsigned diff_from_contents;\n \tunsigned dirty_submodules;\n \tunsigned ignore_untracked_in_submodules;\n+\tunsigned ignore_submodule_set;\n \tunsigned ignore_dirty_submodules;\n \tunsigned override_submodule_config;\n \tunsigned dirstat_by_line;\ndiff --git a/submodule.c b/submodule.c\nindex b3bb59f066..efaba0eff2 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -420,6 +420,7 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy\n void handle_ignore_submodules_arg(struct diff_options *diffopt,\n \t\t\t\t  const char *arg)\n {\n+\tdiffopt->flags.ignore_submodule_set = 1;\n \tdiffopt->flags.ignore_submodules = 0;\n \tdiffopt->flags.ignore_untracked_in_submodules = 0;\n \tdiffopt->flags.ignore_dirty_submodules = 0;\n@@ -1678,6 +1679,8 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)\n \tstrvec_pushl(&cp.args, \"status\", \"--porcelain=2\", NULL);\n \tif (ignore_untracked)\n \t\tstrvec_push(&cp.args, \"-uno\");\n+\telse\n+        strvec_push (&cp.args, \"--ignore-submodules=none\");\n \n \tprepare_submodule_repo_env(&cp.env_array);\n \tcp.git_cmd = 1;\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex ca04fac417..98e46ad1ae 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -761,7 +761,7 @@ test_expect_success 'setup different kinds of dirty submodules' '\n \t\techo dirty >>initial &&\n \t\t: >untracked\n \t) &&\n-\tgit -C for-submodules diff-files --name-only >actual &&\n+\tgit -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&\n \tcat >expected <<-\\EOF &&\n \tdirty-both-ways\n \tdirty-head\ndiff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\nindex d7145ccca4..6432b4331f 100755\n--- a/t/t4027-diff-submodule.sh\n+++ b/t/t4027-diff-submodule.sh\n@@ -93,10 +93,19 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked)' '\n \t) &&\n \tgit diff HEAD >actual &&\n \tsed -e \"1,/^@@/d\" actual >actual.body &&\n-\texpect_from_to >expect.body $subtip $subprev-dirty &&\n+\texpect_from_to >expect.body $subtip $subprev &&\n \ttest_cmp expect.body actual.body\n '\n \n+test_expect_success 'git diff HEAD with dirty submodule (untracked) (none ignored)' '\n+\tgit config diff.ignoreSubmodules none &&\n+\tgit diff HEAD >actual &&\n+\tsed -e \"1,/^@@/d\" actual >actual.body &&\n+\texpect_from_to >expect.body $subtip $subprev-dirty &&\n+\ttest_cmp expect.body actual.body &&\n+\tgit config --unset diff.ignoreSubmodules\n+'\n+\n test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)' '\n \tgit commit -m \"x\" sub &&\n \techo >>sub/world &&\n@@ -168,13 +177,13 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'\n \t\tgit clean -qfdx &&\n \t\t>cruft\n \t) &&\n-\tgit diff HEAD >actual &&\n+\tgit diff --ignore-submodules=none HEAD >actual &&\n \tsed -e \"1,/^@@/d\" actual >actual.body &&\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual.body &&\n \tgit diff --ignore-submodules=all HEAD >actual2 &&\n \ttest_must_be_empty actual2 &&\n-\tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n+\tgit diff HEAD >actual3 &&\n \ttest_must_be_empty actual3 &&\n \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n \ttest_must_be_empty actual4\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex f852136585..bb368b685d 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -262,7 +262,7 @@ test_expect_success 'submodule is up to date' '\n \n test_expect_success 'submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tEOF\n@@ -270,7 +270,7 @@ test_expect_success 'submodule contains untracked content' '\n '\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \ttest_must_be_empty actual\n '\n \n@@ -286,7 +286,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n \n test_expect_success 'submodule contains untracked and modified content' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -296,7 +296,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n \n test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tEOF\n@@ -337,7 +337,7 @@ test_expect_success 'submodule is modified' '\n \n test_expect_success 'modified submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p  --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 $head6..$head8:\n@@ -347,7 +347,7 @@ test_expect_success 'modified submodule contains untracked content' '\n '\n \n test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 $head6..$head8:\n \t  > change\n@@ -371,7 +371,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n \n test_expect_success 'modified submodule contains untracked and modified content' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -383,7 +383,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n \n test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tSubmodule sm1 $head6..$head8:\ndiff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh\nindex fc8229c726..dc7b242697 100755\n--- a/t/t4060-diff-submodule-option-diff-format.sh\n+++ b/t/t4060-diff-submodule-option-diff-format.sh\n@@ -409,7 +409,7 @@ test_expect_success 'submodule is up to date' '\n \n test_expect_success 'submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tEOF\n@@ -417,7 +417,7 @@ test_expect_success 'submodule contains untracked content' '\n '\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \ttest_must_be_empty actual\n '\n \n@@ -433,7 +433,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n \n test_expect_success 'submodule contains untracked and modified content' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -451,7 +451,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n # NOT OK\n test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tdiff --git a/sm1/foo6 b/sm1/foo6\n@@ -512,7 +512,7 @@ test_expect_success 'submodule is modified' '\n \n test_expect_success 'modified submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 $head7..$head8:\n@@ -528,7 +528,7 @@ test_expect_success 'modified submodule contains untracked content' '\n '\n \n test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 $head7..$head8:\n \tdiff --git a/sm1/foo6 b/sm1/foo6\n@@ -564,7 +564,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n \n test_expect_success 'modified submodule contains untracked and modified content' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -583,7 +583,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n \n test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tSubmodule sm1 $head7..$head8:\ndiff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh\nindex 537787e598..78cd86be3a 100755\n--- a/t/t7064-wtstatus-pv2.sh\n+++ b/t/t7064-wtstatus-pv2.sh\n@@ -503,6 +503,31 @@ test_expect_success 'untracked changes in added submodule (AM S..U)' '\n \t\t1 AM S..U 000000 160000 160000 $ZERO_OID $HSUB sub1\n \t\tEOF\n \n+\t\tgit status --porcelain=v2 --branch --untracked-files=all --ignore-submodules=none >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'untracked changes in added submodule (A. S...) (untracked ignored)' '\n+\t(\tcd super_repo &&\n+\t\t## create untracked file in the submodule.\n+\t\t(\tcd sub1 &&\n+\t\t\techo \"xxxx\" >file_in_sub\n+\t\t) &&\n+\n+\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n+\t\tHSUP=$(git rev-parse HEAD) &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n+\t\t1 A. S... 000000 160000 160000 $ZERO_OID $HSUB sub1\n+\t\tEOF\n+\n \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n \t\ttest_cmp expect actual\n \t)\n@@ -582,6 +607,33 @@ test_expect_success 'staged and untracked changes in added submodule (AM S.MU)'\n \t\t1 AM S.MU 000000 160000 160000 $ZERO_OID $HSUB sub1\n \t\tEOF\n \n+\t\tgit status --porcelain=v2 --branch --untracked-files=all --ignore-submodules=none >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'staged and untracked changes in added submodule (AM S.M.) (untracked ignored)' '\n+\t(\tcd super_repo &&\n+\t\t(\tcd sub1 &&\n+\t\t\t## stage new changes in tracked file.\n+\t\t\tgit add file_in_sub &&\n+\t\t\t## create new untracked file.\n+\t\t\techo \"yyyy\" >>another_file_in_sub\n+\t\t) &&\n+\n+\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n+\t\tHSUP=$(git rev-parse HEAD) &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n+\t\t1 AM S.M. 000000 160000 160000 $ZERO_OID $HSUB sub1\n+\t\tEOF\n+\n \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n \t\ttest_cmp expect actual\n \t)\ndiff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh\nindex 3fcb44767f..72da00a962 100755\n--- a/t/t7506-status-submodule.sh\n+++ b/t/t7506-status-submodule.sh\n@@ -94,36 +94,60 @@ test_expect_success 'status with added file in submodule (short)' '\n test_expect_success 'status with untracked file in submodule' '\n \t(cd sub && git reset --hard) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (untracked content)\" output\n '\n \n+test_expect_success 'status with untracked file in submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"^nothing to commit\" output\n+'\n+\n test_expect_success 'status -uno with untracked file in submodule' '\n \tgit status -uno >output &&\n \ttest_i18ngrep \"^nothing to commit\" output\n '\n \n test_expect_success 'status with untracked file in submodule (porcelain)' '\n-\tgit status --porcelain >output &&\n+\tgit status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in submodule (porcelain) (untracked ignored)' '\n+\tgit status --porcelain >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in submodule (short)' '\n-\tgit status --short >output &&\n+\tgit status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t ? sub\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in submodule (short) (untracked ignored)' '\n+\tgit status --short >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with added and untracked file in submodule' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (modified content, untracked content)\" output\n '\n \n+test_expect_success 'status with added and untracked file in submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard && echo >foo && git add foo) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (modified content)\" output\n+'\n+\n test_expect_success 'status with added and untracked file in submodule (porcelain)' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n@@ -168,10 +192,17 @@ test_expect_success 'status with added file in modified submodule (porcelain)' '\n test_expect_success 'status with untracked file in modified submodule' '\n \t(cd sub && git reset --hard) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (new commits, untracked content)\" output\n '\n \n+test_expect_success 'status with untracked file in modified submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (new commits)\" output\n+'\n+\n test_expect_success 'status with untracked file in modified submodule (porcelain)' '\n \tgit status --porcelain >output &&\n \tdiff output - <<-\\EOF\n@@ -182,10 +213,17 @@ test_expect_success 'status with untracked file in modified submodule (porcelain\n test_expect_success 'status with added and untracked file in modified submodule' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (new commits, modified content, untracked content)\" output\n '\n \n+test_expect_success 'status with added and untracked file in modified submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard && echo >foo && git add foo) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (new commits, modified content)\" output\n+'\n+\n test_expect_success 'status with added and untracked file in modified submodule (porcelain)' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n@@ -349,7 +387,7 @@ test_expect_success 'setup superproject with untracked file in nested submodule'\n '\n \n test_expect_success 'status with untracked file in nested submodule (porcelain)' '\n-\tgit -C super status --porcelain >output &&\n+\tgit -C super status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub1\n \t M sub2\n@@ -357,8 +395,13 @@ test_expect_success 'status with untracked file in nested submodule (porcelain)'\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (porcelain) (untracked ignored)' '\n+\tgit -C super status --porcelain >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in nested submodule (porcelain=2)' '\n-\tgit -C super status --porcelain=2 >output &&\n+\tgit -C super status --porcelain=2 --ignore-submodules=none >output &&\n \tsanitize_output output &&\n \tdiff output - <<-\\EOF\n \t1 .M S..U 160000 160000 160000 HASH HASH sub1\n@@ -367,8 +410,13 @@ test_expect_success 'status with untracked file in nested submodule (porcelain=2\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (porcelain=2) (untracked ignored)' '\n+\tgit -C super status --porcelain=2 >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in nested submodule (short)' '\n-\tgit -C super status --short >output &&\n+\tgit -C super status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t ? sub1\n \t ? sub2\n@@ -376,13 +424,18 @@ test_expect_success 'status with untracked file in nested submodule (short)' '\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (short) (untracked ignored)' '\n+\tgit -C super status --short >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'setup superproject with modified file in nested submodule' '\n \tgit -C super/sub1/sub2 add file &&\n \tgit -C super/sub2 add file\n '\n \n test_expect_success 'status with added file in nested submodule (porcelain)' '\n-\tgit -C super status --porcelain >output &&\n+\tgit -C super status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub1\n \t M sub2\n@@ -390,8 +443,16 @@ test_expect_success 'status with added file in nested submodule (porcelain)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (porcelain) (untracked ignored)' '\n+\tgit -C super status --porcelain >output &&\n+\tdiff output - <<-\\EOF\n+\t M sub1\n+\t M sub2\n+\tEOF\n+'\n+\n test_expect_success 'status with added file in nested submodule (porcelain=2)' '\n-\tgit -C super status --porcelain=2 >output &&\n+\tgit -C super status --porcelain=2 --ignore-submodules=none >output &&\n \tsanitize_output output &&\n \tdiff output - <<-\\EOF\n \t1 .M S.M. 160000 160000 160000 HASH HASH sub1\n@@ -400,8 +461,17 @@ test_expect_success 'status with added file in nested submodule (porcelain=2)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (porcelain=2) (untracked ignored)' '\n+\tgit -C super status --porcelain=2 >output &&\n+\tsanitize_output output &&\n+\tdiff output - <<-\\EOF\n+\t1 .M S.M. 160000 160000 160000 HASH HASH sub1\n+\t1 .M S.M. 160000 160000 160000 HASH HASH sub2\n+\tEOF\n+'\n+\n test_expect_success 'status with added file in nested submodule (short)' '\n-\tgit -C super status --short >output &&\n+\tgit -C super status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t m sub1\n \t m sub2\n@@ -409,4 +479,12 @@ test_expect_success 'status with added file in nested submodule (short)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (short) (untracked ignored)' '\n+\tgit -C super status --short >output &&\n+\tdiff output - <<-\\EOF\n+\t m sub1\n+\t m sub2\n+\tEOF\n+'\n+\n test_done\n-- \n2.21.1 (Apple Git-122.3)\n\n"},{"id":"408074","messageId":"CAPig+cSi1SSZTS86-6_0gDCeDqPCEvT+Lh3gLXe--Y1PDJSDfw@mail.gmail.com","threadId":"54429","inReplyTo":"20201021131012.20703-1-sangunb09@gmail.com","subject":"Re: [Outreachy] [PATCH v2] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2020-10-21T17:43:03Z","receivedAt":"2020-10-21T17:43:18Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Oct 21, 2020 at 9:10 AM Sangeeta Jain <sangunb09@gmail.com> wrote:\n> [...]\n> This patch makes `git diff HEAD` consistent with `git describe --dirty`\n> when a submodule contains untracked files by making\n> `--ignore-submodules=untracked` the default.\n> [...]\n> Signed-off-by: Sangeeta Jain <sangunb09@gmail.com>\n> ---\n> diff --git a/diff.c b/diff.c\n> @@ -4585,6 +4585,9 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)\n> +       if(!options->flags.ignore_submodule_set)\n> +               options->flags.ignore_untracked_in_submodules = 1;\n\nStyle nit: insert a space between 'if' and the opening parenthesis\n\n> diff --git a/submodule.c b/submodule.c\n> @@ -1678,6 +1679,8 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)\n>         if (ignore_untracked)\n>                 strvec_push(&cp.args, \"-uno\");\n> +       else\n> +        strvec_push (&cp.args, \"--ignore-submodules=none\");\n\nStyle nit: use TAB for indentation, not spaces\n\nStyle nit: drop space between 'strvec_push' and open parenthesis\n\n> diff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh\n> @@ -503,6 +503,31 @@ test_expect_success 'untracked changes in added submodule (AM S..U)' '\n> +test_expect_success 'untracked changes in added submodule (A. S...) (untracked ignored)' '\n> +       (       cd super_repo &&\n> +               ## create untracked file in the submodule.\n> +               (       cd sub1 &&\n> +                       echo \"xxxx\" >file_in_sub\n> +               ) &&\n\nI realize that you're following style of some, but not all tests, in\nthis file, but current the way we format subshells these days is:\n\n    (\n        cd foo &&\n        ...\n    ) &&\n\nWhether you should adopt modern style or use existing style is a\njudgment call. (If I was doing this, I might be inclined to follow\nmodern style rather than introducing even more of the unwanted old\nstyle.)\n\nBut for really silly stuff like the 'echo', you don't need a subshell\nat all, so it would be cleaner to write it like this without the\nsubshell:\n\n    echo \"xxxx\" >sub1/file_in_sub &&\n\n(But again, I see that you're just following local style.)\n\n> +test_expect_success 'staged and untracked changes in added submodule (AM S.M.) (untracked ignored)' '\n> +       (       cd super_repo &&\n> +               (       cd sub1 &&\n> +                       ## stage new changes in tracked file.\n> +                       git add file_in_sub &&\n> +                       ## create new untracked file.\n> +                       echo \"yyyy\" >>another_file_in_sub\n> +               ) &&\n\nThese days, `git` also understands -C, so this subshell likewise is\nnot necessary, and:\n\n    git -C sub1 add file_in_sub &&\n    echo \"yyyy\" >>sub1/another_file_in_sub\n\nwould be equivalent. (But perhaps that diverges too much from existing\nstyle in the file? It's a judgment call.)\n\n> diff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh\n> @@ -94,36 +94,60 @@ test_expect_success 'status with added file in submodule (short)' '\n> +test_expect_success 'status with untracked file in submodule (untracked ignored)' '\n> +       (cd sub && git reset --hard) &&\n\nThese one-liner subshells are super common in this particular script.\nThese days we'd write this as:\n\n    git -C sub reset --hard &&\n\nAgain, it's a judgment call whether to go with modern style or follow\nexisting style of the file.\n\nAnother option is to have a preparatory patch which first modernizes\nthe script, and then your new tests would follow modern style. But,\nthat may be outside of scope of your submission.\n\nTo summarize: The only really actionable review comments are the minor\nstyle nits in the C code. The nits about style issues in the tests are\njudgement calls, and could be handled (by someone) at a later date.\n"},{"id":"408086","messageId":"CAHjREB6Agm9Nia2+e4=1zAJ6Y3NXgPQLmN_he1353ScaznK5hQ@mail.gmail.com","threadId":"54429","inReplyTo":"CAPig+cSi1SSZTS86-6_0gDCeDqPCEvT+Lh3gLXe--Y1PDJSDfw@mail.gmail.com","subject":"Re: [Outreachy] [PATCH v2] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta NB","fromEmail":"sangunb09@gmail.com","sentAt":"2020-10-21T19:40:21Z","receivedAt":"2020-10-21T19:40:35Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"Hey,\n\n> Again, it's a judgment call whether to go with modern style or follow\n> existing style of the file.\n>\n> Another option is to have a preparatory patch which first modernizes\n> the script, and then your new tests would follow modern style. But,\n> that may be outside of scope of your submission.\n>\n> To summarize: The only really actionable review comments are the minor\n> style nits in the C code. The nits about style issues in the tests are\n> judgement calls, and could be handled (by someone) at a later date.\n\nThanks for the feedback, Eric. I would add the style nits in the\nupcoming patch.\n\nFor the style issues in the tests maybe what I can do is I can submit\nanother patch with this patch to modernize the test scripts of these\nfiles? I am expecting some feedback from the community on how to\nhandle this.\n"},{"id":"408124","messageId":"CAPig+cRLGsSzHZ-280WJD1vMLvK-kL2EEg3mc8gFiEEa8Tj6Aw@mail.gmail.com","threadId":"54429","inReplyTo":"CAHjREB6Agm9Nia2+e4=1zAJ6Y3NXgPQLmN_he1353ScaznK5hQ@mail.gmail.com","subject":"Re: [Outreachy] [PATCH v2] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2020-10-21T23:04:51Z","receivedAt":"2020-10-21T23:05:05Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Oct 21, 2020 at 3:40 PM Sangeeta NB <sangunb09@gmail.com> wrote:\n> > Another option is to have a preparatory patch which first modernizes\n> > the script, and then your new tests would follow modern style. But,\n> > that may be outside of scope of your submission.\n> >\n> > To summarize: The only really actionable review comments are the minor\n> > style nits in the C code. The nits about style issues in the tests are\n> > judgement calls, and could be handled (by someone) at a later date.\n>\n> For the style issues in the tests maybe what I can do is I can submit\n> another patch with this patch to modernize the test scripts of these\n> files? I am expecting some feedback from the community on how to\n> handle this.\n\nIf this is a microproject, then it probably makes sense just to fix\nthe remaining style nits in the C code, and leave it at that.\n\nEven if this is not a microproject, the answer really depends upon how\nmuch time and effort you want to devote to this. As a reviewer, I\ndon't demand or expect you to fix all the problems in the old test\nscripts just to get the change accepted which prompted your submission\nin the first place. It's important to focus on that first rather than\ngetting sidetracked working on stuff which may not be important to\nyour primary goal. Also, keep in mind that fixing all the style issues\nin those old test scripts may require multiple preparatory patches,\nrather than just one, and multiple re-rolls, which could end up eating\nup a lot of extra time to get it all polished properly.\n\nFor these reasons, I'm inclined to suggest polishing the current\nsubmission to get it accepted. Then decide afterward if you want to\ndevote time to working on these ancillary tasks.\n"},{"id":"408163","messageId":"20201022112201.51459-1-sangunb09@gmail.com","threadId":"54429","inReplyTo":"pull.751.git.1602781723670.gitgitgadget@gmail.com","subject":"[Outreachy] [PATCH v3] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta Jain","fromEmail":"sangunb09@gmail.com","sentAt":"2020-10-22T11:22:01Z","receivedAt":"2020-10-22T11:22:17Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"From: sangu09 <sangunb09@gmail.com>\n\nGit diff reports a submodule directory as -dirty even when there are\nonly untracked files in the submodule directory.\nThis is inconsistent with what `git describe --dirty` says when run in\nthe submodule directory in that state.\n\nThis patch makes `git diff HEAD` consistent with `git describe --dirty`\nwhen a submodule contains untracked files by making\n`--ignore-submodules=untracked` the default.\n\nAlso, to avoid `ignoreSubmodules` in user config being overwritten,\nI have made added a flag in diff_flags to keep a track whether\n`handle_ignore_submodules_arg` is called before or not.\n\nSigned-off-by: Sangeeta Jain <sangunb09@gmail.com>\n---\n diff.c                                       |   3 +\n diff.h                                       |   1 +\n submodule.c                                  |   5 +-\n t/t3701-add-interactive.sh                   |   2 +-\n t/t4027-diff-submodule.sh                    |  15 ++-\n t/t4041-diff-submodule-option.sh             |  16 +--\n t/t4060-diff-submodule-option-diff-format.sh |  16 +--\n t/t7064-wtstatus-pv2.sh                      |  52 ++++++++++\n t/t7506-status-submodule.sh                  | 102 ++++++++++++++++---\n 9 files changed, 179 insertions(+), 33 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 2bb2f8f57e..5a80695da8 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4585,6 +4585,9 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)\n \t\tDIFF_XDL_SET(options, INDENT_HEURISTIC);\n \n \toptions->orderfile = diff_order_file_cfg;\n+\t\n+\tif (!options->flags.ignore_submodule_set)\n+\t\toptions->flags.ignore_untracked_in_submodules = 1;\n \n \tif (diff_no_prefix) {\n \t\toptions->a_prefix = options->b_prefix = \"\";\ndiff --git a/diff.h b/diff.h\nindex 11de52e9e9..1e18e6b1c3 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -178,6 +178,7 @@ struct diff_flags {\n \tunsigned diff_from_contents;\n \tunsigned dirty_submodules;\n \tunsigned ignore_untracked_in_submodules;\n+\tunsigned ignore_submodule_set;\n \tunsigned ignore_dirty_submodules;\n \tunsigned override_submodule_config;\n \tunsigned dirstat_by_line;\ndiff --git a/submodule.c b/submodule.c\nindex b3bb59f066..a7956e1539 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -420,6 +420,7 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy\n void handle_ignore_submodules_arg(struct diff_options *diffopt,\n \t\t\t\t  const char *arg)\n {\n+\tdiffopt->flags.ignore_submodule_set = 1;\n \tdiffopt->flags.ignore_submodules = 0;\n \tdiffopt->flags.ignore_untracked_in_submodules = 0;\n \tdiffopt->flags.ignore_dirty_submodules = 0;\n@@ -1677,7 +1678,9 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)\n \n \tstrvec_pushl(&cp.args, \"status\", \"--porcelain=2\", NULL);\n \tif (ignore_untracked)\n-\t\tstrvec_push(&cp.args, \"-uno\");\n+\t\tstrvec_push (&cp.args, \"-uno\");\n+\telse\n+    \tstrvec_push (&cp.args, \"--ignore-submodules=none\");\n \n \tprepare_submodule_repo_env(&cp.env_array);\n \tcp.git_cmd = 1;\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex ca04fac417..98e46ad1ae 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -761,7 +761,7 @@ test_expect_success 'setup different kinds of dirty submodules' '\n \t\techo dirty >>initial &&\n \t\t: >untracked\n \t) &&\n-\tgit -C for-submodules diff-files --name-only >actual &&\n+\tgit -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&\n \tcat >expected <<-\\EOF &&\n \tdirty-both-ways\n \tdirty-head\ndiff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\nindex d7145ccca4..6432b4331f 100755\n--- a/t/t4027-diff-submodule.sh\n+++ b/t/t4027-diff-submodule.sh\n@@ -93,10 +93,19 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked)' '\n \t) &&\n \tgit diff HEAD >actual &&\n \tsed -e \"1,/^@@/d\" actual >actual.body &&\n-\texpect_from_to >expect.body $subtip $subprev-dirty &&\n+\texpect_from_to >expect.body $subtip $subprev &&\n \ttest_cmp expect.body actual.body\n '\n \n+test_expect_success 'git diff HEAD with dirty submodule (untracked) (none ignored)' '\n+\tgit config diff.ignoreSubmodules none &&\n+\tgit diff HEAD >actual &&\n+\tsed -e \"1,/^@@/d\" actual >actual.body &&\n+\texpect_from_to >expect.body $subtip $subprev-dirty &&\n+\ttest_cmp expect.body actual.body &&\n+\tgit config --unset diff.ignoreSubmodules\n+'\n+\n test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)' '\n \tgit commit -m \"x\" sub &&\n \techo >>sub/world &&\n@@ -168,13 +177,13 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'\n \t\tgit clean -qfdx &&\n \t\t>cruft\n \t) &&\n-\tgit diff HEAD >actual &&\n+\tgit diff --ignore-submodules=none HEAD >actual &&\n \tsed -e \"1,/^@@/d\" actual >actual.body &&\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual.body &&\n \tgit diff --ignore-submodules=all HEAD >actual2 &&\n \ttest_must_be_empty actual2 &&\n-\tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n+\tgit diff HEAD >actual3 &&\n \ttest_must_be_empty actual3 &&\n \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n \ttest_must_be_empty actual4\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex f852136585..bb368b685d 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -262,7 +262,7 @@ test_expect_success 'submodule is up to date' '\n \n test_expect_success 'submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tEOF\n@@ -270,7 +270,7 @@ test_expect_success 'submodule contains untracked content' '\n '\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \ttest_must_be_empty actual\n '\n \n@@ -286,7 +286,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n \n test_expect_success 'submodule contains untracked and modified content' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -296,7 +296,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n \n test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tEOF\n@@ -337,7 +337,7 @@ test_expect_success 'submodule is modified' '\n \n test_expect_success 'modified submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p  --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 $head6..$head8:\n@@ -347,7 +347,7 @@ test_expect_success 'modified submodule contains untracked content' '\n '\n \n test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 $head6..$head8:\n \t  > change\n@@ -371,7 +371,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n \n test_expect_success 'modified submodule contains untracked and modified content' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -383,7 +383,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n \n test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tSubmodule sm1 $head6..$head8:\ndiff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh\nindex fc8229c726..dc7b242697 100755\n--- a/t/t4060-diff-submodule-option-diff-format.sh\n+++ b/t/t4060-diff-submodule-option-diff-format.sh\n@@ -409,7 +409,7 @@ test_expect_success 'submodule is up to date' '\n \n test_expect_success 'submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tEOF\n@@ -417,7 +417,7 @@ test_expect_success 'submodule contains untracked content' '\n '\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \ttest_must_be_empty actual\n '\n \n@@ -433,7 +433,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n \n test_expect_success 'submodule contains untracked and modified content' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -451,7 +451,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n # NOT OK\n test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tdiff --git a/sm1/foo6 b/sm1/foo6\n@@ -512,7 +512,7 @@ test_expect_success 'submodule is modified' '\n \n test_expect_success 'modified submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 $head7..$head8:\n@@ -528,7 +528,7 @@ test_expect_success 'modified submodule contains untracked content' '\n '\n \n test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 $head7..$head8:\n \tdiff --git a/sm1/foo6 b/sm1/foo6\n@@ -564,7 +564,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n \n test_expect_success 'modified submodule contains untracked and modified content' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -583,7 +583,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n \n test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tSubmodule sm1 $head7..$head8:\ndiff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh\nindex 537787e598..78cd86be3a 100755\n--- a/t/t7064-wtstatus-pv2.sh\n+++ b/t/t7064-wtstatus-pv2.sh\n@@ -503,6 +503,31 @@ test_expect_success 'untracked changes in added submodule (AM S..U)' '\n \t\t1 AM S..U 000000 160000 160000 $ZERO_OID $HSUB sub1\n \t\tEOF\n \n+\t\tgit status --porcelain=v2 --branch --untracked-files=all --ignore-submodules=none >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'untracked changes in added submodule (A. S...) (untracked ignored)' '\n+\t(\tcd super_repo &&\n+\t\t## create untracked file in the submodule.\n+\t\t(\tcd sub1 &&\n+\t\t\techo \"xxxx\" >file_in_sub\n+\t\t) &&\n+\n+\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n+\t\tHSUP=$(git rev-parse HEAD) &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n+\t\t1 A. S... 000000 160000 160000 $ZERO_OID $HSUB sub1\n+\t\tEOF\n+\n \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n \t\ttest_cmp expect actual\n \t)\n@@ -582,6 +607,33 @@ test_expect_success 'staged and untracked changes in added submodule (AM S.MU)'\n \t\t1 AM S.MU 000000 160000 160000 $ZERO_OID $HSUB sub1\n \t\tEOF\n \n+\t\tgit status --porcelain=v2 --branch --untracked-files=all --ignore-submodules=none >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'staged and untracked changes in added submodule (AM S.M.) (untracked ignored)' '\n+\t(\tcd super_repo &&\n+\t\t(\tcd sub1 &&\n+\t\t\t## stage new changes in tracked file.\n+\t\t\tgit add file_in_sub &&\n+\t\t\t## create new untracked file.\n+\t\t\techo \"yyyy\" >>another_file_in_sub\n+\t\t) &&\n+\n+\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n+\t\tHSUP=$(git rev-parse HEAD) &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n+\t\t1 AM S.M. 000000 160000 160000 $ZERO_OID $HSUB sub1\n+\t\tEOF\n+\n \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n \t\ttest_cmp expect actual\n \t)\ndiff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh\nindex 3fcb44767f..72da00a962 100755\n--- a/t/t7506-status-submodule.sh\n+++ b/t/t7506-status-submodule.sh\n@@ -94,36 +94,60 @@ test_expect_success 'status with added file in submodule (short)' '\n test_expect_success 'status with untracked file in submodule' '\n \t(cd sub && git reset --hard) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (untracked content)\" output\n '\n \n+test_expect_success 'status with untracked file in submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"^nothing to commit\" output\n+'\n+\n test_expect_success 'status -uno with untracked file in submodule' '\n \tgit status -uno >output &&\n \ttest_i18ngrep \"^nothing to commit\" output\n '\n \n test_expect_success 'status with untracked file in submodule (porcelain)' '\n-\tgit status --porcelain >output &&\n+\tgit status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in submodule (porcelain) (untracked ignored)' '\n+\tgit status --porcelain >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in submodule (short)' '\n-\tgit status --short >output &&\n+\tgit status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t ? sub\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in submodule (short) (untracked ignored)' '\n+\tgit status --short >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with added and untracked file in submodule' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (modified content, untracked content)\" output\n '\n \n+test_expect_success 'status with added and untracked file in submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard && echo >foo && git add foo) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (modified content)\" output\n+'\n+\n test_expect_success 'status with added and untracked file in submodule (porcelain)' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n@@ -168,10 +192,17 @@ test_expect_success 'status with added file in modified submodule (porcelain)' '\n test_expect_success 'status with untracked file in modified submodule' '\n \t(cd sub && git reset --hard) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (new commits, untracked content)\" output\n '\n \n+test_expect_success 'status with untracked file in modified submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (new commits)\" output\n+'\n+\n test_expect_success 'status with untracked file in modified submodule (porcelain)' '\n \tgit status --porcelain >output &&\n \tdiff output - <<-\\EOF\n@@ -182,10 +213,17 @@ test_expect_success 'status with untracked file in modified submodule (porcelain\n test_expect_success 'status with added and untracked file in modified submodule' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (new commits, modified content, untracked content)\" output\n '\n \n+test_expect_success 'status with added and untracked file in modified submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard && echo >foo && git add foo) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (new commits, modified content)\" output\n+'\n+\n test_expect_success 'status with added and untracked file in modified submodule (porcelain)' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n@@ -349,7 +387,7 @@ test_expect_success 'setup superproject with untracked file in nested submodule'\n '\n \n test_expect_success 'status with untracked file in nested submodule (porcelain)' '\n-\tgit -C super status --porcelain >output &&\n+\tgit -C super status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub1\n \t M sub2\n@@ -357,8 +395,13 @@ test_expect_success 'status with untracked file in nested submodule (porcelain)'\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (porcelain) (untracked ignored)' '\n+\tgit -C super status --porcelain >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in nested submodule (porcelain=2)' '\n-\tgit -C super status --porcelain=2 >output &&\n+\tgit -C super status --porcelain=2 --ignore-submodules=none >output &&\n \tsanitize_output output &&\n \tdiff output - <<-\\EOF\n \t1 .M S..U 160000 160000 160000 HASH HASH sub1\n@@ -367,8 +410,13 @@ test_expect_success 'status with untracked file in nested submodule (porcelain=2\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (porcelain=2) (untracked ignored)' '\n+\tgit -C super status --porcelain=2 >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in nested submodule (short)' '\n-\tgit -C super status --short >output &&\n+\tgit -C super status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t ? sub1\n \t ? sub2\n@@ -376,13 +424,18 @@ test_expect_success 'status with untracked file in nested submodule (short)' '\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (short) (untracked ignored)' '\n+\tgit -C super status --short >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'setup superproject with modified file in nested submodule' '\n \tgit -C super/sub1/sub2 add file &&\n \tgit -C super/sub2 add file\n '\n \n test_expect_success 'status with added file in nested submodule (porcelain)' '\n-\tgit -C super status --porcelain >output &&\n+\tgit -C super status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub1\n \t M sub2\n@@ -390,8 +443,16 @@ test_expect_success 'status with added file in nested submodule (porcelain)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (porcelain) (untracked ignored)' '\n+\tgit -C super status --porcelain >output &&\n+\tdiff output - <<-\\EOF\n+\t M sub1\n+\t M sub2\n+\tEOF\n+'\n+\n test_expect_success 'status with added file in nested submodule (porcelain=2)' '\n-\tgit -C super status --porcelain=2 >output &&\n+\tgit -C super status --porcelain=2 --ignore-submodules=none >output &&\n \tsanitize_output output &&\n \tdiff output - <<-\\EOF\n \t1 .M S.M. 160000 160000 160000 HASH HASH sub1\n@@ -400,8 +461,17 @@ test_expect_success 'status with added file in nested submodule (porcelain=2)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (porcelain=2) (untracked ignored)' '\n+\tgit -C super status --porcelain=2 >output &&\n+\tsanitize_output output &&\n+\tdiff output - <<-\\EOF\n+\t1 .M S.M. 160000 160000 160000 HASH HASH sub1\n+\t1 .M S.M. 160000 160000 160000 HASH HASH sub2\n+\tEOF\n+'\n+\n test_expect_success 'status with added file in nested submodule (short)' '\n-\tgit -C super status --short >output &&\n+\tgit -C super status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t m sub1\n \t m sub2\n@@ -409,4 +479,12 @@ test_expect_success 'status with added file in nested submodule (short)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (short) (untracked ignored)' '\n+\tgit -C super status --short >output &&\n+\tdiff output - <<-\\EOF\n+\t m sub1\n+\t m sub2\n+\tEOF\n+'\n+\n test_done\n-- \n2.21.1 (Apple Git-122.3)\n\n"},{"id":"408180","messageId":"xmqqft66m8wm.fsf@gitster.c.googlers.com","threadId":"54429","inReplyTo":"20201022112201.51459-1-sangunb09@gmail.com","subject":"Re: [Outreachy] [PATCH v3] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-10-22T18:07:37Z","receivedAt":"2020-10-22T18:07:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sangeeta Jain <sangunb09@gmail.com> writes:\n\n> From: sangu09 <sangunb09@gmail.com>\n\nOops?\n\n> Git diff reports a submodule directory as -dirty even when there are\n> only untracked files in the submodule directory.\n> This is inconsistent with what `git describe --dirty` says when run in\n> the submodule directory in that state.\n\nNicely written.\n\n> This patch makes `git diff HEAD` consistent with `git describe --dirty`\n> when a submodule contains untracked files by making\n> `--ignore-submodules=untracked` the default.\n\nInstead of explaining \"This patch makes...\", it is more common to\ngive an order to the codebase, i.e. \"Make...\".\n\n> Also, to avoid `ignoreSubmodules` in user config being overwritten,\n> I have made added a flag in diff_flags to keep a track whether\n> `handle_ignore_submodules_arg` is called before or not.\n\nWell, that is not \"Also\"; it is an integral part of making\n\"--ignore-submodules=untracked\" the _default_.  We need to make sure\nthat end-user configuration would be honored, and we need to make\nsure that the command line option would be honored, too.\n\nI'd suggest to follow the excellent first paragraph above with\nsomething like the following.\n\n\tMake `--ignore-submodules=untracked` the default for `git\n\tdiff` when there is no configuration variable or command\n\tline option, so that the command would not give '-dirty'\n\tsuffix to a submodule whose working tree has untracked\n\tfiles, to make it consistent with `git describe --dirty`\n\tthat is run in the submodule working tree.\n\n\n> @@ -4585,6 +4585,9 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)\n>  \t\tDIFF_XDL_SET(options, INDENT_HEURISTIC);\n>  \n>  \toptions->orderfile = diff_order_file_cfg;\n> +\t\n> +\tif (!options->flags.ignore_submodule_set)\n\nThis new boolean is meant to be set only when non-default\nignore-submodules option is given either from the command line or\nfrom the configuration---when the bit is unset, we are told to do\nwhatever it is that is the default for us.\n\n> +\t\toptions->flags.ignore_untracked_in_submodules = 1;\n\nAnd the default is to flip only this bit on.  Do we need to turn off\nother bits that submodule.c::handle_ignore_submodules_arg() function\ntouches?  [*1*]\n\n> diff --git a/diff.h b/diff.h\n> index 11de52e9e9..1e18e6b1c3 100644\n> --- a/diff.h\n> +++ b/diff.h\n> @@ -178,6 +178,7 @@ struct diff_flags {\n>  \tunsigned diff_from_contents;\n>  \tunsigned dirty_submodules;\n>  \tunsigned ignore_untracked_in_submodules;\n> +\tunsigned ignore_submodule_set;\n>  \tunsigned ignore_dirty_submodules;\n>  \tunsigned override_submodule_config;\n>  \tunsigned dirstat_by_line;\n> diff --git a/submodule.c b/submodule.c\n> index b3bb59f066..a7956e1539 100644\n> --- a/submodule.c\n> +++ b/submodule.c\n> @@ -420,6 +420,7 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy\n>  void handle_ignore_submodules_arg(struct diff_options *diffopt,\n>  \t\t\t\t  const char *arg)\n>  {\n> +\tdiffopt->flags.ignore_submodule_set = 1;\n\nI like the general idea of having one bit that is set if and only if\nthe command line or configuration told us specifically what to do,\nso that we can dictate the default after they were taken care of.\n\nBut I am not sure if this is a good implementation of that idea.  \n\nCase in point.  I was wondering if the most future-proof way to\nanswer the question I asked (marked with [*1*] above) was to avoid\nflipping the bits in options->flags ourselves, but to make a call\n\n\thandle_ignore_submodules_arg(&options, \"untracked\");\n\nin repo_diff_setup().  When such an improvement is made after this\npatch lands, the assumption that only the end-user preference will\ncall this function no longer holds.\n\nEven without anticipating such a change in the future, there already\nis a callsite of this function in wt-status.c that hands a hardcoded\nstring \"dirty\" to it.  That is *not* caused by an end-user request\n(be it a configuration variable or a command line option), so in a\nsense, the assumption is already broken.\n\nI wonder, if we can do things in a more natural way (at least the\nnatural way in this codebase).  Usually we do things in this order:\n\n - initialize the status and option variables to their default state.\n\n - read the configuration files to allow the state of these\n   variables to be modified from their default state.\n\n - parse the command line arguments to further allow the state of\n   these variables to be modified.\n\nand then use the final state of these variables.  That way, we do\nnot even need the extra bit that is only required if we did things\nin an unnatural way, which is\n\n - read the config; remember if any bits were toggled\n - parse the command line; remember if any bits were toggled\n - only if bits weren't toggled in the above, set the default\n\nI dunno.\n\n> @@ -1677,7 +1678,9 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)\n>  \n>  \tstrvec_pushl(&cp.args, \"status\", \"--porcelain=2\", NULL);\n>  \tif (ignore_untracked)\n> -\t\tstrvec_push(&cp.args, \"-uno\");\n> +\t\tstrvec_push (&cp.args, \"-uno\");\n\nNoise.\n\n> +\telse\n> +    \tstrvec_push (&cp.args, \"--ignore-submodules=none\");\n\nMisindented.\n"},{"id":"408202","messageId":"CAHjREB4qGO1=XCy-F+H39FP_KU_zZjKCDA=b9JxCe0WZdM06KQ@mail.gmail.com","threadId":"54429","inReplyTo":"xmqqft66m8wm.fsf@gitster.c.googlers.com","subject":"Re: [Outreachy] [PATCH v3] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta NB","fromEmail":"sangunb09@gmail.com","sentAt":"2020-10-23T05:23:19Z","receivedAt":"2020-10-23T05:23:34Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"Hey,\n\nSorry for sending it over and over again. I couldn't figure out why\nthe mail is not reaching the community.\n\n>\n> Oops?\n>\n\nSorry about this. Would correct it in the next patch.\n\n> I'd suggest to follow the excellent first paragraph above with\n> something like the following.\n>\n>         Make `--ignore-submodules=untracked` the default for `git\n>         diff` when there is no configuration variable or command\n>         line option, so that the command would not give '-dirty'\n>         suffix to a submodule whose working tree has untracked\n>         files, to make it consistent with `git describe --dirty`\n>         that is run in the submodule working tree.\n\nVery well written. Would update the description to this. Thanks.\n\n> This new boolean is meant to be set only when non-default\n> ignore-submodules option is given either from the command line or\n> from the configuration---when the bit is unset, we are told to do\n> whatever it is that is the default for us.\n\nI fear I might not get your question clearly here. But from what I\nunderstood this boolean( flags.ignore_submodule_set )  is set only\nwhen diff.ignoreSubmodules is set in user-config.\n\n> And the default is to flip only this bit on.  Do we need to turn off\n> other bits that submodule.c::handle_ignore_submodules_arg() function\n> touches?  [*1*]\n>\n\nWe are not flipping the bit, we are setting it to 1. I guess we don't\nhave to turn off other bits because in case if\nsubmodule.c::handle_ignore_submodules_arg() is called we don't have to\nset the default value. So there's no point in flipping any other bits\nas if any of them is set, the user should have added some arguments in\n ignoreSubmodules and therefore flags.ignore_submodule_set would be\nset to 1 and we won't be setting the default value.\n\n>\n> I like the general idea of having one bit that is set if and only if\n> the command line or configuration told us specifically what to do,\n> so that we can dictate the default after they were taken care of.\n>\n> But I am not sure if this is a good implementation of that idea.\n>\n> Case in point.  I was wondering if the most future-proof way to\n> answer the question I asked (marked with [*1*] above) was to avoid\n> flipping the bits in options->flags ourselves, but to make a call\n>\n>         handle_ignore_submodules_arg(&options, \"untracked\");\n>\n> in repo_diff_setup().  When such an improvement is made after this\n> patch lands, the assumption that only the end-user preference will\n> call this function no longer holds.\n\nI tried making the call directly like this:\nhandle_ignore_submodules_arg(&options, \"untracked\") without using the\nextra bit, but in the case when the user specifies\ndiff.ignoreSubmodules in user-config, the\nhandle_ignore_submodules_arg() is called even before repo_diff_setup()\nand therefore the default value overwrites the value mentioned in\nuser-config.\n\n> Even without anticipating such a change in the future, there already\n> is a callsite of this function in wt-status.c that hands a hardcoded\n> string \"dirty\" to it.  That is *not* caused by an end-user request\n> (be it a configuration variable or a command line option), so in a\n> sense, the assumption is already broken.\n>\n\nI couldn't fully understand what assumption are you talking about. I\nwould be glad if you can explain it to me in a little more detail.\nThanks!\n\n> I wonder, if we can do things in a more natural way (at least the\n> natural way in this codebase).  Usually we do things in this order:\n>\n>  - initialize the status and option variables to their default state.\n>\n>  - read the configuration files to allow the state of these\n>    variables to be modified from their default state.\n>\n>  - parse the command line arguments to further allow the state of\n>    these variables to be modified.\n>\n> and then use the final state of these variables.  That way, we do\n> not even need the extra bit that is only required if we did things\n> in an unnatural way, which is\n>\n>  - read the config; remember if any bits were toggled\n>  - parse the command line; remember if any bits were toggled\n>  - only if bits weren't toggled in the above, set the default\n>\n> I dunno.\n\nYa, that makes sense. I would look into when the config values are\nbeing read and bits are set and would try to find a way so that we can\nget rid of the extra bit. Thanks for pointing this out.\n\n>\n> Noise.\n>\nI hope this is a substitute for nice. XD. Hearing this after a long\ntime. I used to hear this more frequently when I was in college.\n\n>\n> Misindented.\n\nNoted. Would change that in the next patch.\n\nThanks and regards,\nSangeeta\n"},{"id":"408221","messageId":"20201023111711.38739-1-sangunb09@gmail.com","threadId":"54429","inReplyTo":"pull.751.git.1602781723670.gitgitgadget@gmail.com","subject":"[PATCH v4] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta Jain","fromEmail":"sangunb09@gmail.com","sentAt":"2020-10-23T11:17:11Z","receivedAt":"2020-10-23T11:17:22Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"From: sangu09 <sangunb09@gmail.com>\n\nMake `--ignore-submodules=untracked` the default for `git diff` when\nthere is no configuration variable or command line option, so that the\ncommand would not give '-dirty' suffix to a submodule whose working\ntree has untracked files, to make it consistent with `git\ndescribe --dirty` that is run in the submodule working tree.\n\nSigned-off-by: Sangeeta Jain <sangunb09@gmail.com>\n---\n diff.c                                       |   3 +\n diff.h                                       |   1 +\n submodule.c                                  |   5 +-\n t/t3701-add-interactive.sh                   |   2 +-\n t/t4027-diff-submodule.sh                    |  15 ++-\n t/t4041-diff-submodule-option.sh             |  16 +--\n t/t4060-diff-submodule-option-diff-format.sh |  16 +--\n t/t7064-wtstatus-pv2.sh                      |  52 ++++++++++\n t/t7506-status-submodule.sh                  | 102 ++++++++++++++++---\n 9 files changed, 179 insertions(+), 33 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 2bb2f8f57e..5a80695da8 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4585,6 +4585,9 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)\n \t\tDIFF_XDL_SET(options, INDENT_HEURISTIC);\n \n \toptions->orderfile = diff_order_file_cfg;\n+\t\n+\tif (!options->flags.ignore_submodule_set)\n+\t\toptions->flags.ignore_untracked_in_submodules = 1;\n \n \tif (diff_no_prefix) {\n \t\toptions->a_prefix = options->b_prefix = \"\";\ndiff --git a/diff.h b/diff.h\nindex 11de52e9e9..1e18e6b1c3 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -178,6 +178,7 @@ struct diff_flags {\n \tunsigned diff_from_contents;\n \tunsigned dirty_submodules;\n \tunsigned ignore_untracked_in_submodules;\n+\tunsigned ignore_submodule_set;\n \tunsigned ignore_dirty_submodules;\n \tunsigned override_submodule_config;\n \tunsigned dirstat_by_line;\ndiff --git a/submodule.c b/submodule.c\nindex b3bb59f066..30c42cbffe 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -420,6 +420,7 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy\n void handle_ignore_submodules_arg(struct diff_options *diffopt,\n \t\t\t\t  const char *arg)\n {\n+\tdiffopt->flags.ignore_submodule_set = 1;\n \tdiffopt->flags.ignore_submodules = 0;\n \tdiffopt->flags.ignore_untracked_in_submodules = 0;\n \tdiffopt->flags.ignore_dirty_submodules = 0;\n@@ -1677,7 +1678,9 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)\n \n \tstrvec_pushl(&cp.args, \"status\", \"--porcelain=2\", NULL);\n \tif (ignore_untracked)\n-\t\tstrvec_push(&cp.args, \"-uno\");\n+\t\tstrvec_push (&cp.args, \"-uno\");\n+\telse\n+\t\tstrvec_push (&cp.args, \"--ignore-submodules=none\");\n \n \tprepare_submodule_repo_env(&cp.env_array);\n \tcp.git_cmd = 1;\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex ca04fac417..98e46ad1ae 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -761,7 +761,7 @@ test_expect_success 'setup different kinds of dirty submodules' '\n \t\techo dirty >>initial &&\n \t\t: >untracked\n \t) &&\n-\tgit -C for-submodules diff-files --name-only >actual &&\n+\tgit -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&\n \tcat >expected <<-\\EOF &&\n \tdirty-both-ways\n \tdirty-head\ndiff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\nindex d7145ccca4..6432b4331f 100755\n--- a/t/t4027-diff-submodule.sh\n+++ b/t/t4027-diff-submodule.sh\n@@ -93,10 +93,19 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked)' '\n \t) &&\n \tgit diff HEAD >actual &&\n \tsed -e \"1,/^@@/d\" actual >actual.body &&\n-\texpect_from_to >expect.body $subtip $subprev-dirty &&\n+\texpect_from_to >expect.body $subtip $subprev &&\n \ttest_cmp expect.body actual.body\n '\n \n+test_expect_success 'git diff HEAD with dirty submodule (untracked) (none ignored)' '\n+\tgit config diff.ignoreSubmodules none &&\n+\tgit diff HEAD >actual &&\n+\tsed -e \"1,/^@@/d\" actual >actual.body &&\n+\texpect_from_to >expect.body $subtip $subprev-dirty &&\n+\ttest_cmp expect.body actual.body &&\n+\tgit config --unset diff.ignoreSubmodules\n+'\n+\n test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)' '\n \tgit commit -m \"x\" sub &&\n \techo >>sub/world &&\n@@ -168,13 +177,13 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'\n \t\tgit clean -qfdx &&\n \t\t>cruft\n \t) &&\n-\tgit diff HEAD >actual &&\n+\tgit diff --ignore-submodules=none HEAD >actual &&\n \tsed -e \"1,/^@@/d\" actual >actual.body &&\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual.body &&\n \tgit diff --ignore-submodules=all HEAD >actual2 &&\n \ttest_must_be_empty actual2 &&\n-\tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n+\tgit diff HEAD >actual3 &&\n \ttest_must_be_empty actual3 &&\n \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n \ttest_must_be_empty actual4\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex f852136585..bb368b685d 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -262,7 +262,7 @@ test_expect_success 'submodule is up to date' '\n \n test_expect_success 'submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tEOF\n@@ -270,7 +270,7 @@ test_expect_success 'submodule contains untracked content' '\n '\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \ttest_must_be_empty actual\n '\n \n@@ -286,7 +286,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n \n test_expect_success 'submodule contains untracked and modified content' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -296,7 +296,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n \n test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tEOF\n@@ -337,7 +337,7 @@ test_expect_success 'submodule is modified' '\n \n test_expect_success 'modified submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p  --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 $head6..$head8:\n@@ -347,7 +347,7 @@ test_expect_success 'modified submodule contains untracked content' '\n '\n \n test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 $head6..$head8:\n \t  > change\n@@ -371,7 +371,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n \n test_expect_success 'modified submodule contains untracked and modified content' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -383,7 +383,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n \n test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tSubmodule sm1 $head6..$head8:\ndiff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh\nindex fc8229c726..dc7b242697 100755\n--- a/t/t4060-diff-submodule-option-diff-format.sh\n+++ b/t/t4060-diff-submodule-option-diff-format.sh\n@@ -409,7 +409,7 @@ test_expect_success 'submodule is up to date' '\n \n test_expect_success 'submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tEOF\n@@ -417,7 +417,7 @@ test_expect_success 'submodule contains untracked content' '\n '\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \ttest_must_be_empty actual\n '\n \n@@ -433,7 +433,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n \n test_expect_success 'submodule contains untracked and modified content' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -451,7 +451,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n # NOT OK\n test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tdiff --git a/sm1/foo6 b/sm1/foo6\n@@ -512,7 +512,7 @@ test_expect_success 'submodule is modified' '\n \n test_expect_success 'modified submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 $head7..$head8:\n@@ -528,7 +528,7 @@ test_expect_success 'modified submodule contains untracked content' '\n '\n \n test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 $head7..$head8:\n \tdiff --git a/sm1/foo6 b/sm1/foo6\n@@ -564,7 +564,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n \n test_expect_success 'modified submodule contains untracked and modified content' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -583,7 +583,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n \n test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tSubmodule sm1 $head7..$head8:\ndiff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh\nindex 537787e598..78cd86be3a 100755\n--- a/t/t7064-wtstatus-pv2.sh\n+++ b/t/t7064-wtstatus-pv2.sh\n@@ -503,6 +503,31 @@ test_expect_success 'untracked changes in added submodule (AM S..U)' '\n \t\t1 AM S..U 000000 160000 160000 $ZERO_OID $HSUB sub1\n \t\tEOF\n \n+\t\tgit status --porcelain=v2 --branch --untracked-files=all --ignore-submodules=none >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'untracked changes in added submodule (A. S...) (untracked ignored)' '\n+\t(\tcd super_repo &&\n+\t\t## create untracked file in the submodule.\n+\t\t(\tcd sub1 &&\n+\t\t\techo \"xxxx\" >file_in_sub\n+\t\t) &&\n+\n+\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n+\t\tHSUP=$(git rev-parse HEAD) &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n+\t\t1 A. S... 000000 160000 160000 $ZERO_OID $HSUB sub1\n+\t\tEOF\n+\n \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n \t\ttest_cmp expect actual\n \t)\n@@ -582,6 +607,33 @@ test_expect_success 'staged and untracked changes in added submodule (AM S.MU)'\n \t\t1 AM S.MU 000000 160000 160000 $ZERO_OID $HSUB sub1\n \t\tEOF\n \n+\t\tgit status --porcelain=v2 --branch --untracked-files=all --ignore-submodules=none >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'staged and untracked changes in added submodule (AM S.M.) (untracked ignored)' '\n+\t(\tcd super_repo &&\n+\t\t(\tcd sub1 &&\n+\t\t\t## stage new changes in tracked file.\n+\t\t\tgit add file_in_sub &&\n+\t\t\t## create new untracked file.\n+\t\t\techo \"yyyy\" >>another_file_in_sub\n+\t\t) &&\n+\n+\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n+\t\tHSUP=$(git rev-parse HEAD) &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n+\t\t1 AM S.M. 000000 160000 160000 $ZERO_OID $HSUB sub1\n+\t\tEOF\n+\n \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n \t\ttest_cmp expect actual\n \t)\ndiff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh\nindex 3fcb44767f..72da00a962 100755\n--- a/t/t7506-status-submodule.sh\n+++ b/t/t7506-status-submodule.sh\n@@ -94,36 +94,60 @@ test_expect_success 'status with added file in submodule (short)' '\n test_expect_success 'status with untracked file in submodule' '\n \t(cd sub && git reset --hard) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (untracked content)\" output\n '\n \n+test_expect_success 'status with untracked file in submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"^nothing to commit\" output\n+'\n+\n test_expect_success 'status -uno with untracked file in submodule' '\n \tgit status -uno >output &&\n \ttest_i18ngrep \"^nothing to commit\" output\n '\n \n test_expect_success 'status with untracked file in submodule (porcelain)' '\n-\tgit status --porcelain >output &&\n+\tgit status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in submodule (porcelain) (untracked ignored)' '\n+\tgit status --porcelain >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in submodule (short)' '\n-\tgit status --short >output &&\n+\tgit status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t ? sub\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in submodule (short) (untracked ignored)' '\n+\tgit status --short >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with added and untracked file in submodule' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (modified content, untracked content)\" output\n '\n \n+test_expect_success 'status with added and untracked file in submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard && echo >foo && git add foo) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (modified content)\" output\n+'\n+\n test_expect_success 'status with added and untracked file in submodule (porcelain)' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n@@ -168,10 +192,17 @@ test_expect_success 'status with added file in modified submodule (porcelain)' '\n test_expect_success 'status with untracked file in modified submodule' '\n \t(cd sub && git reset --hard) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (new commits, untracked content)\" output\n '\n \n+test_expect_success 'status with untracked file in modified submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (new commits)\" output\n+'\n+\n test_expect_success 'status with untracked file in modified submodule (porcelain)' '\n \tgit status --porcelain >output &&\n \tdiff output - <<-\\EOF\n@@ -182,10 +213,17 @@ test_expect_success 'status with untracked file in modified submodule (porcelain\n test_expect_success 'status with added and untracked file in modified submodule' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (new commits, modified content, untracked content)\" output\n '\n \n+test_expect_success 'status with added and untracked file in modified submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard && echo >foo && git add foo) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (new commits, modified content)\" output\n+'\n+\n test_expect_success 'status with added and untracked file in modified submodule (porcelain)' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n@@ -349,7 +387,7 @@ test_expect_success 'setup superproject with untracked file in nested submodule'\n '\n \n test_expect_success 'status with untracked file in nested submodule (porcelain)' '\n-\tgit -C super status --porcelain >output &&\n+\tgit -C super status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub1\n \t M sub2\n@@ -357,8 +395,13 @@ test_expect_success 'status with untracked file in nested submodule (porcelain)'\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (porcelain) (untracked ignored)' '\n+\tgit -C super status --porcelain >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in nested submodule (porcelain=2)' '\n-\tgit -C super status --porcelain=2 >output &&\n+\tgit -C super status --porcelain=2 --ignore-submodules=none >output &&\n \tsanitize_output output &&\n \tdiff output - <<-\\EOF\n \t1 .M S..U 160000 160000 160000 HASH HASH sub1\n@@ -367,8 +410,13 @@ test_expect_success 'status with untracked file in nested submodule (porcelain=2\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (porcelain=2) (untracked ignored)' '\n+\tgit -C super status --porcelain=2 >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in nested submodule (short)' '\n-\tgit -C super status --short >output &&\n+\tgit -C super status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t ? sub1\n \t ? sub2\n@@ -376,13 +424,18 @@ test_expect_success 'status with untracked file in nested submodule (short)' '\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (short) (untracked ignored)' '\n+\tgit -C super status --short >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'setup superproject with modified file in nested submodule' '\n \tgit -C super/sub1/sub2 add file &&\n \tgit -C super/sub2 add file\n '\n \n test_expect_success 'status with added file in nested submodule (porcelain)' '\n-\tgit -C super status --porcelain >output &&\n+\tgit -C super status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub1\n \t M sub2\n@@ -390,8 +443,16 @@ test_expect_success 'status with added file in nested submodule (porcelain)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (porcelain) (untracked ignored)' '\n+\tgit -C super status --porcelain >output &&\n+\tdiff output - <<-\\EOF\n+\t M sub1\n+\t M sub2\n+\tEOF\n+'\n+\n test_expect_success 'status with added file in nested submodule (porcelain=2)' '\n-\tgit -C super status --porcelain=2 >output &&\n+\tgit -C super status --porcelain=2 --ignore-submodules=none >output &&\n \tsanitize_output output &&\n \tdiff output - <<-\\EOF\n \t1 .M S.M. 160000 160000 160000 HASH HASH sub1\n@@ -400,8 +461,17 @@ test_expect_success 'status with added file in nested submodule (porcelain=2)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (porcelain=2) (untracked ignored)' '\n+\tgit -C super status --porcelain=2 >output &&\n+\tsanitize_output output &&\n+\tdiff output - <<-\\EOF\n+\t1 .M S.M. 160000 160000 160000 HASH HASH sub1\n+\t1 .M S.M. 160000 160000 160000 HASH HASH sub2\n+\tEOF\n+'\n+\n test_expect_success 'status with added file in nested submodule (short)' '\n-\tgit -C super status --short >output &&\n+\tgit -C super status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t m sub1\n \t m sub2\n@@ -409,4 +479,12 @@ test_expect_success 'status with added file in nested submodule (short)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (short) (untracked ignored)' '\n+\tgit -C super status --short >output &&\n+\tdiff output - <<-\\EOF\n+\t m sub1\n+\t m sub2\n+\tEOF\n+'\n+\n test_done\n-- \n2.21.1 (Apple Git-122.3)\n\n"},{"id":"408222","messageId":"20201023111827.40188-1-sangunb09@gmail.com","threadId":"54429","inReplyTo":"pull.751.git.1602781723670.gitgitgadget@gmail.com","subject":"[Outreachy] [PATCH v4] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta Jain","fromEmail":"sangunb09@gmail.com","sentAt":"2020-10-23T11:18:27Z","receivedAt":"2020-10-23T11:18:52Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"Make `--ignore-submodules=untracked` the default for `git diff` when\nthere is no configuration variable or command line option, so that the\ncommand would not give '-dirty' suffix to a submodule whose working\ntree has untracked files, to make it consistent with `git\ndescribe --dirty` that is run in the submodule working tree.\n\nSigned-off-by: Sangeeta Jain <sangunb09@gmail.com>\n---\n diff.c                                       |   3 +\n diff.h                                       |   1 +\n submodule.c                                  |   5 +-\n t/t3701-add-interactive.sh                   |   2 +-\n t/t4027-diff-submodule.sh                    |  15 ++-\n t/t4041-diff-submodule-option.sh             |  16 +--\n t/t4060-diff-submodule-option-diff-format.sh |  16 +--\n t/t7064-wtstatus-pv2.sh                      |  52 ++++++++++\n t/t7506-status-submodule.sh                  | 102 ++++++++++++++++---\n 9 files changed, 179 insertions(+), 33 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 2bb2f8f57e..5a80695da8 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4585,6 +4585,9 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)\n \t\tDIFF_XDL_SET(options, INDENT_HEURISTIC);\n \n \toptions->orderfile = diff_order_file_cfg;\n+\t\n+\tif (!options->flags.ignore_submodule_set)\n+\t\toptions->flags.ignore_untracked_in_submodules = 1;\n \n \tif (diff_no_prefix) {\n \t\toptions->a_prefix = options->b_prefix = \"\";\ndiff --git a/diff.h b/diff.h\nindex 11de52e9e9..1e18e6b1c3 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -178,6 +178,7 @@ struct diff_flags {\n \tunsigned diff_from_contents;\n \tunsigned dirty_submodules;\n \tunsigned ignore_untracked_in_submodules;\n+\tunsigned ignore_submodule_set;\n \tunsigned ignore_dirty_submodules;\n \tunsigned override_submodule_config;\n \tunsigned dirstat_by_line;\ndiff --git a/submodule.c b/submodule.c\nindex b3bb59f066..30c42cbffe 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -420,6 +420,7 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy\n void handle_ignore_submodules_arg(struct diff_options *diffopt,\n \t\t\t\t  const char *arg)\n {\n+\tdiffopt->flags.ignore_submodule_set = 1;\n \tdiffopt->flags.ignore_submodules = 0;\n \tdiffopt->flags.ignore_untracked_in_submodules = 0;\n \tdiffopt->flags.ignore_dirty_submodules = 0;\n@@ -1677,7 +1678,9 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)\n \n \tstrvec_pushl(&cp.args, \"status\", \"--porcelain=2\", NULL);\n \tif (ignore_untracked)\n-\t\tstrvec_push(&cp.args, \"-uno\");\n+\t\tstrvec_push (&cp.args, \"-uno\");\n+\telse\n+\t\tstrvec_push (&cp.args, \"--ignore-submodules=none\");\n \n \tprepare_submodule_repo_env(&cp.env_array);\n \tcp.git_cmd = 1;\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex ca04fac417..98e46ad1ae 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -761,7 +761,7 @@ test_expect_success 'setup different kinds of dirty submodules' '\n \t\techo dirty >>initial &&\n \t\t: >untracked\n \t) &&\n-\tgit -C for-submodules diff-files --name-only >actual &&\n+\tgit -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&\n \tcat >expected <<-\\EOF &&\n \tdirty-both-ways\n \tdirty-head\ndiff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\nindex d7145ccca4..6432b4331f 100755\n--- a/t/t4027-diff-submodule.sh\n+++ b/t/t4027-diff-submodule.sh\n@@ -93,10 +93,19 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked)' '\n \t) &&\n \tgit diff HEAD >actual &&\n \tsed -e \"1,/^@@/d\" actual >actual.body &&\n-\texpect_from_to >expect.body $subtip $subprev-dirty &&\n+\texpect_from_to >expect.body $subtip $subprev &&\n \ttest_cmp expect.body actual.body\n '\n \n+test_expect_success 'git diff HEAD with dirty submodule (untracked) (none ignored)' '\n+\tgit config diff.ignoreSubmodules none &&\n+\tgit diff HEAD >actual &&\n+\tsed -e \"1,/^@@/d\" actual >actual.body &&\n+\texpect_from_to >expect.body $subtip $subprev-dirty &&\n+\ttest_cmp expect.body actual.body &&\n+\tgit config --unset diff.ignoreSubmodules\n+'\n+\n test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)' '\n \tgit commit -m \"x\" sub &&\n \techo >>sub/world &&\n@@ -168,13 +177,13 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'\n \t\tgit clean -qfdx &&\n \t\t>cruft\n \t) &&\n-\tgit diff HEAD >actual &&\n+\tgit diff --ignore-submodules=none HEAD >actual &&\n \tsed -e \"1,/^@@/d\" actual >actual.body &&\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual.body &&\n \tgit diff --ignore-submodules=all HEAD >actual2 &&\n \ttest_must_be_empty actual2 &&\n-\tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n+\tgit diff HEAD >actual3 &&\n \ttest_must_be_empty actual3 &&\n \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n \ttest_must_be_empty actual4\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex f852136585..bb368b685d 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -262,7 +262,7 @@ test_expect_success 'submodule is up to date' '\n \n test_expect_success 'submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tEOF\n@@ -270,7 +270,7 @@ test_expect_success 'submodule contains untracked content' '\n '\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \ttest_must_be_empty actual\n '\n \n@@ -286,7 +286,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n \n test_expect_success 'submodule contains untracked and modified content' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -296,7 +296,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n \n test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tEOF\n@@ -337,7 +337,7 @@ test_expect_success 'submodule is modified' '\n \n test_expect_success 'modified submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p  --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 $head6..$head8:\n@@ -347,7 +347,7 @@ test_expect_success 'modified submodule contains untracked content' '\n '\n \n test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 $head6..$head8:\n \t  > change\n@@ -371,7 +371,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n \n test_expect_success 'modified submodule contains untracked and modified content' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -383,7 +383,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n \n test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tSubmodule sm1 $head6..$head8:\ndiff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh\nindex fc8229c726..dc7b242697 100755\n--- a/t/t4060-diff-submodule-option-diff-format.sh\n+++ b/t/t4060-diff-submodule-option-diff-format.sh\n@@ -409,7 +409,7 @@ test_expect_success 'submodule is up to date' '\n \n test_expect_success 'submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tEOF\n@@ -417,7 +417,7 @@ test_expect_success 'submodule contains untracked content' '\n '\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \ttest_must_be_empty actual\n '\n \n@@ -433,7 +433,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n \n test_expect_success 'submodule contains untracked and modified content' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -451,7 +451,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n # NOT OK\n test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tdiff --git a/sm1/foo6 b/sm1/foo6\n@@ -512,7 +512,7 @@ test_expect_success 'submodule is modified' '\n \n test_expect_success 'modified submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 $head7..$head8:\n@@ -528,7 +528,7 @@ test_expect_success 'modified submodule contains untracked content' '\n '\n \n test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 $head7..$head8:\n \tdiff --git a/sm1/foo6 b/sm1/foo6\n@@ -564,7 +564,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n \n test_expect_success 'modified submodule contains untracked and modified content' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -583,7 +583,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n \n test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tSubmodule sm1 $head7..$head8:\ndiff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh\nindex 537787e598..78cd86be3a 100755\n--- a/t/t7064-wtstatus-pv2.sh\n+++ b/t/t7064-wtstatus-pv2.sh\n@@ -503,6 +503,31 @@ test_expect_success 'untracked changes in added submodule (AM S..U)' '\n \t\t1 AM S..U 000000 160000 160000 $ZERO_OID $HSUB sub1\n \t\tEOF\n \n+\t\tgit status --porcelain=v2 --branch --untracked-files=all --ignore-submodules=none >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'untracked changes in added submodule (A. S...) (untracked ignored)' '\n+\t(\tcd super_repo &&\n+\t\t## create untracked file in the submodule.\n+\t\t(\tcd sub1 &&\n+\t\t\techo \"xxxx\" >file_in_sub\n+\t\t) &&\n+\n+\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n+\t\tHSUP=$(git rev-parse HEAD) &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n+\t\t1 A. S... 000000 160000 160000 $ZERO_OID $HSUB sub1\n+\t\tEOF\n+\n \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n \t\ttest_cmp expect actual\n \t)\n@@ -582,6 +607,33 @@ test_expect_success 'staged and untracked changes in added submodule (AM S.MU)'\n \t\t1 AM S.MU 000000 160000 160000 $ZERO_OID $HSUB sub1\n \t\tEOF\n \n+\t\tgit status --porcelain=v2 --branch --untracked-files=all --ignore-submodules=none >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'staged and untracked changes in added submodule (AM S.M.) (untracked ignored)' '\n+\t(\tcd super_repo &&\n+\t\t(\tcd sub1 &&\n+\t\t\t## stage new changes in tracked file.\n+\t\t\tgit add file_in_sub &&\n+\t\t\t## create new untracked file.\n+\t\t\techo \"yyyy\" >>another_file_in_sub\n+\t\t) &&\n+\n+\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n+\t\tHSUP=$(git rev-parse HEAD) &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n+\t\t1 AM S.M. 000000 160000 160000 $ZERO_OID $HSUB sub1\n+\t\tEOF\n+\n \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n \t\ttest_cmp expect actual\n \t)\ndiff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh\nindex 3fcb44767f..72da00a962 100755\n--- a/t/t7506-status-submodule.sh\n+++ b/t/t7506-status-submodule.sh\n@@ -94,36 +94,60 @@ test_expect_success 'status with added file in submodule (short)' '\n test_expect_success 'status with untracked file in submodule' '\n \t(cd sub && git reset --hard) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (untracked content)\" output\n '\n \n+test_expect_success 'status with untracked file in submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"^nothing to commit\" output\n+'\n+\n test_expect_success 'status -uno with untracked file in submodule' '\n \tgit status -uno >output &&\n \ttest_i18ngrep \"^nothing to commit\" output\n '\n \n test_expect_success 'status with untracked file in submodule (porcelain)' '\n-\tgit status --porcelain >output &&\n+\tgit status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in submodule (porcelain) (untracked ignored)' '\n+\tgit status --porcelain >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in submodule (short)' '\n-\tgit status --short >output &&\n+\tgit status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t ? sub\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in submodule (short) (untracked ignored)' '\n+\tgit status --short >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with added and untracked file in submodule' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (modified content, untracked content)\" output\n '\n \n+test_expect_success 'status with added and untracked file in submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard && echo >foo && git add foo) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (modified content)\" output\n+'\n+\n test_expect_success 'status with added and untracked file in submodule (porcelain)' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n@@ -168,10 +192,17 @@ test_expect_success 'status with added file in modified submodule (porcelain)' '\n test_expect_success 'status with untracked file in modified submodule' '\n \t(cd sub && git reset --hard) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (new commits, untracked content)\" output\n '\n \n+test_expect_success 'status with untracked file in modified submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (new commits)\" output\n+'\n+\n test_expect_success 'status with untracked file in modified submodule (porcelain)' '\n \tgit status --porcelain >output &&\n \tdiff output - <<-\\EOF\n@@ -182,10 +213,17 @@ test_expect_success 'status with untracked file in modified submodule (porcelain\n test_expect_success 'status with added and untracked file in modified submodule' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (new commits, modified content, untracked content)\" output\n '\n \n+test_expect_success 'status with added and untracked file in modified submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard && echo >foo && git add foo) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (new commits, modified content)\" output\n+'\n+\n test_expect_success 'status with added and untracked file in modified submodule (porcelain)' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n@@ -349,7 +387,7 @@ test_expect_success 'setup superproject with untracked file in nested submodule'\n '\n \n test_expect_success 'status with untracked file in nested submodule (porcelain)' '\n-\tgit -C super status --porcelain >output &&\n+\tgit -C super status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub1\n \t M sub2\n@@ -357,8 +395,13 @@ test_expect_success 'status with untracked file in nested submodule (porcelain)'\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (porcelain) (untracked ignored)' '\n+\tgit -C super status --porcelain >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in nested submodule (porcelain=2)' '\n-\tgit -C super status --porcelain=2 >output &&\n+\tgit -C super status --porcelain=2 --ignore-submodules=none >output &&\n \tsanitize_output output &&\n \tdiff output - <<-\\EOF\n \t1 .M S..U 160000 160000 160000 HASH HASH sub1\n@@ -367,8 +410,13 @@ test_expect_success 'status with untracked file in nested submodule (porcelain=2\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (porcelain=2) (untracked ignored)' '\n+\tgit -C super status --porcelain=2 >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in nested submodule (short)' '\n-\tgit -C super status --short >output &&\n+\tgit -C super status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t ? sub1\n \t ? sub2\n@@ -376,13 +424,18 @@ test_expect_success 'status with untracked file in nested submodule (short)' '\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (short) (untracked ignored)' '\n+\tgit -C super status --short >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'setup superproject with modified file in nested submodule' '\n \tgit -C super/sub1/sub2 add file &&\n \tgit -C super/sub2 add file\n '\n \n test_expect_success 'status with added file in nested submodule (porcelain)' '\n-\tgit -C super status --porcelain >output &&\n+\tgit -C super status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub1\n \t M sub2\n@@ -390,8 +443,16 @@ test_expect_success 'status with added file in nested submodule (porcelain)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (porcelain) (untracked ignored)' '\n+\tgit -C super status --porcelain >output &&\n+\tdiff output - <<-\\EOF\n+\t M sub1\n+\t M sub2\n+\tEOF\n+'\n+\n test_expect_success 'status with added file in nested submodule (porcelain=2)' '\n-\tgit -C super status --porcelain=2 >output &&\n+\tgit -C super status --porcelain=2 --ignore-submodules=none >output &&\n \tsanitize_output output &&\n \tdiff output - <<-\\EOF\n \t1 .M S.M. 160000 160000 160000 HASH HASH sub1\n@@ -400,8 +461,17 @@ test_expect_success 'status with added file in nested submodule (porcelain=2)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (porcelain=2) (untracked ignored)' '\n+\tgit -C super status --porcelain=2 >output &&\n+\tsanitize_output output &&\n+\tdiff output - <<-\\EOF\n+\t1 .M S.M. 160000 160000 160000 HASH HASH sub1\n+\t1 .M S.M. 160000 160000 160000 HASH HASH sub2\n+\tEOF\n+'\n+\n test_expect_success 'status with added file in nested submodule (short)' '\n-\tgit -C super status --short >output &&\n+\tgit -C super status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t m sub1\n \t m sub2\n@@ -409,4 +479,12 @@ test_expect_success 'status with added file in nested submodule (short)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (short) (untracked ignored)' '\n+\tgit -C super status --short >output &&\n+\tdiff output - <<-\\EOF\n+\t m sub1\n+\t m sub2\n+\tEOF\n+'\n+\n test_done\n-- \n2.21.1 (Apple Git-122.3)\n\n"},{"id":"408242","messageId":"xmqqr1pphsvs.fsf@gitster.c.googlers.com","threadId":"54429","inReplyTo":"CAHjREB4qGO1=XCy-F+H39FP_KU_zZjKCDA=b9JxCe0WZdM06KQ@mail.gmail.com","subject":"Re: [Outreachy] [PATCH v3] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-10-23T15:19:35Z","receivedAt":"2020-10-23T15:19:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sangeeta NB <sangunb09@gmail.com> writes:\n\n> Sorry for sending it over and over again. I couldn't figure out why\n> the mail is not reaching the community.\n\nFWIW, I'm seeing it for the first time, so no worries ;)\n\n>> This new boolean is meant to be set only when non-default\n>> ignore-submodules option is given either from the command line or\n>> from the configuration---when the bit is unset, we are told to do\n>> whatever it is that is the default for us.\n>\n> I fear I might not get your question clearly here. But from what I\n> understood this boolean( flags.ignore_submodule_set )  is set only\n> when diff.ignoreSubmodules is set in user-config.\n\nThe four-line paragraph I wrote above is not a question.  It is\nnormal to \"think aloud\" to express what the reader understood what\nthe patch does/intends to do during the review, which gives the\ncontributor a chance to spot misunderstanding by the reviewer.\n\nIn any case, when \"git diff --ignore-submodules=<when>\" command line\noption is parsed, diff_opt_ignore_submodules() gets called, which in\nturn calls handle_ignore_submodules_arg(), and you set the bit\nthere.\n\nSo this is not limited to configuration, I think.  Command line\noption given by the user can also affect it.\n\nMoreover, wt-status.c:wt_status_collect_changes_index() hardcodes\na call to handle_ignore_submodules_arg() with hardcoded \"dirty\"\nunless the caller specifies s->ignore_submodule_arg.  This is not\neven user-config or any user action---it is more like a hardcoded\ndefault.\n\n>> And the default is to flip only this bit on.  Do we need to turn off\n>> other bits that submodule.c::handle_ignore_submodules_arg() function\n>> touches?  [*1*]\n>>\n>\n> We are not flipping the bit, we are setting it to 1.\n\nYeah, flipping it to on is setting it to 1.  We are saying the same\nthing, aren't we?\n\n> I guess we don't\n> have to turn off other bits because in case if\n> submodule.c::handle_ignore_submodules_arg() is called we don't have to\n> set the default value.\n>\n> So there's no point in flipping any other bits\n> as if any of them is set, the user should have added some arguments in\n>  ignoreSubmodules and therefore flags.ignore_submodule_set would be\n> set to 1 and we won't be setting the default value.\n\nThe reason why a helper function handle_ignore_submodules_arg()\nexists in the first place is because the way ignore_* bits are\nmanaged in the diff_options.flags is tricky and with a helper in\nbetween the callers and the actual bits, is easier to update in the\nfuture if needed.\n\nSo even if we assume that everybody who reacted to end-user\npreference would have called handle_ignore_submodules_arg(), hence\nwe do not want to force our default when the .ignore_submodule_set\nbit set and we do want to do so when the bit is unset, we should\ndo\n\n\tif (!options->flags.ignore_submodule_set)\n\t\thandle_ignore_submodules_arg(\"untracked\");\n\ninstead of only toggling the .ignore_untracked_in_submodules bit on\nmanually.\n\n>> I like the general idea of having one bit that is set if and only if\n>> the command line or configuration told us specifically what to do,\n>> so that we can dictate the default after they were taken care of.\n>> ...\n>> Even without anticipating such a change in the future, there already\n>> is a callsite of this function in wt-status.c that hands a hardcoded\n>> string \"dirty\" to it.  That is *not* caused by an end-user request\n>> (be it a configuration variable or a command line option), so in a\n>> sense, the assumption is already broken.\n>\n> I couldn't fully understand what assumption are you talking about. I\n> would be glad if you can explain it to me in a little more detail.\n\nHave you looked for \"dirty\" (with double-quote around the word) in\nwt-status.c already?  The call to handle_ignore_submodules_arg(),\nwhich would cause your new bit set, is made not as a reaction to any\nend-user input.  Rather it is \"if end-user did not say anything, use\nthis hardcoded setting\".  And it overrides the \"if the end user did\nnot specify anything, we want to use this default\" logic you added\nwith this change, because it dictates \"dirty\" there without end-user\nasking.\n\nIs that desirable?  I dunno.\n\n>> Noise.\n>>\n> I hope this is a substitute for nice. XD. Hearing this after a long\n> time. I used to hear this more frequently when I was in college.\n\nI found this change a \"noise\":\n\n \tstrvec_pushl(&cp.args, \"status\", \"--porcelain=2\", NULL);\n \tif (ignore_untracked)\n-\t\tstrvec_push(&cp.args, \"-uno\");\n+\t\tstrvec_push (&cp.args, \"-uno\");\n\nIf it were going the other direction, \"we fix coding style violation\nwhile at it\" may be a good justification to do so, but this\nparticular change (1) is not neeeded for the purpose of this patch,\nand (2) is making the code worse by deviating from the coding\nguideline.  Please drop it.\n\nThanks.\n"},{"id":"408247","messageId":"xmqq7drhhr5o.fsf@gitster.c.googlers.com","threadId":"54429","inReplyTo":"20201023111711.38739-1-sangunb09@gmail.com","subject":"Re: [PATCH v4] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-10-23T15:56:51Z","receivedAt":"2020-10-23T15:57:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sangeeta Jain <sangunb09@gmail.com> writes:\n\n> From: sangu09 <sangunb09@gmail.com>\n>\n> Make `--ignore-submodules=untracked` the default for `git diff` when\n> there is no configuration variable or command line option, so that the\n> command would not give '-dirty' suffix to a submodule whose working\n> tree has untracked files, to make it consistent with `git\n> describe --dirty` that is run in the submodule working tree.\n\nWhat happened to the first/introductory paragraph that was\nexcellently written in the previous round?\n\nThe usaul way to compose a log message is to\n\n - Give an observation on how the current system work in the present\n   tense (so no need to say \"Currently X is Y\", just \"X is Y\"), and\n   discuss what you perceive as a problem in it.\n\n - Propose a solution (optional---often, problem description\n   trivially leads to an obvious solution in reader's minds).\n\n - Give commands to the codebase to \"become like so\".\n\nThe first paragraph you had in the previous round was a good example\nof the \"observation\".  What we see above is only the \"commands\"\npart.  To those who have been intimately following the discussion,\nit often is understandable without both, but we are not writing for\nthose who review the patches.  We are writing for future readers who\nare not aware of these exchanges we are having, so we should give\nsomething to prepare them by setting the stage and stating the\nobjective.\n\n> diff --git a/diff.c b/diff.c\n> index 2bb2f8f57e..5a80695da8 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -4585,6 +4585,9 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)\n>  \t\tDIFF_XDL_SET(options, INDENT_HEURISTIC);\n>  \n>  \toptions->orderfile = diff_order_file_cfg;\n> +\t\n> +\tif (!options->flags.ignore_submodule_set)\n> +\t\toptions->flags.ignore_untracked_in_submodules = 1;\n\nI think I already touched about this one in the previous review.\n\n>  \tstrvec_pushl(&cp.args, \"status\", \"--porcelain=2\", NULL);\n>  \tif (ignore_untracked)\n> -\t\tstrvec_push(&cp.args, \"-uno\");\n> +\t\tstrvec_push (&cp.args, \"-uno\");\n\nNoise.\n\n> diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\n> index ca04fac417..98e46ad1ae 100755\n> --- a/t/t3701-add-interactive.sh\n> +++ b/t/t3701-add-interactive.sh\n> @@ -761,7 +761,7 @@ test_expect_success 'setup different kinds of dirty submodules' '\n>  \t\techo dirty >>initial &&\n>  \t\t: >untracked\n>  \t) &&\n> -\tgit -C for-submodules diff-files --name-only >actual &&\n> +\tgit -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&\n>  \tcat >expected <<-\\EOF &&\n>  \tdirty-both-ways\n>  \tdirty-head\n\nHmph, it seems that you chose to give options that are no longer the\ndefault to command invocations, so that the expected output from the\nprevious world order before this patch can be reused, but is that a\nsensible way to go?  If we are changing the default behaviour, shouldn't\nwe rather be testing that new behaviour, I wonder?\n\n> diff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh\n> index 537787e598..78cd86be3a 100755\n> --- a/t/t7064-wtstatus-pv2.sh\n> +++ b/t/t7064-wtstatus-pv2.sh\n> @@ -503,6 +503,31 @@ test_expect_success 'untracked changes in added submodule (AM S..U)' '\n>  \t\t1 AM S..U 000000 160000 160000 $ZERO_OID $HSUB sub1\n>  \t\tEOF\n>  \n> +\t\tgit status --porcelain=v2 --branch --untracked-files=all --ignore-submodules=none >actual &&\n> +\t\ttest_cmp expect actual\n> +\t)\n> +'\n> +\n> +test_expect_success 'untracked changes in added submodule (A. S...) (untracked ignored)' '\n> +\t(\tcd super_repo &&\n> +\t\t## create untracked file in the submodule.\n> +\t\t(\tcd sub1 &&\n> +\t\t\techo \"xxxx\" >file_in_sub\n> +\t\t) &&\n> +\n> +\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n> +\t\tHSUP=$(git rev-parse HEAD) &&\n> +\t\tHSUB=$HSUP &&\n> +\n> +\t\tcat >expect <<-EOF &&\n> +\t\t# branch.oid $HSUP\n> +\t\t# branch.head master\n> +\t\t# branch.upstream origin/master\n> +\t\t# branch.ab +0 -0\n> +\t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n> +\t\t1 A. S... 000000 160000 160000 $ZERO_OID $HSUB sub1\n> +\t\tEOF\n> +\n>  \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n>  \t\ttest_cmp expect actual\n>  \t)\n> @@ -582,6 +607,33 @@ test_expect_success 'staged and untracked changes in added submodule (AM S.MU)'\n>  \t\t1 AM S.MU 000000 160000 160000 $ZERO_OID $HSUB sub1\n>  \t\tEOF\n>  \n> +\t\tgit status --porcelain=v2 --branch --untracked-files=all --ignore-submodules=none >actual &&\n> +\t\ttest_cmp expect actual\n> +\t)\n> +'\n> +\n> +test_expect_success 'staged and untracked changes in added submodule (AM S.M.) (untracked ignored)' '\n> +\t(\tcd super_repo &&\n> +\t\t(\tcd sub1 &&\n> +\t\t\t## stage new changes in tracked file.\n> +\t\t\tgit add file_in_sub &&\n> +\t\t\t## create new untracked file.\n> +\t\t\techo \"yyyy\" >>another_file_in_sub\n> +\t\t) &&\n> +\n> +\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n> +\t\tHSUP=$(git rev-parse HEAD) &&\n> +\t\tHSUB=$HSUP &&\n> +\n> +\t\tcat >expect <<-EOF &&\n> +\t\t# branch.oid $HSUP\n> +\t\t# branch.head master\n> +\t\t# branch.upstream origin/master\n> +\t\t# branch.ab +0 -0\n> +\t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n> +\t\t1 AM S.M. 000000 160000 160000 $ZERO_OID $HSUB sub1\n> +\t\tEOF\n> +\n>  \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n>  \t\ttest_cmp expect actual\n>  \t)\n\nOK.\n\nBy the way, in builtin/describe.c there is an invocation of\n\"diff-index\" without any --ignore-submodules=<what> option.\n\n        /* diff-index command arguments to check if working tree is dirty. */\n        static const char *diff_index_args[] = {\n                \"diff-index\", \"--quiet\", \"HEAD\", \"--\", NULL\n        };\n\nWould the behaviour of diff-index invocation in \"git describe --dirty\"\naffected by the change of the default in any way?\n\nThanks.\n"},{"id":"408269","messageId":"CAHjREB4egt95fCz6pzON2h5rVH-XvYKf1oGnyU-8gVL-U3WrmA@mail.gmail.com","threadId":"54429","inReplyTo":"xmqqr1pphsvs.fsf@gitster.c.googlers.com","subject":"Re: [Outreachy] [PATCH v3] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta NB","fromEmail":"sangunb09@gmail.com","sentAt":"2020-10-23T18:17:20Z","receivedAt":"2020-10-23T18:17:34Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"> The four-line paragraph I wrote above is not a question.  It is\n> normal to \"think aloud\" to express what the reader understood what\n> the patch does/intends to do during the review, which gives the\n> contributor a chance to spot misunderstanding by the reviewer.\n>\nOh okay. I thought you meant to ask something. But ya \"think aloud\" is\na nice practice. Sorry for the confusion.\n\n> In any case, when \"git diff --ignore-submodules=<when>\" command line\n> option is parsed, diff_opt_ignore_submodules() gets called, which in\n> turn calls handle_ignore_submodules_arg(), and you set the bit\n> there.\n>\n> So this is not limited to configuration, I think.  Command line\n> option given by the user can also affect it.\n\nUmm, so when diff.ignoreSubmodules is set in user config,\ngit_diff_ui_config() is called which is called(which calls\nhandle_ignore_submodules_arg) even before repo_git_setup() and\ntherefore it sets the bit there. But in the case of command-line\noptions, as you mentioned, diff_opt_ignore_submodules() gets called by\nthe prep_parse_options() which is called after we are checking for\nthat bit. So when we are checking for the bit, prep_parse_options() is\nnot yet called, and therefore that bit is not set.\n\n>\n> Yeah, flipping it to on is setting it to 1.  We are saying the same\n> thing, aren't we?\n\nYa, sorry for the misunderstanding. We are saying the same thing.\n\n>\n>\n> The reason why a helper function handle_ignore_submodules_arg()\n> exists in the first place is because the way ignore_* bits are\n> managed in the diff_options.flags is tricky and with a helper in\n> between the callers and the actual bits, is easier to update in the\n> future if needed.\n>\n> So even if we assume that everybody who reacted to end-user\n> preference would have called handle_ignore_submodules_arg(), hence\n> we do not want to force our default when the .ignore_submodule_set\n> bit set and we do want to do so when the bit is unset, we should\n> do\n>\n>         if (!options->flags.ignore_submodule_set)\n>                 handle_ignore_submodules_arg(\"untracked\");\n>\n> instead of only toggling the .ignore_untracked_in_submodules bit on\n> manually.\n>\n\nOh okay, that makes sense. Would update that in the next patch.\n\n>\n> Have you looked for \"dirty\" (with double-quote around the word) in\n> wt-status.c already?  The call to handle_ignore_submodules_arg(),\n> which would cause your new bit set, is made not as a reaction to any\n> end-user input.  Rather it is \"if end-user did not say anything, use\n> this hardcoded setting\".  And it overrides the \"if the end user did\n> not specify anything, we want to use this default\" logic you added\n> with this change, because it dictates \"dirty\" there without end-user\n> asking.\n>\n> Is that desirable?  I dunno.\n\nThis change was added in this[1] commit and as said there the \"dirty\"\nwas used because here[2] if no arguments are provided with\nignoreSubmodules then it set it to all and it might be confusing for\n`git status` as then even when the user chooses to record a new commit\nfor an ignored submodule by adding it manually this change won't show\nup under the to-be-committed changes.(as mentioned in [1])\n\n[1] https://github.com/git/git/commit/1d2f393ac9bfb4c20f14d6ead7bb4c56e766ab77\n[2] https://github.com/git/git/blob/master/diff.c#L5139\n\nSo I think that's desirable.\n\n> I found this change a \"noise\":\n\nOh okay, Again sorry for the misunderstanding.\n\n>\n>         strvec_pushl(&cp.args, \"status\", \"--porcelain=2\", NULL);\n>         if (ignore_untracked)\n> -               strvec_push(&cp.args, \"-uno\");\n> +               strvec_push (&cp.args, \"-uno\");\n>\n> If it were going the other direction, \"we fix coding style violation\n> while at it\" may be a good justification to do so, but this\n> particular change (1) is not neeeded for the purpose of this patch,\n> and (2) is making the code worse by deviating from the coding\n> guideline.  Please drop it.\n>\n\nThis part of the change was introduced because we had a failing test\nhere[3]. There was some problem it getting both the flags propagated\nthrough the nested submodule and that's why this change. Maybe we can\ndo something better to fix that. It would be great if you can have a\nlook at it.\n\n[3] https://github.com/git/git/blob/master/t/t3600-rm.sh#L690\n\nThanks and Regards,\nSangeeta\n"},{"id":"408271","messageId":"CAHjREB5Uye1b=bVZsAc1WPcrWrqxnrMZxBtLT345CrpU7gTpVg@mail.gmail.com","threadId":"54429","inReplyTo":"xmqq7drhhr5o.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v4] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta NB","fromEmail":"sangunb09@gmail.com","sentAt":"2020-10-23T18:32:44Z","receivedAt":"2020-10-23T18:32:57Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":">\n> What happened to the first/introductory paragraph that was\n> excellently written in the previous round?\n>\n> The usaul way to compose a log message is to\n>\n>  - Give an observation on how the current system work in the present\n>    tense (so no need to say \"Currently X is Y\", just \"X is Y\"), and\n>    discuss what you perceive as a problem in it.\n>\n>  - Propose a solution (optional---often, problem description\n>    trivially leads to an obvious solution in reader's minds).\n>\n>  - Give commands to the codebase to \"become like so\".\n>\n> The first paragraph you had in the previous round was a good example\n> of the \"observation\".  What we see above is only the \"commands\"\n> part.  To those who have been intimately following the discussion,\n> it often is understandable without both, but we are not writing for\n> those who review the patches.  We are writing for future readers who\n> are not aware of these exchanges we are having, so we should give\n> something to prepare them by setting the stage and stating the\n> objective.\n\nOh okay, it makes sense. I thought you told to replace that all with\nthis. Would change it in the next patch.\n\n>\n> > diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\n> > index ca04fac417..98e46ad1ae 100755\n> > --- a/t/t3701-add-interactive.sh\n> > +++ b/t/t3701-add-interactive.sh\n> > @@ -761,7 +761,7 @@ test_expect_success 'setup different kinds of dirty submodules' '\n> >               echo dirty >>initial &&\n> >               : >untracked\n> >       ) &&\n> > -     git -C for-submodules diff-files --name-only >actual &&\n> > +     git -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&\n> >       cat >expected <<-\\EOF &&\n> >       dirty-both-ways\n> >       dirty-head\n>\n> Hmph, it seems that you chose to give options that are no longer the\n> default to command invocations, so that the expected output from the\n> previous world order before this patch can be reused, but is that a\n> sensible way to go?  If we are changing the default behaviour, shouldn't\n> we rather be testing that new behaviour, I wonder?\n>\n\nI have tested the new behavior too. I have added tests for both the\nbehavior, when ignore-submodules is none and when no argument is being\npassed.\n\n>\n> By the way, in builtin/describe.c there is an invocation of\n> \"diff-index\" without any --ignore-submodules=<what> option.\n>\n>         /* diff-index command arguments to check if working tree is dirty. */\n>         static const char *diff_index_args[] = {\n>                 \"diff-index\", \"--quiet\", \"HEAD\", \"--\", NULL\n>         };\n>\n> Would the behaviour of diff-index invocation in \"git describe --dirty\"\n> affected by the change of the default in any way?\n\nI don't think so because describe was already behaving in the way that\nwe won't. We changed the behavior of git diff to match it with that.\nSo it doesn't make sense to add anything to that. Tell me if I am\nmissing something.\n\nThanks for reviewing.\n"},{"id":"408272","messageId":"xmqqd018hivx.fsf@gitster.c.googlers.com","threadId":"54429","inReplyTo":"CAHjREB4egt95fCz6pzON2h5rVH-XvYKf1oGnyU-8gVL-U3WrmA@mail.gmail.com","subject":"Re: [Outreachy] [PATCH v3] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-10-23T18:55:30Z","receivedAt":"2020-10-23T18:55:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sangeeta NB <sangunb09@gmail.com> writes:\n\n>> I found this change a \"noise\":\n>\n> Oh okay, Again sorry for the misunderstanding.\n>\n>>\n>>         strvec_pushl(&cp.args, \"status\", \"--porcelain=2\", NULL);\n>>         if (ignore_untracked)\n>> -               strvec_push(&cp.args, \"-uno\");\n>> +               strvec_push (&cp.args, \"-uno\");\n>>\n>> If it were going the other direction, \"we fix coding style violation\n>> while at it\" may be a good justification to do so, but this\n>> particular change (1) is not neeeded for the purpose of this patch,\n>> and (2) is making the code worse by deviating from the coding\n>> guideline.  Please drop it.\n>>\n> This part of the change was introduced because we had a failing test\n> here[3]. There was some problem it getting both the flags propagated\n> through ...\n\nAre you talking about the new \"else\" clause added to the \"if\"\nstatement we see above?  I am not saying it is a \"noise\".\n\nBut look at what you did to the existing call to strvec_push() to\nadd \"-uno\" shown above in the patch, i.e. the addition of space\nbefore the parenthesis.  We cannot justify that change, can we?\nThat's noise as far as I can see.\n"},{"id":"408274","messageId":"CAHjREB6E+okXUA8tffKkoC++zbv55GWwdYJocxo9ey_X5zPeiA@mail.gmail.com","threadId":"54429","inReplyTo":"xmqqd018hivx.fsf@gitster.c.googlers.com","subject":"Re: [Outreachy] [PATCH v3] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta NB","fromEmail":"sangunb09@gmail.com","sentAt":"2020-10-23T19:08:01Z","receivedAt":"2020-10-23T19:08:14Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"On Sat, Oct 24, 2020 at 12:25 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Sangeeta NB <sangunb09@gmail.com> writes:\n>\n> >> I found this change a \"noise\":\n> >\n> > Oh okay, Again sorry for the misunderstanding.\n> >\n> >>\n> >>         strvec_pushl(&cp.args, \"status\", \"--porcelain=2\", NULL);\n> >>         if (ignore_untracked)\n> >> -               strvec_push(&cp.args, \"-uno\");\n> >> +               strvec_push (&cp.args, \"-uno\");\n> >>\n> >> If it were going the other direction, \"we fix coding style violation\n> >> while at it\" may be a good justification to do so, but this\n> >> particular change (1) is not neeeded for the purpose of this patch,\n> >> and (2) is making the code worse by deviating from the coding\n> >> guideline.  Please drop it.\n> >>\n> > This part of the change was introduced because we had a failing test\n> > here[3]. There was some problem it getting both the flags propagated\n> > through ...\n>\n> Are you talking about the new \"else\" clause added to the \"if\"\n> statement we see above?  I am not saying it is a \"noise\".\n>\n> But look at what you did to the existing call to strvec_push() to\n> add \"-uno\" shown above in the patch, i.e. the addition of space\n> before the parenthesis.  We cannot justify that change, can we?\n> That's noise as far as I can see.\n\nOh okay. Now I understand. Ya, that doesn't make sense. I thought that\nEric above suggested adding it but looking at it again, Eric was\nsaying to drop the space in the else statement below and I\nmisunderstood that to this. I am really very sorry about this. Would\nchange it in the next patch.\n\nThanks again.\n"},{"id":"408277","messageId":"20201023192916.62097-1-sangunb09@gmail.com","threadId":"54429","inReplyTo":"pull.751.git.1602781723670.gitgitgadget@gmail.com","subject":"[Outreachy] [PATCH v5] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta Jain","fromEmail":"sangunb09@gmail.com","sentAt":"2020-10-23T19:29:16Z","receivedAt":"2020-10-23T19:29:48Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"Git diff reports a submodule directory as -dirty even when there are\nonly untracked files in the submodule directory. This is inconsistent\nwith what `git describe --dirty` says when run in the submodule\ndirectory in that state.\n\nMake `--ignore-submodules=untracked` the default for `git diff` when\nthere is no configuration variable or command line option, so that the\ncommand would not give '-dirty' suffix to a submodule whose working\ntree has untracked files, to make it consistent with `git\ndescribe --dirty` that is run in the submodule working tree.\n\nSigned-off-by: Sangeeta Jain <sangunb09@gmail.com>\n---\n diff.c                                       |   3 +\n diff.h                                       |   1 +\n submodule.c                                  |   3 +\n t/t3701-add-interactive.sh                   |   5 +\n t/t4027-diff-submodule.sh                    |  15 ++-\n t/t4041-diff-submodule-option.sh             |  16 +--\n t/t4060-diff-submodule-option-diff-format.sh |  16 +--\n t/t7064-wtstatus-pv2.sh                      |  52 ++++++++++\n t/t7506-status-submodule.sh                  | 102 ++++++++++++++++---\n 9 files changed, 182 insertions(+), 31 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 2bb2f8f57e..5d69c2bb1c 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4585,6 +4585,9 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)\n \t\tDIFF_XDL_SET(options, INDENT_HEURISTIC);\n \n \toptions->orderfile = diff_order_file_cfg;\n+\t\n+\tif (!options->flags.ignore_submodule_set)\n+\t\thandle_ignore_submodules_arg(options, \"untracked\");\n \n \tif (diff_no_prefix) {\n \t\toptions->a_prefix = options->b_prefix = \"\";\ndiff --git a/diff.h b/diff.h\nindex 11de52e9e9..1e18e6b1c3 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -178,6 +178,7 @@ struct diff_flags {\n \tunsigned diff_from_contents;\n \tunsigned dirty_submodules;\n \tunsigned ignore_untracked_in_submodules;\n+\tunsigned ignore_submodule_set;\n \tunsigned ignore_dirty_submodules;\n \tunsigned override_submodule_config;\n \tunsigned dirstat_by_line;\ndiff --git a/submodule.c b/submodule.c\nindex b3bb59f066..afeb754079 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -420,6 +420,7 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy\n void handle_ignore_submodules_arg(struct diff_options *diffopt,\n \t\t\t\t  const char *arg)\n {\n+\tdiffopt->flags.ignore_submodule_set = 1;\n \tdiffopt->flags.ignore_submodules = 0;\n \tdiffopt->flags.ignore_untracked_in_submodules = 0;\n \tdiffopt->flags.ignore_dirty_submodules = 0;\n@@ -1678,6 +1679,8 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)\n \tstrvec_pushl(&cp.args, \"status\", \"--porcelain=2\", NULL);\n \tif (ignore_untracked)\n \t\tstrvec_push(&cp.args, \"-uno\");\n+\telse\n+\t\tstrvec_push(&cp.args, \"--ignore-submodules=none\");\n \n \tprepare_submodule_repo_env(&cp.env_array);\n \tcp.git_cmd = 1;\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex ca04fac417..9104d1946d 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -765,6 +765,11 @@ test_expect_success 'setup different kinds of dirty submodules' '\n \tcat >expected <<-\\EOF &&\n \tdirty-both-ways\n \tdirty-head\n+\tEOF\n+\tgit -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&\n+\tcat >expected <<-\\EOF &&\n+\tdirty-both-ways\n+\tdirty-head\n \tdirty-otherwise\n \tEOF\n \ttest_cmp expected actual &&\ndiff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\nindex d7145ccca4..6432b4331f 100755\n--- a/t/t4027-diff-submodule.sh\n+++ b/t/t4027-diff-submodule.sh\n@@ -93,10 +93,19 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked)' '\n \t) &&\n \tgit diff HEAD >actual &&\n \tsed -e \"1,/^@@/d\" actual >actual.body &&\n-\texpect_from_to >expect.body $subtip $subprev-dirty &&\n+\texpect_from_to >expect.body $subtip $subprev &&\n \ttest_cmp expect.body actual.body\n '\n \n+test_expect_success 'git diff HEAD with dirty submodule (untracked) (none ignored)' '\n+\tgit config diff.ignoreSubmodules none &&\n+\tgit diff HEAD >actual &&\n+\tsed -e \"1,/^@@/d\" actual >actual.body &&\n+\texpect_from_to >expect.body $subtip $subprev-dirty &&\n+\ttest_cmp expect.body actual.body &&\n+\tgit config --unset diff.ignoreSubmodules\n+'\n+\n test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)' '\n \tgit commit -m \"x\" sub &&\n \techo >>sub/world &&\n@@ -168,13 +177,13 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'\n \t\tgit clean -qfdx &&\n \t\t>cruft\n \t) &&\n-\tgit diff HEAD >actual &&\n+\tgit diff --ignore-submodules=none HEAD >actual &&\n \tsed -e \"1,/^@@/d\" actual >actual.body &&\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual.body &&\n \tgit diff --ignore-submodules=all HEAD >actual2 &&\n \ttest_must_be_empty actual2 &&\n-\tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n+\tgit diff HEAD >actual3 &&\n \ttest_must_be_empty actual3 &&\n \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n \ttest_must_be_empty actual4\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex f852136585..bb368b685d 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -262,7 +262,7 @@ test_expect_success 'submodule is up to date' '\n \n test_expect_success 'submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tEOF\n@@ -270,7 +270,7 @@ test_expect_success 'submodule contains untracked content' '\n '\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \ttest_must_be_empty actual\n '\n \n@@ -286,7 +286,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n \n test_expect_success 'submodule contains untracked and modified content' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -296,7 +296,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n \n test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tEOF\n@@ -337,7 +337,7 @@ test_expect_success 'submodule is modified' '\n \n test_expect_success 'modified submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p  --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 $head6..$head8:\n@@ -347,7 +347,7 @@ test_expect_success 'modified submodule contains untracked content' '\n '\n \n test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 $head6..$head8:\n \t  > change\n@@ -371,7 +371,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n \n test_expect_success 'modified submodule contains untracked and modified content' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -383,7 +383,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n \n test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tSubmodule sm1 $head6..$head8:\ndiff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh\nindex fc8229c726..dc7b242697 100755\n--- a/t/t4060-diff-submodule-option-diff-format.sh\n+++ b/t/t4060-diff-submodule-option-diff-format.sh\n@@ -409,7 +409,7 @@ test_expect_success 'submodule is up to date' '\n \n test_expect_success 'submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tEOF\n@@ -417,7 +417,7 @@ test_expect_success 'submodule contains untracked content' '\n '\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \ttest_must_be_empty actual\n '\n \n@@ -433,7 +433,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n \n test_expect_success 'submodule contains untracked and modified content' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -451,7 +451,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n # NOT OK\n test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tdiff --git a/sm1/foo6 b/sm1/foo6\n@@ -512,7 +512,7 @@ test_expect_success 'submodule is modified' '\n \n test_expect_success 'modified submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 $head7..$head8:\n@@ -528,7 +528,7 @@ test_expect_success 'modified submodule contains untracked content' '\n '\n \n test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 $head7..$head8:\n \tdiff --git a/sm1/foo6 b/sm1/foo6\n@@ -564,7 +564,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n \n test_expect_success 'modified submodule contains untracked and modified content' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -583,7 +583,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n \n test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tSubmodule sm1 $head7..$head8:\ndiff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh\nindex 537787e598..78cd86be3a 100755\n--- a/t/t7064-wtstatus-pv2.sh\n+++ b/t/t7064-wtstatus-pv2.sh\n@@ -503,6 +503,31 @@ test_expect_success 'untracked changes in added submodule (AM S..U)' '\n \t\t1 AM S..U 000000 160000 160000 $ZERO_OID $HSUB sub1\n \t\tEOF\n \n+\t\tgit status --porcelain=v2 --branch --untracked-files=all --ignore-submodules=none >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'untracked changes in added submodule (A. S...) (untracked ignored)' '\n+\t(\tcd super_repo &&\n+\t\t## create untracked file in the submodule.\n+\t\t(\tcd sub1 &&\n+\t\t\techo \"xxxx\" >file_in_sub\n+\t\t) &&\n+\n+\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n+\t\tHSUP=$(git rev-parse HEAD) &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n+\t\t1 A. S... 000000 160000 160000 $ZERO_OID $HSUB sub1\n+\t\tEOF\n+\n \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n \t\ttest_cmp expect actual\n \t)\n@@ -582,6 +607,33 @@ test_expect_success 'staged and untracked changes in added submodule (AM S.MU)'\n \t\t1 AM S.MU 000000 160000 160000 $ZERO_OID $HSUB sub1\n \t\tEOF\n \n+\t\tgit status --porcelain=v2 --branch --untracked-files=all --ignore-submodules=none >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'staged and untracked changes in added submodule (AM S.M.) (untracked ignored)' '\n+\t(\tcd super_repo &&\n+\t\t(\tcd sub1 &&\n+\t\t\t## stage new changes in tracked file.\n+\t\t\tgit add file_in_sub &&\n+\t\t\t## create new untracked file.\n+\t\t\techo \"yyyy\" >>another_file_in_sub\n+\t\t) &&\n+\n+\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n+\t\tHSUP=$(git rev-parse HEAD) &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n+\t\t1 AM S.M. 000000 160000 160000 $ZERO_OID $HSUB sub1\n+\t\tEOF\n+\n \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n \t\ttest_cmp expect actual\n \t)\ndiff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh\nindex 3fcb44767f..72da00a962 100755\n--- a/t/t7506-status-submodule.sh\n+++ b/t/t7506-status-submodule.sh\n@@ -94,36 +94,60 @@ test_expect_success 'status with added file in submodule (short)' '\n test_expect_success 'status with untracked file in submodule' '\n \t(cd sub && git reset --hard) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (untracked content)\" output\n '\n \n+test_expect_success 'status with untracked file in submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"^nothing to commit\" output\n+'\n+\n test_expect_success 'status -uno with untracked file in submodule' '\n \tgit status -uno >output &&\n \ttest_i18ngrep \"^nothing to commit\" output\n '\n \n test_expect_success 'status with untracked file in submodule (porcelain)' '\n-\tgit status --porcelain >output &&\n+\tgit status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in submodule (porcelain) (untracked ignored)' '\n+\tgit status --porcelain >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in submodule (short)' '\n-\tgit status --short >output &&\n+\tgit status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t ? sub\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in submodule (short) (untracked ignored)' '\n+\tgit status --short >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with added and untracked file in submodule' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (modified content, untracked content)\" output\n '\n \n+test_expect_success 'status with added and untracked file in submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard && echo >foo && git add foo) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (modified content)\" output\n+'\n+\n test_expect_success 'status with added and untracked file in submodule (porcelain)' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n@@ -168,10 +192,17 @@ test_expect_success 'status with added file in modified submodule (porcelain)' '\n test_expect_success 'status with untracked file in modified submodule' '\n \t(cd sub && git reset --hard) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (new commits, untracked content)\" output\n '\n \n+test_expect_success 'status with untracked file in modified submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (new commits)\" output\n+'\n+\n test_expect_success 'status with untracked file in modified submodule (porcelain)' '\n \tgit status --porcelain >output &&\n \tdiff output - <<-\\EOF\n@@ -182,10 +213,17 @@ test_expect_success 'status with untracked file in modified submodule (porcelain\n test_expect_success 'status with added and untracked file in modified submodule' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (new commits, modified content, untracked content)\" output\n '\n \n+test_expect_success 'status with added and untracked file in modified submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard && echo >foo && git add foo) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (new commits, modified content)\" output\n+'\n+\n test_expect_success 'status with added and untracked file in modified submodule (porcelain)' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n@@ -349,7 +387,7 @@ test_expect_success 'setup superproject with untracked file in nested submodule'\n '\n \n test_expect_success 'status with untracked file in nested submodule (porcelain)' '\n-\tgit -C super status --porcelain >output &&\n+\tgit -C super status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub1\n \t M sub2\n@@ -357,8 +395,13 @@ test_expect_success 'status with untracked file in nested submodule (porcelain)'\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (porcelain) (untracked ignored)' '\n+\tgit -C super status --porcelain >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in nested submodule (porcelain=2)' '\n-\tgit -C super status --porcelain=2 >output &&\n+\tgit -C super status --porcelain=2 --ignore-submodules=none >output &&\n \tsanitize_output output &&\n \tdiff output - <<-\\EOF\n \t1 .M S..U 160000 160000 160000 HASH HASH sub1\n@@ -367,8 +410,13 @@ test_expect_success 'status with untracked file in nested submodule (porcelain=2\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (porcelain=2) (untracked ignored)' '\n+\tgit -C super status --porcelain=2 >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in nested submodule (short)' '\n-\tgit -C super status --short >output &&\n+\tgit -C super status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t ? sub1\n \t ? sub2\n@@ -376,13 +424,18 @@ test_expect_success 'status with untracked file in nested submodule (short)' '\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (short) (untracked ignored)' '\n+\tgit -C super status --short >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'setup superproject with modified file in nested submodule' '\n \tgit -C super/sub1/sub2 add file &&\n \tgit -C super/sub2 add file\n '\n \n test_expect_success 'status with added file in nested submodule (porcelain)' '\n-\tgit -C super status --porcelain >output &&\n+\tgit -C super status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub1\n \t M sub2\n@@ -390,8 +443,16 @@ test_expect_success 'status with added file in nested submodule (porcelain)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (porcelain) (untracked ignored)' '\n+\tgit -C super status --porcelain >output &&\n+\tdiff output - <<-\\EOF\n+\t M sub1\n+\t M sub2\n+\tEOF\n+'\n+\n test_expect_success 'status with added file in nested submodule (porcelain=2)' '\n-\tgit -C super status --porcelain=2 >output &&\n+\tgit -C super status --porcelain=2 --ignore-submodules=none >output &&\n \tsanitize_output output &&\n \tdiff output - <<-\\EOF\n \t1 .M S.M. 160000 160000 160000 HASH HASH sub1\n@@ -400,8 +461,17 @@ test_expect_success 'status with added file in nested submodule (porcelain=2)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (porcelain=2) (untracked ignored)' '\n+\tgit -C super status --porcelain=2 >output &&\n+\tsanitize_output output &&\n+\tdiff output - <<-\\EOF\n+\t1 .M S.M. 160000 160000 160000 HASH HASH sub1\n+\t1 .M S.M. 160000 160000 160000 HASH HASH sub2\n+\tEOF\n+'\n+\n test_expect_success 'status with added file in nested submodule (short)' '\n-\tgit -C super status --short >output &&\n+\tgit -C super status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t m sub1\n \t m sub2\n@@ -409,4 +479,12 @@ test_expect_success 'status with added file in nested submodule (short)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (short) (untracked ignored)' '\n+\tgit -C super status --short >output &&\n+\tdiff output - <<-\\EOF\n+\t m sub1\n+\t m sub2\n+\tEOF\n+'\n+\n test_done\n-- \n2.21.1 (Apple Git-122.3)\n\n"},{"id":"408282","messageId":"xmqqtuukg0a9.fsf@gitster.c.googlers.com","threadId":"54429","inReplyTo":"CAHjREB5Uye1b=bVZsAc1WPcrWrqxnrMZxBtLT345CrpU7gTpVg@mail.gmail.com","subject":"Re: [PATCH v4] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-10-23T20:22:38Z","receivedAt":"2020-10-23T20:22:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sangeeta NB <sangunb09@gmail.com> writes:\n\n>> By the way, in builtin/describe.c there is an invocation of\n>> \"diff-index\" without any --ignore-submodules=<what> option.\n>>\n>>         /* diff-index command arguments to check if working tree is dirty. */\n>>         static const char *diff_index_args[] = {\n>>                 \"diff-index\", \"--quiet\", \"HEAD\", \"--\", NULL\n>>         };\n>>\n>> Would the behaviour of diff-index invocation in \"git describe --dirty\"\n>> affected by the change of the default in any way?\n>\n> I don't think so because describe was already behaving in the way that\n> we won't. We changed the behavior of git diff to match it with that.\n> So it doesn't make sense to add anything to that. Tell me if I am\n> missing something.\n\nHow does \"describe\" see if the working tree is dirty?  What\nmechanism does it use?  Doesn't it run the \"diff-index\" command\ninternally?\n\nAnd with this patch, aren't you changing the default behaviour of\n\"diff\" family of commands by touching repo_diff_setup() function?\nHow does it not affect the behaviour of the \"diff-index\" command,\nhence the input \"git describe\" uses to formulate its output?\n"},{"id":"408285","messageId":"xmqqmu0cfx9a.fsf@gitster.c.googlers.com","threadId":"54429","inReplyTo":"20201023111827.40188-1-sangunb09@gmail.com","subject":"Re: [Outreachy] [PATCH v4] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-10-23T21:28:01Z","receivedAt":"2020-10-23T21:28:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sangeeta Jain <sangunb09@gmail.com> writes:\n\n> diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\n> ...\n> +test_expect_success 'git diff HEAD with dirty submodule (untracked) (none ignored)' '\n> +\tgit config diff.ignoreSubmodules none &&\n> +\tgit diff HEAD >actual &&\n> +\tsed -e \"1,/^@@/d\" actual >actual.body &&\n> +\texpect_from_to >expect.body $subtip $subprev-dirty &&\n> +\ttest_cmp expect.body actual.body &&\n> +\tgit config --unset diff.ignoreSubmodules\n> +'\n\nIf any step concatenated by && in the above sequence fails, the test\nrepository will have diff.ignoreSubmodules set to none (without\ngetting it reset, since &&-chain prevents the last \"config --unset\"\nstep from running).  Unless the test is run under the --immediate\noption, that would affect the environment in which subsequent tests\nare run.\n\nInstead, our test usually do this:\n\n\ttest_expect_success 'test title' '\n                test_config diff.ignoresubmodules none &&\n                git diff HEAD >actual &&\n                ...\n                test_cmp expect.body actual.body\n\t'\n\n\"test_config\" sets up a trigger, which will _always_ fire, whether\nthe test fails at any intermediate steps or runs to the end and\nsucceeds, to remove the configuration it just added.  It is a\nshort-hand for writing\n\n\ttest_when_finished test_unconfig diff.ignoresubmodules &&\n\tgit config diff.ignoresubmodules none\n\ni.e. to use test_when_finished to set up the trigger.\n\n> -\tgit diff HEAD >actual &&\n> +\tgit diff --ignore-submodules=none HEAD >actual &&\n>  \tsed -e \"1,/^@@/d\" actual >actual.body &&\n>  \texpect_from_to >expect.body $subprev $subprev-dirty &&\n>  \ttest_cmp expect.body actual.body &&\n>  \tgit diff --ignore-submodules=all HEAD >actual2 &&\n>  \ttest_must_be_empty actual2 &&\n> -\tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n> +\tgit diff HEAD >actual3 &&\n\nThis line can be left as-is, no?\n\n> diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\n> index f852136585..bb368b685d 100755\n> --- a/t/t4041-diff-submodule-option.sh\n> +++ b/t/t4041-diff-submodule-option.sh\n> @@ -262,7 +262,7 @@ test_expect_success 'submodule is up to date' '\n>  \n>  test_expect_success 'submodule contains untracked content' '\n>  \techo new > sm1/new-file &&\n> -\tgit diff-index -p --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains untracked content\n>  \tEOF\n> @@ -270,7 +270,7 @@ test_expect_success 'submodule contains untracked content' '\n>  '\n>  \n>  test_expect_success 'submodule contains untracked content (untracked ignored)' '\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD >actual &&\n\nLikewise.\n"},{"id":"408343","messageId":"CAHjREB6fC6j30MH1Lb7enE3KJaGdX--Ft8+hwVeDfwApab5FNQ@mail.gmail.com","threadId":"54429","inReplyTo":"xmqqmu0cfx9a.fsf@gitster.c.googlers.com","subject":"Re: [Outreachy] [PATCH v4] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta NB","fromEmail":"sangunb09@gmail.com","sentAt":"2020-10-25T10:23:49Z","receivedAt":"2020-10-25T10:24:15Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"On Sat, Oct 24, 2020 at 2:58 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Sangeeta Jain <sangunb09@gmail.com> writes:\n>\n> > diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\n> > ...\n> > +test_expect_success 'git diff HEAD with dirty submodule (untracked) (none ignored)' '\n> > +     git config diff.ignoreSubmodules none &&\n> > +     git diff HEAD >actual &&\n> > +     sed -e \"1,/^@@/d\" actual >actual.body &&\n> > +     expect_from_to >expect.body $subtip $subprev-dirty &&\n> > +     test_cmp expect.body actual.body &&\n> > +     git config --unset diff.ignoreSubmodules\n> > +'\n>\n> If any step concatenated by && in the above sequence fails, the test\n> repository will have diff.ignoreSubmodules set to none (without\n> getting it reset, since &&-chain prevents the last \"config --unset\"\n> step from running).  Unless the test is run under the --immediate\n> option, that would affect the environment in which subsequent tests\n> are run.\n>\n> Instead, our test usually do this:\n>\n>         test_expect_success 'test title' '\n>                 test_config diff.ignoresubmodules none &&\n>                 git diff HEAD >actual &&\n>                 ...\n>                 test_cmp expect.body actual.body\n>         '\n>\n> \"test_config\" sets up a trigger, which will _always_ fire, whether\n> the test fails at any intermediate steps or runs to the end and\n> succeeds, to remove the configuration it just added.  It is a\n> short-hand for writing\n>\n>         test_when_finished test_unconfig diff.ignoresubmodules &&\n>         git config diff.ignoresubmodules none\n>\n> i.e. to use test_when_finished to set up the trigger.\n>\n\nOh, okay! I would make these changes. Thanks for the explanation.\nThere are also other places where `git config` is used in test\nscripts. Should I change that too? Or maybe as they are not relevant\nto this patch, we can create an issue or even a microproject for other\nfirst-timer contributors?\n\n\n> > -     git diff HEAD >actual &&\n> > +     git diff --ignore-submodules=none HEAD >actual &&\n> >       sed -e \"1,/^@@/d\" actual >actual.body &&\n> >       expect_from_to >expect.body $subprev $subprev-dirty &&\n> >       test_cmp expect.body actual.body &&\n> >       git diff --ignore-submodules=all HEAD >actual2 &&\n> >       test_must_be_empty actual2 &&\n> > -     git diff --ignore-submodules=untracked HEAD >actual3 &&\n> > +     git diff HEAD >actual3 &&\n>\n> This line can be left as-is, no?\n\nYa, they can be left as it is but I removed the\n--ignore-submodules=untracked because we also have to check the\ndefault git behavior and adding that doesn't change anything in the\ncode so I removed that.\nIn general, in all the tests I followed this practice:\n1. I added --ignore-submodules=none where there were no options\nspecified(as this was the earlier default)\n2. I removed --ignore-submodules=untracked(as this should even work if\nno options are specified)\n\nI would put that back if you still want it?\n\nThanks and Regards,\n"},{"id":"408425","messageId":"xmqqblgoga8m.fsf@gitster.c.googlers.com","threadId":"54429","inReplyTo":"CAHjREB6fC6j30MH1Lb7enE3KJaGdX--Ft8+hwVeDfwApab5FNQ@mail.gmail.com","subject":"Re: [Outreachy] [PATCH v4] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-10-26T17:36:41Z","receivedAt":"2020-10-26T17:36:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sangeeta NB <sangunb09@gmail.com> writes:\n\n>> > -     git diff HEAD >actual &&\n>> > +     git diff --ignore-submodules=none HEAD >actual &&\n>> >       sed -e \"1,/^@@/d\" actual >actual.body &&\n>> >       expect_from_to >expect.body $subprev $subprev-dirty &&\n>> >       test_cmp expect.body actual.body &&\n>> >       git diff --ignore-submodules=all HEAD >actual2 &&\n>> >       test_must_be_empty actual2 &&\n>> > -     git diff --ignore-submodules=untracked HEAD >actual3 &&\n>> > +     git diff HEAD >actual3 &&\n>>\n>> This line can be left as-is, no?\n>\n> Ya, they can be left as it is but I removed the\n> --ignore-submodules=untracked because we also have to check the\n> default git behavior and adding that doesn't change anything in the\n> code so I removed that.\n> In general, in all the tests I followed this practice:\n> 1. I added --ignore-submodules=none where there were no options\n> specified(as this was the earlier default)\n> 2. I removed --ignore-submodules=untracked(as this should even work if\n> no options are specified)\n>\n> I would put that back if you still want it?\n\nOK, I re-read the changes to the tests in v5 (an excerpt at the end\nof this message), and I think this one makes sort-of sense.\n\nWe want to see that a plain-vanilla invocation of \"git diff\" without\ncustom \"--ignore-submodules\" option would stop saying -dirty when\nuntracked cruft is in the submodule's working tree, and this test,\nas it says in its title, is exactly testing that case (i.e. \"how is\na submodule without change relative to the gitlink in the\nsuperproject shown when there is untracked cruft there?\").  It is a\nperfect opportunity to give the answer to the question and how that\nanswer will be different from the current system if we took this\npatch.  We used to expect to see that submodule has changed from the\ncommit subprev to the same commit subprev with dirty indicator.\nWhat should we expect under the new world order?  We should stop\nclaiming that submodule has any change.\n\nSo I would have expected that would be shown by the first step in\nfirst \"what happens without custom --ignore-submodules invocation?\"\ntest by changing the expect_from_to that corresponds to it, and then\na *new* test added to show that with \"--ignore-submodules=none\" it\nis still possible to get \"changed from the same commit to the same\ncommit with the -dirty indicator\" as a second test.\n\nAs long as all cases (i.e. all possible values to --ignore-submodules=<what>,\nplus the case where --ignore-submodules=<what> is not given at all) are\ncovered, it is OK, but I think it is the best to show the case without\nan option, especially when the original does so.\n\nThanks.\n\n@@ -168,13 +177,13 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'\n \t\tgit clean -qfdx &&\n \t\t>cruft\n \t) &&\n-\tgit diff HEAD >actual &&\n+\tgit diff --ignore-submodules=none HEAD >actual &&\n \tsed -e \"1,/^@@/d\" actual >actual.body &&\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual.body &&\n \tgit diff --ignore-submodules=all HEAD >actual2 &&\n \ttest_must_be_empty actual2 &&\n-\tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n+\tgit diff HEAD >actual3 &&\n \ttest_must_be_empty actual3 &&\n \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n \ttest_must_be_empty actual4\n"},{"id":"408429","messageId":"20201026175742.33356-1-sangunb09@gmail.com","threadId":"54429","inReplyTo":"pull.751.git.1602781723670.gitgitgadget@gmail.com","subject":"[Outreachy][PATCH v6] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta Jain","fromEmail":"sangunb09@gmail.com","sentAt":"2020-10-26T17:57:42Z","receivedAt":"2020-10-26T17:58:08Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"Git diff reports a submodule directory as -dirty even when there are\nonly untracked files in the submodule directory. This is inconsistent\nwith what `git describe --dirty` says when run in the submodule\ndirectory in that state.\n\nMake `--ignore-submodules=untracked` the default for `git diff` when\nthere is no configuration variable or command line option, so that the\ncommand would not give '-dirty' suffix to a submodule whose working\ntree has untracked files, to make it consistent with `git\ndescribe --dirty` that is run in the submodule working tree.\n\nSigned-off-by: Sangeeta Jain <sangunb09@gmail.com>\n---\n diff.c                                       |   3 +\n diff.h                                       |   1 +\n submodule.c                                  |   3 +\n t/t3701-add-interactive.sh                   |   5 +\n t/t4027-diff-submodule.sh                    |  12 ++-\n t/t4041-diff-submodule-option.sh             |  16 +--\n t/t4060-diff-submodule-option-diff-format.sh |  16 +--\n t/t7064-wtstatus-pv2.sh                      |  52 ++++++++++\n t/t7506-status-submodule.sh                  | 102 ++++++++++++++++---\n 9 files changed, 180 insertions(+), 30 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 2bb2f8f57e..5d69c2bb1c 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4585,6 +4585,9 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)\n \t\tDIFF_XDL_SET(options, INDENT_HEURISTIC);\n \n \toptions->orderfile = diff_order_file_cfg;\n+\t\n+\tif (!options->flags.ignore_submodule_set)\n+\t\thandle_ignore_submodules_arg(options, \"untracked\");\n \n \tif (diff_no_prefix) {\n \t\toptions->a_prefix = options->b_prefix = \"\";\ndiff --git a/diff.h b/diff.h\nindex 11de52e9e9..1e18e6b1c3 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -178,6 +178,7 @@ struct diff_flags {\n \tunsigned diff_from_contents;\n \tunsigned dirty_submodules;\n \tunsigned ignore_untracked_in_submodules;\n+\tunsigned ignore_submodule_set;\n \tunsigned ignore_dirty_submodules;\n \tunsigned override_submodule_config;\n \tunsigned dirstat_by_line;\ndiff --git a/submodule.c b/submodule.c\nindex b3bb59f066..afeb754079 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -420,6 +420,7 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy\n void handle_ignore_submodules_arg(struct diff_options *diffopt,\n \t\t\t\t  const char *arg)\n {\n+\tdiffopt->flags.ignore_submodule_set = 1;\n \tdiffopt->flags.ignore_submodules = 0;\n \tdiffopt->flags.ignore_untracked_in_submodules = 0;\n \tdiffopt->flags.ignore_dirty_submodules = 0;\n@@ -1678,6 +1679,8 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)\n \tstrvec_pushl(&cp.args, \"status\", \"--porcelain=2\", NULL);\n \tif (ignore_untracked)\n \t\tstrvec_push(&cp.args, \"-uno\");\n+\telse\n+\t\tstrvec_push(&cp.args, \"--ignore-submodules=none\");\n \n \tprepare_submodule_repo_env(&cp.env_array);\n \tcp.git_cmd = 1;\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex ca04fac417..9104d1946d 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -765,6 +765,11 @@ test_expect_success 'setup different kinds of dirty submodules' '\n \tcat >expected <<-\\EOF &&\n \tdirty-both-ways\n \tdirty-head\n+\tEOF\n+\tgit -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&\n+\tcat >expected <<-\\EOF &&\n+\tdirty-both-ways\n+\tdirty-head\n \tdirty-otherwise\n \tEOF\n \ttest_cmp expected actual &&\ndiff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\nindex d7145ccca4..894a11b224 100755\n--- a/t/t4027-diff-submodule.sh\n+++ b/t/t4027-diff-submodule.sh\n@@ -93,6 +93,14 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked)' '\n \t) &&\n \tgit diff HEAD >actual &&\n \tsed -e \"1,/^@@/d\" actual >actual.body &&\n+\texpect_from_to >expect.body $subtip $subprev &&\n+\ttest_cmp expect.body actual.body\n+'\n+\n+test_expect_success 'git diff HEAD with dirty submodule (untracked) (none ignored)' '\n+\ttest_config diff.ignoreSubmodules none &&\n+\tgit diff HEAD >actual &&\n+\tsed -e \"1,/^@@/d\" actual >actual.body &&\n \texpect_from_to >expect.body $subtip $subprev-dirty &&\n \ttest_cmp expect.body actual.body\n '\n@@ -168,13 +176,13 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'\n \t\tgit clean -qfdx &&\n \t\t>cruft\n \t) &&\n-\tgit diff HEAD >actual &&\n+\tgit diff --ignore-submodules=none HEAD >actual &&\n \tsed -e \"1,/^@@/d\" actual >actual.body &&\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual.body &&\n \tgit diff --ignore-submodules=all HEAD >actual2 &&\n \ttest_must_be_empty actual2 &&\n-\tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n+\tgit diff HEAD >actual3 &&\n \ttest_must_be_empty actual3 &&\n \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n \ttest_must_be_empty actual4\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex f852136585..bb368b685d 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -262,7 +262,7 @@ test_expect_success 'submodule is up to date' '\n \n test_expect_success 'submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tEOF\n@@ -270,7 +270,7 @@ test_expect_success 'submodule contains untracked content' '\n '\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \ttest_must_be_empty actual\n '\n \n@@ -286,7 +286,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n \n test_expect_success 'submodule contains untracked and modified content' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -296,7 +296,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n \n test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tEOF\n@@ -337,7 +337,7 @@ test_expect_success 'submodule is modified' '\n \n test_expect_success 'modified submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p  --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 $head6..$head8:\n@@ -347,7 +347,7 @@ test_expect_success 'modified submodule contains untracked content' '\n '\n \n test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 $head6..$head8:\n \t  > change\n@@ -371,7 +371,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n \n test_expect_success 'modified submodule contains untracked and modified content' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -383,7 +383,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n \n test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tSubmodule sm1 $head6..$head8:\ndiff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh\nindex fc8229c726..dc7b242697 100755\n--- a/t/t4060-diff-submodule-option-diff-format.sh\n+++ b/t/t4060-diff-submodule-option-diff-format.sh\n@@ -409,7 +409,7 @@ test_expect_success 'submodule is up to date' '\n \n test_expect_success 'submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tEOF\n@@ -417,7 +417,7 @@ test_expect_success 'submodule contains untracked content' '\n '\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \ttest_must_be_empty actual\n '\n \n@@ -433,7 +433,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n \n test_expect_success 'submodule contains untracked and modified content' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -451,7 +451,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n # NOT OK\n test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tdiff --git a/sm1/foo6 b/sm1/foo6\n@@ -512,7 +512,7 @@ test_expect_success 'submodule is modified' '\n \n test_expect_success 'modified submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 $head7..$head8:\n@@ -528,7 +528,7 @@ test_expect_success 'modified submodule contains untracked content' '\n '\n \n test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 $head7..$head8:\n \tdiff --git a/sm1/foo6 b/sm1/foo6\n@@ -564,7 +564,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n \n test_expect_success 'modified submodule contains untracked and modified content' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -583,7 +583,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n \n test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tSubmodule sm1 $head7..$head8:\ndiff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh\nindex 537787e598..78cd86be3a 100755\n--- a/t/t7064-wtstatus-pv2.sh\n+++ b/t/t7064-wtstatus-pv2.sh\n@@ -503,6 +503,31 @@ test_expect_success 'untracked changes in added submodule (AM S..U)' '\n \t\t1 AM S..U 000000 160000 160000 $ZERO_OID $HSUB sub1\n \t\tEOF\n \n+\t\tgit status --porcelain=v2 --branch --untracked-files=all --ignore-submodules=none >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'untracked changes in added submodule (A. S...) (untracked ignored)' '\n+\t(\tcd super_repo &&\n+\t\t## create untracked file in the submodule.\n+\t\t(\tcd sub1 &&\n+\t\t\techo \"xxxx\" >file_in_sub\n+\t\t) &&\n+\n+\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n+\t\tHSUP=$(git rev-parse HEAD) &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n+\t\t1 A. S... 000000 160000 160000 $ZERO_OID $HSUB sub1\n+\t\tEOF\n+\n \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n \t\ttest_cmp expect actual\n \t)\n@@ -582,6 +607,33 @@ test_expect_success 'staged and untracked changes in added submodule (AM S.MU)'\n \t\t1 AM S.MU 000000 160000 160000 $ZERO_OID $HSUB sub1\n \t\tEOF\n \n+\t\tgit status --porcelain=v2 --branch --untracked-files=all --ignore-submodules=none >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'staged and untracked changes in added submodule (AM S.M.) (untracked ignored)' '\n+\t(\tcd super_repo &&\n+\t\t(\tcd sub1 &&\n+\t\t\t## stage new changes in tracked file.\n+\t\t\tgit add file_in_sub &&\n+\t\t\t## create new untracked file.\n+\t\t\techo \"yyyy\" >>another_file_in_sub\n+\t\t) &&\n+\n+\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n+\t\tHSUP=$(git rev-parse HEAD) &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n+\t\t1 AM S.M. 000000 160000 160000 $ZERO_OID $HSUB sub1\n+\t\tEOF\n+\n \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n \t\ttest_cmp expect actual\n \t)\ndiff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh\nindex 3fcb44767f..72da00a962 100755\n--- a/t/t7506-status-submodule.sh\n+++ b/t/t7506-status-submodule.sh\n@@ -94,36 +94,60 @@ test_expect_success 'status with added file in submodule (short)' '\n test_expect_success 'status with untracked file in submodule' '\n \t(cd sub && git reset --hard) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (untracked content)\" output\n '\n \n+test_expect_success 'status with untracked file in submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"^nothing to commit\" output\n+'\n+\n test_expect_success 'status -uno with untracked file in submodule' '\n \tgit status -uno >output &&\n \ttest_i18ngrep \"^nothing to commit\" output\n '\n \n test_expect_success 'status with untracked file in submodule (porcelain)' '\n-\tgit status --porcelain >output &&\n+\tgit status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in submodule (porcelain) (untracked ignored)' '\n+\tgit status --porcelain >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in submodule (short)' '\n-\tgit status --short >output &&\n+\tgit status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t ? sub\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in submodule (short) (untracked ignored)' '\n+\tgit status --short >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with added and untracked file in submodule' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (modified content, untracked content)\" output\n '\n \n+test_expect_success 'status with added and untracked file in submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard && echo >foo && git add foo) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (modified content)\" output\n+'\n+\n test_expect_success 'status with added and untracked file in submodule (porcelain)' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n@@ -168,10 +192,17 @@ test_expect_success 'status with added file in modified submodule (porcelain)' '\n test_expect_success 'status with untracked file in modified submodule' '\n \t(cd sub && git reset --hard) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (new commits, untracked content)\" output\n '\n \n+test_expect_success 'status with untracked file in modified submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (new commits)\" output\n+'\n+\n test_expect_success 'status with untracked file in modified submodule (porcelain)' '\n \tgit status --porcelain >output &&\n \tdiff output - <<-\\EOF\n@@ -182,10 +213,17 @@ test_expect_success 'status with untracked file in modified submodule (porcelain\n test_expect_success 'status with added and untracked file in modified submodule' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n-\tgit status >output &&\n+\tgit status --ignore-submodules=none >output &&\n \ttest_i18ngrep \"modified:   sub (new commits, modified content, untracked content)\" output\n '\n \n+test_expect_success 'status with added and untracked file in modified submodule (untracked ignored)' '\n+\t(cd sub && git reset --hard && echo >foo && git add foo) &&\n+\techo \"content\" >sub/new-file &&\n+\tgit status >output &&\n+\ttest_i18ngrep \"modified:   sub (new commits, modified content)\" output\n+'\n+\n test_expect_success 'status with added and untracked file in modified submodule (porcelain)' '\n \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n \techo \"content\" >sub/new-file &&\n@@ -349,7 +387,7 @@ test_expect_success 'setup superproject with untracked file in nested submodule'\n '\n \n test_expect_success 'status with untracked file in nested submodule (porcelain)' '\n-\tgit -C super status --porcelain >output &&\n+\tgit -C super status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub1\n \t M sub2\n@@ -357,8 +395,13 @@ test_expect_success 'status with untracked file in nested submodule (porcelain)'\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (porcelain) (untracked ignored)' '\n+\tgit -C super status --porcelain >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in nested submodule (porcelain=2)' '\n-\tgit -C super status --porcelain=2 >output &&\n+\tgit -C super status --porcelain=2 --ignore-submodules=none >output &&\n \tsanitize_output output &&\n \tdiff output - <<-\\EOF\n \t1 .M S..U 160000 160000 160000 HASH HASH sub1\n@@ -367,8 +410,13 @@ test_expect_success 'status with untracked file in nested submodule (porcelain=2\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (porcelain=2) (untracked ignored)' '\n+\tgit -C super status --porcelain=2 >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'status with untracked file in nested submodule (short)' '\n-\tgit -C super status --short >output &&\n+\tgit -C super status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t ? sub1\n \t ? sub2\n@@ -376,13 +424,18 @@ test_expect_success 'status with untracked file in nested submodule (short)' '\n \tEOF\n '\n \n+test_expect_success 'status with untracked file in nested submodule (short) (untracked ignored)' '\n+\tgit -C super status --short >output &&\n+\ttest_must_be_empty output\n+'\n+\n test_expect_success 'setup superproject with modified file in nested submodule' '\n \tgit -C super/sub1/sub2 add file &&\n \tgit -C super/sub2 add file\n '\n \n test_expect_success 'status with added file in nested submodule (porcelain)' '\n-\tgit -C super status --porcelain >output &&\n+\tgit -C super status --porcelain --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t M sub1\n \t M sub2\n@@ -390,8 +443,16 @@ test_expect_success 'status with added file in nested submodule (porcelain)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (porcelain) (untracked ignored)' '\n+\tgit -C super status --porcelain >output &&\n+\tdiff output - <<-\\EOF\n+\t M sub1\n+\t M sub2\n+\tEOF\n+'\n+\n test_expect_success 'status with added file in nested submodule (porcelain=2)' '\n-\tgit -C super status --porcelain=2 >output &&\n+\tgit -C super status --porcelain=2 --ignore-submodules=none >output &&\n \tsanitize_output output &&\n \tdiff output - <<-\\EOF\n \t1 .M S.M. 160000 160000 160000 HASH HASH sub1\n@@ -400,8 +461,17 @@ test_expect_success 'status with added file in nested submodule (porcelain=2)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (porcelain=2) (untracked ignored)' '\n+\tgit -C super status --porcelain=2 >output &&\n+\tsanitize_output output &&\n+\tdiff output - <<-\\EOF\n+\t1 .M S.M. 160000 160000 160000 HASH HASH sub1\n+\t1 .M S.M. 160000 160000 160000 HASH HASH sub2\n+\tEOF\n+'\n+\n test_expect_success 'status with added file in nested submodule (short)' '\n-\tgit -C super status --short >output &&\n+\tgit -C super status --short --ignore-submodules=none >output &&\n \tdiff output - <<-\\EOF\n \t m sub1\n \t m sub2\n@@ -409,4 +479,12 @@ test_expect_success 'status with added file in nested submodule (short)' '\n \tEOF\n '\n \n+test_expect_success 'status with added file in nested submodule (short) (untracked ignored)' '\n+\tgit -C super status --short >output &&\n+\tdiff output - <<-\\EOF\n+\t m sub1\n+\t m sub2\n+\tEOF\n+'\n+\n test_done\n-- \n2.21.1 (Apple Git-122.3)\n\n"},{"id":"408988","messageId":"CAHjREB7W2P9_P4LoMHVVzV_YR5-_51zdbRZ0fpEDVkgkd7sh8w@mail.gmail.com","threadId":"54429","inReplyTo":"20201026175742.33356-1-sangunb09@gmail.com","subject":"Re: [Outreachy][PATCH v6] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta","fromEmail":"sangunb09@gmail.com","sentAt":"2020-11-03T10:46:49Z","receivedAt":"2020-11-03T10:47:03Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"Hey Johannes and Junio,\n\nIn continuation of the discussion from here[1]\n\n[1] https://lore.kernel.org/git/nycvar.QRO.7.76.6.2011020251520.18437@tvgsbejvaqbjf.bet/\n\n> >> * sj/untracked-files-in-submodule-directory-is-not-dirty (2020-10-26) 1 commit\n> >>  - diff: do not show submodule with untracked files as \"-dirty\"\n> >>\n> >>  \"git diff\" showed a submodule working tree with untracked cruft as\n> >>  \"Submodule commit <objectname>-dirty\", but a natural expectation is\n> >>  that the \"-dirty\" indicator would align with \"git describe --dirty\",\n> >>  which does not consider having untracked files in the working tree\n> >>  as source of dirtiness.  The inconsistency has been fixed.\n> >>\n> >>  Needs doc update.\n\nDo I need to add the doc update in the same patch?\n\n> > I *think* the original rationale for marking submodules with untracked\n> > (_un-ignored_) files was to avoid deleting a submodule that has\n> > uncommitted (because untracked) files.\n>\n> I agree with you that that the motivation was exactly that, but I\n> have a suspicion that its execution was misguided.\n\nI am really very sorry if I ended up adding some unwanted code.\n\n>\n> When one has a subdirectory D where one might or might not have an\n> untracked new file that one does not want to lose, but one otherwise\n> would want to clean up (perhaps an errant process created tons of\n> garbage files in the directory), one would not\n>\n>         git diff D\n>\n> to see if there are important changes in that directory before doing\n>\n>         rm -rf D && git checkout D\n>\n> to bring it back to pristine state, exactly because one would not\n> want to lose newly-created but not added files.  One would instead\n> use\n>\n>         git status D\n>\n> for checking.  Why would a user change the habit when D happens to\n> be a submodule?\n>\n> So I would say that \"git status [D]\", if it does not let the user\n> notice that there is untracked contents in the submodule working\n> tree, would be a bad idea.  \"git diff\" that ignores untracked paths\n> in the submodule working tree, on the other hand, is a good thing.\n>\n> Now, the patch as-is may change the behaviour of \"git status D\" in\n> this case, and the internal invocation of diff-files made somewhere\n> in wt-status.c may have to be adjusted to keep such a submodule with\n> forgotten newly created files shown as modified.\n>\n> Further discussion on this should be done on the original review\n> thread for continuity, not here, in any case.\n>\n\nSo we want that `git status` should behave in the same way as it was\nbehaving before? Can we do this by passing --ignore-submodules=none as\nthe default args for status? Another approach might be to figure out\nhow the diff is being called(like is this being called from git status\nor git diff) and then add the --ignore-submodules=untracked behavior\nto it accordingly. Though I have no idea how to do that now.\n\nPlease correct me if I am completely going in the wrong direction. As\nit is my first time contributing to git, so any help would be greatly\nbeneficial for me.\n\nThanks and regards,\nSangeeta\n"},{"id":"409024","messageId":"xmqqblges4ue.fsf@gitster.c.googlers.com","threadId":"54429","inReplyTo":"CAHjREB7W2P9_P4LoMHVVzV_YR5-_51zdbRZ0fpEDVkgkd7sh8w@mail.gmail.com","subject":"Re: [Outreachy][PATCH v6] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-11-03T17:55:05Z","receivedAt":"2020-11-03T17:55:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sangeeta <sangunb09@gmail.com> writes:\n\n> Hey Johannes and Junio,\n>\n> In continuation of the discussion from here[1]\n>\n> [1] https://lore.kernel.org/git/nycvar.QRO.7.76.6.2011020251520.18437@tvgsbejvaqbjf.bet/\n>\n>> >> * sj/untracked-files-in-submodule-directory-is-not-dirty (2020-10-26) 1 commit\n>> >>  - diff: do not show submodule with untracked files as \"-dirty\"\n>> >>\n>> >>  \"git diff\" showed a submodule working tree with untracked cruft as\n>> >>  \"Submodule commit <objectname>-dirty\", but a natural expectation is\n>> >>  that the \"-dirty\" indicator would align with \"git describe --dirty\",\n>> >>  which does not consider having untracked files in the working tree\n>> >>  as source of dirtiness.  The inconsistency has been fixed.\n>> >>\n>> >>  Needs doc update.\n>\n> Do I need to add the doc update in the same patch?\n\nIt is ideal if code change, tests and documentation are done\natomically.  For a large series the story may be different, but I\nthought a single commit would be sufficient for this topic?\n\n>> > I *think* the original rationale for marking submodules with untracked\n>> > (_un-ignored_) files was to avoid deleting a submodule that has\n>> > uncommitted (because untracked) files.\n>>\n>> I agree with you that that the motivation was exactly that, but I\n>> have a suspicion that its execution was misguided.\n>\n> I am really very sorry if I ended up adding some unwanted code.\n\nBut you did not.  The \"motivation\" and \"execution\" are both from\nlong time ago, back when submodule support was invented and \"git\ndiff\" in the superproject was taught to pay attention to submodules.\n\nDscho suspects that \"git diff\" were taught to add \"-dirty\" to\nsubmodules with untracked files in their working tree in order to\nprotect them from those who are about to delete them as a way to\ncheck if it is safe.  I agreed that the motivation may have been so,\ni.e. they wanted to protect users from losing untracked files that\nthey forgot to add and commit in the submodule, but the execution\nwas wrong, i.e. \"git diff\" is not the right tool to achieve that\nprotection.\n\nSee that you didn't add any unwanted code---it all happened long\ntime ago ;-)\n\n> So we want that `git status` should behave in the same way as it was\n> behaving before? Can we do this by passing --ignore-submodules=none as\n> the default args for status?\n\nYes, I do not recall offhand where in wt-status.c \"git status\" does so,\nbut there should be an internal invocation of diff-files somewhere, and\nI suspect it is not passing any --ignore-submodules bit.  Just like\nwt_status_collect_changes_index() calls handle_ignore_submodules_arg()\nwith hardcoded \"dirty\", we may have to unignore untracked files in\nsubmodule working trees when checking the working tree changes.\n\n> Another approach might be to figure out\n> how the diff is being called(like is this being called from git status\n> or git diff) and then add the --ignore-submodules=untracked behavior\n> to it accordingly. Though I have no idea how to do that now.\n\nNo, callee shouldn't have knowledge of its caller to perform a\nspecial case action.  The caller should say how it wants its callees\nto behave.\n\nThanks.\n"},{"id":"409320","messageId":"CAHjREB7-QWHBOQQPdDdEM-gJm=w3+4D=N=5TaS3UE__6XnSpJA@mail.gmail.com","threadId":"54429","inReplyTo":"xmqqblges4ue.fsf@gitster.c.googlers.com","subject":"Re: [Outreachy][PATCH v6] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta","fromEmail":"sangunb09@gmail.com","sentAt":"2020-11-07T10:47:24Z","receivedAt":"2020-11-07T10:47:39Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"Hey,\n\nI worked on passing --ignore-submodules=none as the default behavior\nof git status so that the user doesn't end up deleting a submodule\nthat has uncommitted (untracked) files.\n\nThe following changes make git status pass the ignoreSubmodules none\nargument as default.\n\n@@ -4587,7 +4587,7 @@ void repo_diff_setup(struct repository *r,\nstruct diff_options *options)\n        options->orderfile = diff_order_file_cfg;\n\n        if (!options->flags.ignore_submodule_set)\n-               handle_ignore_submodules_arg(options, \"untracked\");\n+               options->flags.ignore_untracked_in_submodules = 1;\n\n        if (diff_no_prefix) {\n                options->a_prefix = options->b_prefix = \"\";\n\n\n@@ -607,6 +607,9 @@ static void\nwt_status_collect_changes_worktree(struct wt_status *s)\n                rev.diffopt.flags.override_submodule_config = 1;\n                handle_ignore_submodules_arg(&rev.diffopt,\ns->ignore_submodule_arg);\n        }\n+       else if(!rev.diffopt.flags.ignore_submodule_set){\n+               handle_ignore_submodules_arg(&rev.diffopt, \"none\");\n+       }\n\nI have had to set the flag manually in diff.c because when we call\nhandle_ignore_submodules_arg() with \"untracked\" arg,\noptions->flags.ignore_submodule_set is set to 1 and therefore when we\ncheck for it in wt-status.c it appears that user has already set some\nconfig and therefore we shouldn't add \"none\" as ignoreSubmodules arg.\n\nAnother way to do that is to have one more flag in diff_options that\ncan let us know whether options->flags.ignore_submodule_set was set by\nthe user or by diff passing untracked as the default argument.\n\nCan someone please help me with what might be the right way to proceed?\n\nThanks!\n"},{"id":"409321","messageId":"20201107111002.GA21309@danh.dev","threadId":"54429","inReplyTo":"20201026175742.33356-1-sangunb09@gmail.com","subject":"Re: [Outreachy][PATCH v6] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-11-07T11:10:02Z","receivedAt":"2020-11-07T11:10:07Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"Hi Sangeeta,\n\nOn 2020-10-26 23:27:42+0530, Sangeeta Jain <sangunb09@gmail.com> wrote:\n> diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\n> index ca04fac417..9104d1946d 100755\n> --- a/t/t3701-add-interactive.sh\n> +++ b/t/t3701-add-interactive.sh\n> @@ -765,6 +765,11 @@ test_expect_success 'setup different kinds of dirty submodules' '\n>  \tcat >expected <<-\\EOF &&\n>  \tdirty-both-ways\n>  \tdirty-head\n> +\tEOF\n> +\tgit -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&\n> +\tcat >expected <<-\\EOF &&\n> +\tdirty-both-ways\n> +\tdirty-head\n\nThis will throw-away above change to \"expected\", I think this is not\nwhat you expected to write!\n\n>  \tdirty-otherwise\n>  \tEOF\n>  \ttest_cmp expected actual &&\n> diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\n> index d7145ccca4..894a11b224 100755\n> --- a/t/t4027-diff-submodule.sh\n> +++ b/t/t4027-diff-submodule.sh\n> @@ -93,6 +93,14 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked)' '\n>  \t) &&\n>  \tgit diff HEAD >actual &&\n>  \tsed -e \"1,/^@@/d\" actual >actual.body &&\n> +\texpect_from_to >expect.body $subtip $subprev &&\n> +\ttest_cmp expect.body actual.body\n> +'\n> +\n> +test_expect_success 'git diff HEAD with dirty submodule (untracked) (none ignored)' '\n> +\ttest_config diff.ignoreSubmodules none &&\n> +\tgit diff HEAD >actual &&\n> +\tsed -e \"1,/^@@/d\" actual >actual.body &&\n>  \texpect_from_to >expect.body $subtip $subprev-dirty &&\n>  \ttest_cmp expect.body actual.body\n>  '\n> @@ -168,13 +176,13 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'\n>  \t\tgit clean -qfdx &&\n>  \t\t>cruft\n>  \t) &&\n> -\tgit diff HEAD >actual &&\n> +\tgit diff --ignore-submodules=none HEAD >actual &&\n>  \tsed -e \"1,/^@@/d\" actual >actual.body &&\n>  \texpect_from_to >expect.body $subprev $subprev-dirty &&\n>  \ttest_cmp expect.body actual.body &&\n>  \tgit diff --ignore-submodules=all HEAD >actual2 &&\n>  \ttest_must_be_empty actual2 &&\n> -\tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n> +\tgit diff HEAD >actual3 &&\n>  \ttest_must_be_empty actual3 &&\n>  \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n>  \ttest_must_be_empty actual4\n> diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\n> index f852136585..bb368b685d 100755\n> --- a/t/t4041-diff-submodule-option.sh\n> +++ b/t/t4041-diff-submodule-option.sh\n> @@ -262,7 +262,7 @@ test_expect_success 'submodule is up to date' '\n>  \n>  test_expect_success 'submodule contains untracked content' '\n>  \techo new > sm1/new-file &&\n> -\tgit diff-index -p --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n\nNit:\n\nI suspect that we're in favour of writing all optional argument before\nall committish here.\n\nIOW, I think we're better move HEAD after --ignore-submodules=none\n\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains untracked content\n>  \tEOF\n> @@ -270,7 +270,7 @@ test_expect_success 'submodule contains untracked content' '\n>  '\n>  \n>  test_expect_success 'submodule contains untracked content (untracked ignored)' '\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD >actual &&\n>  \ttest_must_be_empty actual\n>  '\n>  \n> @@ -286,7 +286,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n>  \n>  test_expect_success 'submodule contains untracked and modified content' '\n>  \techo new > sm1/foo6 &&\n> -\tgit diff-index -p --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains untracked content\n>  \tSubmodule sm1 contains modified content\n> @@ -296,7 +296,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n>  \n>  test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n>  \techo new > sm1/foo6 &&\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains modified content\n>  \tEOF\n> @@ -337,7 +337,7 @@ test_expect_success 'submodule is modified' '\n>  \n>  test_expect_success 'modified submodule contains untracked content' '\n>  \techo new > sm1/new-file &&\n> -\tgit diff-index -p --submodule=log HEAD >actual &&\n> +\tgit diff-index -p  --ignore-submodules=none --submodule=log HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains untracked content\n>  \tSubmodule sm1 $head6..$head8:\n> @@ -347,7 +347,7 @@ test_expect_success 'modified submodule contains untracked content' '\n>  '\n>  \n>  test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 $head6..$head8:\n>  \t  > change\n> @@ -371,7 +371,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n>  \n>  test_expect_success 'modified submodule contains untracked and modified content' '\n>  \techo modification >> sm1/foo6 &&\n> -\tgit diff-index -p --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains untracked content\n>  \tSubmodule sm1 contains modified content\n> @@ -383,7 +383,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n>  \n>  test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n>  \techo modification >> sm1/foo6 &&\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains modified content\n>  \tSubmodule sm1 $head6..$head8:\n> diff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh\n> index fc8229c726..dc7b242697 100755\n> --- a/t/t4060-diff-submodule-option-diff-format.sh\n> +++ b/t/t4060-diff-submodule-option-diff-format.sh\n> @@ -409,7 +409,7 @@ test_expect_success 'submodule is up to date' '\n>  \n>  test_expect_success 'submodule contains untracked content' '\n>  \techo new > sm1/new-file &&\n> -\tgit diff-index -p --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains untracked content\n>  \tEOF\n> @@ -417,7 +417,7 @@ test_expect_success 'submodule contains untracked content' '\n>  '\n>  \n>  test_expect_success 'submodule contains untracked content (untracked ignored)' '\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --submodule=diff HEAD >actual &&\n>  \ttest_must_be_empty actual\n>  '\n>  \n> @@ -433,7 +433,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n>  \n>  test_expect_success 'submodule contains untracked and modified content' '\n>  \techo new > sm1/foo6 &&\n> -\tgit diff-index -p --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains untracked content\n>  \tSubmodule sm1 contains modified content\n> @@ -451,7 +451,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n>  # NOT OK\n>  test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n>  \techo new > sm1/foo6 &&\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --submodule=diff HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains modified content\n>  \tdiff --git a/sm1/foo6 b/sm1/foo6\n> @@ -512,7 +512,7 @@ test_expect_success 'submodule is modified' '\n>  \n>  test_expect_success 'modified submodule contains untracked content' '\n>  \techo new > sm1/new-file &&\n> -\tgit diff-index -p --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains untracked content\n>  \tSubmodule sm1 $head7..$head8:\n> @@ -528,7 +528,7 @@ test_expect_success 'modified submodule contains untracked content' '\n>  '\n>  \n>  test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --submodule=diff HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 $head7..$head8:\n>  \tdiff --git a/sm1/foo6 b/sm1/foo6\n> @@ -564,7 +564,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n>  \n>  test_expect_success 'modified submodule contains untracked and modified content' '\n>  \techo modification >> sm1/foo6 &&\n> -\tgit diff-index -p --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains untracked content\n>  \tSubmodule sm1 contains modified content\n> @@ -583,7 +583,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n>  \n>  test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n>  \techo modification >> sm1/foo6 &&\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --submodule=diff HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains modified content\n>  \tSubmodule sm1 $head7..$head8:\n> diff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh\n> index 537787e598..78cd86be3a 100755\n> --- a/t/t7064-wtstatus-pv2.sh\n> +++ b/t/t7064-wtstatus-pv2.sh\n> @@ -503,6 +503,31 @@ test_expect_success 'untracked changes in added submodule (AM S..U)' '\n>  \t\t1 AM S..U 000000 160000 160000 $ZERO_OID $HSUB sub1\n>  \t\tEOF\n>  \n> +\t\tgit status --porcelain=v2 --branch --untracked-files=all --ignore-submodules=none >actual &&\n> +\t\ttest_cmp expect actual\n> +\t)\n> +'\n> +\n> +test_expect_success 'untracked changes in added submodule (A. S...) (untracked ignored)' '\n> +\t(\tcd super_repo &&\n> +\t\t## create untracked file in the submodule.\n> +\t\t(\tcd sub1 &&\n> +\t\t\techo \"xxxx\" >file_in_sub\n> +\t\t) &&\n\nAnother nit: I think we can avoid subshell by:\n\t\n\techo \"xxxx\" >sub1/file_in_sub\n\nIn general, I think other usages of subshell in this patch could be\nreplaced by above syntax for echo and \"git -C subdir\" for git.\n\n> +\n> +\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n> +\t\tHSUP=$(git rev-parse HEAD) &&\n> +\t\tHSUB=$HSUP &&\n> +\n> +\t\tcat >expect <<-EOF &&\n> +\t\t# branch.oid $HSUP\n> +\t\t# branch.head master\n> +\t\t# branch.upstream origin/master\n> +\t\t# branch.ab +0 -0\n> +\t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n> +\t\t1 A. S... 000000 160000 160000 $ZERO_OID $HSUB sub1\n> +\t\tEOF\n> +\n>  \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n>  \t\ttest_cmp expect actual\n>  \t)\n> @@ -582,6 +607,33 @@ test_expect_success 'staged and untracked changes in added submodule (AM S.MU)'\n>  \t\t1 AM S.MU 000000 160000 160000 $ZERO_OID $HSUB sub1\n>  \t\tEOF\n>  \n> +\t\tgit status --porcelain=v2 --branch --untracked-files=all --ignore-submodules=none >actual &&\n> +\t\ttest_cmp expect actual\n> +\t)\n> +'\n> +\n> +test_expect_success 'staged and untracked changes in added submodule (AM S.M.) (untracked ignored)' '\n> +\t(\tcd super_repo &&\n> +\t\t(\tcd sub1 &&\n> +\t\t\t## stage new changes in tracked file.\n> +\t\t\tgit add file_in_sub &&\n> +\t\t\t## create new untracked file.\n> +\t\t\techo \"yyyy\" >>another_file_in_sub\n> +\t\t) &&\n> +\n> +\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n> +\t\tHSUP=$(git rev-parse HEAD) &&\n> +\t\tHSUB=$HSUP &&\n> +\n> +\t\tcat >expect <<-EOF &&\n> +\t\t# branch.oid $HSUP\n> +\t\t# branch.head master\n> +\t\t# branch.upstream origin/master\n> +\t\t# branch.ab +0 -0\n> +\t\t1 A. N... 000000 100644 100644 $ZERO_OID $HMOD .gitmodules\n> +\t\t1 AM S.M. 000000 160000 160000 $ZERO_OID $HSUB sub1\n> +\t\tEOF\n> +\n>  \t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n>  \t\ttest_cmp expect actual\n>  \t)\n> diff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh\n> index 3fcb44767f..72da00a962 100755\n> --- a/t/t7506-status-submodule.sh\n> +++ b/t/t7506-status-submodule.sh\n> @@ -94,36 +94,60 @@ test_expect_success 'status with added file in submodule (short)' '\n>  test_expect_success 'status with untracked file in submodule' '\n>  \t(cd sub && git reset --hard) &&\n>  \techo \"content\" >sub/new-file &&\n> -\tgit status >output &&\n> +\tgit status --ignore-submodules=none >output &&\n>  \ttest_i18ngrep \"modified:   sub (untracked content)\" output\n>  '\n>  \n> +test_expect_success 'status with untracked file in submodule (untracked ignored)' '\n> +\t(cd sub && git reset --hard) &&\n> +\techo \"content\" >sub/new-file &&\n> +\tgit status >output &&\n> +\ttest_i18ngrep \"^nothing to commit\" output\n> +'\n> +\n>  test_expect_success 'status -uno with untracked file in submodule' '\n>  \tgit status -uno >output &&\n>  \ttest_i18ngrep \"^nothing to commit\" output\n>  '\n>  \n>  test_expect_success 'status with untracked file in submodule (porcelain)' '\n> -\tgit status --porcelain >output &&\n> +\tgit status --porcelain --ignore-submodules=none >output &&\n>  \tdiff output - <<-\\EOF\n>  \t M sub\n>  \tEOF\n>  '\n>  \n> +test_expect_success 'status with untracked file in submodule (porcelain) (untracked ignored)' '\n> +\tgit status --porcelain >output &&\n> +\ttest_must_be_empty output\n> +'\n> +\n>  test_expect_success 'status with untracked file in submodule (short)' '\n> -\tgit status --short >output &&\n> +\tgit status --short --ignore-submodules=none >output &&\n>  \tdiff output - <<-\\EOF\n>  \t ? sub\n>  \tEOF\n>  '\n>  \n> +test_expect_success 'status with untracked file in submodule (short) (untracked ignored)' '\n> +\tgit status --short >output &&\n> +\ttest_must_be_empty output\n> +'\n> +\n>  test_expect_success 'status with added and untracked file in submodule' '\n>  \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n>  \techo \"content\" >sub/new-file &&\n> -\tgit status >output &&\n> +\tgit status --ignore-submodules=none >output &&\n>  \ttest_i18ngrep \"modified:   sub (modified content, untracked content)\" output\n>  '\n>  \n> +test_expect_success 'status with added and untracked file in submodule (untracked ignored)' '\n> +\t(cd sub && git reset --hard && echo >foo && git add foo) &&\n> +\techo \"content\" >sub/new-file &&\n> +\tgit status >output &&\n> +\ttest_i18ngrep \"modified:   sub (modified content)\" output\n> +'\n> +\n>  test_expect_success 'status with added and untracked file in submodule (porcelain)' '\n>  \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n>  \techo \"content\" >sub/new-file &&\n> @@ -168,10 +192,17 @@ test_expect_success 'status with added file in modified submodule (porcelain)' '\n>  test_expect_success 'status with untracked file in modified submodule' '\n>  \t(cd sub && git reset --hard) &&\n>  \techo \"content\" >sub/new-file &&\n> -\tgit status >output &&\n> +\tgit status --ignore-submodules=none >output &&\n>  \ttest_i18ngrep \"modified:   sub (new commits, untracked content)\" output\n>  '\n>  \n> +test_expect_success 'status with untracked file in modified submodule (untracked ignored)' '\n> +\t(cd sub && git reset --hard) &&\n> +\techo \"content\" >sub/new-file &&\n> +\tgit status >output &&\n> +\ttest_i18ngrep \"modified:   sub (new commits)\" output\n> +'\n> +\n>  test_expect_success 'status with untracked file in modified submodule (porcelain)' '\n>  \tgit status --porcelain >output &&\n>  \tdiff output - <<-\\EOF\n> @@ -182,10 +213,17 @@ test_expect_success 'status with untracked file in modified submodule (porcelain\n>  test_expect_success 'status with added and untracked file in modified submodule' '\n>  \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n>  \techo \"content\" >sub/new-file &&\n> -\tgit status >output &&\n> +\tgit status --ignore-submodules=none >output &&\n>  \ttest_i18ngrep \"modified:   sub (new commits, modified content, untracked content)\" output\n>  '\n>  \n> +test_expect_success 'status with added and untracked file in modified submodule (untracked ignored)' '\n> +\t(cd sub && git reset --hard && echo >foo && git add foo) &&\n> +\techo \"content\" >sub/new-file &&\n> +\tgit status >output &&\n> +\ttest_i18ngrep \"modified:   sub (new commits, modified content)\" output\n> +'\n> +\n>  test_expect_success 'status with added and untracked file in modified submodule (porcelain)' '\n>  \t(cd sub && git reset --hard && echo >foo && git add foo) &&\n>  \techo \"content\" >sub/new-file &&\n> @@ -349,7 +387,7 @@ test_expect_success 'setup superproject with untracked file in nested submodule'\n>  '\n>  \n>  test_expect_success 'status with untracked file in nested submodule (porcelain)' '\n> -\tgit -C super status --porcelain >output &&\n> +\tgit -C super status --porcelain --ignore-submodules=none >output &&\n>  \tdiff output - <<-\\EOF\n>  \t M sub1\n>  \t M sub2\n> @@ -357,8 +395,13 @@ test_expect_success 'status with untracked file in nested submodule (porcelain)'\n>  \tEOF\n>  '\n>  \n> +test_expect_success 'status with untracked file in nested submodule (porcelain) (untracked ignored)' '\n> +\tgit -C super status --porcelain >output &&\n> +\ttest_must_be_empty output\n> +'\n> +\n>  test_expect_success 'status with untracked file in nested submodule (porcelain=2)' '\n> -\tgit -C super status --porcelain=2 >output &&\n> +\tgit -C super status --porcelain=2 --ignore-submodules=none >output &&\n>  \tsanitize_output output &&\n>  \tdiff output - <<-\\EOF\n>  \t1 .M S..U 160000 160000 160000 HASH HASH sub1\n> @@ -367,8 +410,13 @@ test_expect_success 'status with untracked file in nested submodule (porcelain=2\n>  \tEOF\n>  '\n>  \n> +test_expect_success 'status with untracked file in nested submodule (porcelain=2) (untracked ignored)' '\n> +\tgit -C super status --porcelain=2 >output &&\n> +\ttest_must_be_empty output\n> +'\n> +\n>  test_expect_success 'status with untracked file in nested submodule (short)' '\n> -\tgit -C super status --short >output &&\n> +\tgit -C super status --short --ignore-submodules=none >output &&\n>  \tdiff output - <<-\\EOF\n>  \t ? sub1\n>  \t ? sub2\n> @@ -376,13 +424,18 @@ test_expect_success 'status with untracked file in nested submodule (short)' '\n>  \tEOF\n>  '\n>  \n> +test_expect_success 'status with untracked file in nested submodule (short) (untracked ignored)' '\n> +\tgit -C super status --short >output &&\n> +\ttest_must_be_empty output\n> +'\n> +\n>  test_expect_success 'setup superproject with modified file in nested submodule' '\n>  \tgit -C super/sub1/sub2 add file &&\n>  \tgit -C super/sub2 add file\n>  '\n>  \n>  test_expect_success 'status with added file in nested submodule (porcelain)' '\n> -\tgit -C super status --porcelain >output &&\n> +\tgit -C super status --porcelain --ignore-submodules=none >output &&\n>  \tdiff output - <<-\\EOF\n>  \t M sub1\n>  \t M sub2\n> @@ -390,8 +443,16 @@ test_expect_success 'status with added file in nested submodule (porcelain)' '\n>  \tEOF\n>  '\n>  \n> +test_expect_success 'status with added file in nested submodule (porcelain) (untracked ignored)' '\n> +\tgit -C super status --porcelain >output &&\n> +\tdiff output - <<-\\EOF\n> +\t M sub1\n> +\t M sub2\n> +\tEOF\n> +'\n> +\n>  test_expect_success 'status with added file in nested submodule (porcelain=2)' '\n> -\tgit -C super status --porcelain=2 >output &&\n> +\tgit -C super status --porcelain=2 --ignore-submodules=none >output &&\n>  \tsanitize_output output &&\n>  \tdiff output - <<-\\EOF\n>  \t1 .M S.M. 160000 160000 160000 HASH HASH sub1\n> @@ -400,8 +461,17 @@ test_expect_success 'status with added file in nested submodule (porcelain=2)' '\n>  \tEOF\n>  '\n>  \n> +test_expect_success 'status with added file in nested submodule (porcelain=2) (untracked ignored)' '\n> +\tgit -C super status --porcelain=2 >output &&\n> +\tsanitize_output output &&\n> +\tdiff output - <<-\\EOF\n> +\t1 .M S.M. 160000 160000 160000 HASH HASH sub1\n> +\t1 .M S.M. 160000 160000 160000 HASH HASH sub2\n> +\tEOF\n> +'\n> +\n>  test_expect_success 'status with added file in nested submodule (short)' '\n> -\tgit -C super status --short >output &&\n> +\tgit -C super status --short --ignore-submodules=none >output &&\n>  \tdiff output - <<-\\EOF\n>  \t m sub1\n>  \t m sub2\n> @@ -409,4 +479,12 @@ test_expect_success 'status with added file in nested submodule (short)' '\n>  \tEOF\n>  '\n>  \n> +test_expect_success 'status with added file in nested submodule (short) (untracked ignored)' '\n> +\tgit -C super status --short >output &&\n> +\tdiff output - <<-\\EOF\n> +\t m sub1\n> +\t m sub2\n> +\tEOF\n> +'\n> +\n>  test_done\n> -- \n> 2.21.1 (Apple Git-122.3)\n> \n\n-- \nDanh\n"},{"id":"409396","messageId":"CAHjREB4=ESipt0r00WmueTH8h+2zQxLjJhky72M6dF-EX3WafQ@mail.gmail.com","threadId":"54429","inReplyTo":"20201107111002.GA21309@danh.dev","subject":"Re: [Outreachy][PATCH v6] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta","fromEmail":"sangunb09@gmail.com","sentAt":"2020-11-09T15:19:51Z","receivedAt":"2020-11-09T15:20:05Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"Hey Danh,\n\n\n> > diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\n> > index ca04fac417..9104d1946d 100755\n> > --- a/t/t3701-add-interactive.sh\n> > +++ b/t/t3701-add-interactive.sh\n> > @@ -765,6 +765,11 @@ test_expect_success 'setup different kinds of dirty submodules' '\n> >       cat >expected <<-\\EOF &&\n> >       dirty-both-ways\n> >       dirty-head\n> > +     EOF\n> > +     git -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&\n> > +     cat >expected <<-\\EOF &&\n> > +     dirty-both-ways\n> > +     dirty-head\n>\n> This will throw-away above change to \"expected\", I think this is not\n> what you expected to write!\n\nI am sorry I couldn't understand what you mean by that. I think that\nis what I expected to write. I want those changes to be in \"expected\".\n\nThanks,\nSangeeta\n"},{"id":"409399","messageId":"xmqqr1p2cvll.fsf@gitster.c.googlers.com","threadId":"54429","inReplyTo":"CAHjREB4=ESipt0r00WmueTH8h+2zQxLjJhky72M6dF-EX3WafQ@mail.gmail.com","subject":"Re: [Outreachy][PATCH v6] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-11-09T17:01:58Z","receivedAt":"2020-11-09T17:02:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sangeeta <sangunb09@gmail.com> writes:\n\n>> > diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\n>> > index ca04fac417..9104d1946d 100755\n>> > --- a/t/t3701-add-interactive.sh\n>> > +++ b/t/t3701-add-interactive.sh\n>> > @@ -765,6 +765,11 @@ test_expect_success 'setup different kinds of dirty submodules' '\n>> >       cat >expected <<-\\EOF &&\n>> >       dirty-both-ways\n>> >       dirty-head\n>> > +     EOF\n>> > +     git -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&\n>> > +     cat >expected <<-\\EOF &&\n>> > +     dirty-both-ways\n>> > +     dirty-head\n>>\n>> This will throw-away above change to \"expected\", I think this is not\n>> what you expected to write!\n>\n> I am sorry I couldn't understand what you mean by that. I think that\n> is what I expected to write. I want those changes to be in \"expected\".\n\nLooking at the above quoted part again...\n\n\tcat >expected <<-\\EOF &&\n\t\t... content 1 ...\n\tEOF\n        git ... >actual &&\n\tcat >expected <<-\\EOF &&\n\t\t... content 2 ...\n\tEOF\n\nI think Đoàn Trần Công Danh wants to say is that expected originally\nhas content 1, and that is discarded because you overwrite the same\nfile with content 2.  So either\n\n - if content1 and content2 are identical, perhaps you do not have\n   to write content2 into expected at all, or\n\n - if content1 and content2 are different, perhaps you forgot to\n   consume content1 before overwriting it.\n\nTHe latter is quite plausible, as the original test without your\naddition must be consuming content1 after the part you added.\n\n"},{"id":"409470","messageId":"20201110083900.88161-1-sangunb09@gmail.com","threadId":"54429","inReplyTo":"pull.751.git.1602781723670.gitgitgadget@gmail.com","subject":"[Outreachy][PATCH v7] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta Jain","fromEmail":"sangunb09@gmail.com","sentAt":"2020-11-10T08:39:00Z","receivedAt":"2020-11-10T08:39:50Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"Git diff reports a submodule directory as -dirty even when there are\nonly untracked files in the submodule directory. This is inconsistent\nwith what `git describe --dirty` says when run in the submodule\ndirectory in that state.\n\nMake `--ignore-submodules=untracked` the default for `git diff` when\nthere is no configuration variable or command line option, so that the\ncommand would not give '-dirty' suffix to a submodule whose working\ntree has untracked files, to make it consistent with `git\ndescribe --dirty` that is run in the submodule working tree.\n\nAnd also make `--ignore-submodules=none` the default for `git status`\nso that the user doesn't end up deleting a submodule that has\nuncommitted (untracked) files.\n\nSigned-off-by: Sangeeta Jain <sangunb09@gmail.com>\n---\n Documentation/config/diff.txt                |  2 ++\n diff.c                                       |  3 +++\n diff.h                                       |  1 +\n submodule.c                                  |  1 +\n t/t3701-add-interactive.sh                   |  6 ++++++\n t/t4027-diff-submodule.sh                    | 12 ++++++++++--\n t/t4041-diff-submodule-option.sh             | 16 ++++++++--------\n t/t4060-diff-submodule-option-diff-format.sh | 16 ++++++++--------\n wt-status.c                                  |  4 +++-\n 9 files changed, 42 insertions(+), 19 deletions(-)\n\ndiff --git a/Documentation/config/diff.txt b/Documentation/config/diff.txt\nindex c3ae136eba..2d3331f55c 100644\n--- a/Documentation/config/diff.txt\n+++ b/Documentation/config/diff.txt\n@@ -85,6 +85,8 @@ diff.ignoreSubmodules::\n \tand 'git status' when `status.submoduleSummary` is set unless it is\n \toverridden by using the --ignore-submodules command-line option.\n \tThe 'git submodule' commands are not affected by this setting.\n+\tBy default this is set to untracked so that any untracked\n+\tsubmodules are ignored.\n \n diff.mnemonicPrefix::\n \tIf set, 'git diff' uses a prefix pair that is different from the\ndiff --git a/diff.c b/diff.c\nindex 2bb2f8f57e..5a80695da8 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4585,6 +4585,9 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)\n \t\tDIFF_XDL_SET(options, INDENT_HEURISTIC);\n \n \toptions->orderfile = diff_order_file_cfg;\n+\t\n+\tif (!options->flags.ignore_submodule_set)\n+\t\toptions->flags.ignore_untracked_in_submodules = 1;\n \n \tif (diff_no_prefix) {\n \t\toptions->a_prefix = options->b_prefix = \"\";\ndiff --git a/diff.h b/diff.h\nindex 11de52e9e9..1e18e6b1c3 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -178,6 +178,7 @@ struct diff_flags {\n \tunsigned diff_from_contents;\n \tunsigned dirty_submodules;\n \tunsigned ignore_untracked_in_submodules;\n+\tunsigned ignore_submodule_set;\n \tunsigned ignore_dirty_submodules;\n \tunsigned override_submodule_config;\n \tunsigned dirstat_by_line;\ndiff --git a/submodule.c b/submodule.c\nindex b3bb59f066..8f6227c993 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -420,6 +420,7 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy\n void handle_ignore_submodules_arg(struct diff_options *diffopt,\n \t\t\t\t  const char *arg)\n {\n+\tdiffopt->flags.ignore_submodule_set = 1;\n \tdiffopt->flags.ignore_submodules = 0;\n \tdiffopt->flags.ignore_untracked_in_submodules = 0;\n \tdiffopt->flags.ignore_dirty_submodules = 0;\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex ca04fac417..9a2489cde0 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -765,6 +765,12 @@ test_expect_success 'setup different kinds of dirty submodules' '\n \tcat >expected <<-\\EOF &&\n \tdirty-both-ways\n \tdirty-head\n+\tEOF\n+\ttest_cmp expected actual &&\n+\tgit -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&\n+\tcat >expected <<-\\EOF &&\n+\tdirty-both-ways\n+\tdirty-head\n \tdirty-otherwise\n \tEOF\n \ttest_cmp expected actual &&\ndiff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\nindex d7145ccca4..894a11b224 100755\n--- a/t/t4027-diff-submodule.sh\n+++ b/t/t4027-diff-submodule.sh\n@@ -93,6 +93,14 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked)' '\n \t) &&\n \tgit diff HEAD >actual &&\n \tsed -e \"1,/^@@/d\" actual >actual.body &&\n+\texpect_from_to >expect.body $subtip $subprev &&\n+\ttest_cmp expect.body actual.body\n+'\n+\n+test_expect_success 'git diff HEAD with dirty submodule (untracked) (none ignored)' '\n+\ttest_config diff.ignoreSubmodules none &&\n+\tgit diff HEAD >actual &&\n+\tsed -e \"1,/^@@/d\" actual >actual.body &&\n \texpect_from_to >expect.body $subtip $subprev-dirty &&\n \ttest_cmp expect.body actual.body\n '\n@@ -168,13 +176,13 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'\n \t\tgit clean -qfdx &&\n \t\t>cruft\n \t) &&\n-\tgit diff HEAD >actual &&\n+\tgit diff --ignore-submodules=none HEAD >actual &&\n \tsed -e \"1,/^@@/d\" actual >actual.body &&\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual.body &&\n \tgit diff --ignore-submodules=all HEAD >actual2 &&\n \ttest_must_be_empty actual2 &&\n-\tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n+\tgit diff HEAD >actual3 &&\n \ttest_must_be_empty actual3 &&\n \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n \ttest_must_be_empty actual4\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex f852136585..b3a7b7acaa 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -262,7 +262,7 @@ test_expect_success 'submodule is up to date' '\n \n test_expect_success 'submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tEOF\n@@ -270,7 +270,7 @@ test_expect_success 'submodule contains untracked content' '\n '\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \ttest_must_be_empty actual\n '\n \n@@ -286,7 +286,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n \n test_expect_success 'submodule contains untracked and modified content' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -296,7 +296,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n \n test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tEOF\n@@ -337,7 +337,7 @@ test_expect_success 'submodule is modified' '\n \n test_expect_success 'modified submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p  --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 $head6..$head8:\n@@ -347,7 +347,7 @@ test_expect_success 'modified submodule contains untracked content' '\n '\n \n test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 $head6..$head8:\n \t  > change\n@@ -371,7 +371,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n \n test_expect_success 'modified submodule contains untracked and modified content' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --submodule=log HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -383,7 +383,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n \n test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n+\tgit diff-index -p --submodule=log HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tSubmodule sm1 $head6..$head8:\ndiff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh\nindex fc8229c726..dc7b242697 100755\n--- a/t/t4060-diff-submodule-option-diff-format.sh\n+++ b/t/t4060-diff-submodule-option-diff-format.sh\n@@ -409,7 +409,7 @@ test_expect_success 'submodule is up to date' '\n \n test_expect_success 'submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tEOF\n@@ -417,7 +417,7 @@ test_expect_success 'submodule contains untracked content' '\n '\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \ttest_must_be_empty actual\n '\n \n@@ -433,7 +433,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n \n test_expect_success 'submodule contains untracked and modified content' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -451,7 +451,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n # NOT OK\n test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n \techo new > sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tdiff --git a/sm1/foo6 b/sm1/foo6\n@@ -512,7 +512,7 @@ test_expect_success 'submodule is modified' '\n \n test_expect_success 'modified submodule contains untracked content' '\n \techo new > sm1/new-file &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 $head7..$head8:\n@@ -528,7 +528,7 @@ test_expect_success 'modified submodule contains untracked content' '\n '\n \n test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 $head7..$head8:\n \tdiff --git a/sm1/foo6 b/sm1/foo6\n@@ -564,7 +564,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n \n test_expect_success 'modified submodule contains untracked and modified content' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains untracked content\n \tSubmodule sm1 contains modified content\n@@ -583,7 +583,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n \n test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n \techo modification >> sm1/foo6 &&\n-\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n+\tgit diff-index -p --submodule=diff HEAD >actual &&\n \tcat >expected <<-EOF &&\n \tSubmodule sm1 contains modified content\n \tSubmodule sm1 $head7..$head8:\ndiff --git a/wt-status.c b/wt-status.c\nindex 7074bbdd53..83d418647d 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -606,7 +606,9 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)\n \tif (s->ignore_submodule_arg) {\n \t\trev.diffopt.flags.override_submodule_config = 1;\n \t\thandle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);\n-\t}\n+\t} else if (!rev.diffopt.flags.ignore_submodule_set && \n+\t\t\ts->show_untracked_files != SHOW_NO_UNTRACKED_FILES)\n+\t\thandle_ignore_submodules_arg(&rev.diffopt, \"none\");\n \trev.diffopt.format_callback = wt_status_collect_changed_cb;\n \trev.diffopt.format_callback_data = s;\n \trev.diffopt.detect_rename = s->detect_rename >= 0 ? s->detect_rename : rev.diffopt.detect_rename;\n-- \n2.21.1 (Apple Git-122.3)\n\n"},{"id":"409501","messageId":"X6rJWpuUHz1qHYZL@danh.dev","threadId":"54429","inReplyTo":"20201110083900.88161-1-sangunb09@gmail.com","subject":"Re: [Outreachy][PATCH v7] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2020-11-10T17:09:46Z","receivedAt":"2020-11-10T17:09:51Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"Hi Sangeeta,\n\nFirst, thanks for correcting the test code that I've noticed in the\nprevious mail (and thanks to Junio, who explained my words in better\nterms).\n\nOn 2020-11-10 14:09:00+0530, Sangeeta Jain <sangunb09@gmail.com> wrote:\n> diff --git a/Documentation/config/diff.txt b/Documentation/config/diff.txt\n> index c3ae136eba..2d3331f55c 100644\n> --- a/Documentation/config/diff.txt\n> +++ b/Documentation/config/diff.txt\n> @@ -85,6 +85,8 @@ diff.ignoreSubmodules::\n>  \tand 'git status' when `status.submoduleSummary` is set unless it is\n>  \toverridden by using the --ignore-submodules command-line option.\n>  \tThe 'git submodule' commands are not affected by this setting.\n> +\tBy default this is set to untracked so that any untracked\n> +\tsubmodules are ignored.\n\nThis rounds looks better to me.\nMy only question now is: Should this change applicable to diff-index,\ndiff-files and other plumbing commands?\n\nAs of it's now, we treat the absent of diff.ignoreSubmodules as\n\"none\" but we're changing to \"untracked\" with this change.\n\nWill someone's scripts break by this change?\nI think it's unlikely, but who knows?\n\nTo contribute to the chaos, --ignore-submodules implies --ignore-submodules=all \nMy first-quick-and-INCORRECT scan to the diff-options, I was puzzled\nby its default, and I thought (incorrectly, for a second) the absent of\n--ignore-submodules mean --ignore-submodules=all.\n\n-- Danh\n\n>  \n>  diff.mnemonicPrefix::\n>  \tIf set, 'git diff' uses a prefix pair that is different from the\n> diff --git a/diff.c b/diff.c\n> index 2bb2f8f57e..5a80695da8 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -4585,6 +4585,9 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)\n>  \t\tDIFF_XDL_SET(options, INDENT_HEURISTIC);\n>  \n>  \toptions->orderfile = diff_order_file_cfg;\n> +\t\n> +\tif (!options->flags.ignore_submodule_set)\n> +\t\toptions->flags.ignore_untracked_in_submodules = 1;\n>  \n>  \tif (diff_no_prefix) {\n>  \t\toptions->a_prefix = options->b_prefix = \"\";\n> diff --git a/diff.h b/diff.h\n> index 11de52e9e9..1e18e6b1c3 100644\n> --- a/diff.h\n> +++ b/diff.h\n> @@ -178,6 +178,7 @@ struct diff_flags {\n>  \tunsigned diff_from_contents;\n>  \tunsigned dirty_submodules;\n>  \tunsigned ignore_untracked_in_submodules;\n> +\tunsigned ignore_submodule_set;\n>  \tunsigned ignore_dirty_submodules;\n>  \tunsigned override_submodule_config;\n>  \tunsigned dirstat_by_line;\n> diff --git a/submodule.c b/submodule.c\n> index b3bb59f066..8f6227c993 100644\n> --- a/submodule.c\n> +++ b/submodule.c\n> @@ -420,6 +420,7 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy\n>  void handle_ignore_submodules_arg(struct diff_options *diffopt,\n>  \t\t\t\t  const char *arg)\n>  {\n> +\tdiffopt->flags.ignore_submodule_set = 1;\n>  \tdiffopt->flags.ignore_submodules = 0;\n>  \tdiffopt->flags.ignore_untracked_in_submodules = 0;\n>  \tdiffopt->flags.ignore_dirty_submodules = 0;\n> diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\n> index ca04fac417..9a2489cde0 100755\n> --- a/t/t3701-add-interactive.sh\n> +++ b/t/t3701-add-interactive.sh\n> @@ -765,6 +765,12 @@ test_expect_success 'setup different kinds of dirty submodules' '\n>  \tcat >expected <<-\\EOF &&\n>  \tdirty-both-ways\n>  \tdirty-head\n> +\tEOF\n> +\ttest_cmp expected actual &&\n> +\tgit -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&\n> +\tcat >expected <<-\\EOF &&\n> +\tdirty-both-ways\n> +\tdirty-head\n>  \tdirty-otherwise\n>  \tEOF\n>  \ttest_cmp expected actual &&\n> diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\n> index d7145ccca4..894a11b224 100755\n> --- a/t/t4027-diff-submodule.sh\n> +++ b/t/t4027-diff-submodule.sh\n> @@ -93,6 +93,14 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked)' '\n>  \t) &&\n>  \tgit diff HEAD >actual &&\n>  \tsed -e \"1,/^@@/d\" actual >actual.body &&\n> +\texpect_from_to >expect.body $subtip $subprev &&\n> +\ttest_cmp expect.body actual.body\n> +'\n> +\n> +test_expect_success 'git diff HEAD with dirty submodule (untracked) (none ignored)' '\n> +\ttest_config diff.ignoreSubmodules none &&\n> +\tgit diff HEAD >actual &&\n> +\tsed -e \"1,/^@@/d\" actual >actual.body &&\n>  \texpect_from_to >expect.body $subtip $subprev-dirty &&\n>  \ttest_cmp expect.body actual.body\n>  '\n> @@ -168,13 +176,13 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'\n>  \t\tgit clean -qfdx &&\n>  \t\t>cruft\n>  \t) &&\n> -\tgit diff HEAD >actual &&\n> +\tgit diff --ignore-submodules=none HEAD >actual &&\n>  \tsed -e \"1,/^@@/d\" actual >actual.body &&\n>  \texpect_from_to >expect.body $subprev $subprev-dirty &&\n>  \ttest_cmp expect.body actual.body &&\n>  \tgit diff --ignore-submodules=all HEAD >actual2 &&\n>  \ttest_must_be_empty actual2 &&\n> -\tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n> +\tgit diff HEAD >actual3 &&\n>  \ttest_must_be_empty actual3 &&\n>  \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n>  \ttest_must_be_empty actual4\n> diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\n> index f852136585..b3a7b7acaa 100755\n> --- a/t/t4041-diff-submodule-option.sh\n> +++ b/t/t4041-diff-submodule-option.sh\n> @@ -262,7 +262,7 @@ test_expect_success 'submodule is up to date' '\n>  \n>  test_expect_success 'submodule contains untracked content' '\n>  \techo new > sm1/new-file &&\n> -\tgit diff-index -p --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains untracked content\n>  \tEOF\n> @@ -270,7 +270,7 @@ test_expect_success 'submodule contains untracked content' '\n>  '\n>  \n>  test_expect_success 'submodule contains untracked content (untracked ignored)' '\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD >actual &&\n>  \ttest_must_be_empty actual\n>  '\n>  \n> @@ -286,7 +286,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n>  \n>  test_expect_success 'submodule contains untracked and modified content' '\n>  \techo new > sm1/foo6 &&\n> -\tgit diff-index -p --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains untracked content\n>  \tSubmodule sm1 contains modified content\n> @@ -296,7 +296,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n>  \n>  test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n>  \techo new > sm1/foo6 &&\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains modified content\n>  \tEOF\n> @@ -337,7 +337,7 @@ test_expect_success 'submodule is modified' '\n>  \n>  test_expect_success 'modified submodule contains untracked content' '\n>  \techo new > sm1/new-file &&\n> -\tgit diff-index -p --submodule=log HEAD >actual &&\n> +\tgit diff-index -p  --ignore-submodules=none --submodule=log HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains untracked content\n>  \tSubmodule sm1 $head6..$head8:\n> @@ -347,7 +347,7 @@ test_expect_success 'modified submodule contains untracked content' '\n>  '\n>  \n>  test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 $head6..$head8:\n>  \t  > change\n> @@ -371,7 +371,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n>  \n>  test_expect_success 'modified submodule contains untracked and modified content' '\n>  \techo modification >> sm1/foo6 &&\n> -\tgit diff-index -p --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains untracked content\n>  \tSubmodule sm1 contains modified content\n> @@ -383,7 +383,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n>  \n>  test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n>  \techo modification >> sm1/foo6 &&\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> +\tgit diff-index -p --submodule=log HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains modified content\n>  \tSubmodule sm1 $head6..$head8:\n> diff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh\n> index fc8229c726..dc7b242697 100755\n> --- a/t/t4060-diff-submodule-option-diff-format.sh\n> +++ b/t/t4060-diff-submodule-option-diff-format.sh\n> @@ -409,7 +409,7 @@ test_expect_success 'submodule is up to date' '\n>  \n>  test_expect_success 'submodule contains untracked content' '\n>  \techo new > sm1/new-file &&\n> -\tgit diff-index -p --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains untracked content\n>  \tEOF\n> @@ -417,7 +417,7 @@ test_expect_success 'submodule contains untracked content' '\n>  '\n>  \n>  test_expect_success 'submodule contains untracked content (untracked ignored)' '\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --submodule=diff HEAD >actual &&\n>  \ttest_must_be_empty actual\n>  '\n>  \n> @@ -433,7 +433,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n>  \n>  test_expect_success 'submodule contains untracked and modified content' '\n>  \techo new > sm1/foo6 &&\n> -\tgit diff-index -p --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains untracked content\n>  \tSubmodule sm1 contains modified content\n> @@ -451,7 +451,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n>  # NOT OK\n>  test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n>  \techo new > sm1/foo6 &&\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --submodule=diff HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains modified content\n>  \tdiff --git a/sm1/foo6 b/sm1/foo6\n> @@ -512,7 +512,7 @@ test_expect_success 'submodule is modified' '\n>  \n>  test_expect_success 'modified submodule contains untracked content' '\n>  \techo new > sm1/new-file &&\n> -\tgit diff-index -p --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains untracked content\n>  \tSubmodule sm1 $head7..$head8:\n> @@ -528,7 +528,7 @@ test_expect_success 'modified submodule contains untracked content' '\n>  '\n>  \n>  test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --submodule=diff HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 $head7..$head8:\n>  \tdiff --git a/sm1/foo6 b/sm1/foo6\n> @@ -564,7 +564,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n>  \n>  test_expect_success 'modified submodule contains untracked and modified content' '\n>  \techo modification >> sm1/foo6 &&\n> -\tgit diff-index -p --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains untracked content\n>  \tSubmodule sm1 contains modified content\n> @@ -583,7 +583,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n>  \n>  test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n>  \techo modification >> sm1/foo6 &&\n> -\tgit diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n> +\tgit diff-index -p --submodule=diff HEAD >actual &&\n>  \tcat >expected <<-EOF &&\n>  \tSubmodule sm1 contains modified content\n>  \tSubmodule sm1 $head7..$head8:\n> diff --git a/wt-status.c b/wt-status.c\n> index 7074bbdd53..83d418647d 100644\n> --- a/wt-status.c\n> +++ b/wt-status.c\n> @@ -606,7 +606,9 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)\n>  \tif (s->ignore_submodule_arg) {\n>  \t\trev.diffopt.flags.override_submodule_config = 1;\n>  \t\thandle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);\n> -\t}\n> +\t} else if (!rev.diffopt.flags.ignore_submodule_set && \n> +\t\t\ts->show_untracked_files != SHOW_NO_UNTRACKED_FILES)\n> +\t\thandle_ignore_submodules_arg(&rev.diffopt, \"none\");\n>  \trev.diffopt.format_callback = wt_status_collect_changed_cb;\n>  \trev.diffopt.format_callback_data = s;\n>  \trev.diffopt.detect_rename = s->detect_rename >= 0 ? s->detect_rename : rev.diffopt.detect_rename;\n> -- \n> 2.21.1 (Apple Git-122.3)\n> \n\n-- \nDanh\n"},{"id":"411715","messageId":"CAHjREB7_BScE3zZVUZho4xi0OTdpsJTqLAbqhS0Tcd_xF6gqHA@mail.gmail.com","threadId":"54429","inReplyTo":"20201110083900.88161-1-sangunb09@gmail.com","subject":"Re: [Outreachy][PATCH v7] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Sangeeta","fromEmail":"sangunb09@gmail.com","sentAt":"2020-12-08T13:36:57Z","receivedAt":"2020-12-08T13:37:53Z","isPatch":true,"sender":{"key":"sangunb09@gmail.com","avatar":"https://avatars.githubusercontent.com/u/64827599?v=4"},"body":"Hey Junio,\n\nIn the \"What's cooking in git.git\" you mentioned that this patch is\nleft on doc update and some adjustments in \"git status\".\n\nThe above patch does adds the `ignore-submodule=none` as the default\nbehavior for git status and also adds documentation too.\nAm I missing something?\n\nThanks and regards,\nSangeeta\n\nSangeeta\n\nOn Tue, Nov 10, 2020 at 2:09 PM Sangeeta Jain <sangunb09@gmail.com> wrote:\n>\n> Git diff reports a submodule directory as -dirty even when there are\n> only untracked files in the submodule directory. This is inconsistent\n> with what `git describe --dirty` says when run in the submodule\n> directory in that state.\n>\n> Make `--ignore-submodules=untracked` the default for `git diff` when\n> there is no configuration variable or command line option, so that the\n> command would not give '-dirty' suffix to a submodule whose working\n> tree has untracked files, to make it consistent with `git\n> describe --dirty` that is run in the submodule working tree.\n>\n> And also make `--ignore-submodules=none` the default for `git status`\n> so that the user doesn't end up deleting a submodule that has\n> uncommitted (untracked) files.\n>\n> Signed-off-by: Sangeeta Jain <sangunb09@gmail.com>\n> ---\n>  Documentation/config/diff.txt                |  2 ++\n>  diff.c                                       |  3 +++\n>  diff.h                                       |  1 +\n>  submodule.c                                  |  1 +\n>  t/t3701-add-interactive.sh                   |  6 ++++++\n>  t/t4027-diff-submodule.sh                    | 12 ++++++++++--\n>  t/t4041-diff-submodule-option.sh             | 16 ++++++++--------\n>  t/t4060-diff-submodule-option-diff-format.sh | 16 ++++++++--------\n>  wt-status.c                                  |  4 +++-\n>  9 files changed, 42 insertions(+), 19 deletions(-)\n>\n> diff --git a/Documentation/config/diff.txt b/Documentation/config/diff.txt\n> index c3ae136eba..2d3331f55c 100644\n> --- a/Documentation/config/diff.txt\n> +++ b/Documentation/config/diff.txt\n> @@ -85,6 +85,8 @@ diff.ignoreSubmodules::\n>         and 'git status' when `status.submoduleSummary` is set unless it is\n>         overridden by using the --ignore-submodules command-line option.\n>         The 'git submodule' commands are not affected by this setting.\n> +       By default this is set to untracked so that any untracked\n> +       submodules are ignored.\n>\n>  diff.mnemonicPrefix::\n>         If set, 'git diff' uses a prefix pair that is different from the\n> diff --git a/diff.c b/diff.c\n> index 2bb2f8f57e..5a80695da8 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -4585,6 +4585,9 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)\n>                 DIFF_XDL_SET(options, INDENT_HEURISTIC);\n>\n>         options->orderfile = diff_order_file_cfg;\n> +\n> +       if (!options->flags.ignore_submodule_set)\n> +               options->flags.ignore_untracked_in_submodules = 1;\n>\n>         if (diff_no_prefix) {\n>                 options->a_prefix = options->b_prefix = \"\";\n> diff --git a/diff.h b/diff.h\n> index 11de52e9e9..1e18e6b1c3 100644\n> --- a/diff.h\n> +++ b/diff.h\n> @@ -178,6 +178,7 @@ struct diff_flags {\n>         unsigned diff_from_contents;\n>         unsigned dirty_submodules;\n>         unsigned ignore_untracked_in_submodules;\n> +       unsigned ignore_submodule_set;\n>         unsigned ignore_dirty_submodules;\n>         unsigned override_submodule_config;\n>         unsigned dirstat_by_line;\n> diff --git a/submodule.c b/submodule.c\n> index b3bb59f066..8f6227c993 100644\n> --- a/submodule.c\n> +++ b/submodule.c\n> @@ -420,6 +420,7 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy\n>  void handle_ignore_submodules_arg(struct diff_options *diffopt,\n>                                   const char *arg)\n>  {\n> +       diffopt->flags.ignore_submodule_set = 1;\n>         diffopt->flags.ignore_submodules = 0;\n>         diffopt->flags.ignore_untracked_in_submodules = 0;\n>         diffopt->flags.ignore_dirty_submodules = 0;\n> diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\n> index ca04fac417..9a2489cde0 100755\n> --- a/t/t3701-add-interactive.sh\n> +++ b/t/t3701-add-interactive.sh\n> @@ -765,6 +765,12 @@ test_expect_success 'setup different kinds of dirty submodules' '\n>         cat >expected <<-\\EOF &&\n>         dirty-both-ways\n>         dirty-head\n> +       EOF\n> +       test_cmp expected actual &&\n> +       git -C for-submodules diff-files --name-only --ignore-submodules=none >actual &&\n> +       cat >expected <<-\\EOF &&\n> +       dirty-both-ways\n> +       dirty-head\n>         dirty-otherwise\n>         EOF\n>         test_cmp expected actual &&\n> diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\n> index d7145ccca4..894a11b224 100755\n> --- a/t/t4027-diff-submodule.sh\n> +++ b/t/t4027-diff-submodule.sh\n> @@ -93,6 +93,14 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked)' '\n>         ) &&\n>         git diff HEAD >actual &&\n>         sed -e \"1,/^@@/d\" actual >actual.body &&\n> +       expect_from_to >expect.body $subtip $subprev &&\n> +       test_cmp expect.body actual.body\n> +'\n> +\n> +test_expect_success 'git diff HEAD with dirty submodule (untracked) (none ignored)' '\n> +       test_config diff.ignoreSubmodules none &&\n> +       git diff HEAD >actual &&\n> +       sed -e \"1,/^@@/d\" actual >actual.body &&\n>         expect_from_to >expect.body $subtip $subprev-dirty &&\n>         test_cmp expect.body actual.body\n>  '\n> @@ -168,13 +176,13 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'\n>                 git clean -qfdx &&\n>                 >cruft\n>         ) &&\n> -       git diff HEAD >actual &&\n> +       git diff --ignore-submodules=none HEAD >actual &&\n>         sed -e \"1,/^@@/d\" actual >actual.body &&\n>         expect_from_to >expect.body $subprev $subprev-dirty &&\n>         test_cmp expect.body actual.body &&\n>         git diff --ignore-submodules=all HEAD >actual2 &&\n>         test_must_be_empty actual2 &&\n> -       git diff --ignore-submodules=untracked HEAD >actual3 &&\n> +       git diff HEAD >actual3 &&\n>         test_must_be_empty actual3 &&\n>         git diff --ignore-submodules=dirty HEAD >actual4 &&\n>         test_must_be_empty actual4\n> diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\n> index f852136585..b3a7b7acaa 100755\n> --- a/t/t4041-diff-submodule-option.sh\n> +++ b/t/t4041-diff-submodule-option.sh\n> @@ -262,7 +262,7 @@ test_expect_success 'submodule is up to date' '\n>\n>  test_expect_success 'submodule contains untracked content' '\n>         echo new > sm1/new-file &&\n> -       git diff-index -p --submodule=log HEAD >actual &&\n> +       git diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n>         cat >expected <<-EOF &&\n>         Submodule sm1 contains untracked content\n>         EOF\n> @@ -270,7 +270,7 @@ test_expect_success 'submodule contains untracked content' '\n>  '\n>\n>  test_expect_success 'submodule contains untracked content (untracked ignored)' '\n> -       git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> +       git diff-index -p --submodule=log HEAD >actual &&\n>         test_must_be_empty actual\n>  '\n>\n> @@ -286,7 +286,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n>\n>  test_expect_success 'submodule contains untracked and modified content' '\n>         echo new > sm1/foo6 &&\n> -       git diff-index -p --submodule=log HEAD >actual &&\n> +       git diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n>         cat >expected <<-EOF &&\n>         Submodule sm1 contains untracked content\n>         Submodule sm1 contains modified content\n> @@ -296,7 +296,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n>\n>  test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n>         echo new > sm1/foo6 &&\n> -       git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> +       git diff-index -p --submodule=log HEAD >actual &&\n>         cat >expected <<-EOF &&\n>         Submodule sm1 contains modified content\n>         EOF\n> @@ -337,7 +337,7 @@ test_expect_success 'submodule is modified' '\n>\n>  test_expect_success 'modified submodule contains untracked content' '\n>         echo new > sm1/new-file &&\n> -       git diff-index -p --submodule=log HEAD >actual &&\n> +       git diff-index -p  --ignore-submodules=none --submodule=log HEAD >actual &&\n>         cat >expected <<-EOF &&\n>         Submodule sm1 contains untracked content\n>         Submodule sm1 $head6..$head8:\n> @@ -347,7 +347,7 @@ test_expect_success 'modified submodule contains untracked content' '\n>  '\n>\n>  test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n> -       git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> +       git diff-index -p --submodule=log HEAD >actual &&\n>         cat >expected <<-EOF &&\n>         Submodule sm1 $head6..$head8:\n>           > change\n> @@ -371,7 +371,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n>\n>  test_expect_success 'modified submodule contains untracked and modified content' '\n>         echo modification >> sm1/foo6 &&\n> -       git diff-index -p --submodule=log HEAD >actual &&\n> +       git diff-index -p --ignore-submodules=none --submodule=log HEAD >actual &&\n>         cat >expected <<-EOF &&\n>         Submodule sm1 contains untracked content\n>         Submodule sm1 contains modified content\n> @@ -383,7 +383,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n>\n>  test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n>         echo modification >> sm1/foo6 &&\n> -       git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> +       git diff-index -p --submodule=log HEAD >actual &&\n>         cat >expected <<-EOF &&\n>         Submodule sm1 contains modified content\n>         Submodule sm1 $head6..$head8:\n> diff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh\n> index fc8229c726..dc7b242697 100755\n> --- a/t/t4060-diff-submodule-option-diff-format.sh\n> +++ b/t/t4060-diff-submodule-option-diff-format.sh\n> @@ -409,7 +409,7 @@ test_expect_success 'submodule is up to date' '\n>\n>  test_expect_success 'submodule contains untracked content' '\n>         echo new > sm1/new-file &&\n> -       git diff-index -p --submodule=diff HEAD >actual &&\n> +       git diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n>         cat >expected <<-EOF &&\n>         Submodule sm1 contains untracked content\n>         EOF\n> @@ -417,7 +417,7 @@ test_expect_success 'submodule contains untracked content' '\n>  '\n>\n>  test_expect_success 'submodule contains untracked content (untracked ignored)' '\n> -       git diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n> +       git diff-index -p --submodule=diff HEAD >actual &&\n>         test_must_be_empty actual\n>  '\n>\n> @@ -433,7 +433,7 @@ test_expect_success 'submodule contains untracked content (all ignored)' '\n>\n>  test_expect_success 'submodule contains untracked and modified content' '\n>         echo new > sm1/foo6 &&\n> -       git diff-index -p --submodule=diff HEAD >actual &&\n> +       git diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n>         cat >expected <<-EOF &&\n>         Submodule sm1 contains untracked content\n>         Submodule sm1 contains modified content\n> @@ -451,7 +451,7 @@ test_expect_success 'submodule contains untracked and modified content' '\n>  # NOT OK\n>  test_expect_success 'submodule contains untracked and modified content (untracked ignored)' '\n>         echo new > sm1/foo6 &&\n> -       git diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n> +       git diff-index -p --submodule=diff HEAD >actual &&\n>         cat >expected <<-EOF &&\n>         Submodule sm1 contains modified content\n>         diff --git a/sm1/foo6 b/sm1/foo6\n> @@ -512,7 +512,7 @@ test_expect_success 'submodule is modified' '\n>\n>  test_expect_success 'modified submodule contains untracked content' '\n>         echo new > sm1/new-file &&\n> -       git diff-index -p --submodule=diff HEAD >actual &&\n> +       git diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n>         cat >expected <<-EOF &&\n>         Submodule sm1 contains untracked content\n>         Submodule sm1 $head7..$head8:\n> @@ -528,7 +528,7 @@ test_expect_success 'modified submodule contains untracked content' '\n>  '\n>\n>  test_expect_success 'modified submodule contains untracked content (untracked ignored)' '\n> -       git diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n> +       git diff-index -p --submodule=diff HEAD >actual &&\n>         cat >expected <<-EOF &&\n>         Submodule sm1 $head7..$head8:\n>         diff --git a/sm1/foo6 b/sm1/foo6\n> @@ -564,7 +564,7 @@ test_expect_success 'modified submodule contains untracked content (all ignored)\n>\n>  test_expect_success 'modified submodule contains untracked and modified content' '\n>         echo modification >> sm1/foo6 &&\n> -       git diff-index -p --submodule=diff HEAD >actual &&\n> +       git diff-index -p --ignore-submodules=none --submodule=diff HEAD >actual &&\n>         cat >expected <<-EOF &&\n>         Submodule sm1 contains untracked content\n>         Submodule sm1 contains modified content\n> @@ -583,7 +583,7 @@ test_expect_success 'modified submodule contains untracked and modified content'\n>\n>  test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '\n>         echo modification >> sm1/foo6 &&\n> -       git diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&\n> +       git diff-index -p --submodule=diff HEAD >actual &&\n>         cat >expected <<-EOF &&\n>         Submodule sm1 contains modified content\n>         Submodule sm1 $head7..$head8:\n> diff --git a/wt-status.c b/wt-status.c\n> index 7074bbdd53..83d418647d 100644\n> --- a/wt-status.c\n> +++ b/wt-status.c\n> @@ -606,7 +606,9 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)\n>         if (s->ignore_submodule_arg) {\n>                 rev.diffopt.flags.override_submodule_config = 1;\n>                 handle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);\n> -       }\n> +       } else if (!rev.diffopt.flags.ignore_submodule_set &&\n> +                       s->show_untracked_files != SHOW_NO_UNTRACKED_FILES)\n> +               handle_ignore_submodules_arg(&rev.diffopt, \"none\");\n>         rev.diffopt.format_callback = wt_status_collect_changed_cb;\n>         rev.diffopt.format_callback_data = s;\n>         rev.diffopt.detect_rename = s->detect_rename >= 0 ? s->detect_rename : rev.diffopt.detect_rename;\n> --\n> 2.21.1 (Apple Git-122.3)\n>\n"},{"id":"411745","messageId":"xmqqblf46mg8.fsf@gitster.c.googlers.com","threadId":"54429","inReplyTo":"CAHjREB7-QWHBOQQPdDdEM-gJm=w3+4D=N=5TaS3UE__6XnSpJA@mail.gmail.com","subject":"Re: [Outreachy][PATCH v6] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-12-08T21:02:15Z","receivedAt":"2020-12-08T21:03:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sangeeta <sangunb09@gmail.com> writes:\n\n> Hey,\n>\n> I worked on passing --ignore-submodules=none as the default behavior\n> of git status so that the user doesn't end up deleting a submodule\n> that has uncommitted (untracked) files.\n>\n> The following changes make git status pass the ignoreSubmodules none\n> argument as default.\n>\n> @@ -4587,7 +4587,7 @@ void repo_diff_setup(struct repository *r,\n> struct diff_options *options)\n>         options->orderfile = diff_order_file_cfg;\n>\n>         if (!options->flags.ignore_submodule_set)\n> -               handle_ignore_submodules_arg(options, \"untracked\");\n> +               options->flags.ignore_untracked_in_submodules = 1;\n>\n>         if (diff_no_prefix) {\n>                 options->a_prefix = options->b_prefix = \"\";\n>\n>\n> @@ -607,6 +607,9 @@ static void\n> wt_status_collect_changes_worktree(struct wt_status *s)\n>                 rev.diffopt.flags.override_submodule_config = 1;\n>                 handle_ignore_submodules_arg(&rev.diffopt,\n> s->ignore_submodule_arg);\n>         }\n> +       else if(!rev.diffopt.flags.ignore_submodule_set){\n> +               handle_ignore_submodules_arg(&rev.diffopt, \"none\");\n> +       }\n>\n> I have had to set the flag manually in diff.c because when we call\n> handle_ignore_submodules_arg() with \"untracked\" arg,\n> options->flags.ignore_submodule_set is set to 1 and therefore when we\n> check for it in wt-status.c it appears that user has already set some\n> config and therefore we shouldn't add \"none\" as ignoreSubmodules arg.\n>\n> Another way to do that is to have one more flag in diff_options that\n> can let us know whether options->flags.ignore_submodule_set was set by\n> the user or by diff passing untracked as the default argument.\n>\n> Can someone please help me with what might be the right way to proceed?\n\nHmph, neither sounds \"right\"---having to circumvent the assignment\nto _set flag made in the handle_ helper by either manually setting\nthe underlying flag, or by introducing another flag that stops from\nthe _set flag getting updated, sounds like working around a flaw of\nthe approach to use _set flag and set it in the handle_ helper in\nthe first place...\n\n\n\n"},{"id":"411785","messageId":"xmqqczzk53yt.fsf@gitster.c.googlers.com","threadId":"54429","inReplyTo":"CAHjREB7_BScE3zZVUZho4xi0OTdpsJTqLAbqhS0Tcd_xF6gqHA@mail.gmail.com","subject":"Re: [Outreachy][PATCH v7] diff: do not show submodule with untracked files as \"-dirty\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-12-08T22:26:50Z","receivedAt":"2020-12-08T22:28:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sangeeta <sangunb09@gmail.com> writes:\n\n> Hey Junio,\n>\n> In the \"What's cooking in git.git\" you mentioned that this patch is\n> left on doc update and some adjustments in \"git status\".\n\nAh, thanks for reminding.  I do not think I've picked the updated one\nup yet.\n\nWill find time to take a look later.\n"}]}