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

Re: [PATCH v1] teach git to support a virtual (partially populated) work directory

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Nov 28, 2018, 13:31 UTC
Message-ID
<20181128133114.GF30222@szeder.dev>
In-Reply-To
<20181127195057.19724-1-peartben@gmail.com>
On Tue, Nov 27, 2018 at 02:50:57PM -0500, Ben Peart wrote:
Show 20 quoted lines
> diff --git a/t/t1092-virtualworkdir.sh b/t/t1092-virtualworkdir.sh
> new file mode 100755
> index 0000000000..0cdfe9b362
> --- /dev/null
> +++ b/t/t1092-virtualworkdir.sh
> @@ -0,0 +1,393 @@
> +#!/bin/sh
> +
> +test_description='virtual work directory tests'
> +
> +. ./test-lib.sh
> +
> +# We need total control of the virtual work directory hook
> +sane_unset GIT_TEST_VIRTUALWORKDIR
> +
> +clean_repo () {
> +	rm .git/index &&
> +	git -c core.virtualworkdir=false reset --hard HEAD &&
> +	git -c core.virtualworkdir=false clean -fd &&
> +	touch untracked.txt &&

We would usually run '>untracked.txt' instead, sparing the external process.

A further nit is that a function called 'clean_repo' creates new untracked files...

Show 7 quoted lines
> +	touch dir1/untracked.txt &&
> +	touch dir2/untracked.txt
> +}
> +
> +test_expect_success 'setup' '
> +	mkdir -p .git/hooks/ &&
> +	cat > .gitignore <<-\EOF &&

CodingGuidelines suggest no space between redirection operator and filename.

Show 16 quoted lines
> +		.gitignore
> +		expect*
> +		actual*
> +	EOF
> +	touch file1.txt &&
> +	touch file2.txt &&
> +	mkdir -p dir1 &&
> +	touch dir1/file1.txt &&
> +	touch dir1/file2.txt &&
> +	mkdir -p dir2 &&
> +	touch dir2/file1.txt &&
> +	touch dir2/file2.txt &&
> +	git add . &&
> +	git commit -m "initial" &&
> +	git config --local core.virtualworkdir true
> +'
> +test_expect_success 'verify files not listed are ignored by git clean -f -x' '
> +	clean_repo &&

I find it odd to clean the repo right after setting it up; but then again, 'clean_repo' not only cleans, but also creates new files. Perhaps rename it to 'reset_repo'? Dunno.

Show 8 quoted lines
> +	write_script .git/hooks/virtual-work-dir <<-\EOF &&
> +		printf "untracked.txt\0"
> +		printf "dir1/\0"
> +	EOF
> +	mkdir -p dir3 &&
> +	touch dir3/untracked.txt &&
> +	git clean -f -x &&
> +	test -f file1.txt &&
Please use the 'test_path_is_file', ...
> +	test -f file2.txt &&
> +	test ! -f untracked.txt &&
... 'test_path_is_missing', and ...
> +	test -d dir1 &&

... 'test_path_is_dir' helpers, respectively, because they print informative error messages on failure.

Show 9 quoted lines
> +	test -f dir1/file1.txt &&
> +	test -f dir1/file2.txt &&
> +	test ! -f dir1/untracked.txt &&
> +	test -f dir2/file1.txt &&
> +	test -f dir2/file2.txt &&
> +	test -f dir2/untracked.txt &&
> +	test -d dir3 &&
> +	test -f dir3/untracked.txt
> +'
Previous: Ben PeartNext: Ben Peart
Message 18 of 21 in “[RFC v1] Add virtual file system settings and hook proc”
  1. Ben PeartOct 30, 2018
  2. Junio C HamanoOct 30, 2018
  3. Ben PeartOct 31, 2018
  4. Junio C HamanoNov 5, 2018
  5. Ben PeartNov 5, 2018
  6. Duy NguyenOct 31, 2018
  7. Ben PeartOct 31, 2018
  8. Duy NguyenNov 4, 2018
  9. brian m. carlsonNov 4, 2018
  10. Duy NguyenNov 5, 2018
  11. Ben PeartNov 5, 2018
  12. Ben PeartNov 5, 2018
  13. Ævar Arnfjörð BjarmasonNov 5, 2018
  14. Duy NguyenNov 5, 2018
  15. Ben PeartNov 5, 2018
  16. Johannes SchindelinNov 5, 2018
  17. teach git to support a virtual (partially populated) work directoryBen Peart, Nov 27, 2018
  18. SZEDER GáborNov 28, 2018
  19. Ben PeartNov 29, 2018
  20. teach git to support a virtual (partially populated) work directoryBen Peart, Dec 13, 2018
  21. Ben PeartJan 28, 2019

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.