From patchwork Thu Nov 25 15:56:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han-Wen Nienhuys X-Patchwork-Id: 12639463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DE74C433EF for ; Thu, 25 Nov 2021 16:09:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356442AbhKYQM4 (ORCPT ); Thu, 25 Nov 2021 11:12:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356391AbhKYQKy (ORCPT ); Thu, 25 Nov 2021 11:10:54 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31D22C0619DF for ; Thu, 25 Nov 2021 07:56:05 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id v11so12579079wrw.10 for ; Thu, 25 Nov 2021 07:56:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=PSFgT9kvFOoMZ0ZTJJHfE++msvyiVThB9xsajCaHxPA=; b=GIv4nxkmVKw8UaBVaHgsLX5WVyxiVKOaURdmjlcFXSjcqOrwo3owmqvhpm8G2O06Mb IxgVHIg6kcJOcm7qfFKvTeA8jsRpzOf5jy7ihAXcefjMaeQbgC5ANKjScZQEJxfHp+ge jjDi/1m22iRuextOf9qbPz3OyNnv+8CZlGJzn5R2JPTmVN7TY+CNWyN0BG0sLzvmqeOO MskRsnB9NTHnoypO+1uhmOUFl1q+x6Iwc04RrCOf5rNcN+DqINqo/SRw7tUzwoFhIiXO 9Jmu4h7oQ8Cn2D7I2XcWUTcmnVuMJtBd9CUMfLMdqQBjsXMOtcyuY+TJGGqJiMBAJrUT bhhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=PSFgT9kvFOoMZ0ZTJJHfE++msvyiVThB9xsajCaHxPA=; b=xulAJz7KznVCHLRw0NCjXS3VghyLagz/gloBWf8scouJW2G0r1aVedZHmic23pr11e bmg9EYEpXtxDWqwmPA/FGOFwoL2gryp8L/lkBv8CHTb7EnrjS5e/CvCBcaIREHc3/3aS 9VS0dEpQ1EOcj0Sqlahs8ECORPTJBJ82snYJd0C7whOuxG8THu8njwuVOXr5pyr2P9Mx C9w858SxRKODX3nGIw8pQJho2NNWK28TQWhmO1vwHLhCxHV88HUu1JdtF2g9+hA0pyyQ xix4eQi/FkEdn/SoM+hZ6L5OLFQqLMp0CGZUfvpmwy5wdH/ug/T+Z5xyilXS5/IIqpQZ SW2g== X-Gm-Message-State: AOAM532W3YUPZc00Tf+nbtKZbtLVMWLp5uLSSVKfxBdtETrlkeJ1hoA3 8U89PyVyWXrrukr2nPdwV1S1mAux5/M= X-Google-Smtp-Source: ABdhPJyfq0C2nQIKvmC4fRTsPD4lxL7CxeDaEGSnLlHJfsdvRCXjMN+gqe292Ema5GoJnxi7qV+orA== X-Received: by 2002:adf:fe81:: with SMTP id l1mr7840642wrr.522.1637855763593; Thu, 25 Nov 2021 07:56:03 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f7sm10417439wmg.6.2021.11.25.07.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 07:56:03 -0800 (PST) Message-Id: In-Reply-To: References: Date: Thu, 25 Nov 2021 15:56:00 +0000 Subject: [PATCH 1/2] refs: update comment. Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Han-Wen Nienhuys Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys From: Han-Wen Nienhuys REF_IS_PRUNING is right below this comment, so it clearly does not belong in this comment. This was apparently introduced in commit 5ac95fee (Nov 5, 2017 "refs: tidy up and adjust visibility of the `ref_update` flags"). Signed-off-by: Han-Wen Nienhuys --- refs/files-backend.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index 151b0056fe5..5cfdec1e820 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -16,8 +16,7 @@ * This backend uses the following flags in `ref_update::flags` for * internal bookkeeping purposes. Their numerical values must not * conflict with REF_NO_DEREF, REF_FORCE_CREATE_REFLOG, REF_HAVE_NEW, - * REF_HAVE_OLD, or REF_IS_PRUNING, which are also stored in - * `ref_update::flags`. + * or REF_HAVE_OLD, which are also stored in `ref_update::flags`. */ /* From patchwork Thu Nov 25 15:56:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han-Wen Nienhuys X-Patchwork-Id: 12639467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E449C433EF for ; Thu, 25 Nov 2021 16:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356452AbhKYQM5 (ORCPT ); Thu, 25 Nov 2021 11:12:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356394AbhKYQKy (ORCPT ); Thu, 25 Nov 2021 11:10:54 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E9BAC0619E0 for ; Thu, 25 Nov 2021 07:56:06 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id a18so12603913wrn.6 for ; Thu, 25 Nov 2021 07:56:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=tnD+EksciJjt6lu/AUx/uUiNsF4xuT/jBC7k5GvwHgg=; b=dxiNBqwAlCz28JlfMemvcimCAwYWAcSOD0Vl0ncMOhxBvIbudzF6swZP0EkBgw6rYD k6W26J1sk/E3xLNSp/mDJB0JI2DmXZG10NzkxuV9l5umpr9THaHgJRjjPmaGjDWMaiea YN+/TVW3/3YQcvHcxV1ezbVgDS10aOski2RAyBsyzcdWVVfLcD6VQS6o0dfDwA76o9cJ c/sVPmKO+NMyJKxBYvjigz67+nm7mnjvmifSkiW9H4u1wLmbI2jr4OnpzfRg3rkuNUpZ FYaYS9w64EDpUIM2LvLqdMjjikOA1nBNrAq3RC6WrfE2nA/hUosrEq5S3fj/5MRM+MnO Jwgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=tnD+EksciJjt6lu/AUx/uUiNsF4xuT/jBC7k5GvwHgg=; b=rmzXHqJhMRSbH4elHMlxrCY1kn+ZP5LOp4LVwYRZiIvgX6CT6Ws3icxOBSfL6OPiMl dwlf0/O0xPGAkXg1GCTkaXFsbTDkfdnG7BT49kpuLtnMZEVmfKkBxIWQrDDsBC5+2GI7 bxhgneSBDEZ/S+/UTQkB6fe3I/ijJS8OOaC8LA9ILvW6VcKc0tf2wLHQ1t9B+cRv5FwZ p/TCbXBcsWVp1kRL4yTI0/5vcnIDykBdjauJcOArhgTTQ1c4282wMpSguORZbriVy+YO 7mLUah9gTDkLtyttwokS0EJRjaO2fxnxMqHdS6DxOhvBeW9UE0h7yJn2IAn9UnwjSPuG pIew== X-Gm-Message-State: AOAM531dTjMUjh2bm2hleQqhmVipU/I6VRl5StSH9xJP74Ejemye9Pvn xACx7C+ard46vf1K+sZikVlandEtd+c= X-Google-Smtp-Source: ABdhPJwRhVvu1pfwmdPCJAM9sB7b/7X5cNLBntmRZwqq3GTEU6t8jGhtjClWqEZ8goUDP6HNASHAFQ== X-Received: by 2002:adf:e8d1:: with SMTP id k17mr7546795wrn.465.1637855764528; Thu, 25 Nov 2021 07:56:04 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a22sm3288514wme.19.2021.11.25.07.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 07:56:03 -0800 (PST) Message-Id: <900cea2ade9e86b135e4189070a68deea5e9b575.1637855761.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 25 Nov 2021 15:56:01 +0000 Subject: [PATCH 2/2] refs: allow skipping OID verification Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Han-Wen Nienhuys Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys From: Han-Wen Nienhuys This introduces the REF_SKIP_OID_VERIFICATION flag, which lets the ref-store test helper write non-existent or unparsable objects into the ref storage. Use this to make t1006 and t3800 independent of the files storage backend. Signed-off-by: Han-Wen Nienhuys --- refs.h | 8 ++++++- refs/files-backend.c | 50 +++++++++++++++++++++++++------------------- t/t1006-cat-file.sh | 5 ++--- t/t3800-mktag.sh | 6 ++++-- 4 files changed, 42 insertions(+), 27 deletions(-) diff --git a/refs.h b/refs.h index d5099d4984e..46e68fd4c2a 100644 --- a/refs.h +++ b/refs.h @@ -611,12 +611,18 @@ struct ref_transaction *ref_transaction_begin(struct strbuf *err); */ #define REF_FORCE_CREATE_REFLOG (1 << 1) +/* + * Blindly write an object_id. This is useful for testing data corruption + * scenarios. + */ +#define REF_SKIP_OID_VERIFICATION (1 << 10) + /* * Bitmask of all of the flags that are allowed to be passed in to * ref_transaction_update() and friends: */ #define REF_TRANSACTION_UPDATE_ALLOWED_FLAGS \ - (REF_NO_DEREF | REF_FORCE_CREATE_REFLOG) + (REF_NO_DEREF | REF_FORCE_CREATE_REFLOG | REF_SKIP_OID_VERIFICATION) /* * Add a reference update to transaction. `new_oid` is the value that diff --git a/refs/files-backend.c b/refs/files-backend.c index 5cfdec1e820..28a349b24ad 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -1351,7 +1351,8 @@ static int rename_tmp_log(struct files_ref_store *refs, const char *newrefname) } static int write_ref_to_lockfile(struct ref_lock *lock, - const struct object_id *oid, struct strbuf *err); + const struct object_id *oid, + int skip_oid_verification, struct strbuf *err); static int commit_ref_update(struct files_ref_store *refs, struct ref_lock *lock, const struct object_id *oid, const char *logmsg, @@ -1468,7 +1469,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store, } oidcpy(&lock->old_oid, &orig_oid); - if (write_ref_to_lockfile(lock, &orig_oid, &err) || + if (write_ref_to_lockfile(lock, &orig_oid, 0, &err) || commit_ref_update(refs, lock, &orig_oid, logmsg, &err)) { error("unable to write current sha1 into %s: %s", newrefname, err.buf); strbuf_release(&err); @@ -1488,7 +1489,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store, flag = log_all_ref_updates; log_all_ref_updates = LOG_REFS_NONE; - if (write_ref_to_lockfile(lock, &orig_oid, &err) || + if (write_ref_to_lockfile(lock, &orig_oid, 0, &err) || commit_ref_update(refs, lock, &orig_oid, NULL, &err)) { error("unable to write current sha1 into %s: %s", oldrefname, err.buf); strbuf_release(&err); @@ -1724,26 +1725,31 @@ static int files_log_ref_write(struct files_ref_store *refs, * errors, rollback the lockfile, fill in *err and return -1. */ static int write_ref_to_lockfile(struct ref_lock *lock, - const struct object_id *oid, struct strbuf *err) + const struct object_id *oid, + int skip_oid_verification, struct strbuf *err) { static char term = '\n'; struct object *o; int fd; - o = parse_object(the_repository, oid); - if (!o) { - strbuf_addf(err, - "trying to write ref '%s' with nonexistent object %s", - lock->ref_name, oid_to_hex(oid)); - unlock_ref(lock); - return -1; - } - if (o->type != OBJ_COMMIT && is_branch(lock->ref_name)) { - strbuf_addf(err, - "trying to write non-commit object %s to branch '%s'", - oid_to_hex(oid), lock->ref_name); - unlock_ref(lock); - return -1; + if (!skip_oid_verification) { + o = parse_object(the_repository, oid); + if (!o) { + strbuf_addf( + err, + "trying to write ref '%s' with nonexistent object %s", + lock->ref_name, oid_to_hex(oid)); + unlock_ref(lock); + return -1; + } + if (o->type != OBJ_COMMIT && is_branch(lock->ref_name)) { + strbuf_addf( + err, + "trying to write non-commit object %s to branch '%s'", + oid_to_hex(oid), lock->ref_name); + unlock_ref(lock); + return -1; + } } fd = get_lock_file_fd(&lock->lk); if (write_in_full(fd, oid_to_hex(oid), the_hash_algo->hexsz) < 0 || @@ -2150,7 +2156,7 @@ static int files_reflog_iterator_advance(struct ref_iterator *ref_iterator) } static int files_reflog_iterator_peel(struct ref_iterator *ref_iterator, - struct object_id *peeled) + struct object_id *peeled) { BUG("ref_iterator_peel() called for reflog_iterator"); } @@ -2534,8 +2540,10 @@ static int lock_ref_for_update(struct files_ref_store *refs, * The reference already has the desired * value, so we don't need to write it. */ - } else if (write_ref_to_lockfile(lock, &update->new_oid, - err)) { + } else if (write_ref_to_lockfile( + lock, &update->new_oid, + update->flags & REF_SKIP_OID_VERIFICATION, + err)) { char *write_err = strbuf_detach(err, NULL); /* diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh index 658628375c8..f5333196b07 100755 --- a/t/t1006-cat-file.sh +++ b/t/t1006-cat-file.sh @@ -452,9 +452,8 @@ test_expect_success 'the --allow-unknown-type option does not consider replaceme # Create it manually, as "git replace" will die on bogus # types. head=$(git rev-parse --verify HEAD) && - test_when_finished "rm -rf .git/refs/replace" && - mkdir -p .git/refs/replace && - echo $head >.git/refs/replace/$bogus_short_sha1 && + test_when_finished "test-tool ref-store main delete-refs 0 msg refs/replace/$bogus_short_sha1" && + test-tool ref-store main update-ref msg "refs/replace/$bogus_short_sha1" $head $ZERO_OID 1024 && cat >expect <<-EOF && commit diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index 0544d58a6ea..128d374f740 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -72,7 +72,8 @@ check_verify_failure () { # Manually create the broken, we cannot do it with # update-ref - echo "$bad_tag" >"bad-tag/$tag_ref" && + test-tool -C bad-tag ref-store main delete-refs 0 msg "$tag_ref" && + test-tool -C bad-tag ref-store main update-ref msg "$tag_ref" $bad_tag $ZERO_OID 1024 && # Unlike fsck-ing unreachable content above, this # will always fail. @@ -83,7 +84,8 @@ check_verify_failure () { # Make sure the earlier test created it for us git rev-parse "$bad_tag" && - echo "$bad_tag" >"bad-tag/$tag_ref" && + test-tool -C bad-tag ref-store main delete-refs 0 msg "$tag_ref" && + test-tool -C bad-tag ref-store main update-ref msg "$tag_ref" $bad_tag $ZERO_OID 1024 && printf "%s tag\t%s\n" "$bad_tag" "$tag_ref" >expected && git -C bad-tag for-each-ref "$tag_ref" >actual && From patchwork Mon Nov 29 18:49:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han-Wen Nienhuys X-Patchwork-Id: 12645795 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BCC4C433EF for ; Mon, 29 Nov 2021 21:52:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232484AbhK2Vz4 (ORCPT ); Mon, 29 Nov 2021 16:55:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232692AbhK2Vxy (ORCPT ); Mon, 29 Nov 2021 16:53:54 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46DCFC043CE3 for ; Mon, 29 Nov 2021 10:49:51 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id d24so39030036wra.0 for ; Mon, 29 Nov 2021 10:49:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=441hnFEP0pDsGPACxyWqkbI6C0pj/gDFlnUBJ2HsBAM=; b=jWOhMXDggGIIHWVwiNv3+GcvEpZC6QlaiSPSPIlaeW6lTDuHMEfjKqbIRKhegUGx9w cc3EY1fxhZgsjqhlazXF6mz1q3hoLLMvykSvxLMI2LTYqG+TM/aVmZSHImt/O/NX7tXq R4Fo/Rp/GhiCvc6zmxJ5Nrt1emZOAG4WqCPix3RLTAS6+CPLF0k+QEIdYJBxrOY87B5j IWxiJL0cGavjDUEqQXslxnT1iITZObYe6iY1LWbSUWf54sGNIbNXaYEZeCjYXy5l3/Wf aEPYS8h7yX1McyCuNzuSs8FW1QpGbu+XQ1fMw4VZfUh7SCWOWU6uwmEuInsMatrgRRLX fy3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=441hnFEP0pDsGPACxyWqkbI6C0pj/gDFlnUBJ2HsBAM=; b=IwYoQPuletCqLKHu/1nRgRi32vbZgKCZ8Qa0jchszyd/V2qaxNkC1eW8ppl+Pn8hr0 rEIC3ZIawXhJSVCuS0w8kc7+inko3za/DYQxGTcwM6+oWSlkBCXEYpaqhL79Z3SENxGK UGyw7Dx9+wUARaz2VduwnzZvm5z/j0l8Oc8x28RQPeUljhOkmvb2Ie2lZPQFKR10tknF tPaxZcFik8J8p9XG0K/65dTHX8w4BBx69nOsPzt1GeCsRGCw6RD1gBRWPZTiRtNe7aEC d4SdAv7KWrvSDpd9iyCadzfkNnRs1I/p0IS178lHS3kV7qV6Y7LraELseKoiNKZugdVl Tycw== X-Gm-Message-State: AOAM532VVejTXfqoEJo9UibeojyHO9tAUcF83rauq7sJcR7TRJFLlwe3 WWC1i7EzrUzFhCL+fC6yeYmqWWDqGMc= X-Google-Smtp-Source: ABdhPJyZIl2S1YG1z0EuiSmT9HIM9A5FD6okl+4SZEApjM/lT4BvicgpuDAK4l3Y5VhSEeIcSd8AjA== X-Received: by 2002:a5d:69c5:: with SMTP id s5mr35844211wrw.283.1638211789599; Mon, 29 Nov 2021 10:49:49 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id w2sm13957139wrn.67.2021.11.29.10.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 10:49:49 -0800 (PST) Message-Id: <0a297f0c3e884c2d4cfb24a6d3b9f1973fc83125.1638211786.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 29 Nov 2021 18:49:44 +0000 Subject: [PATCH v2 4/6] refs: add REF_SKIP_REFNAME_VERIFICATION flag Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Han-Wen Nienhuys Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys From: Han-Wen Nienhuys Use this flag with the test-helper in t1430, to avoid direct writes to the ref database. Signed-off-by: Han-Wen Nienhuys --- refs.c | 7 ++--- refs.h | 10 +++++-- t/t1430-bad-ref-name.sh | 59 ++++++++++++++++++++++------------------- 3 files changed, 44 insertions(+), 32 deletions(-) diff --git a/refs.c b/refs.c index d7cc0a23a3b..086b1341d2a 100644 --- a/refs.c +++ b/refs.c @@ -1078,9 +1078,10 @@ int ref_transaction_update(struct ref_transaction *transaction, { assert(err); - if ((new_oid && !is_null_oid(new_oid)) ? - check_refname_format(refname, REFNAME_ALLOW_ONELEVEL) : - !refname_is_safe(refname)) { + if (!(flags & REF_SKIP_REFNAME_VERIFICATION) && + ((new_oid && !is_null_oid(new_oid)) ? + check_refname_format(refname, REFNAME_ALLOW_ONELEVEL) : + !refname_is_safe(refname))) { strbuf_addf(err, _("refusing to update ref with bad name '%s'"), refname); return -1; diff --git a/refs.h b/refs.h index 46e68fd4c2a..684f8b33d17 100644 --- a/refs.h +++ b/refs.h @@ -617,12 +617,18 @@ struct ref_transaction *ref_transaction_begin(struct strbuf *err); */ #define REF_SKIP_OID_VERIFICATION (1 << 10) +/* + * Skip verifying refname. This is useful for testing data corruption scenarios. + */ +#define REF_SKIP_REFNAME_VERIFICATION (1 << 11) + /* * Bitmask of all of the flags that are allowed to be passed in to * ref_transaction_update() and friends: */ -#define REF_TRANSACTION_UPDATE_ALLOWED_FLAGS \ - (REF_NO_DEREF | REF_FORCE_CREATE_REFLOG | REF_SKIP_OID_VERIFICATION) +#define REF_TRANSACTION_UPDATE_ALLOWED_FLAGS \ + (REF_NO_DEREF | REF_FORCE_CREATE_REFLOG | REF_SKIP_OID_VERIFICATION | \ + REF_SKIP_REFNAME_VERIFICATION) /* * Add a reference update to transaction. `new_oid` is the value that diff --git a/t/t1430-bad-ref-name.sh b/t/t1430-bad-ref-name.sh index 4c77cf89a6c..56d0726944e 100755 --- a/t/t1430-bad-ref-name.sh +++ b/t/t1430-bad-ref-name.sh @@ -9,7 +9,8 @@ TEST_PASSES_SANITIZE_LEAK=true test_expect_success setup ' test_commit one && - test_commit two + test_commit two && + main_sha1=$(git rev-parse refs/heads/main) ' test_expect_success 'fast-import: fail on invalid branch name ".badbranchname"' ' @@ -43,16 +44,16 @@ test_expect_success 'fast-import: fail on invalid branch name "bad[branch]name"' ' test_expect_success 'git branch shows badly named ref as warning' ' - cp .git/refs/heads/main .git/refs/heads/broken...ref && - test_when_finished "rm -f .git/refs/heads/broken...ref" && + test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && git branch >output 2>error && test_i18ngrep -e "ignoring ref with broken name refs/heads/broken\.\.\.ref" error && ! grep -e "broken\.\.\.ref" output ' test_expect_success 'branch -d can delete badly named ref' ' - cp .git/refs/heads/main .git/refs/heads/broken...ref && - test_when_finished "rm -f .git/refs/heads/broken...ref" && + test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && git branch -d broken...ref && git branch >output 2>error && ! grep -e "broken\.\.\.ref" error && @@ -60,8 +61,8 @@ test_expect_success 'branch -d can delete badly named ref' ' ' test_expect_success 'branch -D can delete badly named ref' ' - cp .git/refs/heads/main .git/refs/heads/broken...ref && - test_when_finished "rm -f .git/refs/heads/broken...ref" && + test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && git branch -D broken...ref && git branch >output 2>error && ! grep -e "broken\.\.\.ref" error && @@ -90,7 +91,7 @@ test_expect_success 'branch -D cannot delete absolute path' ' ' test_expect_success 'git branch cannot create a badly named ref' ' - test_when_finished "rm -f .git/refs/heads/broken...ref" && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && test_must_fail git branch broken...ref && git branch >output 2>error && ! grep -e "broken\.\.\.ref" error && @@ -98,7 +99,7 @@ test_expect_success 'git branch cannot create a badly named ref' ' ' test_expect_success 'branch -m cannot rename to a bad ref name' ' - test_when_finished "rm -f .git/refs/heads/broken...ref" && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && test_might_fail git branch -D goodref && git branch goodref && test_must_fail git branch -m goodref broken...ref && @@ -109,8 +110,9 @@ test_expect_success 'branch -m cannot rename to a bad ref name' ' ' test_expect_failure 'branch -m can rename from a bad ref name' ' - cp .git/refs/heads/main .git/refs/heads/broken...ref && - test_when_finished "rm -f .git/refs/heads/broken...ref" && + test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 && + + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && git branch -m broken...ref renamed && test_cmp_rev main renamed && git branch >output 2>error && @@ -119,7 +121,7 @@ test_expect_failure 'branch -m can rename from a bad ref name' ' ' test_expect_success 'push cannot create a badly named ref' ' - test_when_finished "rm -f .git/refs/heads/broken...ref" && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && test_must_fail git push "file://$(pwd)" HEAD:refs/heads/broken...ref && git branch >output 2>error && ! grep -e "broken\.\.\.ref" error && @@ -139,7 +141,7 @@ test_expect_failure 'push --mirror can delete badly named ref' ' cd dest && test_commit two && git checkout --detach && - cp .git/refs/heads/main .git/refs/heads/broken...ref + test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 ) && git -C src push --mirror "file://$top/dest" && git -C dest branch >output 2>error && @@ -148,9 +150,9 @@ test_expect_failure 'push --mirror can delete badly named ref' ' ' test_expect_success 'rev-parse skips symref pointing to broken name' ' - test_when_finished "rm -f .git/refs/heads/broken...ref" && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && git branch shadow one && - cp .git/refs/heads/main .git/refs/heads/broken...ref && + test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 && printf "ref: refs/heads/broken...ref\n" >.git/refs/tags/shadow && test_when_finished "rm -f .git/refs/tags/shadow" && git rev-parse --verify one >expect && @@ -160,8 +162,8 @@ test_expect_success 'rev-parse skips symref pointing to broken name' ' ' test_expect_success 'for-each-ref emits warnings for broken names' ' - cp .git/refs/heads/main .git/refs/heads/broken...ref && - test_when_finished "rm -f .git/refs/heads/broken...ref" && + test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && test_when_finished "rm -f .git/refs/heads/badname" && printf "ref: refs/heads/main\n" >.git/refs/heads/broken...symref && @@ -176,8 +178,8 @@ test_expect_success 'for-each-ref emits warnings for broken names' ' ' test_expect_success 'update-ref -d can delete broken name' ' - cp .git/refs/heads/main .git/refs/heads/broken...ref && - test_when_finished "rm -f .git/refs/heads/broken...ref" && + test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && git update-ref -d refs/heads/broken...ref >output 2>error && test_must_be_empty output && test_must_be_empty error && @@ -187,8 +189,8 @@ test_expect_success 'update-ref -d can delete broken name' ' ' test_expect_success 'branch -d can delete broken name' ' - cp .git/refs/heads/main .git/refs/heads/broken...ref && - test_when_finished "rm -f .git/refs/heads/broken...ref" && + test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && git branch -d broken...ref >output 2>error && test_i18ngrep "Deleted branch broken...ref (was broken)" output && test_must_be_empty error && @@ -198,8 +200,9 @@ test_expect_success 'branch -d can delete broken name' ' ' test_expect_success 'update-ref --no-deref -d can delete symref to broken name' ' - cp .git/refs/heads/main .git/refs/heads/broken...ref && - test_when_finished "rm -f .git/refs/heads/broken...ref" && + test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 && + + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && test_when_finished "rm -f .git/refs/heads/badname" && git update-ref --no-deref -d refs/heads/badname >output 2>error && @@ -209,8 +212,9 @@ test_expect_success 'update-ref --no-deref -d can delete symref to broken name' ' test_expect_success 'branch -d can delete symref to broken name' ' - cp .git/refs/heads/main .git/refs/heads/broken...ref && - test_when_finished "rm -f .git/refs/heads/broken...ref" && + test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 && + + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && test_when_finished "rm -f .git/refs/heads/badname" && git branch -d badname >output 2>error && @@ -238,8 +242,9 @@ test_expect_success 'branch -d can delete dangling symref to broken name' ' ' test_expect_success 'update-ref -d can delete broken name through symref' ' - cp .git/refs/heads/main .git/refs/heads/broken...ref && - test_when_finished "rm -f .git/refs/heads/broken...ref" && + test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 && + + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && test_when_finished "rm -f .git/refs/heads/badname" && git update-ref -d refs/heads/badname >output 2>error && From patchwork Mon Nov 29 18:49:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han-Wen Nienhuys X-Patchwork-Id: 12645799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4045C433F5 for ; Mon, 29 Nov 2021 21:52:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232503AbhK2V4B (ORCPT ); Mon, 29 Nov 2021 16:56:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232740AbhK2Vxy (ORCPT ); Mon, 29 Nov 2021 16:53:54 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E95ACC043CE4 for ; Mon, 29 Nov 2021 10:49:51 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id i5so38976195wrb.2 for ; Mon, 29 Nov 2021 10:49:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=MCuiqxLv9bQVl5PA1+97daaKtvuwv7Ii0bPhxb1xHqQ=; b=QmGww+duLsweCZy2HKcEeGRJQ2kHqZONqboUd9FCOjJZDe56x5kQ4cK++rIceNwaYt mKjOMLuSJNXhYMj8In+URM6QfGrG4zHMjb97mHwmo34xfQNmzGaaoNeh3QNoHh/vrojs 4eVhTUwnJBgmh6SnsyW13i0f2kFqHmvGbihFhHC4OE5bR/wVx5pwLyQrLT1jXmTX2L41 LhsYppT00a7/TxFThXwSz3O4q6hfjME3exAk1sClYfn0y6pSDb59v3YnUT0ujD9rk8Pv 7iPGFz1tsnvo18laX7UDaCGZ5cUOmPhzvCE5iDTQTZgzF65v9E/28r4gF/tcaiqusLad Yp7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=MCuiqxLv9bQVl5PA1+97daaKtvuwv7Ii0bPhxb1xHqQ=; b=BN4gT6kslJy9JjE008q2mQsDr/nmHHku++olFLp9KvL4YDTc8FJRACLU+mVbSo+oGp b+zBPZ5ooY3OoE+2hgxjdY8a74Ql+2mkJsS46zVwg7Yfcsb0jcBtb+ybtzeN3zRPEDU/ E63u6Wo/8gmdRx147GACTiOXQ+mkTPzUh8KEGPML7mMvRV9hRwch/Ma3+oGj+B85ZniK JEMHbQddNGSMeuo0ZVacVRH6c5nzOZj4OhCCU1jO6iqsGD1tnxLeujUuS+eh+RBdtrRX 2balS93OC3gFUG681wd34gOBglUVjSThnGVF6aa7Uoh5/442eIrWSLCcJDD4o8+2VwL0 JZqw== X-Gm-Message-State: AOAM532Xfnta4duQIJbbvB7FfF8xe7m+ZDF5Wo0aIW08wccGBQSYZtaK Z1GysGtKgsD5F8dZ215GC1mfsZOmwbw= X-Google-Smtp-Source: ABdhPJxjeyukhhWS5K0kD/zUTiY8FfAmheZhX1+mql3SQ3CR/FNodjjEHS0ximwuSAAdLj2PQFki3A== X-Received: by 2002:a5d:6481:: with SMTP id o1mr37191922wri.305.1638211790355; Mon, 29 Nov 2021 10:49:50 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v15sm14534971wro.35.2021.11.29.10.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 10:49:50 -0800 (PST) Message-Id: <06c8ff7df15d325c7d66a63d30d94fcfe2ef91c0.1638211786.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 29 Nov 2021 18:49:45 +0000 Subject: [PATCH v2 5/6] t1430: remove refs using test-tool Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Han-Wen Nienhuys Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys From: Han-Wen Nienhuys Signed-off-by: Han-Wen Nienhuys --- t/t1430-bad-ref-name.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/t/t1430-bad-ref-name.sh b/t/t1430-bad-ref-name.sh index 56d0726944e..5c600980b5f 100755 --- a/t/t1430-bad-ref-name.sh +++ b/t/t1430-bad-ref-name.sh @@ -154,7 +154,7 @@ test_expect_success 'rev-parse skips symref pointing to broken name' ' git branch shadow one && test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 && printf "ref: refs/heads/broken...ref\n" >.git/refs/tags/shadow && - test_when_finished "rm -f .git/refs/tags/shadow" && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/tags/shadow" && git rev-parse --verify one >expect && git rev-parse --verify shadow >actual 2>err && test_cmp expect actual && @@ -165,9 +165,9 @@ test_expect_success 'for-each-ref emits warnings for broken names' ' test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 && test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && - test_when_finished "rm -f .git/refs/heads/badname" && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/badname" && printf "ref: refs/heads/main\n" >.git/refs/heads/broken...symref && - test_when_finished "rm -f .git/refs/heads/broken...symref" && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...symref" && git for-each-ref >output 2>error && ! grep -e "broken\.\.\.ref" output && ! grep -e "badname" output && @@ -204,7 +204,7 @@ test_expect_success 'update-ref --no-deref -d can delete symref to broken name' test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && - test_when_finished "rm -f .git/refs/heads/badname" && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/badname" && git update-ref --no-deref -d refs/heads/badname >output 2>error && test_path_is_missing .git/refs/heads/badname && test_must_be_empty output && @@ -216,7 +216,7 @@ test_expect_success 'branch -d can delete symref to broken name' ' test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && - test_when_finished "rm -f .git/refs/heads/badname" && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/badname" && git branch -d badname >output 2>error && test_path_is_missing .git/refs/heads/badname && test_i18ngrep "Deleted branch badname (was refs/heads/broken\.\.\.ref)" output && @@ -225,7 +225,7 @@ test_expect_success 'branch -d can delete symref to broken name' ' test_expect_success 'update-ref --no-deref -d can delete dangling symref to broken name' ' printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && - test_when_finished "rm -f .git/refs/heads/badname" && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/badname" && git update-ref --no-deref -d refs/heads/badname >output 2>error && test_path_is_missing .git/refs/heads/badname && test_must_be_empty output && @@ -234,7 +234,7 @@ test_expect_success 'update-ref --no-deref -d can delete dangling symref to brok test_expect_success 'branch -d can delete dangling symref to broken name' ' printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && - test_when_finished "rm -f .git/refs/heads/badname" && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/badname" && git branch -d badname >output 2>error && test_path_is_missing .git/refs/heads/badname && test_i18ngrep "Deleted branch badname (was refs/heads/broken\.\.\.ref)" output && @@ -246,7 +246,7 @@ test_expect_success 'update-ref -d can delete broken name through symref' ' test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && - test_when_finished "rm -f .git/refs/heads/badname" && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/badname" && git update-ref -d refs/heads/badname >output 2>error && test_path_is_missing .git/refs/heads/broken...ref && test_must_be_empty output && @@ -255,7 +255,7 @@ test_expect_success 'update-ref -d can delete broken name through symref' ' test_expect_success 'update-ref --no-deref -d can delete symref with broken name' ' printf "ref: refs/heads/main\n" >.git/refs/heads/broken...symref && - test_when_finished "rm -f .git/refs/heads/broken...symref" && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...symref" && git update-ref --no-deref -d refs/heads/broken...symref >output 2>error && test_path_is_missing .git/refs/heads/broken...symref && test_must_be_empty output && @@ -264,7 +264,7 @@ test_expect_success 'update-ref --no-deref -d can delete symref with broken name test_expect_success 'branch -d can delete symref with broken name' ' printf "ref: refs/heads/main\n" >.git/refs/heads/broken...symref && - test_when_finished "rm -f .git/refs/heads/broken...symref" && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...symref" && git branch -d broken...symref >output 2>error && test_path_is_missing .git/refs/heads/broken...symref && test_i18ngrep "Deleted branch broken...symref (was refs/heads/main)" output && @@ -273,7 +273,7 @@ test_expect_success 'branch -d can delete symref with broken name' ' test_expect_success 'update-ref --no-deref -d can delete dangling symref with broken name' ' printf "ref: refs/heads/idonotexist\n" >.git/refs/heads/broken...symref && - test_when_finished "rm -f .git/refs/heads/broken...symref" && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...symref" && git update-ref --no-deref -d refs/heads/broken...symref >output 2>error && test_path_is_missing .git/refs/heads/broken...symref && test_must_be_empty output && @@ -282,7 +282,7 @@ test_expect_success 'update-ref --no-deref -d can delete dangling symref with br test_expect_success 'branch -d can delete dangling symref with broken name' ' printf "ref: refs/heads/idonotexist\n" >.git/refs/heads/broken...symref && - test_when_finished "rm -f .git/refs/heads/broken...symref" && + test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...symref" && git branch -d broken...symref >output 2>error && test_path_is_missing .git/refs/heads/broken...symref && test_i18ngrep "Deleted branch broken...symref (was refs/heads/idonotexist)" output && From patchwork Mon Nov 29 18:49:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han-Wen Nienhuys X-Patchwork-Id: 12645797 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF0F9C433EF for ; Mon, 29 Nov 2021 21:52:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232518AbhK2Vz6 (ORCPT ); Mon, 29 Nov 2021 16:55:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232706AbhK2Vxy (ORCPT ); Mon, 29 Nov 2021 16:53:54 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9771C043CE5 for ; Mon, 29 Nov 2021 10:49:52 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id d9so18082700wrw.4 for ; Mon, 29 Nov 2021 10:49:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=tvdxG4YI1fiCV7Kztp+p5tDITH73b9li/1WLF/raObo=; b=pXRQdkQ/cFZmJeUBnNM6tUj9ApuJhBNB7Pu0P15Jv1zSkUpznZrHXrDOwegsrZH6ue ZGELUG75SCQ3X3YXrEbY506hBbokxDfKg1QV3sEY4xw8b/lZIFO7jv2estSF36cuJ5W2 dlpcGfOqIQNF3/Xb8vPCb06JQ5jDAHaHGQRxkkzT4v4KdbKrrZAwsO+hA12tfHeIF77m gujYQT3FtNSZBabXSWjzwMon1rRc32t5ynmFQfyoTOlP2YRwvPrxAP5lAVdFsLhDbWJ5 9UgxR7WOMedu565qr/9AGsF/TbU1ha11qy8XXmSyljvoQYi+Zj4gaxAtSQLroxs6jV4g LTKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=tvdxG4YI1fiCV7Kztp+p5tDITH73b9li/1WLF/raObo=; b=oVFPoo668KsT8myRizlihJO8Gr+FWGr61peXdK46vQRgCTWs37ZrbMdxvgdwOvaDVp fOiqvvTY2r4J+NzteprZkgxN5C+XlKFdU6tGndoF93K7f6ewe4vPbSNL6l0qzIAN77Vq p9mtma/zaX1xNLk4FCbVQPzu1Dco3cu97VHRjGcXmkUTP50tiS/GniW+vcIr2iH+tFJG f5Quugcwk578YFc5Gzx/bZdiFhRgW+zZ94p6Y3ApbQgiitLttXxY6RGAbky+UGSbKRqI plYuRWjQLy8BHUceAqckrhoPcwsJwnMdFxQwpqSZF2Rlw0sT6CZl2wlRVOM7HXbPjY8c y5jg== X-Gm-Message-State: AOAM530Hd4Uq4wTj4FtfIiuBhiO2y5zViNLwNfrmn3CkNiL2s+nYJS/G hC3rMkMGsf0/ATD53L7iYIAY/2GmXaU= X-Google-Smtp-Source: ABdhPJwrPGmUXtV/RXAa4lWg/+EbcDuyWNStS0Sf4PONwuLoKg16Pz/ILWZxfxIaLAqPxwooj5rU2A== X-Received: by 2002:adf:cc91:: with SMTP id p17mr35714138wrj.589.1638211791119; Mon, 29 Nov 2021 10:49:51 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f19sm130239wmq.34.2021.11.29.10.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 10:49:50 -0800 (PST) Message-Id: <3c100702fda81bf4ba572085ebce4e4fee94a4f3.1638211786.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 29 Nov 2021 18:49:46 +0000 Subject: [PATCH v2 6/6] t1430: create valid symrefs using test-helper Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Han-Wen Nienhuys Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys From: Han-Wen Nienhuys This still leaves some other direct filesystem access. Currently, the files backend does not allow invalidly named symrefs. Fixes for this are currently in the 'seen' branch Signed-off-by: Han-Wen Nienhuys --- t/t1430-bad-ref-name.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/t/t1430-bad-ref-name.sh b/t/t1430-bad-ref-name.sh index 5c600980b5f..05a4ee712ca 100755 --- a/t/t1430-bad-ref-name.sh +++ b/t/t1430-bad-ref-name.sh @@ -153,7 +153,7 @@ test_expect_success 'rev-parse skips symref pointing to broken name' ' test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && git branch shadow one && test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 && - printf "ref: refs/heads/broken...ref\n" >.git/refs/tags/shadow && + test-tool ref-store main create-symref refs/tags/shadow refs/heads/broken...ref msg && test_when_finished "test-tool ref-store main delete-refs 1 msg refs/tags/shadow" && git rev-parse --verify one >expect && git rev-parse --verify shadow >actual 2>err && @@ -203,7 +203,7 @@ test_expect_success 'update-ref --no-deref -d can delete symref to broken name' test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 && test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && - printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && + test-tool ref-store main create-symref refs/heads/badname refs/heads/broken...ref msg && test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/badname" && git update-ref --no-deref -d refs/heads/badname >output 2>error && test_path_is_missing .git/refs/heads/badname && @@ -215,7 +215,7 @@ test_expect_success 'branch -d can delete symref to broken name' ' test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 && test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && - printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && + test-tool ref-store main create-symref refs/heads/badname refs/heads/broken...ref msg && test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/badname" && git branch -d badname >output 2>error && test_path_is_missing .git/refs/heads/badname && @@ -224,7 +224,7 @@ test_expect_success 'branch -d can delete symref to broken name' ' ' test_expect_success 'update-ref --no-deref -d can delete dangling symref to broken name' ' - printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && + test-tool ref-store main create-symref refs/heads/badname refs/heads/broken...ref msg && test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/badname" && git update-ref --no-deref -d refs/heads/badname >output 2>error && test_path_is_missing .git/refs/heads/badname && @@ -233,7 +233,7 @@ test_expect_success 'update-ref --no-deref -d can delete dangling symref to brok ' test_expect_success 'branch -d can delete dangling symref to broken name' ' - printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && + test-tool ref-store main create-symref refs/heads/badname refs/heads/broken...ref msg && test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/badname" && git branch -d badname >output 2>error && test_path_is_missing .git/refs/heads/badname && @@ -245,7 +245,7 @@ test_expect_success 'update-ref -d can delete broken name through symref' ' test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID 2048 && test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/broken...ref" && - printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && + test-tool ref-store main create-symref refs/heads/badname refs/heads/broken...ref msg && test_when_finished "test-tool ref-store main delete-refs 1 msg refs/heads/badname" && git update-ref -d refs/heads/badname >output 2>error && test_path_is_missing .git/refs/heads/broken...ref &&