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

Re: [PATCH v2] sha1_file: pass empty buffer to index empty file

From
Junio C Hamano <gitster@pobox.com>
Date
May 16, 2015, 18:48 UTC
Message-ID
<xmqqa8x4fjf5.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20150515233153.GA4157@gadabout.domain.actdsltmp>
Jim Hill <gjthill@gmail.com> writes:
> So, so long as we're testing empty-file filters, I figured I'd add real
> empty-file filter tests, I think that covers it.
>
> So is this better instead?

I wouldn't use "---in-repo-header--" as that extra string. Feeding anything that begins with '-' to 'echo' gives me portability worries for one thing. A single word "Extra" would suffice.

Be careful and consistent wrt redirection operator and its file; we do not write SP there but some of yours do and some others don't.

Do not attempt to align && with excess SPs; other tests don't.
Other than that, yeah, I think that is an improvement.
Thanks.
Show 48 quoted lines
>
> diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
> index 5986bb0..fc2c644 100755
> --- a/t/t0021-conversion.sh
> +++ b/t/t0021-conversion.sh
> @@ -216,15 +216,33 @@ test_expect_success EXPENSIVE 'filter large file' '
>  	! test -s err
>  '
>  
> -test_expect_success "filtering empty file should not produce complaints" '
> -	echo "emptyfile filter=cat" >>.gitattributes &&
> -	git config filter.cat.clean cat &&
> -	git config filter.cat.smudge cat &&
> -	git add . &&
> -	git commit -m "cat filter for emptyfile" &&
> -	> emptyfile &&
> -	git add emptyfile 2>err &&
> -	! grep -Fiqs "bad file descriptor" err
> +test_expect_success "filter: clean empty file" '
> +	header=---in-repo-header--- &&
> +	git config filter.in-repo-header.clean  "echo $header && cat" &&
> +	git config filter.in-repo-header.smudge "sed 1d" &&
> +
> +	echo "empty-in-worktree    filter=in-repo-header" >>.gitattributes &&
> +	> empty-in-worktree &&
> +
> +	echo $header              > expected &&
> +	git add empty-in-worktree            &&
> +	git show :empty-in-worktree > actual &&
> +	test_cmp expected actual
> +'
> +
> +test_expect_success "filter: smudge empty file" '
> +	git config filter.empty-in-repo.smudge "echo smudge added line && cat" &&
> +	git config filter.empty-in-repo.clean   true &&
> +
> +	echo "empty-in-repo      filter=empty-in-repo"  >>.gitattributes &&
> +
> +	echo dead data walking > empty-in-repo &&
> +	git add empty-in-repo &&
> +
> +	:			> expected &&
> +	git show :empty-in-repo	> actual &&
> +	test_cmp expected actual
>  '
>  
>  test_done
> +
Previous: Jim HillNext: Jim Hill
Message 6 of 23 in “sha1_file: pass empty buffer to index empty file”
  1. sha1_file: pass empty buffer to index empty fileJim Hill, May 14, 2015
  2. Junio C HamanoMay 14, 2015
  3. sha1_file: pass empty buffer to index empty fileJim Hill, May 14, 2015
  4. Junio C HamanoMay 15, 2015
  5. Jim HillMay 15, 2015
  6. Junio C HamanoMay 16, 2015
  7. sha1_file: pass empty buffer to index empty fileJim Hill, May 16, 2015
  8. Junio C HamanoMay 16, 2015
  9. Junio C HamanoMay 17, 2015
  10. Junio C HamanoMay 17, 2015
  11. sha1_file: pass empty buffer to index empty fileJim Hill, May 18, 2015
  12. Jeff KingMay 19, 2015
  13. Junio C HamanoMay 19, 2015
  14. Junio C HamanoMay 19, 2015
  15. Junio C HamanoMay 19, 2015
  16. Junio C HamanoMay 19, 2015
  17. Jeff KingMay 19, 2015
  18. Junio C HamanoMay 20, 2015
  19. Eric SunshineMay 19, 2015
  20. Jeff KingMay 19, 2015
  21. Junio C HamanoMay 20, 2015
  22. Jeff KingMay 20, 2015
  23. Jim HillMay 14, 2015

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.