]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5544-pack-objects-hook.sh
The third batch
[thirdparty/git.git] / t / t5544-pack-objects-hook.sh
1 #!/bin/sh
2
3 test_description='test custom script in place of pack-objects'
4
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 test_expect_success 'create some history to fetch' '
9 test_commit one &&
10 test_commit two
11 '
12
13 test_expect_success 'create debugging hook script' '
14 write_script .git/hook <<-\EOF
15 echo >&2 "hook running"
16 echo "$*" >hook.args
17 cat >hook.stdin
18 "$@" <hook.stdin >hook.stdout
19 cat hook.stdout
20 EOF
21 '
22
23 clear_hook_results () {
24 rm -rf .git/hook.* dst.git
25 }
26
27 test_expect_success 'hook runs via global config' '
28 clear_hook_results &&
29 test_config_global uploadpack.packObjectsHook ./hook &&
30 git clone --no-local . dst.git 2>stderr &&
31 grep "hook running" stderr
32 '
33
34 test_expect_success 'hook outputs are sane' '
35 # check that we recorded a usable pack
36 git index-pack --stdin <.git/hook.stdout &&
37
38 # check that we recorded args and stdin. We do not check
39 # the full argument list or the exact pack contents, as it would make
40 # the test brittle. So just sanity check that we could replay
41 # the packing procedure.
42 grep "^git" .git/hook.args &&
43 $(cat .git/hook.args) <.git/hook.stdin >replay
44 '
45
46 test_expect_success 'hook runs from -c config' '
47 clear_hook_results &&
48 git clone --no-local \
49 -u "git -c uploadpack.packObjectsHook=./hook upload-pack" \
50 . dst.git 2>stderr &&
51 grep "hook running" stderr
52 '
53
54 test_expect_success 'hook does not run from repo config' '
55 clear_hook_results &&
56 test_config uploadpack.packObjectsHook "./hook" &&
57 git clone --no-local . dst.git 2>stderr &&
58 ! grep "hook running" stderr &&
59 test_path_is_missing .git/hook.args &&
60 test_path_is_missing .git/hook.stdin &&
61 test_path_is_missing .git/hook.stdout &&
62
63 # check that global config is used instead
64 test_config_global uploadpack.packObjectsHook ./hook &&
65 git clone --no-local . dst2.git 2>stderr &&
66 grep "hook running" stderr
67 '
68
69 test_expect_success 'hook works with partial clone' '
70 clear_hook_results &&
71 test_config_global uploadpack.packObjectsHook ./hook &&
72 test_config_global uploadpack.allowFilter true &&
73 git clone --bare --no-local --filter=blob:none . dst.git &&
74 git -C dst.git rev-list --objects --missing=allow-any --no-object-names --all >objects &&
75 git -C dst.git cat-file --batch-check="%(objecttype)" <objects >types &&
76 ! grep blob types
77 '
78
79 test_done