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

Re: [PATCH 3/6] fsck: prepare dummy objects for --connectivity-check

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 17, 2017, 21:15 UTC
Message-ID
<xmqqa8ape6b6.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170116213204.e7ykwowqzafkexqd@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 7 quoted lines
> +static void mark_object_for_connectivity(const unsigned char *sha1)
> +{
> +	struct object *obj = lookup_object(sha1);
> +
> +	/*
> +	 * Setting the object type here isn't strictly necessary here for a
> +	 * connectivity check.
Drop one of these "here"s?
> The cmd_fsck() part of the diff is pretty nasty without
> "-b".

True. I also wonder if swapping the if/else arms make the end result and the patch easier to read. i.e.

+	if (connectivity_only) {
+		mark loose for connectivity;
+		mark packed for connectivity;
+	} else {
		... existing code comes here reindented ...
	}                
But the patch makes sense.
Show 38 quoted lines
> diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
> index e88ec7747..c1b2dda33 100755
> --- a/t/t1450-fsck.sh
> +++ b/t/t1450-fsck.sh
> @@ -523,9 +523,21 @@ test_expect_success 'fsck --connectivity-only' '
>  		touch empty &&
>  		git add empty &&
>  		test_commit empty &&
> +
> +		# Drop the index now; we want to be sure that we
> +		# recursively notice that we notice the broken objects
> +		# because they are reachable from refs, not because
> +		# they are in the index.
> +		rm -f .git/index &&
> +
> +		# corrupt the blob, but in a way that we can still identify
> +		# its type. That lets us see that --connectivity-only is
> +		# not actually looking at the contents, but leaves it
> +		# free to examine the type if it chooses.
>  		empty=.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 &&
> -		rm -f $empty &&
> -		echo invalid >$empty &&
> +		blob=$(echo unrelated | git hash-object -w --stdin) &&
> +		mv $(sha1_file $blob) $empty &&
> +
>  		test_must_fail git fsck --strict &&
>  		git fsck --strict --connectivity-only &&
>  		tree=$(git rev-parse HEAD:) &&
> @@ -537,6 +549,13 @@ test_expect_success 'fsck --connectivity-only' '
>  	)
>  '
>  
> +test_expect_success 'fsck --connectivity-only with explicit head' '
> +	(
> +		cd connectivity-only &&
> +		test_must_fail git fsck --connectivity-only $tree
> +	)
> +'

Most of the earlier "tree=..." assignments are done in subshells, and it is not clear which tree this refers to. Is this the one that was written in 'rev-list --verify-objects with bad sha1' that has been removed in its when-finished handler?

>  remove_loose_object () {
>  	sha1="$(git rev-parse "$1")" &&
>  	remainder=${sha1#??} &&
Previous: Junio C HamanoNext: Jeff King
Message 11 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.