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 > +'