From patchwork Mon Jul 26 23:44:17 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: 12400929 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 29556C4338F for ; Mon, 26 Jul 2021 23:44:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 057B660F6D for ; Mon, 26 Jul 2021 23:44:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233945AbhGZXEH (ORCPT ); Mon, 26 Jul 2021 19:04:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233380AbhGZXEF (ORCPT ); Mon, 26 Jul 2021 19:04:05 -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 4F1B6C061757 for ; Mon, 26 Jul 2021 16:44:32 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id f14-20020a05600c154eb02902519e4abe10so550998wmg.4 for ; Mon, 26 Jul 2021 16:44:32 -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=cY/y8TYhmPLeR+YdJaOeuX7fgyn4tlFjsF/3VIH9OEQ=; b=KzRdaBX7E2FJdcyeLJ+uWDk17bnzjoktBldURr86mLvA10GkkJoS6uRyiVZeB6SoY+ gAfrUhNjdbhmDOK7+4Z5DcZTX2943mCc7hN0tDyq7tccXq8i/4605eUoQDpuvpAN1t8y 7P1pnHxpi1Nhknn5WBu73pKERmvg5a7DC9Z0o9slcVZNFTrSLKrURMRQlt+7gipv/ld9 e8ncDwiFd/2HIFIl0NDBTR6jssrfRVWl5MdhvCGqhtKeuAPdSdHcB6P+PlnMgjkXhCnA JHIRFHZ91DaER8T715rWVRPXZG1xd3LSeLtiqrbuBBY7fUNuzLu93+qIkUwr0CxK/PpK thKQ== 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=cY/y8TYhmPLeR+YdJaOeuX7fgyn4tlFjsF/3VIH9OEQ=; b=my3FqHhi0SeHe7ZXOt4aPCPvQAEu2V/neDdmTUuX+XX7u4jrygg+DVG4QJmovbTN9q GlmRTstn4/62zhE98w32cQctf/uzuDRylL60+O+RLwAqZQDOrdNzR1VqcT1THnbex4RI fAnvFhg3ihlg8ZWORiwvMIOwDaKteuBA7yrGpSOddL/THcJZPSEPJF7+ojE+IpFzvLUa GSE7bwxMkbyqwpe+f5NrWEJQsq3axQAmjDlgNPyv0MdBJo0dFffcixq7BkhHDi5AdNov O/0XU9lxCNkpCexsyaGEilCh243FhJg58lDBJqA11B7FVtAaQqknbvSfRFO7G/y5EmFu QMJA== X-Gm-Message-State: AOAM532nJ8D0Ife9l0Rbp/Rgg7r80sKENDfAtBRXKefFoBxhM//aDCMe QSg4EbTWy5QnvVFuBSatIsnYkz600TUxcg== X-Google-Smtp-Source: ABdhPJyilt2QanuUZ1e1eWuixZGDlulEXOBXBmP4ud10kuRVHpHsF4hbGbcDTSzLY3odiHK/46Ohww== X-Received: by 2002:a1c:f613:: with SMTP id w19mr18989999wmc.141.1627343070660; Mon, 26 Jul 2021 16:44:30 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id n18sm1214545wrt.89.2021.07.26.16.44.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 16:44:29 -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 v4 01/11] refs/packet: add missing BUG() invocations to reflog callbacks Date: Tue, 27 Jul 2021 01:44:17 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.988.g1a6a4b2c5f 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 f8aa97d799..24a360b719 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 Jul 26 23:44:18 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: 12400927 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 35FECC4320A for ; Mon, 26 Jul 2021 23:44:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B29A60F91 for ; Mon, 26 Jul 2021 23:44:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234020AbhGZXEH (ORCPT ); Mon, 26 Jul 2021 19:04:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233809AbhGZXEF (ORCPT ); Mon, 26 Jul 2021 19:04:05 -0400 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 1A556C061760 for ; Mon, 26 Jul 2021 16:44:33 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id z4so1118747wrv.11 for ; Mon, 26 Jul 2021 16:44:33 -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=tfCQPna/qO14mOzoWOOhf5Qt1GbTwFG3/kyFnef5MbM=; b=r8SCifHpz9XBH8I6A+oSpyKmj+qT21HvbT1ucsn3KURIp7aLk9sQ1a4FLyCc98KCiA uheFzI/rfnIXhyN6MGoBYTM7ydhjh/Eq05ef/vbULRZXM6tNlecPhEW21hvDM/voeJdY F4jSmaiBFE5RbbCigi1+dRXkMaim2F06mn36yubbHT0kuPgQMhXCES8VkbnuOXeJ+/Nl irWqDCVfRTlHL5q+RpuVJz3mV7NxWffm+kh1/z3ak9gOZhJE+YNrAO8Q24npEjnfOJ42 nEsO9CBJa1I1hXCtv1B47D+kHga0VD9TWTxonLIKbJZ7zTQ0IsfuWHhss+NwxUGbZan7 dBzA== 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=tfCQPna/qO14mOzoWOOhf5Qt1GbTwFG3/kyFnef5MbM=; b=U1kxC8a9ZU9oaIJiYNFM+gSandAmenFf/udxiRMceclxIzdPzGyX/Fr663bd/PUL9q TlqhXzqgoWrzWkSjibpMkX+yOHfyorn8/n+wynNMquIXnI0h7gEiepSgEY/l9SCBexu8 LuzwTP1zbWiVZXxtehZRm6zZZZasEpX53zH2f8O4VpfIos4Ul2lcPxPD9QFbOC5O3Gzo Gw0WNzbeGASd6Z/W8egAnnWgLpG8eEo4/pwrJ/eIOBALqMwTsAvBnSfUlbPx1inlWr3E j/xTt8ILx1eBk9KShGy3qUsMzEVAbHlR982a7Yke2akGE5q+EYX8f2GO3xICIYkBlx61 w+lw== X-Gm-Message-State: AOAM533ixZcjWEQv8Le44uBXeGdBS8SPCEjbyvqm1IQTMIRJGG6mx1W4 LfT1WZvE2te2uBedyHuVw5hFSiZpm8smPg== X-Google-Smtp-Source: ABdhPJyIMV5Jt+eeo6dKB4tWgX1O0f/WcaafH1oAqjevhpZkVQgS1N1WumTS3+7neFx+K8ergv1VVA== X-Received: by 2002:a5d:6184:: with SMTP id j4mr9404314wru.340.1627343071555; Mon, 26 Jul 2021 16:44:31 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id n18sm1214545wrt.89.2021.07.26.16.44.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 16:44:30 -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 v4 02/11] refs/files: remove unused REF_DELETING in lock_ref_oid_basic() Date: Tue, 27 Jul 2021 01:44:18 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.988.g1a6a4b2c5f 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 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 677b7e4cdd..326f022421 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 Jul 26 23:44:19 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: 12400931 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 A18DEC432BE for ; Mon, 26 Jul 2021 23:44:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 860C460F6D for ; Mon, 26 Jul 2021 23:44:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234161AbhGZXEM (ORCPT ); Mon, 26 Jul 2021 19:04:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233959AbhGZXEH (ORCPT ); Mon, 26 Jul 2021 19:04:07 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FA4FC061764 for ; Mon, 26 Jul 2021 16:44:34 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id e2so12993315wrq.6 for ; Mon, 26 Jul 2021 16:44:34 -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=cHVPqTEKi5EZQutPKgJ+igxNtsb8o1l3HyV1iLfo8Qc=; b=d4cfpqkzfr2YTktr9oELGXR87rJKxHqAo01LFTpidPj7SZS9oQK9w3/TgIBZojZy6w VDWTkNqFQ6WH2Z8L06imOaqcC2YZO5MJ8wL7gywc0BmPI2f/wCuBDSdKnSxoG2msmJLF XYA6dHRBQpQjebmIDq4XvA+2UZFHcn+GG8hjsUDHO5PiomRsCLTwXV7WkT3Y+KxQTF2n Yz7ETJn7g6AIn1ZXj+a8c33CvNV6AYYAKxXQ822I2Fk0tvTxDxbbnnwV/Ffj223taM1M +YwshLDSTRa2CK2U4tG575dr3U0RAozoF204O+Q5VcAoW1rrq3qTakbsPgAT9iNmtbsR w7XA== 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=cHVPqTEKi5EZQutPKgJ+igxNtsb8o1l3HyV1iLfo8Qc=; b=YXhcnUk94g28OHFMwkeafk10WSgV5BBSzFUvRf0LKM4nMQcGWGCA19RXyr+ASyLZsV i6KvR0pZCGKwkIEUJxdMNcLlO39xiMRQPat9wZQVulDoUgtz3FnlnkEPTsLQYPXfg2vx Y0plWcwIujatX0nWOn4sipPIa2VErqGsw+EgqwGnt5YG0QRBdJZ/UgClPxmhbCSDx2R6 eL6yMkkov67v7+l66D/4M/AAGv4LKm2nLk7I8gVSOlEG6zJFt0+a0pB0a62RTZiO/1hg Jsa14lHyB1RvjODxXhxKyF2jPZvGSdAec4wHYCOmBSHGwsoCPvBKY+1rbwFT/fKzB88f 50DA== X-Gm-Message-State: AOAM531VmhgbPKS6soH4FMOvS/mGhgw5Dl4oYrFXCG98VSiFHMq6Q9Oq 5JAyUZgZ+N5DlCJpR2GftS8tRILtqdVEuQ== X-Google-Smtp-Source: ABdhPJx7S0enW+zd2Hgb7xNaZ+nkwQyiO84w2xHTQ1B+TcrILCKjOzfNqg81wFsbKM/kghzoiBNQkA== X-Received: by 2002:adf:90c6:: with SMTP id i64mr21914464wri.168.1627343072638; Mon, 26 Jul 2021 16:44:32 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id n18sm1214545wrt.89.2021.07.26.16.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 16:44:31 -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 v4 03/11] refs/files: remove unused "extras/skip" in lock_ref_oid_basic() Date: Tue, 27 Jul 2021 01:44:19 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.988.g1a6a4b2c5f 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 | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index 326f022421..a59823d667 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, unsigned int flags, int *type, struct strbuf *err) { @@ -950,7 +948,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; @@ -963,7 +961,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)); @@ -978,7 +976,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; } @@ -1413,8 +1411,8 @@ 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); + lock = lock_ref_oid_basic(refs, newrefname, NULL, REF_NO_DEREF, NULL, + &err); if (!lock) { if (copy) error("unable to copy '%s' to '%s': %s", oldrefname, newrefname, err.buf); @@ -1436,7 +1434,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, + lock = lock_ref_oid_basic(refs, oldrefname, NULL, REF_NO_DEREF, NULL, &err); if (!lock) { error("unable to lock %s for rollback: %s", oldrefname, err.buf); @@ -1845,7 +1843,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, + REF_NO_DEREF, NULL, &err); if (!lock) { error("%s", err.buf); @@ -3064,7 +3062,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, + REF_NO_DEREF, &type, &err); if (!lock) { error("cannot lock ref '%s': %s", refname, err.buf); From patchwork Mon Jul 26 23:44:20 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: 12400935 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 E8603C432BE for ; Mon, 26 Jul 2021 23:44:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D2A7C60F94 for ; Mon, 26 Jul 2021 23:44:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234027AbhGZXEO (ORCPT ); Mon, 26 Jul 2021 19:04:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234038AbhGZXEI (ORCPT ); Mon, 26 Jul 2021 19:04:08 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1779BC061757 for ; Mon, 26 Jul 2021 16:44:35 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id b7so12995457wri.8 for ; Mon, 26 Jul 2021 16:44:35 -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=wZJadjZL3aza8OHq3yrDMTPC1gHXTvaojn9VV1UnHjg=; b=Yw5qnStsqzOiFSGtREIQPgjVIz2u0dZ/nVTQSLZfaRPC9gT5wcZeHKldvJKTnFdzrv srW2rYk/6OloNbN9h7gXUerXIVN0EG7UBbIaw7iC/SI4PrfymfpGVphrS5wU0jRQzFXU eA/rqOaAdmtuukYQuLXCoCPURR6qdqzBr3fDATlCfsC4956is8GV8wMkFUN+wDAHEsQX OgV3ULv/8fYNEf7441TeHlI31GV/Y90qFmd6zR4jyURn9JKkzaY+77eeISXx9D4RhmWv DMhQ27/z6LFtvxxPJG+n9qJz9MkkDjSZUA+P/Qtak7SP8xTO5GU4lbR1H9AbXFRF4O/J KIMg== 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=wZJadjZL3aza8OHq3yrDMTPC1gHXTvaojn9VV1UnHjg=; b=bzlT4vJ3/2gfjVdMgj9Vk2hxJADbg6RBSypeD+aZU4b2+TwYw35MNDQie6TWzIMj0U uTbzzAxG9WO+eLTyGtcF0SJCJVo71H37vLbdASVlEUv0dG+Hct3C3IOFiN4kW9tiO6AX ou/qViMDZg3HJ+zdU9hprdwM5sMbjGyrtYEaigqEhIU0H6E4lpplltADS5LxcT7d8YRv INZ1CRBFmTRQgWe3c1tMvO8Xum3S1Otd2yq6HOVcDkeSAZpA1QMB5XY+YmCHdJmG0WQH j9gxAex2tPCBIQmGGi1z/j26O6l5MStMARq2AycHt27LWHieBy0JJnmaQWbTG58P4y4S 5ISQ== X-Gm-Message-State: AOAM530QVnZToU3/qkfKevWkPax66A5y3G7FHODM8xn1tMIf2d14fu5L E3GkywxmxNc6uhQ7425NzFbnWF5pk83+pw== X-Google-Smtp-Source: ABdhPJyj2FpHH2stVCZCftti5U823Y1OsF3Xd2zxLucL9hlOMe8gQdH+ChBjPM2qUODv2TM4Qj7uKg== X-Received: by 2002:a05:6000:1201:: with SMTP id e1mr12112701wrx.379.1627343073369; Mon, 26 Jul 2021 16:44:33 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id n18sm1214545wrt.89.2021.07.26.16.44.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 16:44:32 -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 v4 04/11] refs/files: remove unused "skip" in lock_raw_ref() too Date: Tue, 27 Jul 2021 01:44:20 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.988.g1a6a4b2c5f 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 a59823d667..af332fa8fe 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; } @@ -2412,7 +2411,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 Jul 26 23:44:21 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: 12400933 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 0F77BC4338F for ; Mon, 26 Jul 2021 23:44:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E536E60F6D for ; Mon, 26 Jul 2021 23:44:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234230AbhGZXEN (ORCPT ); Mon, 26 Jul 2021 19:04:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234055AbhGZXEI (ORCPT ); Mon, 26 Jul 2021 19:04:08 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4535C061760 for ; Mon, 26 Jul 2021 16:44:35 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id p5so7889453wro.7 for ; Mon, 26 Jul 2021 16:44:35 -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=sX3TrWBCaOi/pxUMAFl7QWUvxgRa6IEo9UtCw9XEgqM=; b=kShMefcx4slrBFIf0p/UrihHMn2VlkCd3yk2srj4XbI8A97Ap8hEf/CFhrHM2t+mnm 1J0BrvFyup9ytkGp7o329Y/wHNQfzfcg1wWTNLHCQYRfXAB0R+gqBMfm8Z7NvAU5UTcK rzbytloSoH4+VHuycB1Dh5RXaUtoZ+sTsiiQDATdiI8TSpaCIcd4Kvl8gLNBWNxD4TaY He/VnXVfiTfHo6ojJe9xp74s267RlFPi44Y4KEc4BB59YXMbzQk7ymWqcVGYLIMZ5KMh 6he0TegFa0S50Yb95cLDLMBZOvqsChI3Mmku3CScVDKXehJlGe4I6vaBGM60fLty78AV x3UQ== 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=sX3TrWBCaOi/pxUMAFl7QWUvxgRa6IEo9UtCw9XEgqM=; b=EkwdCiS1XRnO0nc1jDTG93Q9bnZyYotsazRzRBRCsheU5xlW7xV0TnoRsFqttEXfoQ hXUMC4HDJpxG/DXmmbVYysC0F6Fu2YzccH//LDEWZQXIk4cUMfXzjz03j6ETPG2mzD+2 frQY8lTHx9wr1LehT2RGiCXhFe/T1zuyx2KCtwNi61MQSRrSWOxaRgaGlaV4P85meO8e GGoYsnFC1X9rgWjVognjKtFeyL1f70PcS4jDuQIJnmQR6yQW1Kok7TE+CQSoCYn6WNR3 SPrALj5MdChYsSyz5zEpeQToVmK5YLTKkQ0dUom9ahhKGMZHErFRHK2hAC4AlkATvBgh 3tng== X-Gm-Message-State: AOAM5325g84GRKUtB6kwixfpIORxVeBK4VQgal66TbrG0J4pD0tym3Ss Trrtp40jxydpuEOWX82N2ALhaFA/CoMwpg== X-Google-Smtp-Source: ABdhPJzb5wISTtxDnbdplbQhxltvhPP0mgpyntLHRvd4KYXoIGblnSLZ3AvLfosffOm9bqlDJmrDiQ== X-Received: by 2002:a5d:46d1:: with SMTP id g17mr21959696wrs.2.1627343074290; Mon, 26 Jul 2021 16:44:34 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id n18sm1214545wrt.89.2021.07.26.16.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 16:44:33 -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 v4 05/11] refs/debug: re-indent argument list for "prepare" Date: Tue, 27 Jul 2021 01:44:21 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.988.g1a6a4b2c5f 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 7db4abccc3..449ac3e6cc 100644 --- a/refs/debug.c +++ b/refs/debug.c @@ -364,8 +364,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 Jul 26 23:44:22 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: 12400947 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 929D3C4338F for ; Mon, 26 Jul 2021 23:45:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71C57600CD for ; Mon, 26 Jul 2021 23:45:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234077AbhGZXEu (ORCPT ); Mon, 26 Jul 2021 19:04:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234088AbhGZXEI (ORCPT ); Mon, 26 Jul 2021 19:04:08 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E207FC061757 for ; Mon, 26 Jul 2021 16:44:36 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id n12so9444898wrr.2 for ; Mon, 26 Jul 2021 16:44:36 -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=QM0y+WMxfpMN5yNQhUpWsSMS/xysQ3vVWVghsn2/Zv8=; b=SD/jmBe/62znWyBTsZrmVfjjhJZWB2/jvJ1+3EDp2JAiXoOSkeshT2U7Timn12Hz4u TddRwyvt/8gpjcuEZs2oFdryvdnKnrGKIdVXAFy/B6xXd2qDl3wJ/7hXEQ0wKmPHFOaO xq3Zbwz/WNtncO80MJg2RfQEGD61eE8U8quiKBYLSrwr8mI9appZ3w45Nnc5Y878HDiA oQGseP2MeJrfbMdRMF5+Yuy3MJA+/aC8R86XCFR++J7m9cJxk4pLh2gcfp4t+j7Cwb5D 61C2Rh93YNs5n1huhX9a/E/jXYTkDTMnQ/jdNs8jToJeDVIdEwKWd0mZUMXqAHFpvoHF exmA== 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=QM0y+WMxfpMN5yNQhUpWsSMS/xysQ3vVWVghsn2/Zv8=; b=nFQ//+hg7xB1u1qtVlhIWPRa0OYlPfyzU55YoBrx3wm7Q+A466X3E6tyenza/m+y+U 1dcdWQHUOv5Mlt8d88gSGAjRCqwxtwjgcqTwarXQgzIHFtKJYMd+rGzAAXS7YarDLS// hS/nqe9lJH/bSyCxbyxUSJVPzXiKwygXQne4oxM/qTkboMw9qXcbKaHGTHR1MdLulpno +frqriKvq13qNcyKd9a1ZzZ++7fB14CDmorq9fJ78KdJeBisDYmRkV55jpkDOhvxn3BW U9zY2hDkhKIvFf5Cn3BhLQStQ82MxTw+bQqXtp008naC+Oa9djT18XaqUL0gmXzakpJc NaNQ== X-Gm-Message-State: AOAM532Af93ihtleyUjYWQTGw/MURzZMmh50LmqJHQQXXkP7V48C6sbT qYRdIBmJRrQ3fRSFtYCIme458ECnFz0yDw== X-Google-Smtp-Source: ABdhPJx8oQwZcK8PfDY+d6sRzpLpQIOPWIvdnxbnN/p10gY+qu0SLYPzIgMousDQn97os0F4lCeZyw== X-Received: by 2002:a05:6000:10c3:: with SMTP id b3mr21636350wrx.271.1627343075297; Mon, 26 Jul 2021 16:44:35 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id n18sm1214545wrt.89.2021.07.26.16.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 16:44:34 -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 v4 06/11] refs: make repo_dwim_log() accept a NULL oid Date: Tue, 27 Jul 2021 01:44:22 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.988.g1a6a4b2c5f 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 e9cd328369..8ac4b284b6 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 8b9f7c3a80..d963543675 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 Jul 26 23:44:23 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: 12400937 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 E6EF0C4338F for ; Mon, 26 Jul 2021 23:44:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C77E460F90 for ; Mon, 26 Jul 2021 23:44:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234053AbhGZXEP (ORCPT ); Mon, 26 Jul 2021 19:04:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234169AbhGZXEK (ORCPT ); Mon, 26 Jul 2021 19:04:10 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DDFFC061764 for ; Mon, 26 Jul 2021 16:44:38 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id c16so3145706wrp.13 for ; Mon, 26 Jul 2021 16:44:37 -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=yHUkIzinW0ExtWvjDbLMDXh3JzdcggswOPlGuAal3mQ=; b=EL7dIfHIMVBx/EjJiLEgTwWKGwARMzTvdTx1W0HWmPO5KZCWJJL1ib2m+kfmDJT5Yy 8P0m+m5S0s4ZXD/uPe4AbKsWXWWux5oH8uyJLxZU72kpuFcK6dQWpTHns1oLRynzvMUr Res7V5WyxmCEJaT3rdQBUYIHJ1TKtrtlecn5OhdJm3VzDs4PNGQEk3cOXxNwUPNYJWGj j3L8szJN8axlBKwAF623SA7LGASXm5Jplhq5QydZ/K/a+BfFiHEAgTy7QrlNHfPrHLKq iOrKRNfRCprf8wCUg2eD9+oL0qjvzwYoi+oj/+YNGYmFoz4s4YfwJr85t7lNSTN/m6TP mKRQ== 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=yHUkIzinW0ExtWvjDbLMDXh3JzdcggswOPlGuAal3mQ=; b=BwaYdnnD1IN11vewpUSsTxF+MtgPkXyE5vuolCZp1Z/y3OEif7oQeu4pk+mFpW9tbJ SrHVQNl3ZshorKnadHW1AK+O7ZT8MtVZOjYZUrzk+l7RyD4vTmYaBvdLtXDXuivv310J hIS+dPtxP9qdbAigQnmqaSiQgAgtoOAwijZwSX5X8X2etd9HdQZ828dmUL5o2L35dkB0 5jxolzSdzpVH7E67DnMF2UNdif6kj5Z7uy+Api8GkjoaYcagYLhrQIZb08Ok8dY5xQWj vvRGvd8WndjOkbAWB9nOZybmnKELl9UmgNXK9xdbkOyfSbo9Y7lMdf2JMEL8XOSDyI+k dm8A== X-Gm-Message-State: AOAM533nrbun+8GzbBoBHeGLvPSZ1LfOIlyj0fAbsy46TLFm+tukD2SH NIl5h9QXhZxHYcBR/bCZe0YiFitMn7a4pQ== X-Google-Smtp-Source: ABdhPJwFHEwCqh0NbbyNMKiNRrVIDk4XVVDf9kjdUXXQJV67p3ovL1vQgovJh0K3bQCUDiypYBFiwg== X-Received: by 2002:adf:f446:: with SMTP id f6mr8853906wrp.361.1627343076441; Mon, 26 Jul 2021 16:44:36 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id n18sm1214545wrt.89.2021.07.26.16.44.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 16:44:35 -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 v4 07/11] refs/files: add a comment about refs_reflog_exists() call Date: Tue, 27 Jul 2021 01:44:23 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.988.g1a6a4b2c5f 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 af332fa8fe..5415306416 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -3068,6 +3068,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 Jul 26 23:44:24 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: 12400941 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,URIBL_BLOCKED,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 B5DB5C4338F for ; Mon, 26 Jul 2021 23:44:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 930E560F5D for ; Mon, 26 Jul 2021 23:44:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234094AbhGZXER (ORCPT ); Mon, 26 Jul 2021 19:04:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234219AbhGZXEM (ORCPT ); Mon, 26 Jul 2021 19:04:12 -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 0191CC061757 for ; Mon, 26 Jul 2021 16:44:39 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id b7so12995556wri.8 for ; Mon, 26 Jul 2021 16:44:38 -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=MK6Z9Cquc5ZGzDpswqqlxg0vxDFGVV9ytrRsG0F+cXQ=; b=RSrWPabPkIkaFLBFj2FWZkSzyLgInbzwZ6HK8Xpz/KVxSTrr9V+B/sfEElBfsvIU1f qAJ4UXmaY+cB5c2oVM+MXf+gmp1cde1N20OpdT1kUGGsT+BWo7hAlLpp033yUuXzmIjK 3epVc2ReSXwFMwtGXA+jWzt6n02yjc5tabDdqUjbtD7zMZ8Rp26zzZPShsFD2XIi6MWD bLaHtP/hq9Tl5Pgw2EHHFcWTmJFGjKReQ3uTNYxsDKoPzqfpMMTgzSROdJ5I5A2fQtBG qkdBHaUPXiX8X/N8GNfKU34hmSK/8yHGCTCcLg/rdpM64PgS+SHyBGZm90KUrgAqxoQm 3sAA== 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=MK6Z9Cquc5ZGzDpswqqlxg0vxDFGVV9ytrRsG0F+cXQ=; b=rPzfWMvBfGJyis7upxeQlFxJaSJmeaDBH/O6p3//2zmOh3Gi4E/q7p87I7gQOzOJ6P dEwCBKPY8p+HOOv/5OYxvXusyFlhCMFfQeyckJs3hP4OaJ98uW0x5wDRtxV/IYUf7bdi 5bH8yzzAPMVdaIl5NQOAJGrmppYOPw90wTBVPa2lc0KPs7zP3TDgsaFce0eR0f+ZwKP7 vaTrdP2R1GZsnBqJMK3whaNzK0OsiT0JPVyy4vYwFokAEFmUGHLE3lZOv/8yOn9zF5u6 d5pbWXBaqpQxImqWI7oaKHW8TavLdPPedBdWOTeAf+CMFFgRe8gyEVaCfpfslB9m1yvr 1sFw== X-Gm-Message-State: AOAM530Mxwu3XzG5FaWfAxFHkn6N49AbRJOHrIxYXA31C7d/IqhZV84n 8sjL3ixMN6fvNSETUVCd94sbgHeR3UFxVQ== X-Google-Smtp-Source: ABdhPJx1VXC534y7pBIIKmTVtT4aJhZOJIyZTqQtcx2pe5MVNdnog6c49hhc3g17Z/k9IpL1JsU/MQ== X-Received: by 2002:a05:6000:1a86:: with SMTP id f6mr21113641wry.127.1627343077215; Mon, 26 Jul 2021 16:44:37 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id n18sm1214545wrt.89.2021.07.26.16.44.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 16:44:36 -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 v4 08/11] reflog expire: don't lock reflogs using previously seen OID Date: Tue, 27 Jul 2021 01:44:24 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.988.g1a6a4b2c5f 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 09541d1c80..61795f22d5 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 48970dfc7e..ddbf15f1c2 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 5415306416..ccdf455049 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -3032,7 +3032,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, @@ -3049,6 +3049,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; @@ -3060,7 +3061,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, + lock = lock_ref_oid_basic(refs, refname, NULL, REF_NO_DEREF, &type, &err); if (!lock) { @@ -3068,6 +3069,7 @@ static int files_reflog_expire(struct ref_store *ref_store, strbuf_release(&err); return -1; } + oid = &lock->old_oid; /* * When refs are deleted, their reflog is deleted before the @@ -3111,6 +3113,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 Jul 26 23:44:25 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: 12400939 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 29E41C432BE for ; Mon, 26 Jul 2021 23:44:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DD6960F5D for ; Mon, 26 Jul 2021 23:44:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234147AbhGZXEQ (ORCPT ); Mon, 26 Jul 2021 19:04:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233809AbhGZXEM (ORCPT ); Mon, 26 Jul 2021 19:04:12 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C349BC061760 for ; Mon, 26 Jul 2021 16:44:39 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id c16so3145754wrp.13 for ; Mon, 26 Jul 2021 16:44:39 -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=HNxVXXRDyI4L8G5q6ZN0S8Pzigq9Pz5EPYOqEs4g9BA=; b=g8ax7pwG8mAqtbaJn7UkR39rnSYqF842wQ+NCKP0/sePJyXZaxwoLNJfMBm20mzFtO YdcVuDH9V5iVz8lDfhm+wisFvRRVsp+ViSU9UGSz6NY521PoBC+oDBiJH73Kj2c+PXQK 5D4jrN6KNHm22yesxVQZNnArXnfXBV8Mk+ie/poxCLn645F8PV8q+ljFhDuRFpi/crf6 DYliCk6GCVFKQQZ9WcvgpEbRuFDvkFTYKbDvTO5yQmsgBOZJzr1VW8ZmWWWkmTVHyP4x CxbKcjPam+1F9pWYaokcgxJnericKo3SvY232MvIcfeBP3+COW6XrcmaCn3wjy1pTa24 rQEA== 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=HNxVXXRDyI4L8G5q6ZN0S8Pzigq9Pz5EPYOqEs4g9BA=; b=cAS7tASVnRoW62DNLRZCG/yj7GYmUjjtZFwuQR/8O+jWTCv6k3t6FTWU7U7IHpVEQV KumgSh6o/amBWn3rXTz4PIaumyDMl5h1jMS4rmffTu0zStmYhBwj/DKX0hfJJLz1FRiW O4Ybd0FYoqX1goA0AaISgJ15tyfSSnhrIe3SX54USpnCWEdjo6afvlE0nDxCR22sBFpi Fbd4y7mWg+PjOx4McmeeMNFTEi11Dq9C6CV+czI+pIv0g+28s58uM/GZflLC+w7RsKE7 oveRszggShBXcEJA6CXvRqjbdgt/0AIyLFXvkZQd0p6qqtXZaDE9yNrwuBSWXjFAr5xF ApWw== X-Gm-Message-State: AOAM5325rJaMnsqTRTBjMU/dbKT7h17jlrhtWFtZucFy3728L8twUKSw YPOqEWTZucfxHQlQSea5gKiM6y1/ya2nBw== X-Google-Smtp-Source: ABdhPJybHuDxEyCUqvARf3UO04f+k+RpfJh9OQJSNl93AzMG4P0A+nv1cAsFnDO3g9fA1A93Uqksww== X-Received: by 2002:a05:6000:1c4:: with SMTP id t4mr21813217wrx.181.1627343078202; Mon, 26 Jul 2021 16:44:38 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id n18sm1214545wrt.89.2021.07.26.16.44.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 16:44:37 -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 v4 09/11] refs/files: remove unused "oid" in lock_ref_oid_basic() Date: Tue, 27 Jul 2021 01:44:25 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.988.g1a6a4b2c5f 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 | 72 ++++++++------------------------------------ 1 file changed, 12 insertions(+), 60 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index ccdf455049..98d9aa1601 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) { /* @@ -913,15 +877,12 @@ 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, unsigned int flags, 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"); @@ -929,12 +890,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) { /* @@ -952,8 +910,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) { @@ -988,10 +946,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: @@ -1410,8 +1368,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store, logmoved = log; - lock = lock_ref_oid_basic(refs, newrefname, NULL, REF_NO_DEREF, NULL, - &err); + lock = lock_ref_oid_basic(refs, newrefname, REF_NO_DEREF, NULL, &err); if (!lock) { if (copy) error("unable to copy '%s' to '%s': %s", oldrefname, newrefname, err.buf); @@ -1433,8 +1390,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store, goto out; rollback: - lock = lock_ref_oid_basic(refs, oldrefname, NULL, - REF_NO_DEREF, NULL, &err); + lock = lock_ref_oid_basic(refs, oldrefname, REF_NO_DEREF, NULL, &err); if (!lock) { error("unable to lock %s for rollback: %s", oldrefname, err.buf); strbuf_release(&err); @@ -1841,9 +1797,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, - REF_NO_DEREF, NULL, - &err); + lock = lock_ref_oid_basic(refs, refname, REF_NO_DEREF, NULL, &err); if (!lock) { error("%s", err.buf); strbuf_release(&err); @@ -3061,9 +3015,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, - REF_NO_DEREF, - &type, &err); + lock = lock_ref_oid_basic(refs, refname, REF_NO_DEREF, &type, &err); if (!lock) { error("cannot lock ref '%s': %s", refname, err.buf); strbuf_release(&err); From patchwork Mon Jul 26 23:44:26 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: 12400943 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 18DA9C4320A for ; Mon, 26 Jul 2021 23:44:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2DEB60F5D for ; Mon, 26 Jul 2021 23:44:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234187AbhGZXET (ORCPT ); Mon, 26 Jul 2021 19:04:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234251AbhGZXEN (ORCPT ); Mon, 26 Jul 2021 19:04:13 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFB41C061757 for ; Mon, 26 Jul 2021 16:44:40 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id f18-20020a05600c4e92b0290253c32620e7so334850wmq.5 for ; Mon, 26 Jul 2021 16:44:40 -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=y4sr9BQbSFmTjxhb3lc/2Y804+UZrUNMSPLVP1noSdk=; b=hBYveq8NBjHTYQWDmUptfXg+Usxz2xpFRR6Q6/OQBhrnPIl+xH8q8mhJ3M15rKDPrx EFECMtiohh68zERFVcjTL9/LhCvNQRJNe4N/jZedxqb8r17QkFtBq2PNneJBsofwAXNS jKU7ZN+bwrj60rFSCN1BdaA51Q0IImgKLthYBes0mvLoeovv/bQ79rsIwU3fUDIz4lBt E5VrR/DNA1ewyc7ylJ/2wkiKjXkSPFsHXHA2f0SCSv7wY6vy99QtrFcak3qq8lxBFRll OSax+3RBKfDxxOZmptzv+l5yg8cRkurD1KP6uNs+UVfe511/09QjW54XwC4P2WPttHmN PTPw== 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=y4sr9BQbSFmTjxhb3lc/2Y804+UZrUNMSPLVP1noSdk=; b=d5d37gbo4siBi4ZUnXJWoXK/ExeFVkJ1oA5ODJE6n/KvJYQu3ePi5HhKv6WmN3dAiA vrhSWQ4U187Z0FCdVcmK0OijCvWsM5zvVvNGkn/Of3YwLiFOUyy79xNFw3R0aR3ajX8V csNp4bGTVKxuk4BbVqMlezRfPxfgd7IxJ2aMDmqSOdfWxFCsa+7oTaORvGeqxKPaSHWU zMk0tFPzyA5FMG2df2yoZF3N3au3P4RmwHM3QhlUn/XGG2VWy6Vs47+Hu6Q4VOwQvb78 i+CKUBr6hkhFjA8f1egvVSNQrNx+6oDIgh8d8H2Luu7arqklgm4CWgcxSXX+EWdhtwQd 7//Q== X-Gm-Message-State: AOAM531fwRBVQQkNhCH+u8F7m44PO1r/hpjfjA04/O3nvGTWpoVAsw9J icB36ka4848jGdObAtRuqgTF+kEU9TX6JQ== X-Google-Smtp-Source: ABdhPJwQWu9CjkXSRGkWG4CABRzrrYOJIfZThf3bWF1l9TVWZos4m8+CUiJQUPahJaw/7Ri46kXx1Q== X-Received: by 2002:a1c:730d:: with SMTP id d13mr1245341wmb.129.1627343079028; Mon, 26 Jul 2021 16:44:39 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id n18sm1214545wrt.89.2021.07.26.16.44.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 16:44:38 -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 v4 10/11] refs/files: remove unused "errno == EISDIR" code Date: Tue, 27 Jul 2021 01:44:26 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.988.g1a6a4b2c5f 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 98d9aa1601..28cd8853f5 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -883,7 +883,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); @@ -891,30 +890,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 Jul 26 23:44:27 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: 12400945 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 6F1A8C432BE for ; Mon, 26 Jul 2021 23:44:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A719600CD for ; Mon, 26 Jul 2021 23:44:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234153AbhGZXEV (ORCPT ); Mon, 26 Jul 2021 19:04:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234253AbhGZXEO (ORCPT ); Mon, 26 Jul 2021 19:04:14 -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 8A9D9C061760 for ; Mon, 26 Jul 2021 16:44:41 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id m20-20020a05600c4f54b029024e75a15716so1081298wmq.2 for ; Mon, 26 Jul 2021 16:44:41 -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=V+CvTZLf7aDDfTGU5YGydguI2YFS+ZhRmZGRIYFq17M=; b=hHAzd/WNjyxkARufP9z6xFc3crDkUiCll7LB0n7bHmWs4uoWWtS5/d6U9wRFNCO0pf 2sXlbdrNjqQRe3ioHqoFUqst3iOq/zPwxVNVAmHj3S8NYZmD+EcxOwS9jugViYmvMYTw kIbD9Zof4QbeC1R0zMHrqZUngavPDtOLT0cVkLZnWAKjcEiKi/XmmAqPsVmV7h88be8l TzKJ9XN6+8SAi5pfgQqlZYfxuTqlDsMWfnFhxkdarFpPStVPGQqFYEk3uPN6I2b45lJw qYvqgswqKlY3YMnlptGbhp5McmxzbQnBssTmnnKNOTfktgl6zUPdBeDTWgFagBM9dZ53 GsdA== 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=V+CvTZLf7aDDfTGU5YGydguI2YFS+ZhRmZGRIYFq17M=; b=HEUDGlrZyP4WA2AsDrULgQ9OqcEk+742g2P3KLrFHL+atagaq7ISMy9uW2yHnwm5pl GPFA718XGiKHc31/PmBh9G3WKfmo0DV8Dg5rXbg6ubvCjzDjCj1t5SxENwSjAG1SS2sM 6Jj6cdmWW6n73ihqrU2qRWJEqJpMP0zdhNTKVSBkR3HqJHVlban1HkBsybhHbjqBwM1B yCfHdUfiulY2o2DOQoumIumg2G2veZjE4WxRdSy2IeR5Tpd16eIzBJc2cERFeRlyJCVl je1Y+9nTJvXqYmIBRGOKigK3UlXJzetV2lajjskBah33CBhN/FZPeJaw5JJbZmC7uhhK eTCw== X-Gm-Message-State: AOAM530BuAqtFjrutiSWdBH6IMfm9zXkOPEscIDBQ6IeJIOHAyp8hZzw JLaLazVq0teD9Q+spz/qEIucWTN8uHLvjA== X-Google-Smtp-Source: ABdhPJzE9UCv8e833LnaCKzg11yAJ9w9rF3EAVnEZPNT43ylCrZKHC0R77Kl6BlNw7oHwCU8PI8HFg== X-Received: by 2002:a05:600c:4108:: with SMTP id j8mr1188526wmi.67.1627343079988; Mon, 26 Jul 2021 16:44:39 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id n18sm1214545wrt.89.2021.07.26.16.44.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 16:44:39 -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 v4 11/11] refs/files: remove unused "errno != ENOTDIR" condition Date: Tue, 27 Jul 2021 01:44:27 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.988.g1a6a4b2c5f 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 28cd8853f5..5d12003471 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -894,8 +894,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));