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

Re: [PATCH v12 5/5] read-cache: speed up has_dir_name (part 2)

From
René Scharfe <l.s.r@web.de>
Date
Jul 5, 2020, 05:27 UTC
Message-ID
<fd593c77-ac40-9c4a-7556-2f10d60e2cee@web.de>
In-Reply-To
<20200704172708.GC11341@szeder.dev>
Am 04.07.20 um 19:27 schrieb SZEDER Gábor:
Show 48 quoted lines
> diff --git a/t/t9999-test.sh b/t/t9999-test.sh
> new file mode 100755
> index 0000000000..4c802d5940
> --- /dev/null
> +++ b/t/t9999-test.sh
> @@ -0,0 +1,47 @@
> +#!/bin/sh
> +
> +test_description='test'
> +
> +. ./test-lib.sh
> +
> +test_expect_success 'file to dir breakage' '
> +	>file-to-dir &&
> +	# This sorts between "file-to-dir" as a file and "file-to-dir"
> +	# as a directory (with the trailing / appended implicitly.
> +	>file-to-dir.uh-oh &&
> +	git add file-to-dir file-to-dir.uh-oh &&
> +	git commit -m "add a file" &&
> +
> +	# Not "git rm", to preserve "file-to-dir" in the index.
> +	rm file-to-dir &&
> +	mkdir file-to-dir &&
> +	>file-to-dir/file &&
> +
> +	# It is important to add the file in the directory; adding only
> +	# the directory doesnt trigger the bug.
> +	git add file-to-dir/file &&
> +
> +	git diff --cached --no-renames --name-status >actual &&
> +
> +	cat >expect <<-\EOF &&
> +	D	file-to-dir
> +	A	file-to-dir/file
> +	EOF
> +	test_cmp expect actual
> +'
> +
> +test_expect_success 'is it committed as-is?' '
> +	git commit -m "replace file with a dir" &&
> +	git ls-tree HEAD >actual &&
> +
> +	# Hardcoded SHA-1 oid :(, because with this bug present
> +	# "git rev-parse HEAD:file-to-dir" doesnt show the oid of
> +	# the tree, but the oid of the blob that shouldnt be there.
> +	cat >expect <<-EOF &&
> +	100644 blob $EMPTY_BLOB	file-to-dir.uh-oh
> +	040000 tree df2b8fc99e1c1d4dbc0a854d9f72157f1d6ea078	file-to-dir
You can get the hash of the tree with:
  echo "100644 blob $EMPTY_BLOB	file" | git mktree
(TAB before "file", the rest of the whitespace are regular spaces)
Show 6 quoted lines
> +	EOF
> +	test_cmp expect actual
> +'
> +
> +test_done
>
Previous: SZEDER GáborNext: Junio C Hamano
Message 7 of 11 in “read-cache: speed up add_index_entry”
  1. 0/5 read-cache: speed up add_index_entrygit@jeffhostetler.com, Apr 19, 2017
  2. 2/5 p0006-read-tree-checkout: perf test to time read-treegit@jeffhostetler.com, Apr 19, 2017
  3. 1/5 read-cache: add strcmp_offset functiongit@jeffhostetler.com, Apr 19, 2017
  4. 3/5 read-cache: speed up add_index_entry during checkoutgit@jeffhostetler.com, Apr 19, 2017
  5. 5/5 read-cache: speed up has_dir_name (part 2)git@jeffhostetler.com, Apr 19, 2017
  6. SZEDER GáborJul 4, 2020
  7. René ScharfeJul 5, 2020
  8. Junio C HamanoJul 6, 2020
  9. Jeff HostetlerJul 8, 2020
  10. René ScharfeJul 16, 2020
  11. 4/5 read-cache: speed up has_dir_name (part 1)git@jeffhostetler.com, Apr 19, 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.