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

Re: [PATCH 4/4 v6] cache-tree: Write updated cache-tree after commit

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 11, 2014, 15:52 UTC
Message-ID
<xmqq38e76gfi.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1405038686-1138-4-git-send-email-dturner@twitter.com>
David Turner <dturner@twopensource.com> writes:
> @@ -16,8 +16,34 @@ cmp_cache_tree () {
>  # We don't bother with actually checking the SHA1:
>  # test-dump-cache-tree already verifies that all existing data is
>  # correct.
Is this statement now stale and needs to be removed?
Show 27 quoted lines
> -test_shallow_cache_tree () {
> -	printf "SHA  (%d entries, 0 subtrees)\n" $(git ls-files|wc -l) >expect &&
> +generate_expected_cache_tree_rec () {
> +	dir="$1${1:+/}" &&
> +	parent="$2" &&
> +	# ls-files might have foo/bar, foo/bar/baz, and foo/bar/quux
> +	# We want to count only foo because it's the only direct child
> +	subtrees=$(git ls-files|grep /|cut -d / -f 1|uniq) &&
> +	subtree_count=$(echo "$subtrees"|awk '$1 {++c} END {print c}') &&
> +	entries=$(git ls-files|wc -l) &&
> +	printf "SHA $dir (%d entries, %d subtrees)\n" "$entries" "$subtree_count" &&
> +	for subtree in $subtrees
> +	do
> +	    cd "$subtree"
> +	    generate_expected_cache_tree_rec "$dir$subtree" "$dir" || return 1
> +	    cd ..
> +	done &&
> +	dir=$parent
> +}
> +
> +generate_expected_cache_tree () {
> +    cwd=$(pwd)
> +    generate_expected_cache_tree_rec
> +    ret="$?"
> +    cd "$cwd"
> +    return $ret
> +}

As we always have had trouble between $PWD and $(pwd) on other platforms, I'd prefer something simpler, like:

	expected_cache_tree () {
		(
                	# subshell to let it wander around freely
	        	generate_expected_cache_tree_rec
		)
	}

Other than these two, the new tests were good from a cursory look. The change to builtin/commit.c looked good, too.

Thanks.
Previous: David TurnerNext: David Turner
Message 11 of 12 in “cache-tree: Create/update cache-tree on checkout”
  1. 1/4 cache-tree: Create/update cache-tree on checkoutDavid Turner, Jul 11, 2014
  2. 2/4 test-dump-cache-tree: invalid trees are not errorsDavid Turner, Jul 11, 2014
  3. 3/4 cache-tree: subdirectory testsDavid Turner, Jul 11, 2014
  4. Eric SunshineJul 11, 2014
  5. Junio C HamanoJul 11, 2014
  6. Junio C HamanoJul 11, 2014
  7. David TurnerJul 11, 2014
  8. Junio C HamanoJul 13, 2014
  9. David TurnerJul 11, 2014
  10. 4/4 cache-tree: Write updated cache-tree after commitDavid Turner, Jul 11, 2014
  11. Junio C HamanoJul 11, 2014
  12. David TurnerJul 11, 2014

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.