git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [Outreachy] [PATCH v4] diff: do not show submodule with untracked files as "-dirty"

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 23, 2020, 21:28 UTC
Message-ID
<xmqqmu0cfx9a.fsf@gitster.c.googlers.com>
In-Reply-To
<20201023111827.40188-1-sangunb09@gmail.com>
Sangeeta Jain <sangunb09@gmail.com> writes:
Show 10 quoted lines
> diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh
> ...
> +test_expect_success 'git diff HEAD with dirty submodule (untracked) (none ignored)' '
> +	git config diff.ignoreSubmodules none &&
> +	git diff HEAD >actual &&
> +	sed -e "1,/^@@/d" actual >actual.body &&
> +	expect_from_to >expect.body $subtip $subprev-dirty &&
> +	test_cmp expect.body actual.body &&
> +	git config --unset diff.ignoreSubmodules
> +'

If any step concatenated by && in the above sequence fails, the test repository will have diff.ignoreSubmodules set to none (without getting it reset, since &&-chain prevents the last "config --unset" step from running). Unless the test is run under the --immediate option, that would affect the environment in which subsequent tests are run.

Instead, our test usually do this:
	test_expect_success 'test title' '
                test_config diff.ignoresubmodules none &&
                git diff HEAD >actual &&
                ...
                test_cmp expect.body actual.body
	'

"test_config" sets up a trigger, which will _always_ fire, whether the test fails at any intermediate steps or runs to the end and succeeds, to remove the configuration it just added. It is a short-hand for writing

	test_when_finished test_unconfig diff.ignoresubmodules &&
	git config diff.ignoresubmodules none
i.e. to use test_when_finished to set up the trigger.
Show 9 quoted lines
> -	git diff HEAD >actual &&
> +	git diff --ignore-submodules=none HEAD >actual &&
>  	sed -e "1,/^@@/d" actual >actual.body &&
>  	expect_from_to >expect.body $subprev $subprev-dirty &&
>  	test_cmp expect.body actual.body &&
>  	git diff --ignore-submodules=all HEAD >actual2 &&
>  	test_must_be_empty actual2 &&
> -	git diff --ignore-submodules=untracked HEAD >actual3 &&
> +	git diff HEAD >actual3 &&
This line can be left as-is, no?
Show 19 quoted lines
> diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
> index f852136585..bb368b685d 100755
> --- a/t/t4041-diff-submodule-option.sh
> +++ b/t/t4041-diff-submodule-option.sh
> @@ -262,7 +262,7 @@ test_expect_success 'submodule is up to date' '
>  
>  test_expect_success 'submodule contains untracked content' '
>  	echo new > sm1/new-file &&
> -	git diff-index -p --submodule=log HEAD >actual &&
> +	git diff-index -p --submodule=log HEAD --ignore-submodules=none >actual &&
>  	cat >expected <<-EOF &&
>  	Submodule sm1 contains untracked content
>  	EOF
> @@ -270,7 +270,7 @@ test_expect_success 'submodule contains untracked content' '
>  '
>  
>  test_expect_success 'submodule contains untracked content (untracked ignored)' '
> -	git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
> +	git diff-index -p --submodule=log HEAD >actual &&
Likewise.
Previous: Sangeeta JainNext: Sangeeta NB
Message 21 of 36 in “diff: do not show submodule with untracked files as "-dirty"”
  1. diff: do not show submodule with untracked files as "-dirty"Sangeeta via GitGitGadget, Oct 15, 2020
  2. Phillip WoodOct 20, 2020
  3. Sangeeta NBOct 20, 2020
  4. Phillip WoodOct 21, 2020
  5. [Outreachy] [PATCH v2] diff: do not show submodule with untracked files as "-dirty"Sangeeta Jain, Oct 21, 2020
  6. Eric SunshineOct 21, 2020
  7. Sangeeta NBOct 21, 2020
  8. Eric SunshineOct 21, 2020
  9. [Outreachy] [PATCH v3] diff: do not show submodule with untracked files as "-dirty"Sangeeta Jain, Oct 22, 2020
  10. Junio C HamanoOct 22, 2020
  11. Sangeeta NBOct 23, 2020
  12. Junio C HamanoOct 23, 2020
  13. Sangeeta NBOct 23, 2020
  14. Junio C HamanoOct 23, 2020
  15. Sangeeta NBOct 23, 2020
  16. diff: do not show submodule with untracked files as "-dirty"Sangeeta Jain, Oct 23, 2020
  17. Junio C HamanoOct 23, 2020
  18. Sangeeta NBOct 23, 2020
  19. Junio C HamanoOct 23, 2020
  20. [Outreachy] [PATCH v4] diff: do not show submodule with untracked files as "-dirty"Sangeeta Jain, Oct 23, 2020
  21. Junio C HamanoOct 23, 2020
  22. Sangeeta NBOct 25, 2020
  23. Junio C HamanoOct 26, 2020
  24. [Outreachy] [PATCH v5] diff: do not show submodule with untracked files as "-dirty"Sangeeta Jain, Oct 23, 2020
  25. [Outreachy][PATCH v6] diff: do not show submodule with untracked files as "-dirty"Sangeeta Jain, Oct 26, 2020
  26. SangeetaNov 3, 2020
  27. Junio C HamanoNov 3, 2020
  28. SangeetaNov 7, 2020
  29. Junio C HamanoDec 8, 2020
  30. Đoàn Trần Công DanhNov 7, 2020
  31. SangeetaNov 9, 2020
  32. Junio C HamanoNov 9, 2020
  33. [Outreachy][PATCH v7] diff: do not show submodule with untracked files as "-dirty"Sangeeta Jain, Nov 10, 2020
  34. Đoàn Trần Công DanhNov 10, 2020
  35. SangeetaDec 8, 2020
  36. Junio C HamanoDec 8, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.