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

Re: [PATCH v3] stash: avoid recursive hard reset on submodules

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 12, 2019, 01:46 UTC
Message-ID
<xmqqsgnyenwj.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20191011222448.GA650182@OJAN-PAAVO.localdomain>
Jakob Jarmar <jakob.j@gmail.com> writes:
Show 9 quoted lines
> diff --git a/t/t3906-stash-submodule.sh b/t/t3906-stash-submodule.sh
> index d7219d6f8f..83106fa958 100755
> --- a/t/t3906-stash-submodule.sh
> +++ b/t/t3906-stash-submodule.sh
> @@ -1,6 +1,6 @@
>  #!/bin/sh
>  
> -test_description='stash apply can handle submodules'
> +test_description='stash can handle submodules'
Good attention to the detail ;-)
> +setup_basic() {

Style. SP on both sides of () in our shell scripts (as seen in the existing shell function in the same file).

Show 12 quoted lines
> +	git init sub &&
> +	(
> +		cd sub &&
> +		test_commit sub_file
> +	) &&
> +	git init main &&
> +	(
> +		cd main &&
> +		git submodule add ../sub &&
> +		test_commit main_file
> +	) &&
> +	test_when_finished "rm -rf main sub"

Have test_when_finished that removes main and sub _before_ you start creating sub and main.

When the &&-cascade breaks anywhere, the control may not even reach your test_when_finished that registers the clean-up procedure. Imagine "git init sub" succeeds but "git init main" somehow fails---you still want to clean up "sub".

Other than that, looks reasonably well done.  
Thanks for working on this.
Show 28 quoted lines
> +}
> +
> +test_expect_success 'stash push with submodule.recurse=true preserves dirty submodule worktree' '
> +	setup_basic &&
> +	(
> +		cd main &&
> +		git config submodule.recurse true &&
> +		echo "x" >main_file.t &&
> +		echo "y" >sub/sub_file.t &&
> +		git stash push &&
> +		test_must_fail git -C sub diff --quiet
> +	)
> +'
> +
> +test_expect_success 'stash push and pop with submodule.recurse=true preserves dirty submodule worktree' '
> +	setup_basic &&
> +	(
> +		cd main &&
> +		git config submodule.recurse true &&
> +		echo "x" >main_file.t &&
> +		echo "y" >sub/sub_file.t &&
> +		git stash push &&
> +		git stash pop &&
> +		test_must_fail git -C sub diff --quiet
> +	)
> +'
> +
>  test_done
Previous: Jakob JarmarNext: Jakob Jarmar
Message 5 of 8 in “stash: avoid recursive hard reset on submodules”
  1. stash: avoid recursive hard reset on submodulesJakob Jarmar, Oct 10, 2019
  2. stash: avoid recursive hard reset on submodulesJakob Jarmar, Oct 11, 2019
  3. Junio C HamanoOct 11, 2019
  4. stash: avoid recursive hard reset on submodulesJakob Jarmar, Oct 11, 2019
  5. Junio C HamanoOct 12, 2019
  6. Jakob JarmarOct 12, 2019
  7. stash: avoid recursive hard reset on submodulesJakob Jarmar, Oct 12, 2019
  8. Junio C HamanoOct 15, 2019

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.