771
git clone --filter=blob:limit=0 "file://$(pwd)/server" client
772
'
773
774
+test_expect_success 'clone with init.templatedir runs hooks' '
775
+ git init tmpl/hooks &&
776
+ write_script tmpl/hooks/post-checkout <<-EOF &&
777
+ echo HOOK-RUN >&2
778
+ echo I was here >hook.run
779
+ EOF
780
+ git -C tmpl/hooks add . &&
781
+ test_tick &&
782
+ git -C tmpl/hooks commit -m post-checkout &&
783
+
784
+ test_when_finished "git config --global --unset init.templateDir || :" &&
785
+ test_when_finished "git config --unset init.templateDir || :" &&
786
+ (
787
+ sane_unset GIT_TEMPLATE_DIR &&
788
+ NO_SET_GIT_TEMPLATE_DIR=t &&
789
+ export NO_SET_GIT_TEMPLATE_DIR &&
790
+
791
+ git -c core.hooksPath="$(pwd)/tmpl/hooks" \
792
+ clone tmpl/hooks hook-run-hookspath 2>err &&
793
+ ! grep "active .* hook found" err &&
794
+ test_path_is_file hook-run-hookspath/hook.run &&
795
+
796
+ git -c init.templateDir="$(pwd)/tmpl" \
797
+ clone tmpl/hooks hook-run-config 2>err &&
798
+ ! grep "active .* hook found" err &&
799
+ test_path_is_file hook-run-config/hook.run &&
800
+
801
+ git clone --template=tmpl tmpl/hooks hook-run-option 2>err &&
802
+ ! grep "active .* hook found" err &&
803
+ test_path_is_file hook-run-option/hook.run &&
804
+
805
+ git config --global init.templateDir "$(pwd)/tmpl" &&
806
+ git clone tmpl/hooks hook-run-global-config 2>err &&
807
+ git config --global --unset init.templateDir &&
808
+ ! grep "active .* hook found" err &&
809
+ test_path_is_file hook-run-global-config/hook.run &&
810
+
811
+ # clone ignores local `init.templateDir`; need to create
812
+ # a new repository because we deleted `.git/` in the
813
+ # `setup` test case above
814
+ git init local-clone &&
815
+ cd local-clone &&
816
+
817
+ git config init.templateDir "$(pwd)/../tmpl" &&
818
+ git clone ../tmpl/hooks hook-run-local-config 2>err &&
819
+ git config --unset init.templateDir &&
820
+ ! grep "active .* hook found" err &&
821
+ test_path_is_missing hook-run-local-config/hook.run
822
+ )
823
+'
824
+
825
. "$TEST_DIRECTORY"/lib-httpd.sh
826
start_httpd
827