ad5df6b782
Fix a bug in upload-pack.c that occurs when you combine partial clone and uploadpack.packObjectsHook. You can reproduce it as follows: git clone -u 'git -c uploadpack.allowfilter '\ '-c uploadpack.packobjectshook=env '\ 'upload-pack' --filter=blob:none --no-local \ src.git dst.git Be careful with the line endings because this has a long quoted string as the -u argument. The error I get when I run this is: Cloning into '/tmp/broken'... remote: fatal: invalid filter-spec ''blob:none'' error: git upload-pack: git-pack-objects died with error. fatal: git upload-pack: aborting due to possible repository corruption on the remote side. remote: aborting due to possible repository corruption on the remote side. fatal: early EOF fatal: index-pack failed The problem is caused by unneeded quoting. This bug was already present in10ac85c785
(upload-pack: add object filtering for partial clone, 2017-12-08) when the server side filter support was introduced. In fact, in10ac85c785
this was broken regardless of uploadpack.packObjectsHook. Then in0b6069fe0a
(fetch-pack: test support excluding large blobs, 2017-12-08) the quoting was removed but only behind a conditional that depends on whether uploadpack.packObjectsHook is set. Because uploadpack.packObjectsHook is apparently rarely used, nobody noticed the problematic quoting could still happen. Remove the conditional quoting and add a test for partial clone in t5544-pack-objects-hook. Signed-off-by: Jacob Vosmaer <jacob@gitlab.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
72 lines
1.9 KiB
Bash
Executable File
72 lines
1.9 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='test custom script in place of pack-objects'
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'create some history to fetch' '
|
|
test_commit one &&
|
|
test_commit two
|
|
'
|
|
|
|
test_expect_success 'create debugging hook script' '
|
|
write_script .git/hook <<-\EOF
|
|
echo >&2 "hook running"
|
|
echo "$*" >hook.args
|
|
cat >hook.stdin
|
|
"$@" <hook.stdin >hook.stdout
|
|
cat hook.stdout
|
|
EOF
|
|
'
|
|
|
|
clear_hook_results () {
|
|
rm -rf .git/hook.* dst.git
|
|
}
|
|
|
|
test_expect_success 'hook runs via global config' '
|
|
clear_hook_results &&
|
|
test_config_global uploadpack.packObjectsHook ./hook &&
|
|
git clone --no-local . dst.git 2>stderr &&
|
|
grep "hook running" stderr
|
|
'
|
|
|
|
test_expect_success 'hook outputs are sane' '
|
|
# check that we recorded a usable pack
|
|
git index-pack --stdin <.git/hook.stdout &&
|
|
|
|
# check that we recorded args and stdin. We do not check
|
|
# the full argument list or the exact pack contents, as it would make
|
|
# the test brittle. So just sanity check that we could replay
|
|
# the packing procedure.
|
|
grep "^git" .git/hook.args &&
|
|
$(cat .git/hook.args) <.git/hook.stdin >replay
|
|
'
|
|
|
|
test_expect_success 'hook runs from -c config' '
|
|
clear_hook_results &&
|
|
git clone --no-local \
|
|
-u "git -c uploadpack.packObjectsHook=./hook upload-pack" \
|
|
. dst.git 2>stderr &&
|
|
grep "hook running" stderr
|
|
'
|
|
|
|
test_expect_success 'hook does not run from repo config' '
|
|
clear_hook_results &&
|
|
test_config uploadpack.packObjectsHook "./hook" &&
|
|
git clone --no-local . dst.git 2>stderr &&
|
|
! grep "hook running" stderr &&
|
|
test_path_is_missing .git/hook.args &&
|
|
test_path_is_missing .git/hook.stdin &&
|
|
test_path_is_missing .git/hook.stdout
|
|
'
|
|
|
|
test_expect_success 'hook works with partial clone' '
|
|
clear_hook_results &&
|
|
test_config_global uploadpack.packObjectsHook ./hook &&
|
|
test_config_global uploadpack.allowFilter true &&
|
|
git clone --bare --no-local --filter=blob:none . dst.git &&
|
|
git -C dst.git rev-list --objects --missing=print HEAD >objects &&
|
|
grep "^?" objects
|
|
'
|
|
|
|
test_done
|