From: Junio C Hamano Date: Mon, 24 Apr 2017 05:07:51 +0000 (-0700) Subject: Merge branch 'jk/quarantine-received-objects' X-Git-Tag: v2.13.0-rc1~26 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/9f1384f711e4d04d7808d4e24860b17f656b7333?ds=inline;hp=--cc Merge branch 'jk/quarantine-received-objects' Add finishing touches to a recent topic. * jk/quarantine-received-objects: refs: reject ref updates while GIT_QUARANTINE_PATH is set receive-pack: document user-visible quarantine effects receive-pack: drop tmp_objdir_env from run_update_hook --- 9f1384f711e4d04d7808d4e24860b17f656b7333 diff --cc refs.c index d1e1b4399b,916b0d5fa5..a3d5f42e37 --- a/refs.c +++ b/refs.c @@@ -1641,8 -1463,14 +1641,14 @@@ int create_symref(const char *ref_targe int ref_transaction_commit(struct ref_transaction *transaction, struct strbuf *err) { - struct ref_store *refs = get_ref_store(NULL); + struct ref_store *refs = transaction->ref_store; + if (getenv(GIT_QUARANTINE_ENVIRONMENT)) { + strbuf_addstr(err, + _("ref updates forbidden inside quarantine environment")); + return -1; + } + return refs->be->transaction_commit(refs, transaction, err); } diff --cc t/t5547-push-quarantine.sh index af9fcd833a,462bfc9cba..113c87007f --- a/t/t5547-push-quarantine.sh +++ b/t/t5547-push-quarantine.sh @@@ -33,29 -33,15 +33,40 @@@ test_expect_success 'rejected objects a test_cmp expect actual ' +test_expect_success 'push to repo path with path separator (colon)' ' + # The interesting failure case here is when the + # receiving end cannot access its original object directory, + # so make it likely for us to generate a delta by having + # a non-trivial file with multiple versions. + + test-genrandom foo 4096 >file.bin && + git add file.bin && + git commit -m bin && + + if test_have_prereq MINGW + then + pathsep=";" + else + pathsep=":" + fi && + git clone --bare . "xxx${pathsep}yyy.git" && + + echo change >>file.bin && + git commit -am change && + # Note that we have to use the full path here, or it gets confused + # with the ssh host:path syntax. + git push "$(pwd)/xxx${pathsep}yyy.git" HEAD +' + + test_expect_success 'updating a ref from quarantine is forbidden' ' + git init --bare update.git && + write_script update.git/hooks/pre-receive <<-\EOF && + read old new refname + git update-ref refs/heads/unrelated $new + exit 1 + EOF + test_must_fail git push update.git HEAD && + git -C update.git fsck + ' + test_done