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