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

Re: [PATCH 1/6] t1450: clean up sub-objects in duplicate-entry test

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 17, 2017, 20:52 UTC
Message-ID
<xmqqlgu9e7dw.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170116212403.l7ca7crmt47id3mu@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 24 quoted lines
> This test creates a multi-level set of trees, but its
> cleanup routine only removes the top-level tree. After the
> test finishes, the inner tree and the blob it points to
> remain, making the inner tree dangling.
>
> A later test ("cleaned up") verifies that we've removed any
> cruft and "git fsck" output is clean. This passes only
> because of a bug in git-fsck which fails to notice dangling
> trees.
>
> In preparation for fixing the bug, let's teach this earlier
> test to clean up after itself correctly. We have to remove
> the inner tree (and therefore the blob, too, which becomes
> dangling after removing that tree).
>
> Since the setup code happens inside a subshell, we can't
> just set a variable for each object. However, we can stuff
> all of the sha1s into the $T output variable, which is not
> used for anything except cleanup.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  t/t1450-fsck.sh | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
Thanks.  

It is tempting to move this loop to remove_object, but that is not necessary while the user is only this one.

Show 23 quoted lines
>
> diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
> index ee7d4736d..6eef8b28e 100755
> --- a/t/t1450-fsck.sh
> +++ b/t/t1450-fsck.sh
> @@ -189,14 +189,16 @@ test_expect_success 'commit with NUL in header' '
>  '
>  
>  test_expect_success 'tree object with duplicate entries' '
> -	test_when_finished "remove_object \$T" &&
> +	test_when_finished "for i in \$T; do remove_object \$i; done" &&
>  	T=$(
>  		GIT_INDEX_FILE=test-index &&
>  		export GIT_INDEX_FILE &&
>  		rm -f test-index &&
>  		>x &&
>  		git add x &&
> +		git rev-parse :x &&
>  		T=$(git write-tree) &&
> +		echo $T &&
>  		(
>  			git cat-file tree $T &&
>  			git cat-file tree $T
Previous: Jeff KingNext: Jeff King
Message 3 of 15 in “fsck --connectivity-check misses some corruption”
  1. 0/6 fsck --connectivity-check misses some corruptionJeff King, Jan 16, 2017
  2. 1/6 t1450: clean up sub-objects in duplicate-entry testJeff King, Jan 16, 2017
  3. Junio C HamanoJan 17, 2017
  4. Jeff KingJan 17, 2017
  5. 2/6 fsck: report trees as danglingJeff King, Jan 16, 2017
  6. Junio C HamanoJan 17, 2017
  7. 5/6 fsck: do not fallback "git fsck <bogus>" to "git fsck"Jeff King, Jan 16, 2017
  8. 6/6 fsck: check HAS_OBJ more consistentlyJeff King, Jan 16, 2017
  9. 3/6 fsck: prepare dummy objects for --connectivity-checkJeff King, Jan 16, 2017
  10. Junio C HamanoJan 17, 2017
  11. Junio C HamanoJan 17, 2017
  12. Jeff KingJan 17, 2017
  13. 4/6 fsck: tighten error-checks of "git fsck <head>"Jeff King, Jan 16, 2017
  14. Junio C HamanoJan 17, 2017
  15. Jeff KingJan 16, 2017

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.