From patchwork Mon Aug 23 11:36:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12452489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D745C432BE for ; Mon, 23 Aug 2021 11:36:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8D5A611EF for ; Mon, 23 Aug 2021 11:36:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236447AbhHWLhD (ORCPT ); Mon, 23 Aug 2021 07:37:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234997AbhHWLhC (ORCPT ); Mon, 23 Aug 2021 07:37:02 -0400 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 9B03DC061575 for ; Mon, 23 Aug 2021 04:36:19 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id i6so2048674wrv.2 for ; Mon, 23 Aug 2021 04:36:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VhNqIBszNvSCOXeaL1Rm/NBqUYjjXw/gS1D9bFIVE3c=; b=pqzvNoEFC9NFcO2KJicAYTEx736z3pZH3HIzmQsbpvzZP/4vwH0BtxKpo7dY4TUCQi UZ9Zto06dbHfCyl8VzmFdAfqwDuybXl4LxHiw/N9GB4XvV3zwITiEpkBFTxPO4DHTqzE 5xEj9JHi9MQaIgC5PpfnTboSQWm6xhB9HeY2f7uWMNy0rXWQna310Aml1IOYkbhUewjr VaSsQ/Q+GV432i7aEU6w9SK+I+NNRkh7tZpx4Yub8TFBU5YpGoNwWHSmH3aBq8Zg4CJO +T0AiRqbwU6K58g/inh7lMS1L1viyLNwcQeZKx+QBFipS8poAjcZGSppesz0sIpYgjBq dBDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VhNqIBszNvSCOXeaL1Rm/NBqUYjjXw/gS1D9bFIVE3c=; b=cHaQ9uze0ftlOp64ByYGgKzJkYc3S+wxNT4Oh09e/1fSLbFFAAYGtxNPvMuHJ2eize Dj8jwofniM1CJywjnWNV1r0W3tpxB1Y8WRDmkurX0SosddZpf//aSiZHQwVWHmDoHxFn 71zKJ26LAVi1knhUHl3gs4tYjACTvlaFF8NRfioYgtWCoRSU069XEIV74oLsK8NTaCvn G+eR8gw9LgYWXjaygMj7ZYPs8NT2Zi3Fs6sa7vl1AlYyWcTldtnyFAkT201KB/NunPa9 W3KkpCwwEqLSmfghOII+XduiMBrBInUREAgTUFyjjrcRUB9xgnJGWn7o1xBXh7Ht9tXh U1tw== X-Gm-Message-State: AOAM531BwPzsh58A2Mxee2UIWYEgZbe4Uj4EIL6bVo1X7eebwmsyu6X0 ovN96f8H0DcEYNp3tcVicZRHX2G7/qGN3EKf X-Google-Smtp-Source: ABdhPJyfKdIrMpOXkg2eytqsV3L1Dd7XZ8iGAqYQ9fhXZ8qRrYpo3DtITef/n/VFNO9WO/tsiEPHSA== X-Received: by 2002:adf:e389:: with SMTP id e9mr13241661wrm.304.1629718578013; Mon, 23 Aug 2021 04:36:18 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g35sm20555313wmp.9.2021.08.23.04.36.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 04:36:17 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Han-Wen Nienhuys , Michael Haggerty , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 01/13] refs/packet: add missing BUG() invocations to reflog callbacks Date: Mon, 23 Aug 2021 13:36:02 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.662.g438caf9576d In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In e0cc8ac8202 (packed_ref_store: make class into a subclass of `ref_store`, 2017-06-23) a die() was added to packed_create_reflog(), but not to any of the other reflog callbacks, let's do that. Signed-off-by: Ævar Arnfjörð Bjarmason --- refs/packed-backend.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/refs/packed-backend.c b/refs/packed-backend.c index f8aa97d7998..24a360b719f 100644 --- a/refs/packed-backend.c +++ b/refs/packed-backend.c @@ -1600,6 +1600,7 @@ static int packed_for_each_reflog_ent(struct ref_store *ref_store, const char *refname, each_reflog_ent_fn fn, void *cb_data) { + BUG("packed reference store does not support reflogs"); return 0; } @@ -1608,12 +1609,14 @@ static int packed_for_each_reflog_ent_reverse(struct ref_store *ref_store, each_reflog_ent_fn fn, void *cb_data) { + BUG("packed reference store does not support reflogs"); return 0; } static int packed_reflog_exists(struct ref_store *ref_store, const char *refname) { + BUG("packed reference store does not support reflogs"); return 0; } @@ -1627,6 +1630,7 @@ static int packed_create_reflog(struct ref_store *ref_store, static int packed_delete_reflog(struct ref_store *ref_store, const char *refname) { + BUG("packed reference store does not support reflogs"); return 0; } @@ -1638,6 +1642,7 @@ static int packed_reflog_expire(struct ref_store *ref_store, reflog_expiry_cleanup_fn cleanup_fn, void *policy_cb_data) { + BUG("packed reference store does not support reflogs"); return 0; } From patchwork Mon Aug 23 11:36:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12452491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B8D3C4338F for ; Mon, 23 Aug 2021 11:36:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86EB1610A5 for ; Mon, 23 Aug 2021 11:36:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236496AbhHWLhF (ORCPT ); Mon, 23 Aug 2021 07:37:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236431AbhHWLhC (ORCPT ); Mon, 23 Aug 2021 07:37:02 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57374C061575 for ; Mon, 23 Aug 2021 04:36:20 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id f10so10323838wml.2 for ; Mon, 23 Aug 2021 04:36:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EdLhCfkTp/+ES1NxZP/qC5aV2h/1GTWwLkGCzaWJOtk=; b=K+y6hRLcpJBZ1/Vquay92jHc5/vx1N0DicNkrEtVKrKvEebaEo1u5eN1ckcam4Pekq 6aoyLyaz6CtOPuY9ckwEeQOAT/tGBzeyJqAh1f0RwaJ6eBj+S6fWOxzGrLo8/iC6huD+ tMeDBVo/BORzpdRb2+fh0Rk/L/p1+AsGo1qHOREwCxZW+YWCIJptc5IFUoVeplhMqZzr Ko34bdi/fcT9zK8hQhtosw4j+ABBaa7fJvhrQqhlVwpI2dg4OQiBdMiWSltSQsi2W9u7 ++FWvJqX3PMpt/pafdVhd+OXdCzlI+amQO50g91WaVc6HrqMlN00DZOZlDd+WpwO4ZNB vc4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EdLhCfkTp/+ES1NxZP/qC5aV2h/1GTWwLkGCzaWJOtk=; b=Gw8qUUspTt7gaLlRVRABAX2+93pC8v3nC//Eu6zFHhGexH6AIdIGap+niXt9OnoJoU F6+pV6UIj8r4CSr4cpsJESAQJ0lbXUO/9g+on6B92qSTDqx6jYgAm8+pnY/kZ/D3u0ix lcikaKiur97yEuXfu6Dtkr5CXQpJZC4JgszAuXDFBuhDQ0HoD9/10lWMg5wMgHYiVXVs ezOB1TT57CchxNtExnDsqEXjFq+KW5DVthBu5ePMZQlwSVw9vQwlBxwpEHInesMJahC+ JBKVacv6FKe+TKFyP1Tmr/iMIaSKv0AAUD5IBSCEMt7MN4mHpToy4FeO2KyCsCgO8XAz qPkA== X-Gm-Message-State: AOAM532Jv2AgShPzVhytlEZ0UNWA2I163GPfSrDpU8kM69iJgj0K++6e fVHckkbM4tG6nYpOeWdbUDVhZb3ckTBU66p/ X-Google-Smtp-Source: ABdhPJxFb0CsCJRCY2Ga0ew8OCSuNe0VnLPaAZrADwUSBIOqFdav2lsb58Jilp2hNoxmbBX4KBAqUQ== X-Received: by 2002:a1c:2b04:: with SMTP id r4mr16020464wmr.168.1629718578755; Mon, 23 Aug 2021 04:36:18 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g35sm20555313wmp.9.2021.08.23.04.36.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 04:36:18 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Han-Wen Nienhuys , Michael Haggerty , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 02/13] refs/files: remove unused REF_DELETING in lock_ref_oid_basic() Date: Mon, 23 Aug 2021 13:36:03 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.662.g438caf9576d In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The lock_ref_oid_basic() function has gradually been replaced by most callers no longer performing a low-level "acquire lock, update and release", and instead using the ref transaction API. So there are only 4 remaining callers of lock_ref_oid_basic(). None of those callers pass REF_DELETING anymore, the last caller went away in 92b1551b1d (refs: resolve symbolic refs first, 2016-04-25). Before that we'd refactored and moved this code in: - 8df4e511387 (struct ref_update: move "have_old" into "flags", 2015-02-17) - 7bd9bcf372d (refs: split filesystem-based refs code into a new file, 2015-11-09) - 165056b2fc (lock_ref_for_update(): new function, 2016-04-24) We then finally stopped using it in 92b1551b1d (noted above). So let's remove the handling of this parameter. By itself this change doesn't benefit us much, but it's the start of even more removal of unused code in and around this function in subsequent commits. Signed-off-by: Ævar Arnfjörð Bjarmason --- refs/files-backend.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index 677b7e4cdd2..326f0224218 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -934,8 +934,6 @@ static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs, if (mustexist) resolve_flags |= RESOLVE_REF_READING; - if (flags & REF_DELETING) - resolve_flags |= RESOLVE_REF_ALLOW_BAD_NAME; files_ref_path(refs, &ref_file, refname); resolved = !!refs_resolve_ref_unsafe(&refs->base, From patchwork Mon Aug 23 11:36:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12452493 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E813C432BE for ; Mon, 23 Aug 2021 11:36:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24DF0611EF for ; Mon, 23 Aug 2021 11:36:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236517AbhHWLhF (ORCPT ); Mon, 23 Aug 2021 07:37:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236445AbhHWLhE (ORCPT ); Mon, 23 Aug 2021 07:37:04 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FF06C061757 for ; Mon, 23 Aug 2021 04:36:21 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id u15so10307351wmj.1 for ; Mon, 23 Aug 2021 04:36:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nWEvP/rgqF998BLYui1IRCFqFy97LCGOvuaM5Kyt9uU=; b=RCIY+8KWvefZxaUlpf/Y9OBlzzoai/SXwQSWRu2CH68+Di3r8G43r05mLS46iPwIMF kgwONCgxD9qeQl7JtgPvuRoXyu0PKQfRW4mBWvktMUKS+ZIpJVSmjWHCd5C8UGh3ONaT UaV/3VRbKvqESMqJ6BC0nPtVHXDXyOVthxgQb7Zv1NurXnCEuwx7Ft1Jsoi/Pwr6XlNt MXrDC9WeATQ54ONFwS90vhVnmMSJQBSVlr3dled99z6i+J0IGtCilj7lVqANCDvE3tGb OVpwUbEZD8xFqgwEY26u768gD+0UIR/Zamk9N8ZkxTsJ6IwZMEYcAjU0u4R3dRKp18JN RGbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nWEvP/rgqF998BLYui1IRCFqFy97LCGOvuaM5Kyt9uU=; b=HmpPNqzeMhffrkShxF99YbiospA9J5sVZtlz2M+tehz05z8ybq8hIJnm1Z1p04KF/O 8IXd6tdtj3pmvuXwZQJ3cz4JzRyuAXW1rkhlZwcdeF97uMH9V4U4Lhhimx0ZVObrSkn2 LQOwn0i8XtN3EYpIqZ2lqoGwFWA79ZDcpViHPHbu+xylzJIm3qMpoeZWIg5nZT6o+oga 6jwXjVahtJHCZJHJi35k/I16tqi8sFW4KIrlicXQ2vi2Z/9jwiciBdVZ2KsEPqdWIv5j Uz6SAmOUr+uzj5km/dmTpm51iw57czdpNjXsukTzYY/VySpm2aA03Nse1VOvEJHZx+C5 wsWg== X-Gm-Message-State: AOAM533CxUWFsCHMJjmURI2T2t5Zp2p7suqS7rdP1XbncrUK3NaMIIVG 2xpBkfWFVmMtqX729GYxqRXXX1OBwubN7+rY X-Google-Smtp-Source: ABdhPJwrNUXNafVzJLflMwP8KUMvJRhCWTZXdoTnvP7u8qxGpqeKnZFf4VHg1k+vZGYtUrvvi6V/ew== X-Received: by 2002:a05:600c:2281:: with SMTP id 1mr16037770wmf.9.1629718579414; Mon, 23 Aug 2021 04:36:19 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g35sm20555313wmp.9.2021.08.23.04.36.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 04:36:18 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Han-Wen Nienhuys , Michael Haggerty , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 03/13] refs: drop unused "flags" parameter to lock_ref_oid_basic() Date: Mon, 23 Aug 2021 13:36:04 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.662.g438caf9576d In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff King In the last commit we removed the REF_DELETING flag from lock_ref_oid_basic(). Since then all of the remaining callers do pass REF_NO_DEREF, but that has been ignored completely since 7a418f3a17 (lock_ref_sha1_basic(): only handle REF_NODEREF mode, 2016-04-22). So we can simply get rid of the parameter entirely. Signed-off-by: Jeff King Signed-off-by: Ævar Arnfjörð Bjarmason --- refs/files-backend.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index 326f0224218..e73458e2571 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -917,8 +917,7 @@ static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs, const struct object_id *old_oid, const struct string_list *extras, const struct string_list *skip, - unsigned int flags, int *type, - struct strbuf *err) + int *type, struct strbuf *err) { struct strbuf ref_file = STRBUF_INIT; struct ref_lock *lock; @@ -1413,8 +1412,9 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store, logmoved = log; + lock = lock_ref_oid_basic(refs, newrefname, NULL, NULL, NULL, - REF_NO_DEREF, NULL, &err); + NULL, &err); if (!lock) { if (copy) error("unable to copy '%s' to '%s': %s", oldrefname, newrefname, err.buf); @@ -1437,7 +1437,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store, rollback: lock = lock_ref_oid_basic(refs, oldrefname, NULL, NULL, NULL, - REF_NO_DEREF, NULL, &err); + NULL, &err); if (!lock) { error("unable to lock %s for rollback: %s", oldrefname, err.buf); strbuf_release(&err); @@ -1845,7 +1845,7 @@ static int files_create_symref(struct ref_store *ref_store, int ret; lock = lock_ref_oid_basic(refs, refname, NULL, - NULL, NULL, REF_NO_DEREF, NULL, + NULL, NULL, NULL, &err); if (!lock) { error("%s", err.buf); @@ -3064,8 +3064,7 @@ static int files_reflog_expire(struct ref_store *ref_store, * reference if --updateref was specified: */ lock = lock_ref_oid_basic(refs, refname, oid, - NULL, NULL, REF_NO_DEREF, - &type, &err); + NULL, NULL, &type, &err); if (!lock) { error("cannot lock ref '%s': %s", refname, err.buf); strbuf_release(&err); From patchwork Mon Aug 23 11:36:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12452495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65FE8C4338F for ; Mon, 23 Aug 2021 11:36:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4AD8F61374 for ; Mon, 23 Aug 2021 11:36:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236431AbhHWLhI (ORCPT ); Mon, 23 Aug 2021 07:37:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236467AbhHWLhE (ORCPT ); Mon, 23 Aug 2021 07:37:04 -0400 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 DFD4CC061575 for ; Mon, 23 Aug 2021 04:36:21 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id d26so5473191wrc.0 for ; Mon, 23 Aug 2021 04:36:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3VmN9U+E+gBxRctGKAtlVszevCwliafyE9Oyg3Us6sg=; b=lrPmPcsAgiqvrifZ2dBVP9FDHpuRqtP0eKbcDqK4+5BOXn7JLepLj8YmJL399ZpGWy uZsGhc68O2fdwbZrH+5YNRBhb0R2ffwN14Lq1Z0ZEBZ6ms+vGNUCHVJaQIp4zaPhDrks Bg8M2lcjGm3Zc/9CBHsMh4LIndTCFAO8nUqlyzdqQS06Iii4A0XLhWq7HOwb58v9XQ8/ gK2fq7MqIoV3hHlr1dN5ANstniVolWJJ+4T3BCKVM4byJOEM3W63+f34gPPfTqgde7eH nAyC6UbgZvNmZ5YUt0ndhCAnuLobsyAlCZbAvYucoogD4eTiF6LPjETvoGD8bvPoWOg5 XvQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3VmN9U+E+gBxRctGKAtlVszevCwliafyE9Oyg3Us6sg=; b=Pa5jj8sF427odFJ8jgNgMwhnVH5+Jsl7zOeealiqVuZ5QVf0jK/bv+R58pKYoLlCMd WLNCcgVJYgSAqg0aJUCf4KvYxpsT19MjAP+K5OLanT+fSgDFLw4/HWQuWynM/gBtda5a t58FsT+/7ZL717HxwCm190qJPoWSZ9wiWalb661BgOxzofB5H5eadyTX8aP55weCrg76 xReNQ1k7HuGTlPaSR8RUxR2JnsvXNza4xn0fUUHoXuHxvnoBxJ7cJ/o3hF/q/WD9A19U 5DIR0fvlrvA8L3RhPQgJhlNSxKFwwNfYRpjeF5XsCKXCdMVX7GbkDECQsk7HJVbr3d5w DQXQ== X-Gm-Message-State: AOAM531KBl95iMYDsNMLvpuOZ6qVSb1xYDcLcYcBEhDd2sJR3NeKbwWJ otOghx8gflpHx0MdWj2JAwvVHMhaQNna6+kV X-Google-Smtp-Source: ABdhPJy9FQvvHDzveip6TmS5mBD0lyCVNqHPtPVGTwIbBZw0jeTYxCIqysECNvYn96TaHNSvircf6Q== X-Received: by 2002:adf:e901:: with SMTP id f1mr13108449wrm.13.1629718580217; Mon, 23 Aug 2021 04:36:20 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g35sm20555313wmp.9.2021.08.23.04.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 04:36:19 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Han-Wen Nienhuys , Michael Haggerty , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 04/13] refs/files: remove unused "extras/skip" in lock_ref_oid_basic() Date: Mon, 23 Aug 2021 13:36:05 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.662.g438caf9576d In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The lock_ref_oid_basic() function has gradually been replaced by use of the file transaction API, there are only 4 remaining callers of it. None of those callers pass non-NULL "extras" and "skip" parameters, the last such caller went away in 92b1551b1d4 (refs: resolve symbolic refs first, 2016-04-25), so let's remove the parameters. Signed-off-by: Ævar Arnfjörð Bjarmason --- refs/files-backend.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index e73458e2571..69f7f54e03b 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -915,8 +915,6 @@ static int create_reflock(const char *path, void *cb) static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs, const char *refname, const struct object_id *old_oid, - const struct string_list *extras, - const struct string_list *skip, int *type, struct strbuf *err) { struct strbuf ref_file = STRBUF_INIT; @@ -949,7 +947,7 @@ static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs, last_errno = errno; if (!refs_verify_refname_available( &refs->base, - refname, extras, skip, err)) + refname, NULL, NULL, err)) strbuf_addf(err, "there are still refs under '%s'", refname); goto error_return; @@ -962,7 +960,7 @@ static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs, last_errno = errno; if (last_errno != ENOTDIR || !refs_verify_refname_available(&refs->base, refname, - extras, skip, err)) + NULL, NULL, err)) strbuf_addf(err, "unable to resolve reference '%s': %s", refname, strerror(last_errno)); @@ -977,7 +975,7 @@ static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs, */ if (is_null_oid(&lock->old_oid) && refs_verify_refname_available(refs->packed_ref_store, refname, - extras, skip, err)) { + NULL, NULL, err)) { last_errno = ENOTDIR; goto error_return; } @@ -1412,9 +1410,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store, logmoved = log; - - lock = lock_ref_oid_basic(refs, newrefname, NULL, NULL, NULL, - NULL, &err); + lock = lock_ref_oid_basic(refs, newrefname, NULL, NULL, &err); if (!lock) { if (copy) error("unable to copy '%s' to '%s': %s", oldrefname, newrefname, err.buf); @@ -1436,8 +1432,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store, goto out; rollback: - lock = lock_ref_oid_basic(refs, oldrefname, NULL, NULL, NULL, - NULL, &err); + lock = lock_ref_oid_basic(refs, oldrefname, NULL, NULL, &err); if (!lock) { error("unable to lock %s for rollback: %s", oldrefname, err.buf); strbuf_release(&err); @@ -1844,9 +1839,7 @@ static int files_create_symref(struct ref_store *ref_store, struct ref_lock *lock; int ret; - lock = lock_ref_oid_basic(refs, refname, NULL, - NULL, NULL, NULL, - &err); + lock = lock_ref_oid_basic(refs, refname, NULL, NULL, &err); if (!lock) { error("%s", err.buf); strbuf_release(&err); @@ -3063,8 +3056,7 @@ static int files_reflog_expire(struct ref_store *ref_store, * reference itself, plus we might need to update the * reference if --updateref was specified: */ - lock = lock_ref_oid_basic(refs, refname, oid, - NULL, NULL, &type, &err); + lock = lock_ref_oid_basic(refs, refname, oid, &type, &err); if (!lock) { error("cannot lock ref '%s': %s", refname, err.buf); strbuf_release(&err); From patchwork Mon Aug 23 11:36:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12452497 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 391C3C4320A for ; Mon, 23 Aug 2021 11:36:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2023461378 for ; Mon, 23 Aug 2021 11:36:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236518AbhHWLhJ (ORCPT ); Mon, 23 Aug 2021 07:37:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236494AbhHWLhH (ORCPT ); Mon, 23 Aug 2021 07:37:07 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7209C061764 for ; Mon, 23 Aug 2021 04:36:22 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id u1so10336140wmm.0 for ; Mon, 23 Aug 2021 04:36:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mkVLWDGCHkfK8N5vklaasW/9asq9Tm8FgDwK0N75EHs=; b=snxkXepySemk34SQDdTxSUW9Qv3En/oJBdEaUu6f1FDk4M2mY+1GZ/AVyN8NX/qNUD jDmx9DlASGOqmZ7f3AlahgWX9ib3JtLwUAijXSmTywLQYsyM6/Xl+RDRQzCzMndBdaAV UHSTCRiTDNTL+OweQz7OElOUITNF5RF8ijUyoinx1qpQ6dPQ3gAr+Uj9mXjlJoT8VThQ FpZG08VbltkFL2tVkDMrtVHgC3fzidL9O7+tlWrAFjq04A62Y9n+Gh/fyFjYhczZMYUQ Ez7mMV5OiAn8LNiTloMsKcC2e1+aBymtbgPaRLFPe2SCCXTOKeETnYm/8ear4+DBkS1q lbWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mkVLWDGCHkfK8N5vklaasW/9asq9Tm8FgDwK0N75EHs=; b=Yp6EFYHuO0aJwV9K7SABqRH6O6YhlhKdy2YCdai0N3R2XglL4uABrX7FarT9qPq69Y vRHd0oVTRnQqYT3KK03CaKsn2Zg5Cgl3X8W3Xz4gOTmwnuMVcihG59OQcX4OlZkYsQKG A6CQh5JhRxSRHJ825CJqceF+eOyzYFKXMmiKy7qdr1fbIVMQ7qHhx6AuIzlqcXqajNTA 7tf/B/OYgJb+tPGmQK2JrX527smOial8JImMDZGeXqQcxuMT2b2imfbOaMLmthGzjsNC u0HTTgki2tTQ3RtUWTH0wdlGEjDe6rCygSaLBa1vvFKFBA29jh4pcT8aZqC4bm1M6nsn /t8A== X-Gm-Message-State: AOAM531FVFN8Kn33RTMsz921FckSFW+ivn7AibYyziotj0N/3WCHL+vE XGqrVZQyHwgRWMwsjqU/Qi9/bB3mDGduXHfj X-Google-Smtp-Source: ABdhPJzaUpN7D+eLRZNoxpiNN1M/bgpvYQ6GQxxC0UTs5gzpOZW4nEn4O3/bgJQED7PWLtNZekyfag== X-Received: by 2002:a1c:1d1:: with SMTP id 200mr8125730wmb.53.1629718581201; Mon, 23 Aug 2021 04:36:21 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g35sm20555313wmp.9.2021.08.23.04.36.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 04:36:20 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Han-Wen Nienhuys , Michael Haggerty , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 05/13] refs/files: remove unused "skip" in lock_raw_ref() too Date: Mon, 23 Aug 2021 13:36:06 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.662.g438caf9576d In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove the unused "skip" parameter to lock_raw_ref(), it was never used. We do use it when passing "skip" to the refs_rename_ref_available() function in files_copy_or_rename_ref(), but not here. This is part of a larger series that modifies lock_ref_oid_basic() extensively, there will be no more modifications of this function in this series, but since the preceding commit removed this unused parameter from lock_ref_oid_basic(), let's do it here too for consistency. Signed-off-by: Ævar Arnfjörð Bjarmason --- refs/files-backend.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index 69f7f54e03b..997e021c1c4 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -531,7 +531,6 @@ static void unlock_ref(struct ref_lock *lock) static int lock_raw_ref(struct files_ref_store *refs, const char *refname, int mustexist, const struct string_list *extras, - const struct string_list *skip, struct ref_lock **lock_p, struct strbuf *referent, unsigned int *type, @@ -568,7 +567,7 @@ static int lock_raw_ref(struct files_ref_store *refs, * reason to expect this error to be transitory. */ if (refs_verify_refname_available(&refs->base, refname, - extras, skip, err)) { + extras, NULL, err)) { if (mustexist) { /* * To the user the relevant error is @@ -673,7 +672,7 @@ static int lock_raw_ref(struct files_ref_store *refs, REMOVE_DIR_EMPTY_ONLY)) { if (refs_verify_refname_available( &refs->base, refname, - extras, skip, err)) { + extras, NULL, err)) { /* * The error message set by * verify_refname_available() is OK. @@ -710,7 +709,7 @@ static int lock_raw_ref(struct files_ref_store *refs, */ if (refs_verify_refname_available( refs->packed_ref_store, refname, - extras, skip, err)) + extras, NULL, err)) goto error_return; } @@ -2407,7 +2406,7 @@ static int lock_ref_for_update(struct files_ref_store *refs, } ret = lock_raw_ref(refs, update->refname, mustexist, - affected_refnames, NULL, + affected_refnames, &lock, &referent, &update->type, err); if (ret) { From patchwork Mon Aug 23 11:36:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12452499 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9A1CC432BE for ; Mon, 23 Aug 2021 11:36:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3E4E61378 for ; Mon, 23 Aug 2021 11:36:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236611AbhHWLhK (ORCPT ); Mon, 23 Aug 2021 07:37:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236509AbhHWLhH (ORCPT ); Mon, 23 Aug 2021 07:37:07 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DB99C0613CF for ; Mon, 23 Aug 2021 04:36:23 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id l7-20020a1c2507000000b002e6be5d86b3so10498570wml.3 for ; Mon, 23 Aug 2021 04:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gnnPIouhRiMkdlXzQwixtqUxX/ryUUSg9y1GW4JA69U=; b=etkywXXa3S5ndxqcpnSzxh85DEl0CO4ZiozTi9pdDlyojBChwgxMUk09bj/9u4moSH 56I1mdPBXaEhvk2uzZ4/y8JvBRcXwz1/FfzrCoBKnTdj9jsevbVMSYLNZxu7ODiI4hoh AhamPCqRvOKtxb3ppN0DCqoyGi/37XfHGJqZd2zeJqV1LMorEg3ueDil8BUUJeJ640uE vOdZ1SVncPuCex+xstR5srx7VeskAQrvRvWbTwabotmQlz9HBWdqsqp1kmpPspf2UyDX cdLCdw84P6hXHuq5kPLZV2m70EB8sNHMa/Nr5SZQ6dQg3kSvuTI273myssHh7t9QjVZL voCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gnnPIouhRiMkdlXzQwixtqUxX/ryUUSg9y1GW4JA69U=; b=k3QF5hMDNzp4fBXzfzVHTEIIAx95TUUw2hAOoO7CwX2MI1MFkFSLU01I+ql9iPA+GX Lwx5wQ7AwuOXAv7XlrOnW5zC7ikJbNKO3gIoK3YltmtSOk/dYJI1CwqZ0fMw8jxQGhyx JNnDOpc21lXm8SixRu2+JwgTSmGQ2kPShUJSSie0rQkZVAkAySyZme7IIDks7+GUq59g Snr/aPLmxPutDABoPXv8W8e90TNhijrToJxqLR7HunMeTNl/0t1tvdvj9vcm67SJ68ZC XhScPpoHDePeyL0SqItOA5zEbTzraUmWEuuU3ORIpOi//UDRwZO1D4/x+dj5+lUSCOBV +sMQ== X-Gm-Message-State: AOAM532HzlkDzF06cqrrRoyHyK8kzJFQri74b4tcRP6aszHgUoPjarK1 M7HpYNs1LQL5ByZ0rNntG1+HKlotLeCpIEAR X-Google-Smtp-Source: ABdhPJxL1kWjqlaCM1td3mbjxAyAmq1VclrX1ZdOoQl56CWYVlTFXCQ4JNIPjiYsG79A/ugoyQ2Fhw== X-Received: by 2002:a1c:2090:: with SMTP id g138mr15741447wmg.98.1629718581988; Mon, 23 Aug 2021 04:36:21 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g35sm20555313wmp.9.2021.08.23.04.36.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 04:36:21 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Han-Wen Nienhuys , Michael Haggerty , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 06/13] refs/debug: re-indent argument list for "prepare" Date: Mon, 23 Aug 2021 13:36:07 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.662.g438caf9576d In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Re-indent this argument list that's been mis-indented since it was added in 34c319970d1 (refs/debug: trace into reflog expiry too, 2021-04-23). This makes a subsequent change smaller. Signed-off-by: Ævar Arnfjörð Bjarmason --- refs/debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/refs/debug.c b/refs/debug.c index 1a7a9e11cfa..3f1455db2df 100644 --- a/refs/debug.c +++ b/refs/debug.c @@ -365,8 +365,8 @@ struct debug_reflog_expiry_should_prune { }; static void debug_reflog_expiry_prepare(const char *refname, - const struct object_id *oid, - void *cb_data) + const struct object_id *oid, + void *cb_data) { struct debug_reflog_expiry_should_prune *prune = cb_data; trace_printf_key(&trace_refs, "reflog_expire_prepare: %s\n", refname); From patchwork Mon Aug 23 11:36:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12452501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 257FAC4338F for ; Mon, 23 Aug 2021 11:36:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B3A261361 for ; Mon, 23 Aug 2021 11:36:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236459AbhHWLhL (ORCPT ); Mon, 23 Aug 2021 07:37:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236520AbhHWLhI (ORCPT ); Mon, 23 Aug 2021 07:37:08 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A119C061796 for ; Mon, 23 Aug 2021 04:36:24 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id o15so10301139wmr.3 for ; Mon, 23 Aug 2021 04:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tW26Fcp2CGQ4f1SMeqyp+VsGDGG5nOLyFn6hYbLR0eo=; b=p2VwxYt7Ogs13/9kfuW6qoTQPvmrL64PXbiGwO5svFpBlwIS5WUMKSoZo2ZseTgFUw 9Kt+y5FXmlFAXFuU+2WYij49wy9Zf6uRNSfayx1Ofeh5QtxsLQjBK8U8BYgLqUogsOwY 9zzHSMYskjIehD2fn3bTK97zmICF/s/TN36Fdz3lm8YPnv+zB27WIafDJLlAXShjwBxW CCAX5NhzJwNPVw7Azf6OuYCYv+jyi9NQhQD9lAeLcu9kcQtCmbkCtBCvaMZ9vATqInKC 2fejfCWk/3OoP+ch49/vlPC5Q1RVtDUKr+XiFK2hLhIHroHLaTt4uB8gLFoqJdpcQhGX PxYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tW26Fcp2CGQ4f1SMeqyp+VsGDGG5nOLyFn6hYbLR0eo=; b=OK8FwXYLq1vPhZaews260/njMPWUAsKvfFD8C0hbzc5E7olVNInGeRmtJvYrIc9ybN 3uo3h91xZlw+H1N6grC3VwDhDbBPyP63vEQq4SIZ17OueUYn2uS6OFbByWze+6fIOm0B j+VQFivwU0iwuscVuehNXESnWelSVmEPx6FEE2ZjgfvGdkgC94yCXjbw46PCPdEIa64Z ZTZuiFT7cxIThwyo8/VUK2+jyPcrIWs8hnpTLlvXB95IKAM3dU8sNSTe31aXZBgbnmvk 1/9UupW0ndK2GHn+Kwwq2RuxhbpOfxEHVLTqLVuc1y8tAQ8HTKoEFcSaa5gFlHRzTXMt CUuA== X-Gm-Message-State: AOAM533c/5lW6NiGeeuqHWz5zAHTfMMlqCAJ/FecmQatpsfb8+yRrctQ TUSyCYZlSAIOdpz+Vv6O4txFQz5ijUoky7Fp X-Google-Smtp-Source: ABdhPJzb/3adTYqWNNzB0A1yR4MPzPBjYFj3LOfhMZBrbMdJ4MpH2C8YvnPRpkIHXStBwfDwVwFVTQ== X-Received: by 2002:a05:600c:26c4:: with SMTP id 4mr4938597wmv.111.1629718582712; Mon, 23 Aug 2021 04:36:22 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g35sm20555313wmp.9.2021.08.23.04.36.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 04:36:22 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Han-Wen Nienhuys , Michael Haggerty , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 07/13] refs: make repo_dwim_log() accept a NULL oid Date: Mon, 23 Aug 2021 13:36:08 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.662.g438caf9576d In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the repo_dwim_log() function initially added as dwim_log() in eb3a48221fd (log --reflog: use dwim_log, 2007-02-09) to accept a NULL oid parameter. The refs_resolve_ref_unsafe() function it invokes already deals with it, but it didn't. This allows for a bit more clarity in a reflog-walk.c codepath added in f2eba66d4d1 (Enable HEAD@{...} and make it independent from the current branch, 2007-02-03). We'll shortly use this in builtin/reflog.c as well. Signed-off-by: Ævar Arnfjörð Bjarmason --- reflog-walk.c | 3 +-- refs.c | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/reflog-walk.c b/reflog-walk.c index e9cd3283694..8ac4b284b6b 100644 --- a/reflog-walk.c +++ b/reflog-walk.c @@ -158,10 +158,9 @@ int add_reflog_for_walk(struct reflog_walk_info *info, } reflogs = read_complete_reflog(branch); if (!reflogs || reflogs->nr == 0) { - struct object_id oid; char *b; int ret = dwim_log(branch, strlen(branch), - &oid, &b); + NULL, &b); if (ret > 1) free(b); else if (ret == 1) { diff --git a/refs.c b/refs.c index 8b9f7c3a80a..d9635436759 100644 --- a/refs.c +++ b/refs.c @@ -698,7 +698,7 @@ int repo_dwim_log(struct repository *r, const char *str, int len, strbuf_addf(&path, *p, len, str); ref = refs_resolve_ref_unsafe(refs, path.buf, RESOLVE_REF_READING, - &hash, NULL); + oid ? &hash : NULL, NULL); if (!ref) continue; if (refs_reflog_exists(refs, path.buf)) @@ -710,7 +710,8 @@ int repo_dwim_log(struct repository *r, const char *str, int len, continue; if (!logs_found++) { *log = xstrdup(it); - oidcpy(oid, &hash); + if (oid) + oidcpy(oid, &hash); } if (!warn_ambiguous_refs) break; From patchwork Mon Aug 23 11:36:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12452503 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B949DC4320A for ; Mon, 23 Aug 2021 11:36:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A0FD66124B for ; Mon, 23 Aug 2021 11:36:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236527AbhHWLhN (ORCPT ); Mon, 23 Aug 2021 07:37:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236551AbhHWLhI (ORCPT ); Mon, 23 Aug 2021 07:37:08 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 269B5C0617AF for ; Mon, 23 Aug 2021 04:36:25 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id q11-20020a7bce8b0000b02902e6880d0accso13845996wmj.0 for ; Mon, 23 Aug 2021 04:36:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=80KTX3V2r9szeWBOA+8iBUpO+6nDYEI6IfW++wZejF8=; b=euhuCkzOZJsyau45aQrv+o0jNm4W354zkOHJ79/8Vp0Nvr0KzgDSdBHC63Hpbo+/Rd ng+DBTmTu372TQ+ibhDDoUUawc+6y3uyKSxmwhLDmUck/eTeizAJIuukMHPOZO1ObBQU fUfiUA2YZVqIdguBG02oLwZPZUr3t7sbKkTBPv/mc4sdvqkNOPvzbBUBfJ1K0hTal5A2 yKjzx1u9JHWM0eEYfT/PEO4ILWnz7n5GWQvf6ac5aAh/kq4i5HyureHlU+FqLbOeGNQV w18nSUgOGsuL4k9F8xaHI1i74jIep8K59+UKEDDBv06bkr9ftq1YJZcKNRStYMjPRemA Qjpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=80KTX3V2r9szeWBOA+8iBUpO+6nDYEI6IfW++wZejF8=; b=JV5P/cYuXPsjnusoImTaVRD6mhTdgI83bJwu5HGLH9/cOE3xqf91CriY8YcOTsm7zE +/x74hkLngBSsV+JScA2Cz0JaYcpxRP0s3RGcw5J7WBBJ7RzRoai1RWotvOTFeLH60kY bfQAzDxHmE8CxWcn0bO0JfqNqzGNnNlNAioWUd8tBuTRnR1EPBTHeC4jb3pDTmaPBoGz BOzP6iIlzQBnYs05OrUxpWW9U7jC7XwsdqN3C8aqonxJV/wdJfCMXwXNjnTpntGZMwEL 9S9f1BNAEooeZL06cnON7H1PSQH1HAOInhJAqzIhFII3uS0g9HN9G8pP2HLyI7Q38Ife sfdA== X-Gm-Message-State: AOAM532Z9APlEsJ33vXuaZehww5w0NqRmF+8OR8qHLn6NrZpbCfIQSt3 IPaXesbIv6cAtK7T0nag+/6GxNTQy00sZqMJ X-Google-Smtp-Source: ABdhPJwa7h7HXgGD/V5IuvZsZeWfrNyKvqhQjBdJs3T8IRHjjlMmhJJMp6mWLU+TVepGRyMFyvErcA== X-Received: by 2002:a1c:4686:: with SMTP id t128mr8119437wma.183.1629718583526; Mon, 23 Aug 2021 04:36:23 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g35sm20555313wmp.9.2021.08.23.04.36.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 04:36:22 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Han-Wen Nienhuys , Michael Haggerty , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 08/13] refs/files: add a comment about refs_reflog_exists() call Date: Mon, 23 Aug 2021 13:36:09 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.662.g438caf9576d In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add a comment about why it is that we need to check for the the existence of a reflog we're deleting after we've successfully acquired the lock in files_reflog_expire(). As noted in [1] the lock protocol for reflogs is somewhat intuitive. This early exit code the comment applies to dates all the way back to 4264dc15e19 (git reflog expire, 2006-12-19). 1. https://lore.kernel.org/git/54DCDA42.2060800@alum.mit.edu/ Signed-off-by: Ævar Arnfjörð Bjarmason --- refs/files-backend.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/refs/files-backend.c b/refs/files-backend.c index 997e021c1c4..fbcd0c790bc 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -3061,6 +3061,19 @@ static int files_reflog_expire(struct ref_store *ref_store, strbuf_release(&err); return -1; } + + /* + * When refs are deleted, their reflog is deleted before the + * ref itself is deleted. This is because there is no separate + * lock for reflog; instead we take a lock on the ref with + * lock_ref_oid_basic(). + * + * If a race happens and the reflog doesn't exist after we've + * acquired the lock that's OK. We've got nothing more to do; + * We were asked to delete the reflog, but someone else + * deleted it! The caller doesn't care that we deleted it, + * just that it is deleted. So we can return successfully. + */ if (!refs_reflog_exists(ref_store, refname)) { unlock_ref(lock); return 0; From patchwork Mon Aug 23 11:36:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12452505 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48997C4338F for ; Mon, 23 Aug 2021 11:36:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2AE4461361 for ; Mon, 23 Aug 2021 11:36:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236551AbhHWLhO (ORCPT ); Mon, 23 Aug 2021 07:37:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236575AbhHWLhI (ORCPT ); Mon, 23 Aug 2021 07:37:08 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED559C061757 for ; Mon, 23 Aug 2021 04:36:25 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id j17-20020a05600c1c1100b002e754875260so687173wms.4 for ; Mon, 23 Aug 2021 04:36:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H5B8djGujbu/JyJreI6ZhAaipoCfWkLVE5+VILHd1Y8=; b=MwnoorlmSG9B8FDm4b3qWkFveP/C+fJ8h31k40oKjAOLnzOwBhksFPmDzKJZJ9tWWq z5gbckkvXFnFRKptBmEUhqPJ4lk8d2FXyrtUL+vJz/6Ye2Ut4r/aOwCF9adRcJlNrKD3 XbFXnD5HrbNWSjSSV5EftjFPWPq7yrFEX+e4V/ncLth8OuKH9PAARsiatLvVO1VxWRnv xBh0iyMKNHxUbBufA/RBTIL/urXBbg6Kyyk2SW05vESQ14F4fncUBzAR5bcPQcvAhF+o mhE7+UoeBH9l8oM8/PRwDnUzjaKoXeHAa0qGGhv9Hk2LnCnPUeKKGXIU85s2ysNnkHlD I0Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H5B8djGujbu/JyJreI6ZhAaipoCfWkLVE5+VILHd1Y8=; b=b9XSmn8Ic/2KQH8jS3fUFi3GEeJClMN8MevjnHLje+T7B3z5w3XuddYo96nWfNTWkg WmW1EOjL/o6uuF+7EH4FnZNw45iSTS0UFaQ9sJRLwlSq7Er1kr39SuFZPjLOXoAWeBYi yu93xcq77De1GrdngDfAz38Zhc6xWbrD1Uo9v4ZH4PaYdUuErmjhvQB4bg0+98pcZo0i BSbRSIMFYiOQvp4ts+fOnve1YNoefT2Y0XM4k/5erUmCFzZvH14PC4Xgf7vBbqGYwfPE tK0qLnFtWg72iW2n8gGjDeCLrh1n7A30nu125W+oHj40MeFcqU0gmFpIKXlr0DmdUB3t dJ0A== X-Gm-Message-State: AOAM530LUJA6Xet3AY/1X/GNPy94gWp4ICIPTeWjanTcH1mgqkq7lLyS G8520oiukadr0k+PqXkVKbNeAcFaJO6RewzW X-Google-Smtp-Source: ABdhPJxhdl5hsN8C1wfNZG5Nisk1CgfqhuG64dP8eK71tQWNPFP7S12S16LgoSYbjlNTrE2JjK3vug== X-Received: by 2002:a7b:c8cd:: with SMTP id f13mr15981938wml.6.1629718584285; Mon, 23 Aug 2021 04:36:24 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g35sm20555313wmp.9.2021.08.23.04.36.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 04:36:23 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Han-Wen Nienhuys , Michael Haggerty , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 09/13] reflog expire: don't lock reflogs using previously seen OID Date: Mon, 23 Aug 2021 13:36:10 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.662.g438caf9576d In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org During reflog expiry, the cmd_reflog_expire() function first iterates over all reflogs in logs/*, and then one-by-one acquires the lock for each one and expires it. This behavior has been with us since this command was implemented in 4264dc15e1 ("git reflog expire", 2006-12-19). Change this to stop calling lock_ref_oid_basic() with the OID we saw when we looped over the logs, instead have it pass the OID it managed to lock. This mostly mitigates a race condition where e.g. "git gc" will fail in a concurrently updated repository because the branch moved since "git reflog expire --all" was started. I.e. with: error: cannot lock ref '': ref '' is at but expected This behavior of passing in an "oid" was needed for an edge-case that I've untangled in this and preceding commits though, namely that we needed this OID because we'd: 1. Lookup the reflog name/OID via dwim_log() 2. With that OID, lock the reflog 3. Later in builtin/reflog.c we use the OID we looked as input to lookup_commit_reference_gently(), assured that it's equal to the OID we got from dwim_log(). We can be sure that this change is safe to make because between dwim_log (step #1) and lock_ref_oid_basic (step #2) there was no other logic relevant to the OID or expiry run in the cmd_reflog_expire() caller. We can thus treat that code as a black box, before and after this change it would get an OID that's been locked, the only difference is that now we mostly won't be failing to get the lock due to the TOCTOU race[0]. That failure was purely an implementation detail in how the "current OID" was looked up, it was divorced from the locking mechanism. What do we mean with "mostly"? It mostly mitigates it because we'll still run into cases where the ref is locked and being updated as we want to expire it, and other git processes wanting to update the refs will in turn race with us as we expire the reflog. That remaining race can in turn be mitigated with the core.filesRefLockTimeout setting, see 4ff0f01cb7 ("refs: retry acquiring reference locks for 100ms", 2017-08-21). In practice if that value is high enough we'll probably never have ref updates or reflog expiry failing, since the clients involved will retry for far longer than the time any of those operations could take. See [1] for an initial report of how this impacted "git gc" and a large discussion about this change in early 2019. In particular patch looked good to Michael Haggerty, see his[2]. That message seems to not have made it to the ML archive, its content is quoted in full in my [3]. I'm leaving behind now-unused code the refs API etc. that takes the now-NULL "unused_oid" argument, and other code that can be simplified now that we never have on OID in that context, that'll be cleaned up in subsequent commits, but for now let's narrowly focus on fixing the "git gc" issue. As the modified assert() shows we always pass a NULL oid to reflog_expire() now. Unfortunately this sort of probabilistic contention is hard to turn into a test. I've tested this by running the following three subshells in concurrent terminals: ( rm -rf /tmp/git && git init /tmp/git && while true do head -c 10 /dev/urandom | hexdump >/tmp/git/out && git -C /tmp/git add out && git -C /tmp/git commit -m"out" done ) ( rm -rf /tmp/git-clone && git clone file:///tmp/git /tmp/git-clone && while git -C /tmp/git-clone pull do date done ) ( while git -C /tmp/git-clone reflog expire --all do date done ) Before this change the "reflog expire" would fail really quickly with the "but expected" error noted above. After this change both the "pull" and "reflog expire" will run for a while, but eventually fail because I get unlucky with core.filesRefLockTimeout (the "reflog expire" is in a really tight loop). As noted above that can in turn be mitigated with higher values of core.filesRefLockTimeout than the 100ms default. As noted in the commentary added in the preceding commit there's also the case of branches being racily deleted, that can be tested by adding this to the above: ( while git -C /tmp/git-clone branch topic master && git -C /tmp/git-clone branch -D topic do date done ) With core.filesRefLockTimeout set to 10 seconds (it can probably be a lot lower) I managed to run all four of these concurrently for about an hour, and accumulated ~125k commits, auto-gc's and all, and didn't have a single failure. The loops visibly stall while waiting for the lock, but that's expected and desired behavior. 0. https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use 1. https://lore.kernel.org/git/87tvg7brlm.fsf@evledraar.gmail.com/ 2. http://lore.kernel.org/git/b870a17d-2103-41b8-3cbc-7389d5fff33a@alum.mit.edu 3. https://lore.kernel.org/git/87pnqkco8v.fsf@evledraar.gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/reflog.c | 13 ++++++------- refs.h | 2 +- refs/files-backend.c | 7 +++++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/builtin/reflog.c b/builtin/reflog.c index 09541d1c804..61795f22d53 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -629,8 +629,9 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix) free_worktrees(worktrees); for (i = 0; i < collected.nr; i++) { struct collected_reflog *e = collected.e[i]; + set_reflog_expiry_param(&cb.cmd, explicit_expiry, e->reflog); - status |= reflog_expire(e->reflog, &e->oid, flags, + status |= reflog_expire(e->reflog, NULL, flags, reflog_expiry_prepare, should_expire_reflog_ent, reflog_expiry_cleanup, @@ -642,13 +643,12 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix) for (; i < argc; i++) { char *ref; - struct object_id oid; - if (!dwim_log(argv[i], strlen(argv[i]), &oid, &ref)) { + if (!dwim_log(argv[i], strlen(argv[i]), NULL, &ref)) { status |= error(_("%s points nowhere!"), argv[i]); continue; } set_reflog_expiry_param(&cb.cmd, explicit_expiry, ref); - status |= reflog_expire(ref, &oid, flags, + status |= reflog_expire(ref, NULL, flags, reflog_expiry_prepare, should_expire_reflog_ent, reflog_expiry_cleanup, @@ -700,7 +700,6 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix) for ( ; i < argc; i++) { const char *spec = strstr(argv[i], "@{"); - struct object_id oid; char *ep, *ref; int recno; @@ -709,7 +708,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix) continue; } - if (!dwim_log(argv[i], spec - argv[i], &oid, &ref)) { + if (!dwim_log(argv[i], spec - argv[i], NULL, &ref)) { status |= error(_("no reflog for '%s'"), argv[i]); continue; } @@ -724,7 +723,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix) cb.cmd.expire_total = 0; } - status |= reflog_expire(ref, &oid, flags, + status |= reflog_expire(ref, NULL, flags, reflog_expiry_prepare, should_expire_reflog_ent, reflog_expiry_cleanup, diff --git a/refs.h b/refs.h index 48970dfc7e0..ddbf15f1c21 100644 --- a/refs.h +++ b/refs.h @@ -796,7 +796,7 @@ enum expire_reflog_flags { * expiration policy that is desired. * * reflog_expiry_prepare_fn -- Called once after the reference is - * locked. + * locked. Called with the OID of the locked reference. * * reflog_expiry_should_prune_fn -- Called once for each entry in the * existing reflog. It should return true iff that entry should be diff --git a/refs/files-backend.c b/refs/files-backend.c index fbcd0c790bc..d81bda8bc25 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -3027,7 +3027,7 @@ static int expire_reflog_ent(struct object_id *ooid, struct object_id *noid, } static int files_reflog_expire(struct ref_store *ref_store, - const char *refname, const struct object_id *oid, + const char *refname, const struct object_id *unused_oid, unsigned int flags, reflog_expiry_prepare_fn prepare_fn, reflog_expiry_should_prune_fn should_prune_fn, @@ -3044,6 +3044,7 @@ static int files_reflog_expire(struct ref_store *ref_store, int status = 0; int type; struct strbuf err = STRBUF_INIT; + const struct object_id *oid; memset(&cb, 0, sizeof(cb)); cb.flags = flags; @@ -3055,12 +3056,13 @@ static int files_reflog_expire(struct ref_store *ref_store, * reference itself, plus we might need to update the * reference if --updateref was specified: */ - lock = lock_ref_oid_basic(refs, refname, oid, &type, &err); + lock = lock_ref_oid_basic(refs, refname, NULL, &type, &err); if (!lock) { error("cannot lock ref '%s': %s", refname, err.buf); strbuf_release(&err); return -1; } + oid = &lock->old_oid; /* * When refs are deleted, their reflog is deleted before the @@ -3104,6 +3106,7 @@ static int files_reflog_expire(struct ref_store *ref_store, } } + assert(!unused_oid); (*prepare_fn)(refname, oid, cb.policy_cb); refs_for_each_reflog_ent(ref_store, refname, expire_reflog_ent, &cb); (*cleanup_fn)(cb.policy_cb); From patchwork Mon Aug 23 11:36:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12452509 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB8D3C432BE for ; Mon, 23 Aug 2021 11:36:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D990D61212 for ; Mon, 23 Aug 2021 11:36:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236235AbhHWLhQ (ORCPT ); Mon, 23 Aug 2021 07:37:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236475AbhHWLhJ (ORCPT ); Mon, 23 Aug 2021 07:37:09 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C58BEC0613C1 for ; Mon, 23 Aug 2021 04:36:26 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id f5so25741588wrm.13 for ; Mon, 23 Aug 2021 04:36:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wghmPfL5lBgMi4V/ythx4RZuCQ0GO5ckah/zFELQ3jA=; b=HbSZk2s4how15bE0jtMQdpjDfSojKW6LKu2K+yYvAmtm0FgYqWtX1KR3i+0J0zJ6aw fIqAsmKf2jaNjhzxqEmTy6RG1qk0IIO7I0TIuG0BzHp9pdrum4SCPgfoSSCV17mZefEp ExPkfhUXiPsqcFQLDeFKWz4OT4gegrqMd58BFmLa6xODmxHFCF0ChH5mPXIv2BxbZcPU Eux/N3scDjyE3Tf17BcvCHclKTYsE0StFNyymw+4aJkMjD8jHvhhBaFWhqo5EWohfmM6 QXX3+lKlxV8eLBfiDKvjdaBmNL8lgxs5hXJmZvJ766B9lHiXiTVFaYLId8iAI289z1WI aCag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wghmPfL5lBgMi4V/ythx4RZuCQ0GO5ckah/zFELQ3jA=; b=iUJGDyxhhPHqXyUxYxgR8PBoAdP+or/9Ley6Q6JbbwTsd/x8AjbPO7DKbBiffmIX// /DjFk4KMpzqQABXKVAedSJps6J4Cm9Nq1K1bJfPccBtVbQFZYkbqktnLdfhgu9H3W8FA LoItP1d0ue72EjCSUddMW2n1k6eFT114te6KT4wXbtmVnmnrHmKubgZfjylaBgfzPLPz jJllB/OdZgbPex53UpheHogzDhF7xUrM/HAKhyVEnHyCAsrDDTk7p5zsdm39knc1IRh0 /bpD+coHcsWHlgv+ETcca2dh3P4wdP8x6IgBcoAfHJS01JiJKWFJLVizxXqzqtjhtPzd Y9/Q== X-Gm-Message-State: AOAM533rYpuJ1M2uOP4FVAFDV1nqbLuhfMSol4uzb3hSCvuotV/Z+5Ct S8OmHLbCdiJu/yb+vH/LzkPIsyekndINy3hX X-Google-Smtp-Source: ABdhPJyI09C+Sc0wwvJWjrBG0rVOy/jjsyVbhbbKWUEPUiryscQoblzfqG7N4MS57DvqbR56PYfSvQ== X-Received: by 2002:a5d:548e:: with SMTP id h14mr7865256wrv.7.1629718585158; Mon, 23 Aug 2021 04:36:25 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g35sm20555313wmp.9.2021.08.23.04.36.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 04:36:24 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Han-Wen Nienhuys , Michael Haggerty , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 10/13] refs API: remove OID argument to reflog_expire() Date: Mon, 23 Aug 2021 13:36:11 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.662.g438caf9576d In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Since the the preceding commit the "oid" parameter to reflog_expire() is always NULL, but it was not cleaned up to reduce the size of the diff. Let's do that subsequent API and documentation cleanup now. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/reflog.c | 6 +++--- refs.c | 8 ++++---- refs.h | 7 +++---- refs/debug.c | 4 ++-- refs/files-backend.c | 3 +-- refs/packed-backend.c | 2 +- refs/refs-internal.h | 2 +- 7 files changed, 15 insertions(+), 17 deletions(-) diff --git a/builtin/reflog.c b/builtin/reflog.c index 61795f22d53..bd4c669918d 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -631,7 +631,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix) struct collected_reflog *e = collected.e[i]; set_reflog_expiry_param(&cb.cmd, explicit_expiry, e->reflog); - status |= reflog_expire(e->reflog, NULL, flags, + status |= reflog_expire(e->reflog, flags, reflog_expiry_prepare, should_expire_reflog_ent, reflog_expiry_cleanup, @@ -648,7 +648,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix) continue; } set_reflog_expiry_param(&cb.cmd, explicit_expiry, ref); - status |= reflog_expire(ref, NULL, flags, + status |= reflog_expire(ref, flags, reflog_expiry_prepare, should_expire_reflog_ent, reflog_expiry_cleanup, @@ -723,7 +723,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix) cb.cmd.expire_total = 0; } - status |= reflog_expire(ref, NULL, flags, + status |= reflog_expire(ref, flags, reflog_expiry_prepare, should_expire_reflog_ent, reflog_expiry_cleanup, diff --git a/refs.c b/refs.c index d9635436759..05944d8e725 100644 --- a/refs.c +++ b/refs.c @@ -2371,19 +2371,19 @@ int delete_reflog(const char *refname) } int refs_reflog_expire(struct ref_store *refs, - const char *refname, const struct object_id *oid, + const char *refname, unsigned int flags, reflog_expiry_prepare_fn prepare_fn, reflog_expiry_should_prune_fn should_prune_fn, reflog_expiry_cleanup_fn cleanup_fn, void *policy_cb_data) { - return refs->be->reflog_expire(refs, refname, oid, flags, + return refs->be->reflog_expire(refs, refname, flags, prepare_fn, should_prune_fn, cleanup_fn, policy_cb_data); } -int reflog_expire(const char *refname, const struct object_id *oid, +int reflog_expire(const char *refname, unsigned int flags, reflog_expiry_prepare_fn prepare_fn, reflog_expiry_should_prune_fn should_prune_fn, @@ -2391,7 +2391,7 @@ int reflog_expire(const char *refname, const struct object_id *oid, void *policy_cb_data) { return refs_reflog_expire(get_main_ref_store(the_repository), - refname, oid, flags, + refname, flags, prepare_fn, should_prune_fn, cleanup_fn, policy_cb_data); } diff --git a/refs.h b/refs.h index ddbf15f1c21..fda8aef1547 100644 --- a/refs.h +++ b/refs.h @@ -816,20 +816,19 @@ typedef int reflog_expiry_should_prune_fn(struct object_id *ooid, typedef void reflog_expiry_cleanup_fn(void *cb_data); /* - * Expire reflog entries for the specified reference. oid is the old - * value of the reference. flags is a combination of the constants in + * Expire reflog entries for the specified reference. + * flags is a combination of the constants in * enum expire_reflog_flags. The three function pointers are described * above. On success, return zero. */ int refs_reflog_expire(struct ref_store *refs, const char *refname, - const struct object_id *oid, unsigned int flags, reflog_expiry_prepare_fn prepare_fn, reflog_expiry_should_prune_fn should_prune_fn, reflog_expiry_cleanup_fn cleanup_fn, void *policy_cb_data); -int reflog_expire(const char *refname, const struct object_id *oid, +int reflog_expire(const char *refname, unsigned int flags, reflog_expiry_prepare_fn prepare_fn, reflog_expiry_should_prune_fn should_prune_fn, diff --git a/refs/debug.c b/refs/debug.c index 3f1455db2df..bf4a82bccb6 100644 --- a/refs/debug.c +++ b/refs/debug.c @@ -392,7 +392,7 @@ static void debug_reflog_expiry_cleanup(void *cb_data) } static int debug_reflog_expire(struct ref_store *ref_store, const char *refname, - const struct object_id *oid, unsigned int flags, + unsigned int flags, reflog_expiry_prepare_fn prepare_fn, reflog_expiry_should_prune_fn should_prune_fn, reflog_expiry_cleanup_fn cleanup_fn, @@ -405,7 +405,7 @@ static int debug_reflog_expire(struct ref_store *ref_store, const char *refname, .should_prune = should_prune_fn, .cb_data = policy_cb_data, }; - int res = drefs->refs->be->reflog_expire(drefs->refs, refname, oid, + int res = drefs->refs->be->reflog_expire(drefs->refs, refname, flags, &debug_reflog_expiry_prepare, &debug_reflog_expiry_should_prune_fn, &debug_reflog_expiry_cleanup, diff --git a/refs/files-backend.c b/refs/files-backend.c index d81bda8bc25..a4adac46443 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -3027,7 +3027,7 @@ static int expire_reflog_ent(struct object_id *ooid, struct object_id *noid, } static int files_reflog_expire(struct ref_store *ref_store, - const char *refname, const struct object_id *unused_oid, + const char *refname, unsigned int flags, reflog_expiry_prepare_fn prepare_fn, reflog_expiry_should_prune_fn should_prune_fn, @@ -3106,7 +3106,6 @@ static int files_reflog_expire(struct ref_store *ref_store, } } - assert(!unused_oid); (*prepare_fn)(refname, oid, cb.policy_cb); refs_for_each_reflog_ent(ref_store, refname, expire_reflog_ent, &cb); (*cleanup_fn)(cb.policy_cb); diff --git a/refs/packed-backend.c b/refs/packed-backend.c index 24a360b719f..65ba4214b8d 100644 --- a/refs/packed-backend.c +++ b/refs/packed-backend.c @@ -1635,7 +1635,7 @@ static int packed_delete_reflog(struct ref_store *ref_store, } static int packed_reflog_expire(struct ref_store *ref_store, - const char *refname, const struct object_id *oid, + const char *refname, unsigned int flags, reflog_expiry_prepare_fn prepare_fn, reflog_expiry_should_prune_fn should_prune_fn, diff --git a/refs/refs-internal.h b/refs/refs-internal.h index 3155708345f..d496c5ed52d 100644 --- a/refs/refs-internal.h +++ b/refs/refs-internal.h @@ -593,7 +593,7 @@ typedef int create_reflog_fn(struct ref_store *ref_store, const char *refname, int force_create, struct strbuf *err); typedef int delete_reflog_fn(struct ref_store *ref_store, const char *refname); typedef int reflog_expire_fn(struct ref_store *ref_store, - const char *refname, const struct object_id *oid, + const char *refname, unsigned int flags, reflog_expiry_prepare_fn prepare_fn, reflog_expiry_should_prune_fn should_prune_fn, From patchwork Mon Aug 23 11:36:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12452507 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F343EC4338F for ; Mon, 23 Aug 2021 11:36:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD4B761374 for ; Mon, 23 Aug 2021 11:36:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236645AbhHWLhR (ORCPT ); Mon, 23 Aug 2021 07:37:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236603AbhHWLhK (ORCPT ); Mon, 23 Aug 2021 07:37:10 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9984AC061757 for ; Mon, 23 Aug 2021 04:36:27 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id k29so25792415wrd.7 for ; Mon, 23 Aug 2021 04:36:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xjnofT3qeKXtrhtcuHHTTgXHHktvE7xIs89nEW/5w1Q=; b=FHKyyOxucu3tfJIUgBizwxWsTAORtTDDORXdGVIkoTcN9E2EEN451KBzuBRCx20zCA tFAEc3nimqA/eVVPL2GnCrfemB4olhXELJq9BqjqeA9A4hR3lildVwBmcqjn4NA2rjiq Me54NVeZNT4I/wrv1/v3wybqMDhWBZ++goOJZ25VH95X/uf4H52xIy1+9LXcOyd0frhm 8KCIJcjCUAFY78aHvNlM5S5TxcGDS0l87Yk/Cz/LCoSBTsyAs1bzuM1JU7OXEJPijLC6 FXJaJMd3BHUuIE2u85YLHelLprbJPY8+XsZi1XKJKvWIp7TVcUsQgNEZi0ZPqWt1S1jW 1/ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xjnofT3qeKXtrhtcuHHTTgXHHktvE7xIs89nEW/5w1Q=; b=WKENuSqCCxgCnMH7+DIlB0hJfs9Z3MwA7UORfBwJZXp5yfLwfy7t2qWaBcCjPnhdul wFqg7rVfdsa5YQrvjgv/OF9Aqzlcwrexfr5rg8qQXIePQu8zN58XGIK+HegdaruY9WYT M0nEqWYVhPPQm1D0WC1zWGLEIGF0ZNpB8xtNzGH/J/q/1sRcWoDR2pOn5eN0iokb8Fmz k/Lk1X+LaYdhycsu3epqik4XIDAm88C/pwXQOR9o5UbnpWSWJiEkFFQ7/nFOpTBIO8E6 hGG2Ie6cIWWsEnLl0E/tO7iLdCLAxds1f/7JaC/JKzNL1n4ba/dFAm4/JlA4MjvOgVG/ oV6g== X-Gm-Message-State: AOAM531hRy9gzx2e4mZFBJYwbe82pkWAAXxJ+NpWLmvs4ryBfDgBw549 bDwvOw4lyPC18orEU1AVJOp66uL4kt5L2jnm X-Google-Smtp-Source: ABdhPJx3AQziFlxk8SvxU1x/H2DY9nL10YCTIT6r5vFq4FuOoSNGzso5IKAvmAPpkS87cNkVVaojVg== X-Received: by 2002:adf:dc0b:: with SMTP id t11mr12781022wri.259.1629718585956; Mon, 23 Aug 2021 04:36:25 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g35sm20555313wmp.9.2021.08.23.04.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 04:36:25 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Han-Wen Nienhuys , Michael Haggerty , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 11/13] refs/files: remove unused "oid" in lock_ref_oid_basic() Date: Mon, 23 Aug 2021 13:36:12 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.662.g438caf9576d In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In the preceding commit the last caller that passed a non-NULL OID was changed to pass NULL to lock_ref_oid_basic(). As noted in preceding commits use of this API has been going away (we should use ref transactions, or lock_raw_ref()), so we're unlikely to gain new callers that want to pass the "oid". So let's remove it, doing so means we can remove the "mustexist" condition, and therefore anything except the "flags = RESOLVE_REF_NO_RECURSE" case. Furthermore, since the verify_lock() function we called did most of its work when the "oid" was passed (as "old_oid") we can inline the trivial part of it that remains in its only remaining caller. Without a NULL "oid" passed it was equivalent to calling refs_read_ref_full() followed by oidclr(). Signed-off-by: Ævar Arnfjörð Bjarmason --- refs/files-backend.c | 70 +++++++++----------------------------------- 1 file changed, 14 insertions(+), 56 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index a4adac46443..4f2d907597a 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -852,42 +852,6 @@ static struct ref_iterator *files_ref_iterator_begin( return ref_iterator; } -/* - * Verify that the reference locked by lock has the value old_oid - * (unless it is NULL). Fail if the reference doesn't exist and - * mustexist is set. Return 0 on success. On error, write an error - * message to err, set errno, and return a negative value. - */ -static int verify_lock(struct ref_store *ref_store, struct ref_lock *lock, - const struct object_id *old_oid, int mustexist, - struct strbuf *err) -{ - assert(err); - - if (refs_read_ref_full(ref_store, lock->ref_name, - mustexist ? RESOLVE_REF_READING : 0, - &lock->old_oid, NULL)) { - if (old_oid) { - int save_errno = errno; - strbuf_addf(err, "can't verify ref '%s'", lock->ref_name); - errno = save_errno; - return -1; - } else { - oidclr(&lock->old_oid); - return 0; - } - } - if (old_oid && !oideq(&lock->old_oid, old_oid)) { - strbuf_addf(err, "ref '%s' is at %s but expected %s", - lock->ref_name, - oid_to_hex(&lock->old_oid), - oid_to_hex(old_oid)); - errno = EBUSY; - return -1; - } - return 0; -} - static int remove_empty_directories(struct strbuf *path) { /* @@ -912,15 +876,12 @@ static int create_reflock(const char *path, void *cb) * On failure errno is set to something meaningful. */ static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs, - const char *refname, - const struct object_id *old_oid, - int *type, struct strbuf *err) + const char *refname, int *type, + struct strbuf *err) { struct strbuf ref_file = STRBUF_INIT; struct ref_lock *lock; int last_errno = 0; - int mustexist = (old_oid && !is_null_oid(old_oid)); - int resolve_flags = RESOLVE_REF_NO_RECURSE; int resolved; files_assert_main_repository(refs, "lock_ref_oid_basic"); @@ -928,12 +889,9 @@ static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs, CALLOC_ARRAY(lock, 1); - if (mustexist) - resolve_flags |= RESOLVE_REF_READING; - files_ref_path(refs, &ref_file, refname); - resolved = !!refs_resolve_ref_unsafe(&refs->base, - refname, resolve_flags, + resolved = !!refs_resolve_ref_unsafe(&refs->base, refname, + RESOLVE_REF_NO_RECURSE, &lock->old_oid, type); if (!resolved && errno == EISDIR) { /* @@ -951,8 +909,8 @@ static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs, refname); goto error_return; } - resolved = !!refs_resolve_ref_unsafe(&refs->base, - refname, resolve_flags, + resolved = !!refs_resolve_ref_unsafe(&refs->base, refname, + RESOLVE_REF_NO_RECURSE, &lock->old_oid, type); } if (!resolved) { @@ -987,10 +945,10 @@ static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs, goto error_return; } - if (verify_lock(&refs->base, lock, old_oid, mustexist, err)) { - last_errno = errno; - goto error_return; - } + if (refs_read_ref_full(&refs->base, lock->ref_name, + 0, + &lock->old_oid, NULL)) + oidclr(&lock->old_oid); goto out; error_return: @@ -1409,7 +1367,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store, logmoved = log; - lock = lock_ref_oid_basic(refs, newrefname, NULL, NULL, &err); + lock = lock_ref_oid_basic(refs, newrefname, NULL, &err); if (!lock) { if (copy) error("unable to copy '%s' to '%s': %s", oldrefname, newrefname, err.buf); @@ -1431,7 +1389,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store, goto out; rollback: - lock = lock_ref_oid_basic(refs, oldrefname, NULL, NULL, &err); + lock = lock_ref_oid_basic(refs, oldrefname, NULL, &err); if (!lock) { error("unable to lock %s for rollback: %s", oldrefname, err.buf); strbuf_release(&err); @@ -1838,7 +1796,7 @@ static int files_create_symref(struct ref_store *ref_store, struct ref_lock *lock; int ret; - lock = lock_ref_oid_basic(refs, refname, NULL, NULL, &err); + lock = lock_ref_oid_basic(refs, refname, NULL, &err); if (!lock) { error("%s", err.buf); strbuf_release(&err); @@ -3056,7 +3014,7 @@ static int files_reflog_expire(struct ref_store *ref_store, * reference itself, plus we might need to update the * reference if --updateref was specified: */ - lock = lock_ref_oid_basic(refs, refname, NULL, &type, &err); + lock = lock_ref_oid_basic(refs, refname, &type, &err); if (!lock) { error("cannot lock ref '%s': %s", refname, err.buf); strbuf_release(&err); From patchwork Mon Aug 23 11:36:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12452511 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ED87C4320E for ; Mon, 23 Aug 2021 11:36:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A78D6138E for ; Mon, 23 Aug 2021 11:36:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236649AbhHWLhS (ORCPT ); Mon, 23 Aug 2021 07:37:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236558AbhHWLhL (ORCPT ); Mon, 23 Aug 2021 07:37:11 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BBC8C061575 for ; Mon, 23 Aug 2021 04:36:28 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id i6so2049351wrv.2 for ; Mon, 23 Aug 2021 04:36:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V8xBeAg97XsG0kqjzEUpFtk396VwEkbYjV78tfKCaLU=; b=h4Mq+wttFBs5oVItjGxXj532p8PtIfZZmronMCXWCykWNMbOqcz/p0tSr0i/UiHKlB XmRtxVGm2MYFT7GnTdH47+vbLAVrQTyAla47Kvutkp3ZqNNn8y0sR0vIiskCSUdNGcve iFsN6nJYP7QXha/OITewUtpDlfQyMf3EDCm/8Cr65hpSCPJR6nmVFskOieD+GQGIAC8B TNXCbzev5eAyHwH2XRZvGAcePxACDbhBg4qPxRIbJMvUfxcT86Jac2RhDNjZcOmvrJ0h hQo9WArwkSXAjcpJNuZ3qnu+MPaHhsPkfdRUQRq6XF2pJ0Z8j5TPTDiew/MJKsLB888s 80Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V8xBeAg97XsG0kqjzEUpFtk396VwEkbYjV78tfKCaLU=; b=G080jgux2ARu8ADDzJqqrHRrJck7jMRGSgBx68DSWheMhFoJ96GnyMWWsik9VTTywO RxoPqti6gUqKgjk5pCSqqmoj6YAFpU0Vc8FQKjs3yzx/7CPcYGDJGpNdyoZjxJakscIf RCsqYtmMSX/EgwHcs2rLQ3C4Wp9bZNN9su6jTMeH9SIXoh7+DndE6DY+DHIZBVddxuYA l1fOqhmbttCwIHPwNZ5k2foI+bCodHkXHME0PP0ugHz9gteXhK0B4EqKUTuCqE5R17Tn r4K205yxw1t1DtPDSX2VPFOmWkEuopy8xX2+zMRqJXagNx7P/eSrYN0PEqLlN2V5wPUl ZtZg== X-Gm-Message-State: AOAM532rZfDkaOw2jh9QwTjwm2527x4HExgykO03konBgJVq/hQOhfGm ZI0zrndaSCMFKMKREEk4lOAUTJ7eJZrrONMD X-Google-Smtp-Source: ABdhPJxfukKjbjDZokyX/oVir7jYHon9cpZXwfQf6L2XUYCGtMfytiwhyCoPNmF9p3g/xXwHi5qZsw== X-Received: by 2002:a5d:58e9:: with SMTP id f9mr7463306wrd.154.1629718586830; Mon, 23 Aug 2021 04:36:26 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g35sm20555313wmp.9.2021.08.23.04.36.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 04:36:26 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Han-Wen Nienhuys , Michael Haggerty , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 12/13] refs/files: remove unused "errno == EISDIR" code Date: Mon, 23 Aug 2021 13:36:13 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.662.g438caf9576d In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When we lock a reference like "foo" we need to handle the case where "foo" exists, but is an empty directory. That's what this code added in bc7127ef0f (ref locking: allow 'foo' when 'foo/bar' used to exist but not anymore., 2006-09-30) seems like it should be dealing with. Except it doesn't, and we never take this branch. The reason is that when bc7127ef0f was written this looked like: ref = resolve_ref([...]); if (!ref && errno == EISDIR) { [...] And in resolve_ref() we had this code: fd = open(path, O_RDONLY); if (fd < 0) return NULL; I.e. we would attempt to read "foo" with open(), which would fail with EISDIR and we'd return NULL. We'd then take this branch, call remove_empty_directories() and continue. Since a1c1d8170d (refs_resolve_ref_unsafe: handle d/f conflicts for writes, 2017-10-06) we don't. E.g. in the case of files_copy_or_rename_ref() our callstack will look something like: [...] -> files_copy_or_rename_ref() -> lock_ref_oid_basic() -> refs_resolve_ref_unsafe() At that point the first (now only) refs_resolve_ref_unsafe() call in lock_ref_oid_basic() would do the equivalent of this in the resulting call to refs_read_raw_ref() in refs_resolve_ref_unsafe(): /* Via refs_read_raw_ref() */ fd = open(path, O_RDONLY); if (fd < 0) /* get errno == EISDIR */ /* later, in refs_resolve_ref_unsafe() */ if ([...] && errno != EISDIR) return NULL; [...] /* returns the refs/heads/foo to the caller, even though it's a directory */ return refname; I.e. even though we got an "errno == EISDIR" we won't take this branch, since in cases of EISDIR "resolved" is always non-NULL. I.e. we pretend at this point as though everything's OK and there is no "foo" directory. We then proceed with the entire ref update and don't call remove_empty_directories() until we call commit_ref_update(). See 5387c0d883 (commit_ref(): if there is an empty dir in the way, delete it, 2016-05-05) for the addition of that code, and a1c1d8170db (refs_resolve_ref_unsafe: handle d/f conflicts for writes, 2017-10-06) for the commit that changed the original codepath added in bc7127ef0f to use this "EISDIR" handling. Further historical commentary: Before the two preceding commits the caller in files_reflog_expire() was the only one out of our 4 callers that would pass non-NULL as an oid. We would then set a (now gone) "resolve_flags" to "RESOLVE_REF_READING" and just before that "errno != EISDIR" check do: if (resolve_flags & RESOLVE_REF_READING) return NULL; There may have been some case where this ended up mattering and we couldn't safely make this change before we removed the "oid" parameter, but I don't think there was, see [1] for some discussion on that. In any case, now that we've removed the "oid" parameter in a preceding commit we can be sure that this code is redundant, so let's remove it. 1. http://lore.kernel.org/git/871r801yp6.fsf@evledraar.gmail.com Signed-off-by: Ævar Arnfjörð Bjarmason --- refs/files-backend.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index 4f2d907597a..bed2ab25c3a 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -882,7 +882,6 @@ static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs, struct strbuf ref_file = STRBUF_INIT; struct ref_lock *lock; int last_errno = 0; - int resolved; files_assert_main_repository(refs, "lock_ref_oid_basic"); assert(err); @@ -890,30 +889,9 @@ static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs, CALLOC_ARRAY(lock, 1); files_ref_path(refs, &ref_file, refname); - resolved = !!refs_resolve_ref_unsafe(&refs->base, refname, - RESOLVE_REF_NO_RECURSE, - &lock->old_oid, type); - if (!resolved && errno == EISDIR) { - /* - * we are trying to lock foo but we used to - * have foo/bar which now does not exist; - * it is normal for the empty directory 'foo' - * to remain. - */ - if (remove_empty_directories(&ref_file)) { - last_errno = errno; - if (!refs_verify_refname_available( - &refs->base, - refname, NULL, NULL, err)) - strbuf_addf(err, "there are still refs under '%s'", - refname); - goto error_return; - } - resolved = !!refs_resolve_ref_unsafe(&refs->base, refname, - RESOLVE_REF_NO_RECURSE, - &lock->old_oid, type); - } - if (!resolved) { + if (!refs_resolve_ref_unsafe(&refs->base, refname, + RESOLVE_REF_NO_RECURSE, + &lock->old_oid, type)) { last_errno = errno; if (last_errno != ENOTDIR || !refs_verify_refname_available(&refs->base, refname, From patchwork Mon Aug 23 11:36:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12452513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2437EC4338F for ; Mon, 23 Aug 2021 11:36:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E09E61361 for ; Mon, 23 Aug 2021 11:36:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236631AbhHWLh3 (ORCPT ); Mon, 23 Aug 2021 07:37:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236625AbhHWLhP (ORCPT ); Mon, 23 Aug 2021 07:37:15 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B2FCC061760 for ; Mon, 23 Aug 2021 04:36:29 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 79-20020a1c0452000000b002e6cf79e572so13848098wme.1 for ; Mon, 23 Aug 2021 04:36:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OvPGQ33S4qFAznPr6D20ZOrMiJZvRBK5c5WslOpBaEM=; b=VsejhdZtaA0BY56UKUZZTq6g+Rky4piqS+z8D3+wmFjWlntkm4fY+j2aC7nVSSDcZz JkWxmeHZNZnWFVR5+C4Ax7BokNsKg4H26K75o90O83+gOoBP9hr6PxNEh37VN+sSnkfA AcRF5KR2qGuj6oGFexigbQfa4g4eGVqgxXD+nbGirgZPtfpKagPSV68APTFV5LYxIsES wr5jHafklGMdtf6AC65Ivc7gFIMiUInXbCybqXK6RHpjLYmkSVg0P1O7iB5qAdtCPP58 VYAPN1LDbyPmw2+0O+SMIRtkiuWgJP+enGgHHxin1R1J1NmHS9Ie6EBD1qAC4cfu/Zay vI+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OvPGQ33S4qFAznPr6D20ZOrMiJZvRBK5c5WslOpBaEM=; b=be9j3jnMSYbTUiLXWOOkrJTgKXBg3esDAF5mTUzJdmIhocGUtCNwLQy3ywZ2YJ6t1C Ig7x5i7q1eL6JzxHh05YBjLRqqFyQa2km8/6BYgQCR9NGZJpuXMAKODOKl0S7tQV3DTy rQ58zvWIa43CVb8wTLTGnTwQroXmEnJ/IkG0mZKk1fDWkDYWz/2ZquJzpemm1l+k05FY i1myFn5h6omSfp+W4RPPHDxF0UNF2udAEwJzC+81A5w5tO7L+tbxWNJpzLZ3S9xWLmK/ q1qKnFMlkScmLP4AEs3YoJ3PBLll3OCxX9FJlt8SJJdLOKmez/USCZUoJgWDLgGEs8qd /vZQ== X-Gm-Message-State: AOAM532Q2bESncX8vI1Lb9GOoqo+48HIGdHGzVDvG6vbjAZGgtodgBMk K4dU4or/1NgBprp1Oa4nzjgtbIqunXIJ0Lhf X-Google-Smtp-Source: ABdhPJwfQ6DMVzqnUYt2caDmhG2dXi/hitxA74FETRFPll2scr/F6nEIVDKFFidwNT/kpvNOLbW55A== X-Received: by 2002:a1c:ed13:: with SMTP id l19mr16052813wmh.48.1629718587593; Mon, 23 Aug 2021 04:36:27 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id g35sm20555313wmp.9.2021.08.23.04.36.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 04:36:27 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Han-Wen Nienhuys , Michael Haggerty , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v5 13/13] refs/files: remove unused "errno != ENOTDIR" condition Date: Mon, 23 Aug 2021 13:36:14 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.662.g438caf9576d In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org As a follow-up to the preceding commit where we removed the adjacent "errno == EISDIR" condition in the same function, remove the "last_errno != ENOTDIR" condition here. It's not possible for us to hit this condition added in 5b2d8d6f218 (lock_ref_sha1_basic(): improve diagnostics for ref D/F conflicts, 2015-05-11). Since a1c1d8170db (refs_resolve_ref_unsafe: handle d/f conflicts for writes, 2017-10-06) we've explicitly caught these in refs_resolve_ref_unsafe() before returning NULL: if (errno != ENOENT && errno != EISDIR && errno != ENOTDIR) return NULL; We'd then always return the refname from refs_resolve_ref_unsafe() even if we were in a broken state as explained in the preceding commit. The elided context here is a call to refs_resolve_ref_unsafe(). Signed-off-by: Ævar Arnfjörð Bjarmason --- 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 bed2ab25c3a..ab666af4b75 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -893,8 +893,7 @@ static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs, RESOLVE_REF_NO_RECURSE, &lock->old_oid, type)) { last_errno = errno; - if (last_errno != ENOTDIR || - !refs_verify_refname_available(&refs->base, refname, + if (!refs_verify_refname_available(&refs->base, refname, NULL, NULL, err)) strbuf_addf(err, "unable to resolve reference '%s': %s", refname, strerror(last_errno));