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

Re: [PATCH v2 1/2] format-patch: create leading components of output directory

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Oct 7, 2019, 21:03 UTC
Message-ID
<20191007210306.GF11529@szeder.dev>
In-Reply-To
<2b8b000d76a20349f1f9e09260eff91429beebfb.1570264824.git.bert.wesarg@googlemail.com>
On Sat, Oct 05, 2019 at 10:43:51AM +0200, Bert Wesarg wrote:
Show 13 quoted lines
> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
> index 83f52614d3..2f2cd6fea6 100755
> --- a/t/t4014-format-patch.sh
> +++ b/t/t4014-format-patch.sh
> @@ -1606,6 +1606,26 @@ test_expect_success 'From line has expected format' '
>  	test_cmp from filtered
>  '
>  
> +test_expect_success 'format-patch -o with no leading directories' '
> +	rm -fr patches &&
> +	git format-patch -o patches master..side &&
> +	git rev-list master..side >list &&
> +	test_line_count = $(ls patches | wc -l) list
This is sort of a nit...

So, these tests check that 'git rev-list ...' lists as many commits as the number of files created by 'git format-patch'. While it doesn't affect the tests' correctness, this is subtly different from checking that 'git format-patch' created as many files as the number of commits listed by 'git rev-list'.

Consider how the tests' output would look like on failure: 'test_line_count' shows an error message that includes the content of the file to be checked, which in this case would consist of a bunch of commit object ids:

  test_line_count: line count for list != 3
  f7af51d27933a90554b6e9212a7e5d4ad1c74569
  bd89fce9f5096eb5cad67c342b40818b7e3ce9e4

On one hand, these object ids won't mean much to anyone who might have to debug such a test failure in the future, and on the other these tests are about 'git format-patch', not about 'git rev-list'. If the check were written like this:

  count=$(git rev-list --count master..side) &&
  ls patches >list &&
  test_line_count = $count list
then the error message on failure would look something like this:
  test_line_count: line count for list != 3
  0001-first.patch
  0002-second.patch
which, I think, would be more useful.
Show 21 quoted lines
> +'
> +
> +test_expect_success 'format-patch -o with leading existing directories' '
> +	git format-patch -o patches/side master..side &&
> +	git rev-list master..side >list &&
> +	test_line_count = $(ls patches/side | wc -l) list
> +'
> +
> +test_expect_success 'format-patch -o with leading non-existing directories' '
> +	rm -fr patches &&
> +	git format-patch -o patches/side master..side &&
> +	git rev-list master..side >list &&
> +	test_line_count = $(ls patches/side | wc -l) list
> +'
> +
>  test_expect_success 'format-patch format.outputDirectory option' '
>  	test_config format.outputDirectory patches &&
>  	rm -fr patches &&
> -- 
> 2.23.0.11.g242cf7f110
> 
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 7 in “format-patch: create leading components of output directory”
  1. 1/2 format-patch: create leading components of output directoryBert Wesarg, Oct 5, 2019
  2. 2/2 [RFC] format-patch: configure a command to generate the output directory nameBert Wesarg, Oct 5, 2019
  3. Junio C HamanoOct 6, 2019
  4. SZEDER GáborOct 7, 2019
  5. Junio C HamanoOct 8, 2019
  6. Bert WesargOct 8, 2019
  7. t4014: treat rev-list output as the expected valueDenton Liu, Oct 8, 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.