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

Re: [PATCH v2] diff-lib: honor override_submodule_config flag bit

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 14, 2023, 16:14 UTC
Message-ID
<xmqqa5x2xbqr.fsf@gitster.g>
In-Reply-To
<20230614153142.3138028-1-sokcevic@google.com>
Josip Sokcevic <sokcevic@google.com> writes:
Show 7 quoted lines
> +add_submodule_commits_and_validate () {
> +	HASH=$(git rev-parse HEAD) &&
> +	git update-index --add --cacheinfo 160000,$HASH,sub &&
> +	git commit -m "create submodule" &&
> +	git ls-tree HEAD >output &&
> +	test_when_finished "rm -f output" &&
> +	grep "$HASH" output

If ls-tree exits with non-zero status, test_when_finished will not be seen, and will not arrange output to be removed. If we are going to use test_when_finished to remove the file, we should do so before we do anything that potentially creates the file.

The test with "grep" is overly loose, as I suspect that you won't be happy to see the $HASH (i.e. the commit object name) just anywhere in the output, but exactly where you placed it, i.e. at path "sub".

So it may make more sense to do the test like so:
	...
	git commit -m "create" &&
	echo "160000 commit $HASH	sub" >expect &&
	git ls-tree HEAD -- sub >actual &&
	test_cmp expect actual
If we were to add
	test_when_finished "rm -f expect actual" &&

we would do so immediately after "git commit" step, but I personally do not think it is worth doing in this case. These two files are what many if not most of our test pieces use and having them as untracked files is a norm. Unless we have a need to have strict control of what untracked files are in the working tree in later tests, it is OK to leave these files around.

Other than that, looking much better.
Thanks.
Show 17 quoted lines
> +}
> +
> +test_expect_success 'commit with staged submodule change' '
> +	add_submodule_commits_and_validate
> +'
> +
> +test_expect_success 'commit with staged submodule change with ignoreSubmodules dirty' '
> +	test_config diff.ignoreSubmodules dirty &&
> +	add_submodule_commits_and_validate
> +'
> +
> +test_expect_success 'commit with staged submodule change with ignoreSubmodules all' '
> +	test_config diff.ignoreSubmodules all &&
> +	add_submodule_commits_and_validate
> +'
> +
>  test_done
Previous: Josip Sokcevic
Message 2 of 2 in “diff-lib: honor override_submodule_config flag bit”
  1. diff-lib: honor override_submodule_config flag bitJosip Sokcevic, Jun 14, 2023
  2. Junio C HamanoJun 14, 2023

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.