From patchwork Thu Dec 15 09:59:00 2022 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: 13074059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4E03C4332F for ; Thu, 15 Dec 2022 09:59:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230009AbiLOJ7T (ORCPT ); Thu, 15 Dec 2022 04:59:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229866AbiLOJ7M (ORCPT ); Thu, 15 Dec 2022 04:59:12 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63C4C2C134 for ; Thu, 15 Dec 2022 01:59:11 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id m14so2458952wrh.7 for ; Thu, 15 Dec 2022 01:59:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bKhBS7qSxRaKu9gxOB6W951SkAx8S38zzVpBihycuro=; b=CaZkjB8pYWQRS0sXy3CnbGLQWLj1PcpmSBz9Xapkf8LTDP/RhAtpjhJb0MW627ilqd V5w2ZbiweDUN9eAEevi5LIluo5YwFxmUJJwydGGcnC+L1uTKYXAFqBssfTUJpsrZlef4 S7UCTVs65Lk2nlDDiHHEkO41BgZXH/mfdGlrIxJOuFGRYTMt9wQVruYFUdm0MPbuZL0p AVc7G4m05QrA86ujcBJh95A0eEUmAFdGJOyPQoFxQLnrhnu/Pt+4RJA/5LvnAccdNLPV Qoj3jOKQ7aoVCE5xse4LlpM56/1t9zNdTmnq6449Zr7NXCn8NG2PnKZ2Iy640SjHE1pO 18Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bKhBS7qSxRaKu9gxOB6W951SkAx8S38zzVpBihycuro=; b=HSV/2aayjQnCOVTC+JR4vapQnQs6jYtBC/nOQSUojvY9FZGBPWZpAtKpyb7r2QeFi3 pLhSY8/v6tgZ/H/KJPyAgRTmbXl5oSP6U0XbfPys4IfOp59ZyJigPDJpGYT0C8qtz6EY i09B8AgmG/zQFCUsddp+uZMkGAWbvR+2sIw0xp7AZ37V1UK/46XHZBAAZ3BJmhDzz6on ExA2fYmd+44tOZtSPjWqe/qkL0vAkYRDoszM+j0M2Y+Hjrre8R1GqaSXFqjbuz/9vMKY Z4uXWUCS7qK3qBgwTcx5SorEz9jc35A0Es99yKr6/hMhJ7s29lAu1eFk3Rs8rI5wWcxi 4bRg== X-Gm-Message-State: ANoB5pnJ0v0YF4URU0mWIbnar0uasnBwXVg0nQS8SW/T4NhSLR8x1/0W SGAsWwJUwIg4oCKi2na8WihFG9XfQmhCQg== X-Google-Smtp-Source: AA0mqf7jnd+4S6ZfqADOi5sXf+AqLfA2fEEdId3g41lkNdUMbYIEKDD0T/+IdQMbySztq/3MjhnY9g== X-Received: by 2002:a5d:4888:0:b0:232:be5c:ec7e with SMTP id g8-20020a5d4888000000b00232be5cec7emr17793124wrq.58.1671098349534; Thu, 15 Dec 2022 01:59:09 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a13-20020adfe5cd000000b00228cbac7a25sm5495948wrn.64.2022.12.15.01.59.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 01:59:08 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Taylor Blau , Junio C Hamano , Phillip Wood , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= Subject: [PATCH 1/6] builtin/rm.c: use narrower "USE_THE_INDEX_VARIABLE" Date: Thu, 15 Dec 2022 10:59:00 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc2.1048.g0e5493b8d5b In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Replace the "USE_THE_INDEX_COMPATIBILITY_MACROS" define with the narrower "USE_THE_INDEX_VARIABLE". This could have been done in 07047d68294 (cocci: apply "pending" index-compatibility to some "builtin/*.c", 2022-11-19), but I missed it at the time. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/rm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/rm.c b/builtin/rm.c index d4989d4d863..2cddf921951 100644 --- a/builtin/rm.c +++ b/builtin/rm.c @@ -3,7 +3,7 @@ * * Copyright (C) Linus Torvalds 2006 */ -#define USE_THE_INDEX_COMPATIBILITY_MACROS +#define USE_THE_INDEX_VARIABLE #include "builtin.h" #include "advice.h" #include "config.h" From patchwork Thu Dec 15 09:59:01 2022 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: 13074060 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B59E8C4332F for ; Thu, 15 Dec 2022 09:59:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230174AbiLOJ7X (ORCPT ); Thu, 15 Dec 2022 04:59:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbiLOJ7N (ORCPT ); Thu, 15 Dec 2022 04:59:13 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48911193EB for ; Thu, 15 Dec 2022 01:59:12 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id m19so13327186wms.5 for ; Thu, 15 Dec 2022 01:59:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lNXD1TmzXUDz5bUNux6HcT6l24jtDGfKq7GTpKAGU2Y=; b=LeCeq1IE4lyc6xsemcqmXRdq4kTLjSjnaI02FOHsbKaDKWb0ve0GIuqridU0eAUjPZ V8o7qAgKnrQ12NMmIMks1ZWcRofpMJ3OzB16M992I2jGyB9vU7PDdmXRmG0JFIp1etkM YekDeagXNxP/8ajV3V4kJqlZBZy/6qRHDTll5LeFIWVRFOKLnQQFf/iJs/c2VJ1yxOw1 OI665okFAY+YYFZvHMrv/44aREWZgrc9b+2zjJw/gZjtrIbec1CZYmir/0pGjrnczjLE kq+Q6mIqUUUbt+Wt+hCCmyNwk+xeEEZ9Cctdy0HBVvyMqc9aE2T3SJWVhJg6qbYEDHVV tW3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lNXD1TmzXUDz5bUNux6HcT6l24jtDGfKq7GTpKAGU2Y=; b=jnOfzyDYsdoEvKxv/HhKrmzuvRbvgdAoT0QGN2QC7mQWQTzpSyoXQtz0dZu936HGpP HPQb8Y9nAX3ZCJxgSxbqygvgwwR/a5PAWRiT0yBVkhRsgIjGygcZ7+c6kmPdsNNfzFyu g8wneRidBJNKDisGuBCqmDsXSI4jp6bXrki0a+V3D19FfsTcSqTDkPJjdpajlzmtyh5L gnmBh/F8S07SwBkKIjG1lmBFCI8w7KcVXVVPdu8aFbeGa7/X7ukXkVzAMrkcl9H6cF7n qlt7jZf6DCgRsQdt55/C3kDVq4tG1qy+2MYjUfBa8of4QMUuqkWh0epHzXOpWw51Cvfa 7l/g== X-Gm-Message-State: ANoB5plZkaw7fcle3yR76rYWzB6t+md9fIr8u1uRjQstx/UaiOMuBiTz rBSvSuEwki/MS7a3DcNtQ6Ka3Jxv8nLQag== X-Google-Smtp-Source: AA0mqf5mbnUPMQliJMZNn6SRF8hPKnS9tL3TcgIMYVz1S90I8K1Jir21EeS8QXJZv6Y1pmAjyvx9pA== X-Received: by 2002:a05:600c:6899:b0:3d1:cfcb:7d19 with SMTP id fn25-20020a05600c689900b003d1cfcb7d19mr28814810wmb.32.1671098350493; Thu, 15 Dec 2022 01:59:10 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a13-20020adfe5cd000000b00228cbac7a25sm5495948wrn.64.2022.12.15.01.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 01:59:09 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Taylor Blau , Junio C Hamano , Phillip Wood , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= Subject: [PATCH 2/6] cocci & cache.h: fully apply "active_nr" part of index-compatibility Date: Thu, 15 Dec 2022 10:59:01 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc2.1048.g0e5493b8d5b In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Apply the "active_nr" part of "index-compatibility.pending.cocci", which was left out in [1] due to an in-flight conflict. As of [2] the topic we conflicted with has been merged to "master", so we can fully apply this rule. 1. dc594180d9e (cocci & cache.h: apply variable section of "pending" index-compatibility, 2022-11-19) 2. 9ea1378d046 (Merge branch 'ab/various-leak-fixes', 2022-12-14) Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/commit.c | 2 +- cache.h | 2 -- contrib/coccinelle/index-compatibility.cocci | 13 ++++--------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index 44b763d7cd0..57a95123dff 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -991,7 +991,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, struct object_id oid; const char *parent = "HEAD"; - if (!active_nr) { + if (!the_index.cache_nr) { discard_cache(); if (read_cache() < 0) die(_("Cannot read index")); diff --git a/cache.h b/cache.h index 07d40b0964b..9de988574e0 100644 --- a/cache.h +++ b/cache.h @@ -438,8 +438,6 @@ extern struct index_state the_index; #ifndef USE_THE_INDEX_VARIABLE #ifdef USE_THE_INDEX_COMPATIBILITY_MACROS -#define active_nr (the_index.cache_nr) - #define read_cache() repo_read_index(the_repository) #define discard_cache() discard_index(&the_index) #define cache_name_pos(name, namelen) index_name_pos(&the_index,(name),(namelen)) diff --git a/contrib/coccinelle/index-compatibility.cocci b/contrib/coccinelle/index-compatibility.cocci index 8520f03128a..028ff53354a 100644 --- a/contrib/coccinelle/index-compatibility.cocci +++ b/contrib/coccinelle/index-compatibility.cocci @@ -1,6 +1,7 @@ // the_index.* variables @@ identifier AC = active_cache; +identifier AN = active_nr; identifier ACC = active_cache_changed; identifier ACT = active_cache_tree; @@ @@ -8,6 +9,9 @@ identifier ACT = active_cache_tree; - AC + the_index.cache | +- AN ++ the_index.cache_nr +| - ACC + the_index.cache_changed | @@ -15,15 +19,6 @@ identifier ACT = active_cache_tree; + the_index.cache_tree ) -@@ -identifier AN = active_nr; -identifier f != prepare_to_commit; -@@ - f(...) {<... -- AN -+ the_index.cache_nr - ...>} - // "the_repository" simple cases @@ @@ From patchwork Thu Dec 15 09:59:02 2022 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: 13074061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24C55C10F31 for ; Thu, 15 Dec 2022 09:59:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230176AbiLOJ70 (ORCPT ); Thu, 15 Dec 2022 04:59:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230143AbiLOJ7P (ORCPT ); Thu, 15 Dec 2022 04:59:15 -0500 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 3A8422BB32 for ; Thu, 15 Dec 2022 01:59:13 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id m5-20020a7bca45000000b003d2fbab35c6so1035301wml.4 for ; Thu, 15 Dec 2022 01:59:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Y7KnLYvbMQBTPvHXxDqa/WX7P/XmY2tzxlMNnKwEudI=; b=V5mi+6aLohmx0LzHW3YubhyJ0oB5BgfEQpKybhAi9Zb/WcWQ+saEOkm14+7Bgjzm5Y g+ZCZMgTTOVgC9HordNvHoOcZFusGDLdZjDn744OSjRc2Bp+uuLSxT8fQqvgcFEG3Lgw mjsSK/J/FI/cKK7KkEY6c1MUgBoRSukxsQ1gP0qJWuWnqHdIxItLWPGITrFIbSlosqhI 6ndpvR14Oq25iJ7fFh2dmsEeQoFMdacsTWC+92pMGb2JyQtnq0RwcJDqeAGXt+xaEFd0 f66tvqsAyxZlL6U8/HgPjgr7I5F84uTt7sqF+K5SSRt7vBAEgFtUDyCebQsOwhv2nlj2 b2jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y7KnLYvbMQBTPvHXxDqa/WX7P/XmY2tzxlMNnKwEudI=; b=1EPJFxLqGxfLbQiac9xNtO3c386dmG94mqSLRdCsLeD14KviHVyVvFqOQlbGe8aWhB CVbl22sE22TGRwJjoo8FwzKYOsYzSJfCwBhnALK6lr3WqOtZM11+mMiRDzEf2JrYUhzo nm4P4mHejqOHYcVlOUJhXTPc2y0WP8QVtvu550CXjTn/iUNSB5mZASZRTo/DKkMnjaYj YKKfN78jGFLrhu5AxY3fS9wsUKY+uOAtIJVbJxMKZtkwRutJ8V+zl2+hO20BM/ldoeBS JS47JlhEZG88oGbH7CcMldj6Bjgupr/g5ezdIn+5D/AAQKCjnSVYoH4ZUyXd9DGlOeUI 8jvA== X-Gm-Message-State: ANoB5pkVoKHlDlUBw8pTs2SM3ep91YRiiyDdCIgiDd2mAyeAY7wVn0us 52m8p66hXhfhVTbMSmexOmaOgcMb6+k0LQ== X-Google-Smtp-Source: AA0mqf6y7VsRcxyfpzokj83I4CbA8fMX4tvBQn2wj/VWIDQbO7eQWiNfHr588VRwX8WziA6Lwx/9Uw== X-Received: by 2002:a05:600c:5546:b0:3d1:f6b3:2ce3 with SMTP id iz6-20020a05600c554600b003d1f6b32ce3mr28198332wmb.35.1671098351434; Thu, 15 Dec 2022 01:59:11 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a13-20020adfe5cd000000b00228cbac7a25sm5495948wrn.64.2022.12.15.01.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 01:59:10 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Taylor Blau , Junio C Hamano , Phillip Wood , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= Subject: [PATCH 3/6] cocci & cache.h: apply pending "index_cache_pos" rule Date: Thu, 15 Dec 2022 10:59:02 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc2.1048.g0e5493b8d5b In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Apply the rule added in [1] to change "cache_name_pos" to "index_name_pos", which allows us to get rid of another "USE_THE_INDEX_COMPATIBILITY_MACROS" macro. The replacement of "USE_THE_INDEX_COMPATIBILITY_MACROS" here with "USE_THE_INDEX_VARIABLE" is a manual change on top, now that these files only use "&the_index", and don't need any compatibility macros (or functions). 1. 0e6550a2c63 (cocci: add a index-compatibility.pending.cocci, 2022-11-19) Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/mv.c | 8 +++++--- builtin/update-index.c | 4 ++-- cache.h | 1 - contrib/coccinelle/index-compatibility.cocci | 3 +++ contrib/coccinelle/index-compatibility.pending.cocci | 3 --- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/builtin/mv.c b/builtin/mv.c index 19790ce38fa..edd7b931fdb 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -3,7 +3,7 @@ * * Copyright (C) 2006 Johannes Schindelin */ -#define USE_THE_INDEX_COMPATIBILITY_MACROS +#define USE_THE_INDEX_VARIABLE #include "builtin.h" #include "config.h" #include "pathspec.h" @@ -489,7 +489,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix) if ((mode & SPARSE) && path_in_sparse_checkout(dst, &the_index)) { /* from out-of-cone to in-cone */ - int dst_pos = cache_name_pos(dst, strlen(dst)); + int dst_pos = index_name_pos(&the_index, dst, + strlen(dst)); struct cache_entry *dst_ce = the_index.cache[dst_pos]; dst_ce->ce_flags &= ~CE_SKIP_WORKTREE; @@ -500,7 +501,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix) !(mode & SPARSE) && !path_in_sparse_checkout(dst, &the_index)) { /* from in-cone to out-of-cone */ - int dst_pos = cache_name_pos(dst, strlen(dst)); + int dst_pos = index_name_pos(&the_index, dst, + strlen(dst)); struct cache_entry *dst_ce = the_index.cache[dst_pos]; /* diff --git a/builtin/update-index.c b/builtin/update-index.c index 82d5902cc8b..bf38885d546 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -3,7 +3,7 @@ * * Copyright (C) Linus Torvalds, 2005 */ -#define USE_THE_INDEX_COMPATIBILITY_MACROS +#define USE_THE_INDEX_VARIABLE #include "cache.h" #include "bulk-checkin.h" #include "config.h" @@ -381,7 +381,7 @@ static int process_path(const char *path, struct stat *st, int stat_errno) if (has_symlink_leading_path(path, len)) return error("'%s' is beyond a symbolic link", path); - pos = cache_name_pos(path, len); + pos = index_name_pos(&the_index, path, len); ce = pos < 0 ? NULL : the_index.cache[pos]; if (ce && ce_skip_worktree(ce)) { /* diff --git a/cache.h b/cache.h index 9de988574e0..4c79e732e45 100644 --- a/cache.h +++ b/cache.h @@ -440,7 +440,6 @@ extern struct index_state the_index; #ifdef USE_THE_INDEX_COMPATIBILITY_MACROS #define read_cache() repo_read_index(the_repository) #define discard_cache() discard_index(&the_index) -#define cache_name_pos(name, namelen) index_name_pos(&the_index,(name),(namelen)) #endif #endif #endif diff --git a/contrib/coccinelle/index-compatibility.cocci b/contrib/coccinelle/index-compatibility.cocci index 028ff53354a..1d37546fdbd 100644 --- a/contrib/coccinelle/index-compatibility.cocci +++ b/contrib/coccinelle/index-compatibility.cocci @@ -91,6 +91,9 @@ identifier ACT = active_cache_tree; | - resolve_undo_clear + resolve_undo_clear_index +| +- cache_name_pos ++ index_name_pos ) ( + &the_index, diff --git a/contrib/coccinelle/index-compatibility.pending.cocci b/contrib/coccinelle/index-compatibility.pending.cocci index 01f875d0060..ecf3b45deca 100644 --- a/contrib/coccinelle/index-compatibility.pending.cocci +++ b/contrib/coccinelle/index-compatibility.pending.cocci @@ -15,9 +15,6 @@ ( - discard_cache + discard_index -| -- cache_name_pos -+ index_name_pos ) ( + &the_index, From patchwork Thu Dec 15 09:59:03 2022 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: 13074062 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 004F7C4332F for ; Thu, 15 Dec 2022 09:59:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230150AbiLOJ71 (ORCPT ); Thu, 15 Dec 2022 04:59:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230155AbiLOJ7P (ORCPT ); Thu, 15 Dec 2022 04:59:15 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75A851A818 for ; Thu, 15 Dec 2022 01:59:14 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id h7so2474196wrs.6 for ; Thu, 15 Dec 2022 01:59:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=97J33TpXZ86EbbZiJ5gp7zqhHnQEL1Z75hIZgJKmU0Q=; b=RldsHXdXlSLBgWXF+DMbFO61Br7MlInLr0wvcMpbPcvhQ4a6ZShfV+JSgnzi53X2uK ZTDAOKPbSlHGDfSyixpjr856BrlOPeUkYQQcWLZwpQUT4CAs3hq/KltNd1+sblan/CB3 uEUV29QQD5jcGVhn6ZJalqKv9WGtA6kOyBoOClladlSUsTz0Nckyfb5vhwJWTsIAS0n+ qUmOFRZz8veMSaUnA29X7iZGLa1jX1hqtEQjRKwxO+tfLZPKHC3KCEvBgeZJxKMFAt1p tnDXr9HtWoyGbif+Kz1stQcVsDfI7wKy4wQfn/IW8bcxS075yBEeM4kILcSfiwSLJmpu 9AIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=97J33TpXZ86EbbZiJ5gp7zqhHnQEL1Z75hIZgJKmU0Q=; b=LtkHvqG7yidgDlwvWDKcMZfP5DHeE1HKDKW/mojlBA71/qRmIRYslL5qbIQC85ayp3 4tjPRRMxg1/evJK/7wO4K2J8QuxhFVOVStHXfjk0SwFNeH30gZ2+pUMJFPFso1HcPjQa la7dWhM4rLykBqNW/9C9UOEw5K1oQdcXYLjZCHqoAAtUgydOXNVw3EM73M+5UwO/JJHI eC71fFjHuaLZwwiQVZEpSvQycPeLEGP8jaq0LwaTiUnLTXTlYtTsa9TwvMswLxcYkhv5 Dpg2lT/A2iDIfDDY0XXqZASABJTrYGgYgcxKhJOemsrw01Vk9+CQCTPeAnsyJTPBeVOc jJ1g== X-Gm-Message-State: ANoB5pmJfuAVjr4MW8LCJszT4gyJbLDkMlyhliIim4K/Bf5G8PFJJ18P QYhzt3jawdXL3aE4+7wo/9pDllaVf3YpCw== X-Google-Smtp-Source: AA0mqf5ChW/lwFmEFXHLEmfsgoDJv/o23V5nqNIuTix7F1WmLwJZAmsidb7nPdjRIC6ojk9XQH8h+A== X-Received: by 2002:adf:d4c1:0:b0:242:6485:4cd7 with SMTP id w1-20020adfd4c1000000b0024264854cd7mr17576724wrk.1.1671098352376; Thu, 15 Dec 2022 01:59:12 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a13-20020adfe5cd000000b00228cbac7a25sm5495948wrn.64.2022.12.15.01.59.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 01:59:11 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Taylor Blau , Junio C Hamano , Phillip Wood , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= Subject: [PATCH 4/6] cocci & cache-tree.h: migrate "write_cache_as_tree" to "*_index_*" Date: Thu, 15 Dec 2022 10:59:03 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc2.1048.g0e5493b8d5b In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add a trivial rule for "write_cache_as_tree" to "index-compatibility.cocci", and apply it. This was left out of the rules added in 0e6550a2c63 (cocci: add a index-compatibility.pending.cocci, 2022-11-19) because this compatibility wrapper lived in "cache-tree.h", not "cache.h" But it's like the other "USE_THE_INDEX_COMPATIBILITY_MACROS", so let's migrate it too. The replacement of "USE_THE_INDEX_COMPATIBILITY_MACROS" here with "USE_THE_INDEX_VARIABLE" is a manual change on top, now that these files only use "&the_index", and don't need any compatibility macros (or functions). The wrapping of some argument lists is likewise manual, as coccinelle would otherwise give us overly long argument lists. The reason for putting the "O" in the cocci rule on the "-" and "+" lines is because I couldn't get correct whitespacing otherwise, i.e. I'd end up with "oid,&the_index", not "oid, &the_index". Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/am.c | 6 +++--- builtin/merge.c | 2 +- builtin/stash.c | 11 +++++++---- builtin/write-tree.c | 5 +++-- cache-tree.h | 5 ----- contrib/coccinelle/index-compatibility.cocci | 11 +++++++++++ 6 files changed, 25 insertions(+), 15 deletions(-) diff --git a/builtin/am.c b/builtin/am.c index 30c9b3a9cd7..0e2e86fe3d1 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -3,7 +3,7 @@ * * Based on git-am.sh by Junio C Hamano. */ -#define USE_THE_INDEX_COMPATIBILITY_MACROS +#define USE_THE_INDEX_VARIABLE #include "cache.h" #include "config.h" #include "builtin.h" @@ -1643,7 +1643,7 @@ static void do_commit(const struct am_state *state) if (run_hooks("pre-applypatch")) exit(1); - if (write_cache_as_tree(&tree, 0, NULL)) + if (write_index_as_tree(&tree, &the_index, get_index_file(), 0, NULL)) die(_("git write-tree failed to write a tree")); if (!get_oid_commit("HEAD", &parent)) { @@ -2051,7 +2051,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem if (fast_forward_to(head_tree, head_tree, 1)) return -1; - if (write_cache_as_tree(&index, 0, NULL)) + if (write_index_as_tree(&index, &the_index, get_index_file(), 0, NULL)) return -1; index_tree = parse_tree_indirect(&index); diff --git a/builtin/merge.c b/builtin/merge.c index ecccd5e9119..ad2e4114617 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -706,7 +706,7 @@ static int read_tree_trivial(struct object_id *common, struct object_id *head, static void write_tree_trivial(struct object_id *oid) { - if (write_cache_as_tree(oid, 0, NULL)) + if (write_index_as_tree(oid, &the_index, get_index_file(), 0, NULL)) die(_("git write-tree failed to write a tree")); } diff --git a/builtin/stash.c b/builtin/stash.c index bb0fd861434..ba5d4c6c516 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -1,4 +1,4 @@ -#define USE_THE_INDEX_COMPATIBILITY_MACROS +#define USE_THE_INDEX_VARIABLE #include "builtin.h" #include "config.h" #include "parse-options.h" @@ -528,7 +528,8 @@ static int do_apply_stash(const char *prefix, struct stash_info *info, NULL, NULL, NULL)) return -1; - if (write_cache_as_tree(&c_tree, 0, NULL)) + if (write_index_as_tree(&c_tree, &the_index, get_index_file(), 0, + NULL)) return error(_("cannot apply a stash in the middle of a merge")); if (index) { @@ -552,7 +553,8 @@ static int do_apply_stash(const char *prefix, struct stash_info *info, discard_index(&the_index); repo_read_index(the_repository); - if (write_cache_as_tree(&index_tree, 0, NULL)) + if (write_index_as_tree(&index_tree, &the_index, + get_index_file(), 0, NULL)) return error(_("could not save index tree")); reset_head(); @@ -1377,7 +1379,8 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b strbuf_addf(&commit_tree_label, "index on %s\n", msg.buf); commit_list_insert(head_commit, &parents); - if (write_cache_as_tree(&info->i_tree, 0, NULL) || + if (write_index_as_tree(&info->i_tree, &the_index, get_index_file(), 0, + NULL) || commit_tree(commit_tree_label.buf, commit_tree_label.len, &info->i_tree, parents, &info->i_commit, NULL, NULL)) { if (!quiet) diff --git a/builtin/write-tree.c b/builtin/write-tree.c index 45d61707e7d..078010315f0 100644 --- a/builtin/write-tree.c +++ b/builtin/write-tree.c @@ -3,7 +3,7 @@ * * Copyright (C) Linus Torvalds, 2005 */ -#define USE_THE_INDEX_COMPATIBILITY_MACROS +#define USE_THE_INDEX_VARIABLE #include "builtin.h" #include "cache.h" #include "config.h" @@ -38,7 +38,8 @@ int cmd_write_tree(int argc, const char **argv, const char *cmd_prefix) argc = parse_options(argc, argv, cmd_prefix, write_tree_options, write_tree_usage, 0); - ret = write_cache_as_tree(&oid, flags, tree_prefix); + ret = write_index_as_tree(&oid, &the_index, get_index_file(), flags, + tree_prefix); switch (ret) { case 0: printf("%s\n", oid_to_hex(&oid)); diff --git a/cache-tree.h b/cache-tree.h index 8efeccebfc9..84890c9ff32 100644 --- a/cache-tree.h +++ b/cache-tree.h @@ -55,11 +55,6 @@ void prime_cache_tree(struct repository *, struct index_state *, struct tree *); int cache_tree_matches_traversal(struct cache_tree *, struct name_entry *ent, struct traverse_info *info); #ifdef USE_THE_INDEX_COMPATIBILITY_MACROS -static inline int write_cache_as_tree(struct object_id *oid, int flags, const char *prefix) -{ - return write_index_as_tree(oid, &the_index, get_index_file(), flags, prefix); -} - static inline int update_main_cache_tree(int flags) { if (!the_index.cache_tree) diff --git a/contrib/coccinelle/index-compatibility.cocci b/contrib/coccinelle/index-compatibility.cocci index 1d37546fdbd..e245d805dcd 100644 --- a/contrib/coccinelle/index-compatibility.cocci +++ b/contrib/coccinelle/index-compatibility.cocci @@ -135,3 +135,14 @@ identifier ACT = active_cache_tree; ... + , NULL, NULL, NULL ) + +@@ +expression O; +@@ +- write_cache_as_tree ++ write_index_as_tree + ( +- O, ++ O, &the_index, get_index_file(), + ... + ) From patchwork Thu Dec 15 09:59:04 2022 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: 13074063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5163C4332F for ; Thu, 15 Dec 2022 09:59:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230054AbiLOJ7a (ORCPT ); Thu, 15 Dec 2022 04:59:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230159AbiLOJ7Q (ORCPT ); Thu, 15 Dec 2022 04:59:16 -0500 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 2A09C2C118 for ; Thu, 15 Dec 2022 01:59:15 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id co23so2479999wrb.4 for ; Thu, 15 Dec 2022 01:59:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oOeJygt9Hlxa3hm9n6OxMSt1rLNYevxtuwPO1P8L/Yo=; b=WZwrPvxB0oIrAp12b9xkUM0PPEdoUVh0lPfp9rZUkcvcpva177RZLhE/v2LKf3QCky zuxqRYm7dIKSDxyTu2DGB14KjYPCG3w9Vcm+5RN/4zngnUkeC/nKunCD2Sr1ETGpUJKw iIdub4uLOWtyu7f9g1ARQEtLT5g3S3uteZlOq6fQg3YFwau1EkI9g1S3HtOBwKUsjnMG n3hXp61eu6d1gax4lFsuIuiVyjmB+HKyFmnaRfUGaH6ZvItgUDZurPGTYT0CxW0qaEQ7 fyVxFhFbHjtT0gorWK0ccOwGqaEIeDlXSbtpLdooA3QCCWlfyn31SPzfpmQ1WNUBTOoA Kbeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oOeJygt9Hlxa3hm9n6OxMSt1rLNYevxtuwPO1P8L/Yo=; b=YFWu3shGGHQ1oYlJE4pCkH/uvapBMeD9BMyUp3lcWzJ4mqKgKsnZAsMsfICk8xSOZK 0Pfk0eDD+DsUFiwnBqh9VkMfRsSoJLjSXaYJnEsDb3e1B3VbAeGlkmuO8O1U82ErYpDE zQjDHyMH1Uqz6XYCMfiPfjX+Timiy1hY2VDaOh94bG+/8NWbbr6IrzZHpSJuNs3EUVpK NneDJpVx/u1JXBrlQ5p5/iWfhf2TKbyIMPU35U8VRWEF/33PwmpeqFPmCd2d4RSNFEVX oWHMJufeJtkSl/8r4EytSQu2j8+CY9CIpi8ALs9eY16k/xU9N72LSqQz6S5QPF2qaiDn ZiQg== X-Gm-Message-State: ANoB5pmW5LPwZv3cSN0Gc2ZayRrMT4tgmmodrLOQJZRWBX9QQtArqKrh r9wGf+TRyTwjvhDYSo6tR9V8DbjM/IG7Mg== X-Google-Smtp-Source: AA0mqf6IDgSZ1FXriun1kNSRwGtX9c959Meyb459NgCVRnlFnF/qUiOcSqFR5SiAPWXQ3SAz7ats3Q== X-Received: by 2002:adf:f407:0:b0:242:fdb0:3eaa with SMTP id g7-20020adff407000000b00242fdb03eaamr23158049wro.30.1671098353357; Thu, 15 Dec 2022 01:59:13 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a13-20020adfe5cd000000b00228cbac7a25sm5495948wrn.64.2022.12.15.01.59.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 01:59:12 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Taylor Blau , Junio C Hamano , Phillip Wood , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= Subject: [PATCH 5/6] cache-tree API: remove redundant update_main_cache_tree() Date: Thu, 15 Dec 2022 10:59:04 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc2.1048.g0e5493b8d5b In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove the redundant update_main_cache_tree() function, and make its users use cache_tree_update() instead. The behavior of populating the "the_index.cache_tree" if it wasn't present already was needed when this function was introduced in [1], but it hasn't been needed since [2]; The "cache_tree_update()" will now lazy-allocate, so there's no need for the wrapper. 1. 996277c5206 (Refactor cache_tree_update idiom from commit, 2011-12-06) 2. fb0882648e0 (cache-tree: clean up cache_tree_update(), 2021-01-23) Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/commit.c | 10 +++++----- cache-tree.h | 10 ---------- contrib/coccinelle/index-compatibility.cocci | 3 +++ 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index 57a95123dff..31fbbd73d16 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -414,7 +414,7 @@ static const char *prepare_index(const char **argv, const char *prefix, discard_index(&the_index); read_index_from(&the_index, get_lock_file_path(&index_lock), get_git_dir()); - if (update_main_cache_tree(WRITE_TREE_SILENT) == 0) { + if (cache_tree_update(&the_index, WRITE_TREE_SILENT) == 0) { if (reopen_lock_file(&index_lock) < 0) die(_("unable to write index file")); if (write_locked_index(&the_index, &index_lock, 0)) @@ -444,7 +444,7 @@ static const char *prepare_index(const char **argv, const char *prefix, LOCK_DIE_ON_ERROR); add_files_to_cache(also ? prefix : NULL, &pathspec, 0); refresh_cache_or_die(refresh_flags); - update_main_cache_tree(WRITE_TREE_SILENT); + cache_tree_update(&the_index, WRITE_TREE_SILENT); if (write_locked_index(&the_index, &index_lock, 0)) die(_("unable to write new_index file")); commit_style = COMMIT_NORMAL; @@ -467,7 +467,7 @@ static const char *prepare_index(const char **argv, const char *prefix, refresh_cache_or_die(refresh_flags); if (the_index.cache_changed || !cache_tree_fully_valid(the_index.cache_tree)) - update_main_cache_tree(WRITE_TREE_SILENT); + cache_tree_update(&the_index, WRITE_TREE_SILENT); if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK | SKIP_IF_UNCHANGED)) die(_("unable to write new_index file")); @@ -516,7 +516,7 @@ static const char *prepare_index(const char **argv, const char *prefix, repo_hold_locked_index(the_repository, &index_lock, LOCK_DIE_ON_ERROR); add_remove_files(&partial); refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL); - update_main_cache_tree(WRITE_TREE_SILENT); + cache_tree_update(&the_index, WRITE_TREE_SILENT); if (write_locked_index(&the_index, &index_lock, 0)) die(_("unable to write new_index file")); @@ -1079,7 +1079,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, } read_index_from(&the_index, index_file, get_git_dir()); - if (update_main_cache_tree(0)) { + if (cache_tree_update(&the_index, 0)) { error(_("Error building trees")); return 0; } diff --git a/cache-tree.h b/cache-tree.h index 84890c9ff32..bd97caa07b0 100644 --- a/cache-tree.h +++ b/cache-tree.h @@ -53,14 +53,4 @@ int write_index_as_tree(struct object_id *oid, struct index_state *index_state, void prime_cache_tree(struct repository *, struct index_state *, struct tree *); int cache_tree_matches_traversal(struct cache_tree *, struct name_entry *ent, struct traverse_info *info); - -#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS -static inline int update_main_cache_tree(int flags) -{ - if (!the_index.cache_tree) - the_index.cache_tree = cache_tree(); - return cache_tree_update(&the_index, flags); -} -#endif - #endif diff --git a/contrib/coccinelle/index-compatibility.cocci b/contrib/coccinelle/index-compatibility.cocci index e245d805dcd..9fca870162d 100644 --- a/contrib/coccinelle/index-compatibility.cocci +++ b/contrib/coccinelle/index-compatibility.cocci @@ -94,6 +94,9 @@ identifier ACT = active_cache_tree; | - cache_name_pos + index_name_pos +| +- update_main_cache_tree ++ cache_tree_update ) ( + &the_index, From patchwork Thu Dec 15 09:59:05 2022 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: 13074064 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24753C4332F for ; Thu, 15 Dec 2022 09:59:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230191AbiLOJ7e (ORCPT ); Thu, 15 Dec 2022 04:59:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230078AbiLOJ7Q (ORCPT ); Thu, 15 Dec 2022 04:59:16 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F6C72C10C for ; Thu, 15 Dec 2022 01:59:15 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id m14so2459131wrh.7 for ; Thu, 15 Dec 2022 01:59:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3gpJRb6RvovGVlU0vuffMsaczaAyW8HumArCfl1H5lo=; b=lzaBNBrYxlsxVg+FovBYA4sMUxcBln8bcPq62iVyUt6qXsHwMjX9EGEPYaOqG+Adav 6dbgHA/rzDmU9VK8nTHhODFSfJuQ4zqGS41D6lOeg1mIfliUxHCHzJ30ieiHQiWsapl1 HYz+D3QMWS6gPtevTPZvTbTb4uT5BK06jXovuXqRLABA6L6pWLVHTi4R8e1kETZInM4A dYxDFvFyMvok4q+5hUvzogpqG8z+sASyT1yi/5CbSXmvFbQ1YMzBIpjbD2YcCeckU1sT LPpiQMVuaXCk3UOWun+Q2D+oaH9p2Zz0Nm5bREQm3J8XVhUtyIA8XRicpoJKWTj9k7TH zjEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3gpJRb6RvovGVlU0vuffMsaczaAyW8HumArCfl1H5lo=; b=2UhyblDuUb1lUb4Gh9k6YVYuOqmfzan3DlAtWUDIFOT99x5ww+OZM21QEX3O6BLZs3 IHVhYgyWqJ4PwNnvvQRFhvK6FJoChvgZd5EybdORyNwiGCJ0wGdNWnt16Jnl6/pLb0FC I2csy9aWyVSpsqL0W5y2vG+5T2GcAbuPA88QKTAJ8rEfb6+e4XrJAlpV2Se+xKbYAKRk gXps3jNbMmnMF1JNG8fckcNLi4nVWO7niai5tWadmGXx6MkPvmrpD3TtZm49pW8ve37A RBtbDCa+egAVVJzHWXOWCayprzP2H0BIYIw56sMAfV0A0bL3rPM0WQDTSDhI1FKHdAP2 aMIA== X-Gm-Message-State: ANoB5pmwgC71DYte50KRX4OEUw/91T4nrXjrjBoQrffYzP1dPlK4n7a+ MWaUgDL33CJfPnONzuVRvdBVX4DqNg4U2A== X-Google-Smtp-Source: AA0mqf7w1ntPrrd5YJMyu9x6KAqHmHojlxq5BX9grFygSxuyob52H49FrF0AZaqH8Cara25gJJF49w== X-Received: by 2002:a05:6000:1e02:b0:242:6aad:879e with SMTP id bj2-20020a0560001e0200b002426aad879emr18977061wrb.7.1671098354319; Thu, 15 Dec 2022 01:59:14 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a13-20020adfe5cd000000b00228cbac7a25sm5495948wrn.64.2022.12.15.01.59.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 01:59:13 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Taylor Blau , Junio C Hamano , Phillip Wood , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= Subject: [PATCH 6/6] cocci & cache.h: remove "USE_THE_INDEX_COMPATIBILITY_MACROS" Date: Thu, 15 Dec 2022 10:59:05 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.rc2.1048.g0e5493b8d5b In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Have the last users of "USE_THE_INDEX_COMPATIBILITY_MACROS" use the underlying *_index() variants instead. Now all previous users of "USE_THE_INDEX_COMPATIBILITY_MACROS" have been migrated away from the wrapper macros, and if applicable to use the "USE_THE_INDEX_VARIABLE" added in [1]. Let's leave the "index-compatibility.cocci" in place, even though it won't be doing anything on "master". It will benefit any out-of-tree code that need to use these compatibility macros. We can eventually remove it. 1. bdafeae0b9c (cache.h & test-tool.h: add & use "USE_THE_INDEX_VARIABLE", 2022-11-19) Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/commit.c | 6 +++--- builtin/merge.c | 6 +++--- cache.h | 9 +------- contrib/coccinelle/index-compatibility.cocci | 6 ++++++ .../index-compatibility.pending.cocci | 21 ------------------- 5 files changed, 13 insertions(+), 35 deletions(-) delete mode 100644 contrib/coccinelle/index-compatibility.pending.cocci diff --git a/builtin/commit.c b/builtin/commit.c index 31fbbd73d16..985a0445b78 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -5,7 +5,7 @@ * Based on git-commit.sh by Junio C Hamano and Linus Torvalds */ -#define USE_THE_INDEX_COMPATIBILITY_MACROS +#define USE_THE_INDEX_VARIABLE #include "cache.h" #include "config.h" #include "lockfile.h" @@ -992,8 +992,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix, const char *parent = "HEAD"; if (!the_index.cache_nr) { - discard_cache(); - if (read_cache() < 0) + discard_index(&the_index); + if (repo_read_index(the_repository) < 0) die(_("Cannot read index")); } diff --git a/builtin/merge.c b/builtin/merge.c index ad2e4114617..659fa10481e 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -6,7 +6,7 @@ * Based on git-merge.sh by Junio C Hamano. */ -#define USE_THE_INDEX_COMPATIBILITY_MACROS +#define USE_THE_INDEX_VARIABLE #include "cache.h" #include "config.h" #include "parse-options.h" @@ -390,8 +390,8 @@ static void restore_state(const struct object_id *head, run_command(&cmd); refresh_cache: - discard_cache(); - if (read_cache() < 0) + discard_index(&the_index); + if (repo_read_index(the_repository) < 0) die(_("could not read index")); } diff --git a/cache.h b/cache.h index 4c79e732e45..36bd5667334 100644 --- a/cache.h +++ b/cache.h @@ -433,15 +433,8 @@ typedef int (*must_prefetch_predicate)(const struct cache_entry *); void prefetch_cache_entries(const struct index_state *istate, must_prefetch_predicate must_prefetch); -#if defined(USE_THE_INDEX_COMPATIBILITY_MACROS) || defined(USE_THE_INDEX_VARIABLE) +#ifdef USE_THE_INDEX_VARIABLE extern struct index_state the_index; - -#ifndef USE_THE_INDEX_VARIABLE -#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS -#define read_cache() repo_read_index(the_repository) -#define discard_cache() discard_index(&the_index) -#endif -#endif #endif #define TYPE_BITS 3 diff --git a/contrib/coccinelle/index-compatibility.cocci b/contrib/coccinelle/index-compatibility.cocci index 9fca870162d..31e36cf3c41 100644 --- a/contrib/coccinelle/index-compatibility.cocci +++ b/contrib/coccinelle/index-compatibility.cocci @@ -23,6 +23,9 @@ identifier ACT = active_cache_tree; @@ @@ ( +- read_cache ++ repo_read_index +| - read_cache_unmerged + repo_read_index_unmerged | @@ -97,6 +100,9 @@ identifier ACT = active_cache_tree; | - update_main_cache_tree + cache_tree_update +| +- discard_cache ++ discard_index ) ( + &the_index, diff --git a/contrib/coccinelle/index-compatibility.pending.cocci b/contrib/coccinelle/index-compatibility.pending.cocci deleted file mode 100644 index ecf3b45deca..00000000000 --- a/contrib/coccinelle/index-compatibility.pending.cocci +++ /dev/null @@ -1,21 +0,0 @@ -// "the_repository" simple cases -@@ -@@ -( -- read_cache -+ repo_read_index -) - ( -+ the_repository, - ...) - -// "the_index" simple cases -@@ -@@ -( -- discard_cache -+ discard_index -) - ( -+ &the_index, - ...)