From patchwork Thu Feb 23 08:05:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13149916 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 1D5E3C636D7 for ; Thu, 23 Feb 2023 08:05:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233291AbjBWIFb (ORCPT ); Thu, 23 Feb 2023 03:05:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233241AbjBWIF2 (ORCPT ); Thu, 23 Feb 2023 03:05:28 -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 1CAFF43467 for ; Thu, 23 Feb 2023 00:05:26 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id l2-20020a05600c1d0200b003e1f6dff952so8943857wms.1 for ; Thu, 23 Feb 2023 00:05:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=KzX04it5y4U5u1z7dnjykdrOr76kSmwW89WHbeh+wac=; b=cMgHQYlp931Dos0YlA6aKkma8yXGlEQmHInOdXuWAqesaiaXvRch2BNxncjQ9/jhYh r4aXYK46s3Z8kJnqEdo2yvVIog7vDWLO0xwYUEs1fxQWSQ2EOy2SUaQXUxVfc6vyuObJ cm+Pkf+pyoYLYBLOYbu4xhBEHegQgvap22lV0q9RCt4+FGCzKFsqMOkMjssUYqW+ivBi RwN3Z2b44T9sic3NNM+CyyfcI2iSaiiWCoDGGhRA03XMkM5In9UNPW4tl1RpPr+GUxmw r3hpNgvGU546pVY7cR9kNcZxIonaTKIW8OPmCtUVrtSPWuwCjjCzjE8JW7JeDQCaGFvc 49wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KzX04it5y4U5u1z7dnjykdrOr76kSmwW89WHbeh+wac=; b=5yFL+O7TOAhUBtaougPF+BvFlNjpqOWO6RvPmkgOrLWmCVHeSFS6uZoawb7oIuKyND 3ImxvEGpD9FxjFvXqnBRScSIMWxlFmfKhOHcRT253rW6IQ5z8ruefNRs8xjLSIwcV81q xOIlKuB4YE6WY/abCgs+mIEt8mXu2y/itqm6Rz30Dir4QR7KsH74nClD+alETzGw2YOT B+MufStD1fyDQA552HplmrmXKPhTjor3bFuazZYmu0aI5j1Ac6JSVR8EUDgP29HHtoNR 7w89TxgKSe42CtGrK3nIWXWfx1+iOuwmr0qQCAcD3OVADROQHREi+xhJ0M/sWClwCbD5 gGUg== X-Gm-Message-State: AO0yUKWgcxJ2rOVj4QxA7XZXUU18I2BEm5gXEh3f1Ed+gzRpw6ivsGfN oYKlLeBkG+viP1OnrYO8SSo399Lb1TI= X-Google-Smtp-Source: AK7set/dxqeyun4qdrUZc60JSKQagcEFb0X+pW7clyBai+8iGsLkGNxBIIQjocvoEwZf+K3pq1J0Pw== X-Received: by 2002:a05:600c:1693:b0:3e2:1f00:bd02 with SMTP id k19-20020a05600c169300b003e21f00bd02mr4266426wmn.5.1677139524458; Thu, 23 Feb 2023 00:05:24 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id r8-20020a05600c458800b003db01178b62sm4022196wmo.40.2023.02.23.00.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:05:24 -0800 (PST) Message-Id: In-Reply-To: References: Date: Thu, 23 Feb 2023 08:05:06 +0000 Subject: [PATCH 01/16] treewide: ensure one of the appropriate headers is sourced first Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren We had several C files ignoring the rule to include one of the appropriate headers first; fix that. While at it, the rule in Documentation/CodingGuidelines about which header to include has also fallen out of sync, so update the wording to mention other allowed headers. Unfortunately, C files in reftable/ don't actually follow the previous or updated rule. If you follow the #include chain in its C files, reftable/system.h _tends_ to be first (i.e. record.c first includes record.h, which first includes basics.h, which first includees system.h), but not always (e.g. publicbasics.c includes another header first that does not include system.h). However, I'm going to punt on making actual changes to the C files in reftable/ since I do not want to risk bringing it out-of-sync with any version being used externally. Signed-off-by: Elijah Newren --- Documentation/CodingGuidelines | 8 ++++++-- cbtree.c | 1 + diff-merges.c | 1 + fmt-merge-msg.c | 1 + oidtree.c | 1 + oss-fuzz/fuzz-commit-graph.c | 1 + oss-fuzz/fuzz-pack-headers.c | 1 + oss-fuzz/fuzz-pack-idx.c | 1 + prune-packed.c | 1 + rebase.c | 1 + refs/debug.c | 2 +- sub-process.c | 1 + 12 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines index 9d5c27807a4..003393ed161 100644 --- a/Documentation/CodingGuidelines +++ b/Documentation/CodingGuidelines @@ -442,8 +442,12 @@ For C programs: detail. - The first #include in C files, except in platform specific compat/ - implementations, must be either "git-compat-util.h", "cache.h" or - "builtin.h". You do not have to include more than one of these. + implementations and sha1dc/, must be either "git-compat-util.h" or + one of the approved headers that includes it first for you. (The + approved headers currently include "cache.h", "builtin.h", + "t/helper/test-tool.h", "xdiff/xinclude.h", or + "reftable/system.h"). You do not have to include more than one of + these. - A C file must directly include the header files that declare the functions and the types it uses, except for the functions and types diff --git a/cbtree.c b/cbtree.c index 336e46dbba5..c1cc30a5dc7 100644 --- a/cbtree.c +++ b/cbtree.c @@ -4,6 +4,7 @@ * Based on Adam Langley's adaptation of Dan Bernstein's public domain code * git clone https://github.com/agl/critbit.git */ +#include "git-compat-util.h" #include "cbtree.h" static struct cb_node *cb_node_of(const void *p) diff --git a/diff-merges.c b/diff-merges.c index 85cbefa5afd..faa7bc73a34 100644 --- a/diff-merges.c +++ b/diff-merges.c @@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "diff-merges.h" #include "revision.h" diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c index f48f44f9cd1..f317f129904 100644 --- a/fmt-merge-msg.c +++ b/fmt-merge-msg.c @@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "config.h" #include "refs.h" #include "object-store.h" diff --git a/oidtree.c b/oidtree.c index 0d39389bee2..7d57b7b19e3 100644 --- a/oidtree.c +++ b/oidtree.c @@ -2,6 +2,7 @@ * A wrapper around cbtree which stores oids * May be used to replace oid-array for prefix (abbreviation) matches */ +#include "git-compat-util.h" #include "oidtree.h" #include "alloc.h" #include "hash.h" diff --git a/oss-fuzz/fuzz-commit-graph.c b/oss-fuzz/fuzz-commit-graph.c index 914026f5d80..2992079dd97 100644 --- a/oss-fuzz/fuzz-commit-graph.c +++ b/oss-fuzz/fuzz-commit-graph.c @@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "commit-graph.h" #include "repository.h" diff --git a/oss-fuzz/fuzz-pack-headers.c b/oss-fuzz/fuzz-pack-headers.c index 99da1d0fd38..150c0f5fa2d 100644 --- a/oss-fuzz/fuzz-pack-headers.c +++ b/oss-fuzz/fuzz-pack-headers.c @@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "packfile.h" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); diff --git a/oss-fuzz/fuzz-pack-idx.c b/oss-fuzz/fuzz-pack-idx.c index 0c3d777aac8..609a343ee3e 100644 --- a/oss-fuzz/fuzz-pack-idx.c +++ b/oss-fuzz/fuzz-pack-idx.c @@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "object-store.h" #include "packfile.h" diff --git a/prune-packed.c b/prune-packed.c index 261520b472c..d2813f6a405 100644 --- a/prune-packed.c +++ b/prune-packed.c @@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "object-store.h" #include "packfile.h" #include "progress.h" diff --git a/rebase.c b/rebase.c index 6775cddb284..17a570f1ff9 100644 --- a/rebase.c +++ b/rebase.c @@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "rebase.h" #include "config.h" #include "gettext.h" diff --git a/refs/debug.c b/refs/debug.c index eed8bc94b04..ff7766bc636 100644 --- a/refs/debug.c +++ b/refs/debug.c @@ -1,4 +1,4 @@ - +#include "git-compat-util.h" #include "refs-internal.h" #include "trace.h" diff --git a/sub-process.c b/sub-process.c index 6d4232294db..1daf5a97525 100644 --- a/sub-process.c +++ b/sub-process.c @@ -1,6 +1,7 @@ /* * Generic implementation of background process infrastructure. */ +#include "git-compat-util.h" #include "sub-process.h" #include "sigchain.h" #include "pkt-line.h" From patchwork Thu Feb 23 08:05:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13149917 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 AAC60C61DA4 for ; Thu, 23 Feb 2023 08:05:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232110AbjBWIFd (ORCPT ); Thu, 23 Feb 2023 03:05:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233018AbjBWIFa (ORCPT ); Thu, 23 Feb 2023 03:05:30 -0500 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 E24FD3D0A6 for ; Thu, 23 Feb 2023 00:05:26 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id i11so3745332wrp.5 for ; Thu, 23 Feb 2023 00:05:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=OahwylFSuFVh75SWtV1jtNAo8uK09U25UM+V+A1RSbI=; b=p3BOSy6cBb9ansZEHNBYgwZrQe1GVoEXFyAyzELeh7D6P5YQaZnZE06Wvqz+dD31Nn FFIiF040m/JeA4qkukqIzVFqxJVtwIup07C51ViyPBU+uPK8gWjwQqZqkEgAqeLsb5J/ WjmE+fhAhEuiZY7TbDsGiVyBazVGAlMbiQv9k2N/XbLRx5Z5CBrJWmHj/d5qfjlN9Yxf OXkAYm67w07ljt/dwdG4SBNcHG3+Gw2eDWUdjje91j2T3qSAz8Aa4BeY39X4Nf4CpHtI 6ZKDUSnlyzEgZuE12KduSAJzxbDXMSRJhmG6+pgmBo/FqVJ90inzXFcEtd1bFGJtpxIn M7EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OahwylFSuFVh75SWtV1jtNAo8uK09U25UM+V+A1RSbI=; b=eQgLTUloI/R4Q7RLJKn0aXjc8ll6K2W9kVMZr+B/8jWCVRrjiAuqBIhH5jTFO0OJZm rToYl0pvAyvBPziVxrz1B9mfhb8Zh8ZLJ9AMtZ2E0XfO/46t/UgxZUhvC2+4ezc2GvDr JD6SsRnAwVCs0qdRQchkovZEyX2K33ZCRhKCnTBpR9Uqt5Kb7TAXztQ1Wh60+Y+2zpDs rpaSw8QAyzxDZjqoZMe7K1HNr4TTGo6IIK7jNAaWuzUFWv5d9HxZsM8I6zALa3UYUItX X2B5HbWA5EWKyne9H8LqZlBum6GkN0rffTQS3hbYkkhl2x1b1CswA7HR0MbuPlCmYlSp i6sA== X-Gm-Message-State: AO0yUKUi43GpPX0DCFRa/s4eSIjPMU/sWfiJTyG/sFI6qUq05VfNA4uT XLSoKrCyypPRMu8G/Lkixqp0t4X2FCc= X-Google-Smtp-Source: AK7set8j8oxsLadNCmJMRGrs+8YTVgN5mBq06YyQabaV23UdOM4p7vpn/fMRVwxSaam8lR5rK0F8Nw== X-Received: by 2002:a05:6000:1cd:b0:2c5:8575:c37 with SMTP id t13-20020a05600001cd00b002c585750c37mr9779469wrx.66.1677139525168; Thu, 23 Feb 2023 00:05:25 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a22-20020a05600c225600b003e2058a7109sm10601092wmm.14.2023.02.23.00.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:05:24 -0800 (PST) Message-Id: In-Reply-To: References: Date: Thu, 23 Feb 2023 08:05:07 +0000 Subject: [PATCH 02/16] treewide: remove unnecessary git-compat-util.h includes in headers Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Since git-compat-util.h needs to be included first in C files, having it appear in header files is unnecessary. More importantly, having it included in header files seems to lead to folks leaving it out of C files, which makes it harder to verify that the rule is being followed. Remove it from header files, other than the ones that have been approved as alternate first includes. Signed-off-by: Elijah Newren --- advice.h | 2 -- cbtree.h | 2 -- chunk-format.h | 1 - commit-graph.h | 1 - commit-slab-impl.h | 2 -- compat/fsmonitor/fsm-ipc-win32.c | 1 + compat/fsmonitor/fsm-settings-darwin.c | 1 + hash.h | 1 - pack-mtimes.h | 2 -- pkt-line.h | 1 - repository.h | 1 - sub-process.h | 1 - trace.h | 1 - 13 files changed, 2 insertions(+), 15 deletions(-) diff --git a/advice.h b/advice.h index 07e0f76833e..3e1b48bf68d 100644 --- a/advice.h +++ b/advice.h @@ -1,8 +1,6 @@ #ifndef ADVICE_H #define ADVICE_H -#include "git-compat-util.h" - struct string_list; /* diff --git a/cbtree.h b/cbtree.h index 0be14fb7ee4..43193abdda2 100644 --- a/cbtree.h +++ b/cbtree.h @@ -14,8 +14,6 @@ #ifndef CBTREE_H #define CBTREE_H -#include "git-compat-util.h" - struct cb_node; struct cb_node { struct cb_node *child[2]; diff --git a/chunk-format.h b/chunk-format.h index 7885aa08487..025c38f938e 100644 --- a/chunk-format.h +++ b/chunk-format.h @@ -1,7 +1,6 @@ #ifndef CHUNK_FORMAT_H #define CHUNK_FORMAT_H -#include "git-compat-util.h" #include "hash.h" struct hashfile; diff --git a/commit-graph.h b/commit-graph.h index 37faee6b66d..bb88bec7aa3 100644 --- a/commit-graph.h +++ b/commit-graph.h @@ -1,7 +1,6 @@ #ifndef COMMIT_GRAPH_H #define COMMIT_GRAPH_H -#include "git-compat-util.h" #include "object-store.h" #include "oidset.h" diff --git a/commit-slab-impl.h b/commit-slab-impl.h index 557738df271..4a414ee905d 100644 --- a/commit-slab-impl.h +++ b/commit-slab-impl.h @@ -1,8 +1,6 @@ #ifndef COMMIT_SLAB_IMPL_H #define COMMIT_SLAB_IMPL_H -#include "git-compat-util.h" - #define implement_static_commit_slab(slabname, elemtype) \ implement_commit_slab(slabname, elemtype, MAYBE_UNUSED static) diff --git a/compat/fsmonitor/fsm-ipc-win32.c b/compat/fsmonitor/fsm-ipc-win32.c index e08c505c148..c9536dfb666 100644 --- a/compat/fsmonitor/fsm-ipc-win32.c +++ b/compat/fsmonitor/fsm-ipc-win32.c @@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "config.h" #include "fsmonitor-ipc.h" diff --git a/compat/fsmonitor/fsm-settings-darwin.c b/compat/fsmonitor/fsm-settings-darwin.c index 6abbc7af3ab..58b623fbb9a 100644 --- a/compat/fsmonitor/fsm-settings-darwin.c +++ b/compat/fsmonitor/fsm-settings-darwin.c @@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "config.h" #include "fsmonitor.h" #include "fsmonitor-ipc.h" diff --git a/hash.h b/hash.h index 36b64165fc9..351afc2ce3b 100644 --- a/hash.h +++ b/hash.h @@ -1,7 +1,6 @@ #ifndef HASH_H #define HASH_H -#include "git-compat-util.h" #include "repository.h" #if defined(SHA1_APPLE) diff --git a/pack-mtimes.h b/pack-mtimes.h index cc957b3e852..107327cec0b 100644 --- a/pack-mtimes.h +++ b/pack-mtimes.h @@ -1,8 +1,6 @@ #ifndef PACK_MTIMES_H #define PACK_MTIMES_H -#include "git-compat-util.h" - #define MTIMES_SIGNATURE 0x4d544d45 /* "MTME" */ #define MTIMES_VERSION 1 diff --git a/pkt-line.h b/pkt-line.h index 79c538b99e4..8e9846f3151 100644 --- a/pkt-line.h +++ b/pkt-line.h @@ -1,7 +1,6 @@ #ifndef PKTLINE_H #define PKTLINE_H -#include "git-compat-util.h" #include "strbuf.h" #include "sideband.h" diff --git a/repository.h b/repository.h index e8c67ffe165..15a8afc5fb5 100644 --- a/repository.h +++ b/repository.h @@ -1,7 +1,6 @@ #ifndef REPOSITORY_H #define REPOSITORY_H -#include "git-compat-util.h" #include "path.h" struct config_set; diff --git a/sub-process.h b/sub-process.h index e85f21fa1a7..6a61638a8ac 100644 --- a/sub-process.h +++ b/sub-process.h @@ -1,7 +1,6 @@ #ifndef SUBPROCESS_H #define SUBPROCESS_H -#include "git-compat-util.h" #include "hashmap.h" #include "run-command.h" diff --git a/trace.h b/trace.h index 4e771f86ac2..1a75824b15e 100644 --- a/trace.h +++ b/trace.h @@ -1,7 +1,6 @@ #ifndef TRACE_H #define TRACE_H -#include "git-compat-util.h" #include "strbuf.h" /** From patchwork Thu Feb 23 08:05:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13149918 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 CF003C636D7 for ; Thu, 23 Feb 2023 08:05:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233338AbjBWIFl (ORCPT ); Thu, 23 Feb 2023 03:05:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233249AbjBWIFa (ORCPT ); Thu, 23 Feb 2023 03:05:30 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0CAA34C2D for ; Thu, 23 Feb 2023 00:05:27 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id p26so7816921wmc.4 for ; Thu, 23 Feb 2023 00:05:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=8QwkNxqQ1aAfiwPys3A2H/JpmCw/ma/puEdHmDE3g0c=; b=SaSod6TRyPAg/wBmSFVJAaJyxdr3Eu2hppHrFZjLCIBRguqYQjFceIrg3NVC6hQwO5 UdWcR9dnFTXlNOQpA3IUNy8Tgg+bUcayXqwnLOFaEr9a4C/Ybdgy00HpdHzgX8wDWcsH /LJ32rBvaNqbfc0yE/HdlYcDOi8xjtIhwRc1tVfa7CnUwM4SooDx38jQoUU0bTUsruIa soozKKOWJeA6707zYvLV0vK8yX+cVLPwTwOSBu+JcSLVLtb1zw5Fakt5BpVR2l5ufNMJ PfMkUfrFdZk24KkxgAfb2+OBOvIH5JtVF3xm+BtoYnoJD7gu31bO/GEAAtTK+mmhKu+N puaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8QwkNxqQ1aAfiwPys3A2H/JpmCw/ma/puEdHmDE3g0c=; b=i/YisDDEFyySs/i29nB4A+lRuW43SKS6u6YP7oT64e02rnFn4Q2TXDiZIPmZb4I4dO +QFxvVnhhgAyRFgPxkr6QScY/kFoRS3cKwh1SS7JcpxY9qm9iixW/jxqj00hUlo/k07z gCBA2mfPLDFNwIbYVgxTe9IgJRMyCODlhpsNSgZ6ifWv46D80MQw1xkivY0AsCuAkKSY hHvWH+3ITQCSCed7mkTVypaIhCLqcdWf/YFBcMd+5vEQg+1RllANkQtAZRQ7e9cnHSzv ySRFFrqBXV1d4MQ6GuDlvlp0PsqQErVwgXOd5JUdkKzm63DUgq0npuwc+4y1LhsBYYNt 2ZwQ== X-Gm-Message-State: AO0yUKXXyBa7RAtg9UOAjqyQJDFNlR1r6esB/Dlz/glS29sZWDwnscfq 9lpNvhqxXCOC3GXAOGmX6m0j30xIc+4= X-Google-Smtp-Source: AK7set9xE/jzJwvtS9d7PmKNkyp0xdBuVR3fSSHUCuxBVKIiiqF1+p9bqWGpdFU3HGfMVvvqqkLDZw== X-Received: by 2002:a05:600c:b97:b0:3e2:22f9:c4b9 with SMTP id fl23-20020a05600c0b9700b003e222f9c4b9mr10122464wmb.4.1677139525852; Thu, 23 Feb 2023 00:05:25 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id i16-20020adfefd0000000b002c552c6c8c2sm7163775wrp.87.2023.02.23.00.05.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:05:25 -0800 (PST) Message-Id: <73d012f631a8a5f93ab0c016a759f03d92a9c96d.1677139521.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 23 Feb 2023 08:05:08 +0000 Subject: [PATCH 03/16] treewide: remove unnecessary cache.h includes Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren We had several header files include cache.h unnecessarily. Remove those. These have all been verified via both ensuring that gcc -E $HEADER | grep '"cache.h"' found no hits and that cat >temp.c < --- checkout.h | 2 +- entry.h | 4 +++- khash.h | 1 - oidmap.h | 1 - pretty.h | 2 +- reflog-walk.h | 2 -- refs/refs-internal.h | 1 - remote.h | 1 - sequencer.h | 2 +- xdiff-interface.h | 2 +- 10 files changed, 7 insertions(+), 11 deletions(-) diff --git a/checkout.h b/checkout.h index 1152133bd77..1917f3b3230 100644 --- a/checkout.h +++ b/checkout.h @@ -1,7 +1,7 @@ #ifndef CHECKOUT_H #define CHECKOUT_H -#include "cache.h" +#include "hash.h" /* * Check if the branch name uniquely matches a branch name on a remote diff --git a/entry.h b/entry.h index 2d4fbb88c8f..7329f918a97 100644 --- a/entry.h +++ b/entry.h @@ -1,9 +1,11 @@ #ifndef ENTRY_H #define ENTRY_H -#include "cache.h" #include "convert.h" +struct cache_entry; +struct index_state; + struct checkout { struct index_state *istate; const char *base_dir; diff --git a/khash.h b/khash.h index cb79bf88567..85362718c56 100644 --- a/khash.h +++ b/khash.h @@ -26,7 +26,6 @@ #ifndef __AC_KHASH_H #define __AC_KHASH_H -#include "cache.h" #include "hashmap.h" #define AC_VERSION_KHASH_H "0.2.8" diff --git a/oidmap.h b/oidmap.h index c66a83ab1d6..c1642927fa6 100644 --- a/oidmap.h +++ b/oidmap.h @@ -1,7 +1,6 @@ #ifndef OIDMAP_H #define OIDMAP_H -#include "cache.h" #include "hashmap.h" /* diff --git a/pretty.h b/pretty.h index f34e24c53a4..9508c22f030 100644 --- a/pretty.h +++ b/pretty.h @@ -1,11 +1,11 @@ #ifndef PRETTY_H #define PRETTY_H -#include "cache.h" #include "date.h" #include "string-list.h" struct commit; +struct repository; struct strbuf; struct process_trailer_options; diff --git a/reflog-walk.h b/reflog-walk.h index 8076f10d9fb..4d93a269571 100644 --- a/reflog-walk.h +++ b/reflog-walk.h @@ -1,8 +1,6 @@ #ifndef REFLOG_WALK_H #define REFLOG_WALK_H -#include "cache.h" - struct commit; struct reflog_walk_info; struct date_mode; diff --git a/refs/refs-internal.h b/refs/refs-internal.h index 69f93b0e2ac..a85d113123c 100644 --- a/refs/refs-internal.h +++ b/refs/refs-internal.h @@ -1,7 +1,6 @@ #ifndef REFS_REFS_INTERNAL_H #define REFS_REFS_INTERNAL_H -#include "cache.h" #include "refs.h" #include "iterator.h" diff --git a/remote.h b/remote.h index 1ebbe42792e..5b38ee20b84 100644 --- a/remote.h +++ b/remote.h @@ -1,7 +1,6 @@ #ifndef REMOTE_H #define REMOTE_H -#include "cache.h" #include "parse-options.h" #include "hashmap.h" #include "refspec.h" diff --git a/sequencer.h b/sequencer.h index 3bcdfa1b586..33dbaf5b66d 100644 --- a/sequencer.h +++ b/sequencer.h @@ -1,11 +1,11 @@ #ifndef SEQUENCER_H #define SEQUENCER_H -#include "cache.h" #include "strbuf.h" #include "wt-status.h" struct commit; +struct index_state; struct repository; const char *git_path_commit_editmsg(void); diff --git a/xdiff-interface.h b/xdiff-interface.h index 4301a7eef27..3750794afe9 100644 --- a/xdiff-interface.h +++ b/xdiff-interface.h @@ -1,7 +1,7 @@ #ifndef XDIFF_INTERFACE_H #define XDIFF_INTERFACE_H -#include "cache.h" +#include "hash.h" #include "xdiff/xdiff.h" /* From patchwork Thu Feb 23 08:05:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13149919 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 CBADDC61DA4 for ; Thu, 23 Feb 2023 08:05:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230048AbjBWIFn (ORCPT ); Thu, 23 Feb 2023 03:05:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233018AbjBWIFe (ORCPT ); Thu, 23 Feb 2023 03:05:34 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3EB22DE57 for ; Thu, 23 Feb 2023 00:05:28 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id i11so3745387wrp.5 for ; Thu, 23 Feb 2023 00:05:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=66yT4IR/Kh5UEh3Fpk/pth6pxmHxbTQb/Jp9GIuHxMA=; b=XBtfkawVdXhQMDVHngcPaaNJ6XHmTu6qi+imYqDqMM6fd5tVRaRIwIVS46CbwTik/X l6sR7imylhx0zJjiOzsPnlsp/sb7SYuN1RTyAOL9uGDyNAz/8Px0akvaPYlPdb8ZCdWm sfT3DIulXCo53gdPa4kFtKg6E3ztwaM1oEgOVI2B0+HCMjiZkUVUmiissg1uN8o3BHf7 ps97nwny3qYqE+yDuVoPydtok/NAAhPzzbrTmcPc9+cSPAr25APsDwgtEGiC3eCYwiJN E9zPgcJyvPngNw62VeVOYSU5ktHWzrnIIDCUeCb2e9cFiP0cf1D3efPWK97rk+bpSROu YaNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=66yT4IR/Kh5UEh3Fpk/pth6pxmHxbTQb/Jp9GIuHxMA=; b=bsK9bTXGAkVSmGpQO+/rryI4wvZMUenuxOP0TxYN/EbRYTV2eN2DKyk1sJHD38X+p4 MD5XSYczP1LwZ3vOtlaAKUyznPK/y8DaFyuFO07rnwAgK7ccpSy7LbtRD6eUq/IyPp+A PHGPx7rN+C2h2SupnHkyeuYRpKEAmCyBOkPLGWC2kfX4OI2wAjHrk+wTT4KEh2+mR4OO Osu7rXZxWVKS6pRS2bk9ZBIfaG52cXEDj3phWVSt2uUZtYbPhN+TYJAxMSVpEm6oH0x0 tO63jtZ11ngTKWS6nupC92bOHnUuDJajfrDuWXSCdk0DwWdwR0L7NWPh97KPZLQMKdZO mCfg== X-Gm-Message-State: AO0yUKXQQ+2d/Buo4EWoZ5wYZUTCQZoIQZvYjYsE5DponMDRh/u8x95Q so6e5njSAECvTARH72X8EcWkjPgxaJI= X-Google-Smtp-Source: AK7set9XGFhHS6eTepVaaECN6f/uZZ74ngh7zJg5z2PELuJGSgnVKFKysbBedzsbboz3lK53HNxiZQ== X-Received: by 2002:adf:f2cf:0:b0:2c7:a3c:5b90 with SMTP id d15-20020adff2cf000000b002c70a3c5b90mr4707592wrp.9.1677139526694; Thu, 23 Feb 2023 00:05:26 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n30-20020a05600c3b9e00b003e206cc7237sm11727291wms.24.2023.02.23.00.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:05:26 -0800 (PST) Message-Id: In-Reply-To: References: Date: Thu, 23 Feb 2023 08:05:09 +0000 Subject: [PATCH 04/16] treewide: remove unnecessary cache.h includes in source files Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren We had several C files include cache.h unnecessarily. Replace those with an include of "git-compat-util.h" instead. Much like the previous commit, these have all been verified via both ensuring that gcc -E $SOURCE_FILE | grep '"cache.h"' found no hits and that make DEVELOPER=1 ${OBJECT_FILE_FOR_SOURCE_FILE} successfully compiles without warnings. Signed-off-by: Elijah Newren --- hashmap.c | 2 +- imap-send.c | 2 +- json-writer.c | 2 +- kwset.c | 2 +- levenshtein.c | 2 +- linear-assignment.c | 2 +- mem-pool.c | 2 +- oidmap.c | 2 +- repo-settings.c | 2 +- serve.c | 3 ++- shell.c | 2 +- t/helper/test-crontab.c | 1 - t/helper/test-ctype.c | 1 - t/helper/test-json-writer.c | 1 - t/helper/test-pcre2-config.c | 1 - t/helper/test-prio-queue.c | 1 - t/helper/test-run-command.c | 2 -- t/helper/test-sigchain.c | 1 - t/helper/test-simple-ipc.c | 3 ++- t/helper/test-wildmatch.c | 1 - thread-utils.c | 2 +- trace2.c | 3 ++- trace2/tr2_ctr.c | 2 +- trace2/tr2_tbuf.c | 2 +- trace2/tr2_tgt_event.c | 2 +- trace2/tr2_tgt_normal.c | 2 +- trace2/tr2_tgt_perf.c | 2 +- trace2/tr2_tmr.c | 3 ++- unix-stream-server.c | 2 +- 29 files changed, 25 insertions(+), 30 deletions(-) diff --git a/hashmap.c b/hashmap.c index cf5fea87eb0..ee45ef00852 100644 --- a/hashmap.c +++ b/hashmap.c @@ -1,7 +1,7 @@ /* * Generic implementation of hash-based key value mappings. */ -#include "cache.h" +#include "git-compat-util.h" #include "hashmap.h" #define FNV32_BASE ((unsigned int) 0x811c9dc5) diff --git a/imap-send.c b/imap-send.c index a50af56b827..93e9018439c 100644 --- a/imap-send.c +++ b/imap-send.c @@ -21,7 +21,7 @@ * along with this program; if not, see . */ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "credential.h" #include "exec-cmd.h" diff --git a/json-writer.c b/json-writer.c index f1cfd8fa8c6..005c820aa42 100644 --- a/json-writer.c +++ b/json-writer.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "json-writer.h" void jw_init(struct json_writer *jw) diff --git a/kwset.c b/kwset.c index 08aadf03117..4b14d4f86b8 100644 --- a/kwset.c +++ b/kwset.c @@ -32,7 +32,7 @@ String Matching: An Aid to Bibliographic Search," CACM June 1975, Vol. 18, No. 6, which describes the failure function used below. */ -#include "cache.h" +#include "git-compat-util.h" #include "kwset.h" #include "compat/obstack.h" diff --git a/levenshtein.c b/levenshtein.c index d2632690d51..fd8026fe201 100644 --- a/levenshtein.c +++ b/levenshtein.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "levenshtein.h" /* diff --git a/linear-assignment.c b/linear-assignment.c index ecffc09be6e..5416cbcf409 100644 --- a/linear-assignment.c +++ b/linear-assignment.c @@ -3,7 +3,7 @@ * algorithm for dense and sparse linear assignment problems. Computing, * 38(4), 325-340. */ -#include "cache.h" +#include "git-compat-util.h" #include "linear-assignment.h" #define COST(column, row) cost[(column) + column_count * (row)] diff --git a/mem-pool.c b/mem-pool.c index 599d8e895f8..c34846d176c 100644 --- a/mem-pool.c +++ b/mem-pool.c @@ -2,7 +2,7 @@ * Memory Pool implementation logic. */ -#include "cache.h" +#include "git-compat-util.h" #include "mem-pool.h" #define BLOCK_GROWTH_SIZE (1024 * 1024 - sizeof(struct mp_block)) diff --git a/oidmap.c b/oidmap.c index 49965fe8568..8c1a139c974 100644 --- a/oidmap.c +++ b/oidmap.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "oidmap.h" static int oidmap_neq(const void *hashmap_cmp_fn_data UNUSED, diff --git a/repo-settings.c b/repo-settings.c index 3dbd3f0e2ec..0a6c0b381fe 100644 --- a/repo-settings.c +++ b/repo-settings.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "repository.h" #include "midx.h" diff --git a/serve.c b/serve.c index cbf4a143cfe..d128822347d 100644 --- a/serve.c +++ b/serve.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "repository.h" #include "config.h" #include "pkt-line.h" @@ -8,6 +8,7 @@ #include "serve.h" #include "upload-pack.h" #include "bundle-uri.h" +#include "trace2.h" static int advertise_sid = -1; static int client_hash_algo = GIT_HASH_SHA1; diff --git a/shell.c b/shell.c index af0d7c734f8..5c67e7bd97e 100644 --- a/shell.c +++ b/shell.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "quote.h" #include "exec-cmd.h" #include "strbuf.h" diff --git a/t/helper/test-crontab.c b/t/helper/test-crontab.c index e6c1b1e22bb..597027a96e9 100644 --- a/t/helper/test-crontab.c +++ b/t/helper/test-crontab.c @@ -1,5 +1,4 @@ #include "test-tool.h" -#include "cache.h" /* * Usage: test-tool crontab -l| diff --git a/t/helper/test-ctype.c b/t/helper/test-ctype.c index 92c4c2313e7..d6c1a2ed09c 100644 --- a/t/helper/test-ctype.c +++ b/t/helper/test-ctype.c @@ -1,5 +1,4 @@ #include "test-tool.h" -#include "cache.h" static int rc; diff --git a/t/helper/test-json-writer.c b/t/helper/test-json-writer.c index 8c3edacc000..86887f53203 100644 --- a/t/helper/test-json-writer.c +++ b/t/helper/test-json-writer.c @@ -1,5 +1,4 @@ #include "test-tool.h" -#include "cache.h" #include "json-writer.h" static const char *expect_obj1 = "{\"a\":\"abc\",\"b\":42,\"c\":true}"; diff --git a/t/helper/test-pcre2-config.c b/t/helper/test-pcre2-config.c index 5258fdddba0..5d0b2a2e10f 100644 --- a/t/helper/test-pcre2-config.c +++ b/t/helper/test-pcre2-config.c @@ -1,5 +1,4 @@ #include "test-tool.h" -#include "cache.h" #include "grep.h" int cmd__pcre2_config(int argc, const char **argv) diff --git a/t/helper/test-prio-queue.c b/t/helper/test-prio-queue.c index 133b5e6f4ae..ac4c65d7056 100644 --- a/t/helper/test-prio-queue.c +++ b/t/helper/test-prio-queue.c @@ -1,5 +1,4 @@ #include "test-tool.h" -#include "cache.h" #include "prio-queue.h" static int intcmp(const void *va, const void *vb, void *data) diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c index 3ecb830f4a8..67b42ef50eb 100644 --- a/t/helper/test-run-command.c +++ b/t/helper/test-run-command.c @@ -9,8 +9,6 @@ */ #include "test-tool.h" -#include "git-compat-util.h" -#include "cache.h" #include "run-command.h" #include "strvec.h" #include "strbuf.h" diff --git a/t/helper/test-sigchain.c b/t/helper/test-sigchain.c index d013bccddae..d1cf7377b7c 100644 --- a/t/helper/test-sigchain.c +++ b/t/helper/test-sigchain.c @@ -1,5 +1,4 @@ #include "test-tool.h" -#include "cache.h" #include "sigchain.h" #define X(f) \ diff --git a/t/helper/test-simple-ipc.c b/t/helper/test-simple-ipc.c index 28365ff85b6..3d1436da598 100644 --- a/t/helper/test-simple-ipc.c +++ b/t/helper/test-simple-ipc.c @@ -3,13 +3,14 @@ */ #include "test-tool.h" -#include "cache.h" +#include "gettext.h" #include "strbuf.h" #include "simple-ipc.h" #include "parse-options.h" #include "thread-utils.h" #include "strvec.h" #include "run-command.h" +#include "trace2.h" #ifndef SUPPORTS_SIMPLE_IPC int cmd__simple_ipc(int argc, const char **argv) diff --git a/t/helper/test-wildmatch.c b/t/helper/test-wildmatch.c index 2c103d1824c..a95bb4da9b1 100644 --- a/t/helper/test-wildmatch.c +++ b/t/helper/test-wildmatch.c @@ -1,5 +1,4 @@ #include "test-tool.h" -#include "cache.h" int cmd__wildmatch(int argc, const char **argv) { diff --git a/thread-utils.c b/thread-utils.c index 53298456913..1f89ffab4c3 100644 --- a/thread-utils.c +++ b/thread-utils.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "thread-utils.h" #if defined(hpux) || defined(__hpux) || defined(_hpux) diff --git a/trace2.c b/trace2.c index 279bddf53b4..e8ba62c0c3d 100644 --- a/trace2.c +++ b/trace2.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "json-writer.h" #include "quote.h" @@ -6,6 +6,7 @@ #include "sigchain.h" #include "thread-utils.h" #include "version.h" +#include "trace.h" #include "trace2/tr2_cfg.h" #include "trace2/tr2_cmd_name.h" #include "trace2/tr2_ctr.h" diff --git a/trace2/tr2_ctr.c b/trace2/tr2_ctr.c index 483ca7c308f..b342d3b1a3c 100644 --- a/trace2/tr2_ctr.c +++ b/trace2/tr2_ctr.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "thread-utils.h" #include "trace2/tr2_tgt.h" #include "trace2/tr2_tls.h" diff --git a/trace2/tr2_tbuf.c b/trace2/tr2_tbuf.c index 2498482d9ad..c3b3822ed7e 100644 --- a/trace2/tr2_tbuf.c +++ b/trace2/tr2_tbuf.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "tr2_tbuf.h" void tr2_tbuf_local_time(struct tr2_tbuf *tb) diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c index 16f6332755e..9e7aab6d510 100644 --- a/trace2/tr2_tgt_event.c +++ b/trace2/tr2_tgt_event.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "json-writer.h" #include "run-command.h" diff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c index fbbef68dfc0..8672c2c2d04 100644 --- a/trace2/tr2_tgt_normal.c +++ b/trace2/tr2_tgt_normal.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "run-command.h" #include "quote.h" diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c index adae8032639..3f2b2d53118 100644 --- a/trace2/tr2_tgt_perf.c +++ b/trace2/tr2_tgt_perf.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "run-command.h" #include "quote.h" diff --git a/trace2/tr2_tmr.c b/trace2/tr2_tmr.c index 786762dfd26..31d0e4d1bd1 100644 --- a/trace2/tr2_tmr.c +++ b/trace2/tr2_tmr.c @@ -1,8 +1,9 @@ -#include "cache.h" +#include "git-compat-util.h" #include "thread-utils.h" #include "trace2/tr2_tgt.h" #include "trace2/tr2_tls.h" #include "trace2/tr2_tmr.h" +#include "trace.h" #define MY_MAX(a, b) ((a) > (b) ? (a) : (b)) #define MY_MIN(a, b) ((a) < (b) ? (a) : (b)) diff --git a/unix-stream-server.c b/unix-stream-server.c index efa2a207abc..22ac2373e07 100644 --- a/unix-stream-server.c +++ b/unix-stream-server.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "lockfile.h" #include "unix-socket.h" #include "unix-stream-server.h" From patchwork Thu Feb 23 08:05:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13149922 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 61BF5C636D7 for ; Thu, 23 Feb 2023 08:05:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233272AbjBWIFr (ORCPT ); Thu, 23 Feb 2023 03:05:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232115AbjBWIFk (ORCPT ); Thu, 23 Feb 2023 03:05:40 -0500 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 84AC03644E for ; Thu, 23 Feb 2023 00:05:29 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id t15so10020154wrz.7 for ; Thu, 23 Feb 2023 00:05:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=Yc45gmmqdesZwODmpUGo2qVQxJ9HhavkkZKwBpyEc+4=; b=aiBev12oTu7GyjjdsORfEUZb13Ji2T6AwF4j8nL/R73bXRnO58NDjNm4yfsm5R+9ZZ mHsfsskRtm3OP2Hpvip+3EVi7alb5GDNidUvuUv5W/OVekg15K/tv9JWZGl8cXjGUnJk hgpebV093OFTsuHP40uyiYdFp12h0uQ5BPyGPwHxXezK+cbib+3xGoYLMdNKZdpY7pig 4XbrSfbdC4uhSHvo0gTu2VkCLtK12r0QiguvhEEmlkBOVu3eIeabe6xFHUv/yP23xRI1 zDslGsdPVCVi6MAuSgIfMl9kbX/CtB1greDxCoyJLK5eVPFiHqBqF8st5E+NWUMpJwtD 0hzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Yc45gmmqdesZwODmpUGo2qVQxJ9HhavkkZKwBpyEc+4=; b=UszzIvgQvlAgsi6txjHV1m/duzWuoCgoQf1RuvKJQjiMT0wipLrjSSMm2HydYrcAUV BYqN2eI/5YXXrbKplBScjtWA7RgokaNSpubwUzGSc356UoudYEZ893wMJHQCCmbk2TZD NC+1EpTAouLGjbjQxoMwiZCAS/J4QGjdgJnL2u8TSHXB6PBJmA1cjP9fG9FaOXXAbav+ iTZosDartWd/mzDCk6UWjJs0MCYh201pzBjzsmA7kROfy/SBu1tnrneVvGiFH1ZUkmnq iQU6Jya/cB+162w8V+LbtU6VUM3lgWSPZHVhG7Hb17a9rEzxUfNukgMg1CPc/hmsOywU QFKA== X-Gm-Message-State: AO0yUKV8icyAnKKnrDgjxwk1pemJ422WoEDNOwYVlSZU/n59mkAMqMl5 aC2ZTDbcPgrr8fyi9GJJcxyaWugUe/I= X-Google-Smtp-Source: AK7set9LeSxWvJi2cBKhn5Vnr8HANrNwWtWAYAM+kEKSr2y2PvXXOvYrdqjBIAYslcqm32n6cZr2Ew== X-Received: by 2002:a05:6000:14e:b0:2bf:dcdc:afb8 with SMTP id r14-20020a056000014e00b002bfdcdcafb8mr9538452wrx.64.1677139527513; Thu, 23 Feb 2023 00:05:27 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d18-20020a5d6452000000b002c54f4d0f71sm10716839wrw.38.2023.02.23.00.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:05:27 -0800 (PST) Message-Id: In-Reply-To: References: Date: Thu, 23 Feb 2023 08:05:10 +0000 Subject: [PATCH 05/16] alloc.h: move ALLOC_GROW() functions from cache.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren This allows us to replace includes of cache.h with includes of the much smaller alloc.h in many places. Signed-off-by: Elijah Newren --- add-patch.c | 2 + alias.c | 4 +- alloc.h | 75 ++++++++++++++++++++++++++++++ apply.c | 1 + archive-tar.c | 3 +- archive.c | 3 +- attr.c | 1 + builtin/blame.c | 3 +- builtin/cat-file.c | 1 + builtin/checkout--worker.c | 1 + builtin/config.c | 2 +- builtin/credential-cache--daemon.c | 1 + builtin/fetch-pack.c | 1 + builtin/fsmonitor--daemon.c | 1 + builtin/grep.c | 1 + builtin/index-pack.c | 1 + builtin/log.c | 3 +- builtin/merge.c | 1 + builtin/mktree.c | 1 + builtin/mv.c | 1 + builtin/name-rev.c | 2 +- builtin/pack-objects.c | 2 +- builtin/repack.c | 2 +- builtin/rev-parse.c | 1 + builtin/revert.c | 3 +- builtin/rm.c | 1 + builtin/submodule--helper.c | 1 + bulk-checkin.c | 3 +- cache-tree.c | 3 +- cache.h | 75 ------------------------------ chunk-format.c | 3 +- commit-reach.c | 3 +- compat/mingw.c | 1 + config.c | 3 +- daemon.c | 1 + delta-islands.c | 3 +- diff.c | 1 + diffcore-rename.c | 1 + dir-iterator.c | 3 +- dir.c | 3 +- ewah/bitmap.c | 3 +- ewah/ewah_bitmap.c | 2 +- fetch-pack.c | 3 +- fmt-merge-msg.c | 1 + fsck.c | 3 +- fsmonitor-settings.c | 3 +- help.c | 3 +- http-backend.c | 3 +- line-log.c | 1 + list-objects-filter-options.c | 4 +- list-objects-filter.c | 1 + midx.c | 3 +- object-file.c | 3 +- oid-array.c | 3 +- pack-bitmap-write.c | 3 +- pack-bitmap.c | 3 +- pack-objects.c | 3 +- packfile.c | 3 +- parallel-checkout.c | 1 + pretty.c | 1 + prio-queue.c | 3 +- quote.c | 1 + read-cache.c | 1 + ref-filter.c | 5 +- reflog-walk.c | 3 +- refs.c | 3 +- refs/packed-backend.c | 3 +- refs/ref-cache.c | 3 +- refspec.c | 3 +- remote-curl.c | 3 +- remote.c | 3 +- rerere.c | 3 +- revision.c | 3 +- sequencer.c | 1 + server-info.c | 3 +- shallow.c | 3 +- sigchain.c | 3 +- sparse-index.c | 1 + split-index.c | 1 + strbuf.c | 3 +- string-list.c | 3 +- strvec.c | 3 +- submodule-config.c | 1 + submodule.c | 4 +- t/helper/test-reach.c | 2 +- trace2/tr2_tls.c | 4 +- trailer.c | 1 + transport.c | 4 +- tree-walk.c | 1 + userdiff.c | 4 +- worktree.c | 3 +- 91 files changed, 220 insertions(+), 134 deletions(-) diff --git a/add-patch.c b/add-patch.c index a86a92e1646..7fe6b66d866 100644 --- a/add-patch.c +++ b/add-patch.c @@ -1,5 +1,7 @@ #include "cache.h" #include "add-interactive.h" +#include "alloc.h" +#include "gettext.h" #include "strbuf.h" #include "run-command.h" #include "strvec.h" diff --git a/alias.c b/alias.c index 00abde08173..e814948ced3 100644 --- a/alias.c +++ b/alias.c @@ -1,6 +1,8 @@ -#include "cache.h" +#include "git-compat-util.h" #include "alias.h" +#include "alloc.h" #include "config.h" +#include "gettext.h" #include "string-list.h" struct config_alias_data { diff --git a/alloc.h b/alloc.h index 3f4a0ad310a..4312db4bd08 100644 --- a/alloc.h +++ b/alloc.h @@ -17,4 +17,79 @@ void *alloc_object_node(struct repository *r); struct alloc_state *allocate_alloc_state(void); void clear_alloc_state(struct alloc_state *s); +#define alloc_nr(x) (((x)+16)*3/2) + +/** + * Dynamically growing an array using realloc() is error prone and boring. + * + * Define your array with: + * + * - a pointer (`item`) that points at the array, initialized to `NULL` + * (although please name the variable based on its contents, not on its + * type); + * + * - an integer variable (`alloc`) that keeps track of how big the current + * allocation is, initialized to `0`; + * + * - another integer variable (`nr`) to keep track of how many elements the + * array currently has, initialized to `0`. + * + * Then before adding `n`th element to the item, call `ALLOC_GROW(item, n, + * alloc)`. This ensures that the array can hold at least `n` elements by + * calling `realloc(3)` and adjusting `alloc` variable. + * + * ------------ + * sometype *item; + * size_t nr; + * size_t alloc + * + * for (i = 0; i < nr; i++) + * if (we like item[i] already) + * return; + * + * // we did not like any existing one, so add one + * ALLOC_GROW(item, nr + 1, alloc); + * item[nr++] = value you like; + * ------------ + * + * You are responsible for updating the `nr` variable. + * + * If you need to specify the number of elements to allocate explicitly + * then use the macro `REALLOC_ARRAY(item, alloc)` instead of `ALLOC_GROW`. + * + * Consider using ALLOC_GROW_BY instead of ALLOC_GROW as it has some + * added niceties. + * + * DO NOT USE any expression with side-effect for 'x', 'nr', or 'alloc'. + */ +#define ALLOC_GROW(x, nr, alloc) \ + do { \ + if ((nr) > alloc) { \ + if (alloc_nr(alloc) < (nr)) \ + alloc = (nr); \ + else \ + alloc = alloc_nr(alloc); \ + REALLOC_ARRAY(x, alloc); \ + } \ + } while (0) + +/* + * Similar to ALLOC_GROW but handles updating of the nr value and + * zeroing the bytes of the newly-grown array elements. + * + * DO NOT USE any expression with side-effect for any of the + * arguments. + */ +#define ALLOC_GROW_BY(x, nr, increase, alloc) \ + do { \ + if (increase) { \ + size_t new_nr = nr + (increase); \ + if (new_nr < nr) \ + BUG("negative growth in ALLOC_GROW_BY"); \ + ALLOC_GROW(x, new_nr, alloc); \ + memset((x) + nr, 0, sizeof(*(x)) * (increase)); \ + nr = new_nr; \ + } \ + } while (0) + #endif diff --git a/apply.c b/apply.c index 5cc5479c9c3..7f12ebf04c5 100644 --- a/apply.c +++ b/apply.c @@ -8,6 +8,7 @@ */ #include "cache.h" +#include "alloc.h" #include "config.h" #include "object-store.h" #include "blob.h" diff --git a/archive-tar.c b/archive-tar.c index f8fad2946ef..9406f03e804 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -1,7 +1,8 @@ /* * Copyright (c) 2005, 2006 Rene Scharfe */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "tar.h" #include "archive.h" diff --git a/archive.c b/archive.c index f2a8756d84f..35719e5e367 100644 --- a/archive.c +++ b/archive.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "refs.h" #include "object-store.h" diff --git a/attr.c b/attr.c index 1053dfcd4b6..657ee52229e 100644 --- a/attr.c +++ b/attr.c @@ -7,6 +7,7 @@ */ #include "cache.h" +#include "alloc.h" #include "config.h" #include "exec-cmd.h" #include "attr.h" diff --git a/builtin/blame.c b/builtin/blame.c index 71f925e456c..4d1609c9ac0 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -5,7 +5,8 @@ * See COPYING for licensing conditions */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "color.h" #include "builtin.h" diff --git a/builtin/cat-file.c b/builtin/cat-file.c index cc17635e765..5b8be7cb63b 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -5,6 +5,7 @@ */ #define USE_THE_INDEX_VARIABLE #include "cache.h" +#include "alloc.h" #include "config.h" #include "builtin.h" #include "diff.h" diff --git a/builtin/checkout--worker.c b/builtin/checkout--worker.c index ede7dc32a43..0a7d762573c 100644 --- a/builtin/checkout--worker.c +++ b/builtin/checkout--worker.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "alloc.h" #include "config.h" #include "entry.h" #include "parallel-checkout.h" diff --git a/builtin/config.c b/builtin/config.c index 060cf9f3e05..ca006e9cc15 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -1,5 +1,5 @@ #include "builtin.h" -#include "cache.h" +#include "alloc.h" #include "config.h" #include "color.h" #include "parse-options.h" diff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c index f3c89831d4a..590aefc6ead 100644 --- a/builtin/credential-cache--daemon.c +++ b/builtin/credential-cache--daemon.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "alloc.h" #include "parse-options.h" #ifndef NO_UNIX_SOCKETS diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c index afe679368de..113f22c09dd 100644 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "alloc.h" #include "pkt-line.h" #include "fetch-pack.h" #include "remote.h" diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c index 0feef8caf6d..cae804a1908 100644 --- a/builtin/fsmonitor--daemon.c +++ b/builtin/fsmonitor--daemon.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "alloc.h" #include "config.h" #include "parse-options.h" #include "fsmonitor.h" diff --git a/builtin/grep.c b/builtin/grep.c index f7821c5fbba..a08e5841ddb 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -4,6 +4,7 @@ * Copyright (c) 2006 Junio C Hamano */ #include "cache.h" +#include "alloc.h" #include "repository.h" #include "config.h" #include "blob.h" diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 6648f2daef5..7e4b69f9a3e 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "alloc.h" #include "config.h" #include "delta.h" #include "pack.h" diff --git a/builtin/log.c b/builtin/log.c index 04412dd9c93..85540963d95 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -4,7 +4,8 @@ * (C) Copyright 2006 Linus Torvalds * 2006 Junio Hamano */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "refs.h" #include "object-store.h" diff --git a/builtin/merge.c b/builtin/merge.c index 0a3c10a0966..716a23f880d 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -8,6 +8,7 @@ #define USE_THE_INDEX_VARIABLE #include "cache.h" +#include "alloc.h" #include "config.h" #include "parse-options.h" #include "builtin.h" diff --git a/builtin/mktree.c b/builtin/mktree.c index 06d81400f55..ec721ffb947 100644 --- a/builtin/mktree.c +++ b/builtin/mktree.c @@ -4,6 +4,7 @@ * Copyright (c) Junio C Hamano, 2006, 2009 */ #include "builtin.h" +#include "alloc.h" #include "quote.h" #include "tree.h" #include "parse-options.h" diff --git a/builtin/mv.c b/builtin/mv.c index edd7b931fdb..81290503775 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -5,6 +5,7 @@ */ #define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "alloc.h" #include "config.h" #include "pathspec.h" #include "lockfile.h" diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 97959bfaf9e..29752e7afe6 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -1,5 +1,5 @@ #include "builtin.h" -#include "cache.h" +#include "alloc.h" #include "repository.h" #include "config.h" #include "commit.h" diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 74a167a180c..72c33fd739a 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1,5 +1,5 @@ #include "builtin.h" -#include "cache.h" +#include "alloc.h" #include "repository.h" #include "config.h" #include "attr.h" diff --git a/builtin/repack.c b/builtin/repack.c index f6493795318..545b368168f 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -1,5 +1,5 @@ #include "builtin.h" -#include "cache.h" +#include "alloc.h" #include "config.h" #include "dir.h" #include "parse-options.h" diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index e67999e5ebc..fd4f59ff2b9 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -5,6 +5,7 @@ */ #define USE_THE_INDEX_VARIABLE #include "cache.h" +#include "alloc.h" #include "config.h" #include "commit.h" #include "refs.h" diff --git a/builtin/revert.c b/builtin/revert.c index 77d2035616e..62986a7b1b0 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "builtin.h" #include "parse-options.h" diff --git a/builtin/rm.c b/builtin/rm.c index 8844f906557..dc198f79082 100644 --- a/builtin/rm.c +++ b/builtin/rm.c @@ -5,6 +5,7 @@ */ #define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "alloc.h" #include "advice.h" #include "config.h" #include "lockfile.h" diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 4c173d8b37a..9edc785d8d2 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1,5 +1,6 @@ #define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "alloc.h" #include "repository.h" #include "cache.h" #include "config.h" diff --git a/bulk-checkin.c b/bulk-checkin.c index 855b68ec23b..62ed104c7e6 100644 --- a/bulk-checkin.c +++ b/bulk-checkin.c @@ -1,7 +1,8 @@ /* * Copyright (c) 2011, Google Inc. */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "bulk-checkin.h" #include "lockfile.h" #include "repository.h" diff --git a/cache-tree.c b/cache-tree.c index 88c2c04f87f..256f98c3c33 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "lockfile.h" #include "tree.h" #include "tree-walk.h" diff --git a/cache.h b/cache.h index 12789903e88..0f1f9dde56b 100644 --- a/cache.h +++ b/cache.h @@ -656,81 +656,6 @@ void initialize_repository_version(int hash_algo, int reinit); void sanitize_stdfds(void); int daemonize(void); -#define alloc_nr(x) (((x)+16)*3/2) - -/** - * Dynamically growing an array using realloc() is error prone and boring. - * - * Define your array with: - * - * - a pointer (`item`) that points at the array, initialized to `NULL` - * (although please name the variable based on its contents, not on its - * type); - * - * - an integer variable (`alloc`) that keeps track of how big the current - * allocation is, initialized to `0`; - * - * - another integer variable (`nr`) to keep track of how many elements the - * array currently has, initialized to `0`. - * - * Then before adding `n`th element to the item, call `ALLOC_GROW(item, n, - * alloc)`. This ensures that the array can hold at least `n` elements by - * calling `realloc(3)` and adjusting `alloc` variable. - * - * ------------ - * sometype *item; - * size_t nr; - * size_t alloc - * - * for (i = 0; i < nr; i++) - * if (we like item[i] already) - * return; - * - * // we did not like any existing one, so add one - * ALLOC_GROW(item, nr + 1, alloc); - * item[nr++] = value you like; - * ------------ - * - * You are responsible for updating the `nr` variable. - * - * If you need to specify the number of elements to allocate explicitly - * then use the macro `REALLOC_ARRAY(item, alloc)` instead of `ALLOC_GROW`. - * - * Consider using ALLOC_GROW_BY instead of ALLOC_GROW as it has some - * added niceties. - * - * DO NOT USE any expression with side-effect for 'x', 'nr', or 'alloc'. - */ -#define ALLOC_GROW(x, nr, alloc) \ - do { \ - if ((nr) > alloc) { \ - if (alloc_nr(alloc) < (nr)) \ - alloc = (nr); \ - else \ - alloc = alloc_nr(alloc); \ - REALLOC_ARRAY(x, alloc); \ - } \ - } while (0) - -/* - * Similar to ALLOC_GROW but handles updating of the nr value and - * zeroing the bytes of the newly-grown array elements. - * - * DO NOT USE any expression with side-effect for any of the - * arguments. - */ -#define ALLOC_GROW_BY(x, nr, increase, alloc) \ - do { \ - if (increase) { \ - size_t new_nr = nr + (increase); \ - if (new_nr < nr) \ - BUG("negative growth in ALLOC_GROW_BY"); \ - ALLOC_GROW(x, new_nr, alloc); \ - memset((x) + nr, 0, sizeof(*(x)) * (increase)); \ - nr = new_nr; \ - } \ - } while (0) - /* Initialize and use the cache information */ struct lock_file; void preload_index(struct index_state *index, diff --git a/chunk-format.c b/chunk-format.c index 0275b74a895..f65e9a1e429 100644 --- a/chunk-format.c +++ b/chunk-format.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "chunk-format.h" #include "csum-file.h" diff --git a/commit-reach.c b/commit-reach.c index 2e33c599a82..1f0ddc5c883 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "commit.h" #include "commit-graph.h" #include "decorate.h" diff --git a/compat/mingw.c b/compat/mingw.c index e433740381b..3afbde78944 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -7,6 +7,7 @@ #include "../strbuf.h" #include "../run-command.h" #include "../cache.h" +#include "../alloc.h" #include "win32/lazyload.h" #include "../config.h" #include "dir.h" diff --git a/config.c b/config.c index 00090a32fc3..1d22f232516 100644 --- a/config.c +++ b/config.c @@ -5,7 +5,8 @@ * Copyright (C) Johannes Schindelin, 2005 * */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "date.h" #include "branch.h" #include "config.h" diff --git a/daemon.c b/daemon.c index 0ae7d12b5c1..eb733d222fa 100644 --- a/daemon.c +++ b/daemon.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "alloc.h" #include "config.h" #include "pkt-line.h" #include "run-command.h" diff --git a/delta-islands.c b/delta-islands.c index 8b234cb85b0..1cfdc2cc040 100644 --- a/delta-islands.c +++ b/delta-islands.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "attr.h" #include "object.h" #include "blob.h" diff --git a/diff.c b/diff.c index 329eebf16a0..3c3565995d9 100644 --- a/diff.c +++ b/diff.c @@ -2,6 +2,7 @@ * Copyright (C) 2005 Junio C Hamano */ #include "cache.h" +#include "alloc.h" #include "config.h" #include "tempfile.h" #include "quote.h" diff --git a/diffcore-rename.c b/diffcore-rename.c index c0422d9e709..62c0299984e 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -3,6 +3,7 @@ * Copyright (C) 2005 Junio C Hamano */ #include "cache.h" +#include "alloc.h" #include "diff.h" #include "diffcore.h" #include "object-store.h" diff --git a/dir-iterator.c b/dir-iterator.c index 3764dd81a18..87364d68a2e 100644 --- a/dir-iterator.c +++ b/dir-iterator.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "dir.h" #include "iterator.h" #include "dir-iterator.h" diff --git a/dir.c b/dir.c index 4e99f0c868f..d3f1aeaca3b 100644 --- a/dir.c +++ b/dir.c @@ -5,7 +5,8 @@ * Copyright (C) Linus Torvalds, 2005-2006 * Junio Hamano, 2005-2006 */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "dir.h" #include "object-store.h" diff --git a/ewah/bitmap.c b/ewah/bitmap.c index ac618641632..12d6aa398e9 100644 --- a/ewah/bitmap.c +++ b/ewah/bitmap.c @@ -16,7 +16,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "ewok.h" #define EWAH_MASK(x) ((eword_t)1 << (x % BITS_IN_EWORD)) diff --git a/ewah/ewah_bitmap.c b/ewah/ewah_bitmap.c index 6fe48d3ae04..c6d4ffc87ca 100644 --- a/ewah/ewah_bitmap.c +++ b/ewah/ewah_bitmap.c @@ -17,9 +17,9 @@ * along with this program; if not, see . */ #include "git-compat-util.h" +#include "alloc.h" #include "ewok.h" #include "ewok_rlw.h" -#include "cache.h" static inline size_t min_size(size_t a, size_t b) { diff --git a/fetch-pack.c b/fetch-pack.c index 04016d1e325..271e2a6fbd6 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "repository.h" #include "config.h" #include "lockfile.h" diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c index f317f129904..d4d6fd3d9d9 100644 --- a/fmt-merge-msg.c +++ b/fmt-merge-msg.c @@ -1,4 +1,5 @@ #include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "refs.h" #include "object-store.h" diff --git a/fsck.c b/fsck.c index 2b18717ee80..20e1aac39a9 100644 --- a/fsck.c +++ b/fsck.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "object-store.h" #include "repository.h" #include "object.h" diff --git a/fsmonitor-settings.c b/fsmonitor-settings.c index 899bfe9c813..b62acf44aee 100644 --- a/fsmonitor-settings.c +++ b/fsmonitor-settings.c @@ -1,5 +1,6 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" +#include "gettext.h" #include "repository.h" #include "fsmonitor-ipc.h" #include "fsmonitor-settings.h" diff --git a/help.c b/help.c index 812af4cdea6..5f84a50b948 100644 --- a/help.c +++ b/help.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "builtin.h" #include "exec-cmd.h" diff --git a/http-backend.c b/http-backend.c index 8ab58e55f85..d756d120dc9 100644 --- a/http-backend.c +++ b/http-backend.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "repository.h" #include "refs.h" diff --git a/line-log.c b/line-log.c index a7f3e7f6ce4..4956eae748e 100644 --- a/line-log.c +++ b/line-log.c @@ -1,4 +1,5 @@ #include "git-compat-util.h" +#include "alloc.h" #include "line-range.h" #include "cache.h" #include "tag.h" diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c index ee01bcd2cc3..1d25a5737db 100644 --- a/list-objects-filter-options.c +++ b/list-objects-filter-options.c @@ -1,6 +1,8 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "commit.h" #include "config.h" +#include "gettext.h" #include "revision.h" #include "strvec.h" #include "list-objects.h" diff --git a/list-objects-filter.c b/list-objects-filter.c index 7ed21cb299c..e40ea9b0a8f 100644 --- a/list-objects-filter.c +++ b/list-objects-filter.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "alloc.h" #include "dir.h" #include "tag.h" #include "commit.h" diff --git a/midx.c b/midx.c index 7cfad04a240..84d7a53d66d 100644 --- a/midx.c +++ b/midx.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "csum-file.h" #include "dir.h" diff --git a/object-file.c b/object-file.c index 939865c1ae0..18d65220d70 100644 --- a/object-file.c +++ b/object-file.c @@ -6,7 +6,8 @@ * This handles basic git object files - packing, unpacking, * creation etc. */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "string-list.h" #include "lockfile.h" diff --git a/oid-array.c b/oid-array.c index 73ba76e9e9a..e8228c777b1 100644 --- a/oid-array.c +++ b/oid-array.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "oid-array.h" #include "hash-lookup.h" diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c index cfa67a510fd..155939e77b2 100644 --- a/pack-bitmap-write.c +++ b/pack-bitmap-write.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "object-store.h" #include "commit.h" #include "tag.h" diff --git a/pack-bitmap.c b/pack-bitmap.c index d2a42abf28c..5a978341200 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "commit.h" #include "strbuf.h" #include "tag.h" diff --git a/pack-objects.c b/pack-objects.c index 272e8d45173..ccab09fe654 100644 --- a/pack-objects.c +++ b/pack-objects.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "object.h" #include "pack.h" #include "pack-objects.h" diff --git a/packfile.c b/packfile.c index 79e21ab18e7..3e3063de445 100644 --- a/packfile.c +++ b/packfile.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "list.h" #include "pack.h" #include "repository.h" diff --git a/parallel-checkout.c b/parallel-checkout.c index 4f6819f2406..decdc8d8a1e 100644 --- a/parallel-checkout.c +++ b/parallel-checkout.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "alloc.h" #include "config.h" #include "entry.h" #include "parallel-checkout.h" diff --git a/pretty.c b/pretty.c index 1e1e21878c8..b6080844498 100644 --- a/pretty.c +++ b/pretty.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "alloc.h" #include "config.h" #include "commit.h" #include "utf8.h" diff --git a/prio-queue.c b/prio-queue.c index d31b48e7250..dc2476be53a 100644 --- a/prio-queue.c +++ b/prio-queue.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "prio-queue.h" static inline int compare(struct prio_queue *queue, int i, int j) diff --git a/quote.c b/quote.c index 26719d21d1e..2453397fbbd 100644 --- a/quote.c +++ b/quote.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "alloc.h" #include "quote.h" #include "strvec.h" diff --git a/read-cache.c b/read-cache.c index 35e5657877c..3cc8e312dce 100644 --- a/read-cache.c +++ b/read-cache.c @@ -4,6 +4,7 @@ * Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "alloc.h" #include "config.h" #include "diff.h" #include "diffcore.h" diff --git a/ref-filter.c b/ref-filter.c index f8203c6b052..c8230a08589 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -1,5 +1,5 @@ -#include "builtin.h" -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "parse-options.h" #include "refs.h" #include "wildmatch.h" @@ -13,7 +13,6 @@ #include "ref-filter.h" #include "revision.h" #include "utf8.h" -#include "git-compat-util.h" #include "version.h" #include "trailer.h" #include "wt-status.h" diff --git a/reflog-walk.c b/reflog-walk.c index 8a4d8fa3bd5..4ba1a10c82c 100644 --- a/reflog-walk.c +++ b/reflog-walk.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "commit.h" #include "refs.h" #include "diff.h" diff --git a/refs.c b/refs.c index e31dbcda599..f90f953551b 100644 --- a/refs.c +++ b/refs.c @@ -2,7 +2,8 @@ * The backend-independent part of the reference module. */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "hashmap.h" #include "lockfile.h" diff --git a/refs/packed-backend.c b/refs/packed-backend.c index 6f5a0709fba..186dcafcd00 100644 --- a/refs/packed-backend.c +++ b/refs/packed-backend.c @@ -1,4 +1,5 @@ -#include "../cache.h" +#include "../git-compat-util.h" +#include "../alloc.h" #include "../config.h" #include "../refs.h" #include "refs-internal.h" diff --git a/refs/ref-cache.c b/refs/ref-cache.c index 32afd8a40b0..dc1ca49c85f 100644 --- a/refs/ref-cache.c +++ b/refs/ref-cache.c @@ -1,4 +1,5 @@ -#include "../cache.h" +#include "../git-compat-util.h" +#include "../alloc.h" #include "../refs.h" #include "refs-internal.h" #include "ref-cache.h" diff --git a/refspec.c b/refspec.c index 63e3112104a..ec336ec5e9c 100644 --- a/refspec.c +++ b/refspec.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "strvec.h" #include "refs.h" #include "refspec.h" diff --git a/remote-curl.c b/remote-curl.c index a76b6405eb2..380ef3fccfb 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "remote.h" #include "connect.h" diff --git a/remote.c b/remote.c index 60869beebe7..daade49a6f6 100644 --- a/remote.c +++ b/remote.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "remote.h" #include "urlmatch.h" diff --git a/rerere.c b/rerere.c index 876ab435da9..d4bcb908531 100644 --- a/rerere.c +++ b/rerere.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "lockfile.h" #include "string-list.h" diff --git a/revision.c b/revision.c index 21f5f572c22..b8f925f088c 100644 --- a/revision.c +++ b/revision.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "object-store.h" #include "tag.h" diff --git a/sequencer.c b/sequencer.c index 65a34f9676c..fcf8740ce1c 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "alloc.h" #include "config.h" #include "lockfile.h" #include "dir.h" diff --git a/server-info.c b/server-info.c index 0ec6c0c1654..f07daa16f36 100644 --- a/server-info.c +++ b/server-info.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "dir.h" #include "repository.h" #include "refs.h" diff --git a/shallow.c b/shallow.c index 17f9bcdb5f3..7dc73fb8989 100644 --- a/shallow.c +++ b/shallow.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "repository.h" #include "tempfile.h" #include "lockfile.h" diff --git a/sigchain.c b/sigchain.c index 022677b6aba..ee778c0580b 100644 --- a/sigchain.c +++ b/sigchain.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "sigchain.h" #define SIGCHAIN_MAX_SIGNALS 32 diff --git a/sparse-index.c b/sparse-index.c index 147a13386a4..63216b3e57f 100644 --- a/sparse-index.c +++ b/sparse-index.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "alloc.h" #include "repository.h" #include "sparse-index.h" #include "tree.h" diff --git a/split-index.c b/split-index.c index 5d0f04763ea..95ecfa53195 100644 --- a/split-index.c +++ b/split-index.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "alloc.h" #include "split-index.h" #include "ewah/ewok.h" diff --git a/strbuf.c b/strbuf.c index c383f41a3c5..bc4c2c09e60 100644 --- a/strbuf.c +++ b/strbuf.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "refs.h" #include "string-list.h" #include "utf8.h" diff --git a/string-list.c b/string-list.c index 42bacaec55b..db473f273e1 100644 --- a/string-list.c +++ b/string-list.c @@ -1,5 +1,6 @@ -#include "cache.h" +#include "git-compat-util.h" #include "string-list.h" +#include "alloc.h" void string_list_init_nodup(struct string_list *list) { diff --git a/strvec.c b/strvec.c index 61a76ce6cb9..94d504e3805 100644 --- a/strvec.c +++ b/strvec.c @@ -1,5 +1,6 @@ -#include "cache.h" +#include "git-compat-util.h" #include "strvec.h" +#include "alloc.h" #include "strbuf.h" const char *empty_strvec[] = { NULL }; diff --git a/submodule-config.c b/submodule-config.c index 4dc61b3a78a..bb7c35fc317 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "alloc.h" #include "dir.h" #include "repository.h" #include "config.h" diff --git a/submodule.c b/submodule.c index 3a0dfc417c0..340ffad1c29 100644 --- a/submodule.c +++ b/submodule.c @@ -1,5 +1,5 @@ - -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "repository.h" #include "config.h" #include "submodule-config.h" diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c index 2f65c7f6a55..883d8e20a8e 100644 --- a/t/helper/test-reach.c +++ b/t/helper/test-reach.c @@ -1,5 +1,5 @@ #include "test-tool.h" -#include "cache.h" +#include "alloc.h" #include "commit.h" #include "commit-reach.h" #include "config.h" diff --git a/trace2/tr2_tls.c b/trace2/tr2_tls.c index 04900bb4c3a..9f46ae12f50 100644 --- a/trace2/tr2_tls.c +++ b/trace2/tr2_tls.c @@ -1,5 +1,7 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "thread-utils.h" +#include "trace.h" #include "trace2/tr2_tls.h" /* diff --git a/trailer.c b/trailer.c index 0fd5b142a37..72c3fed5c6e 100644 --- a/trailer.c +++ b/trailer.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "alloc.h" #include "config.h" #include "string-list.h" #include "run-command.h" diff --git a/transport.c b/transport.c index 77a61a9d7bb..ac9e06a6cea 100644 --- a/transport.c +++ b/transport.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "transport.h" #include "hook.h" @@ -10,6 +11,7 @@ #include "walker.h" #include "bundle.h" #include "dir.h" +#include "gettext.h" #include "refs.h" #include "refspec.h" #include "branch.h" diff --git a/tree-walk.c b/tree-walk.c index 74f4d710e8f..d22f3fe5b05 100644 --- a/tree-walk.c +++ b/tree-walk.c @@ -1,5 +1,6 @@ #include "cache.h" #include "tree-walk.h" +#include "alloc.h" #include "dir.h" #include "object-store.h" #include "tree.h" diff --git a/userdiff.c b/userdiff.c index 94cca1a2a8e..7f0ecbffbb5 100644 --- a/userdiff.c +++ b/userdiff.c @@ -1,7 +1,9 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "userdiff.h" #include "attr.h" +#include "strbuf.h" static struct userdiff_driver *drivers; static int ndrivers; diff --git a/worktree.c b/worktree.c index aa43c641191..c99939a4d1f 100644 --- a/worktree.c +++ b/worktree.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "repository.h" #include "refs.h" #include "strbuf.h" From patchwork Thu Feb 23 08:05:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13149920 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 83ED6C636D7 for ; Thu, 23 Feb 2023 08:05:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233226AbjBWIFp (ORCPT ); Thu, 23 Feb 2023 03:05:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233295AbjBWIFe (ORCPT ); Thu, 23 Feb 2023 03:05:34 -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 B82B64344D for ; Thu, 23 Feb 2023 00:05:29 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id i11so3745414wrp.5 for ; Thu, 23 Feb 2023 00:05:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=CHKMijW1eUPMPRyg2Q0Jq29ImqY0YEZawbk+GyMBAH4=; b=LUFSGsUH4LZSAfKPs5u/0hoJ0DjlczR9hgp9AJjGl3PQE3A0yVuwa2UAaU1wOqXoH0 2fcVRgY8LqxntYJAjiD0KsW/zI0D/lgX5oxT4i6nesrSzl9Ryb4vJItfzD2MLBY9pWbY YMrLXlSRJ8wdX7Rb8byS/xsRKui5sSQnZgaVkaAkVbzXhJUBTiNucd6ZQCvIzZmYYKZG 27f6euQvVpcHi8N9Krj8txS7XD8hFPsMaHHfzg4CPGNnYcbXTTg6F24ngPR44uuqDDnM vuE91OgnaRJmT0An4BWZgKMlUJOMgbr13g4923f8SkAft4wS3VPKMOT/zyiTjioZfIlM vb2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CHKMijW1eUPMPRyg2Q0Jq29ImqY0YEZawbk+GyMBAH4=; b=e/4fO09AlYu3GBApgDwrjAD6lX2UK0fxy1jGYl24fs4POYpBq8SNvyG2mE4+VR/caU +CCB1sgA0c64g39bz6ySbaTV8aFr09O1FnkJh0QuJxeed+eOncuht4pftspusUOWeTjQ CY6OAQhVyYOrs6K1z3p0UA5xsAkwdSsVsvNk0efhYM8Pbx2+6o6qjDaqQu9bRFk1uU/5 yFxdzNzHJNF1Jk8a/dnVsuvQpVUuezERg+wXm5uRtZuP5p7IQ403tXH/sUG4Vhit5svO hP0hJYCm8sJvA29KUrle6K0V3PgcTPbmiWvYptOrgZuiHZKynk7VOHXNEJr++jQTLNHC TxqA== X-Gm-Message-State: AO0yUKWIfqgxoFpVAskKBBoV0vhZE/APHg9INBmplLTU0aNS18TyrMAZ fNZrQrmhKevLvEvghlZ8BCj2UqTKRsg= X-Google-Smtp-Source: AK7set/16vn7dL0o5KTwRNfIsnjNnWv4swVvRJ7llXQrIf/cYDyYtA2V8julLxtud1iE2aa0h5TIUA== X-Received: by 2002:a5d:5912:0:b0:2c5:58aa:35cb with SMTP id v18-20020a5d5912000000b002c558aa35cbmr10054344wrd.47.1677139528161; Thu, 23 Feb 2023 00:05:28 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a9-20020a5d5709000000b002be099f78c0sm9762597wrv.69.2023.02.23.00.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:05:27 -0800 (PST) Message-Id: <9f78f0f215595d55ead4d82d20e1d0c9892171ec.1677139522.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 23 Feb 2023 08:05:11 +0000 Subject: [PATCH 06/16] hash.h: move some oid-related declarations from cache.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren These defines and enum are all oid-related and as such seem to make more sense being included in hash.h. Further, moving them there allows us to remove some includes of cache.h in other files. Signed-off-by: Elijah Newren --- cache.h | 34 -------------------- diffcore.h | 4 ++- hash.h | 34 ++++++++++++++++++++ line-log.h | 1 + submodule-config.h | 1 - t/helper/test-submodule-nested-repo-config.c | 1 + tree-walk.h | 4 ++- 7 files changed, 42 insertions(+), 37 deletions(-) diff --git a/cache.h b/cache.h index 0f1f9dde56b..daf6150bb3c 100644 --- a/cache.h +++ b/cache.h @@ -1363,40 +1363,6 @@ struct object_context { char *path; }; -#define GET_OID_QUIETLY 01 -#define GET_OID_COMMIT 02 -#define GET_OID_COMMITTISH 04 -#define GET_OID_TREE 010 -#define GET_OID_TREEISH 020 -#define GET_OID_BLOB 040 -#define GET_OID_FOLLOW_SYMLINKS 0100 -#define GET_OID_RECORD_PATH 0200 -#define GET_OID_ONLY_TO_DIE 04000 -#define GET_OID_REQUIRE_PATH 010000 - -#define GET_OID_DISAMBIGUATORS \ - (GET_OID_COMMIT | GET_OID_COMMITTISH | \ - GET_OID_TREE | GET_OID_TREEISH | \ - GET_OID_BLOB) - -enum get_oid_result { - FOUND = 0, - MISSING_OBJECT = -1, /* The requested object is missing */ - SHORT_NAME_AMBIGUOUS = -2, - /* The following only apply when symlinks are followed */ - DANGLING_SYMLINK = -4, /* - * The initial symlink is there, but - * (transitively) points to a missing - * in-tree file - */ - SYMLINK_LOOP = -5, - NOT_DIR = -6, /* - * Somewhere along the symlink chain, a path is - * requested which contains a file as a - * non-final element. - */ -}; - int repo_get_oid(struct repository *r, const char *str, struct object_id *oid); __attribute__((format (printf, 2, 3))) int get_oidf(struct object_id *oid, const char *fmt, ...); diff --git a/diffcore.h b/diffcore.h index 9b588a1ee15..1701ed50b9c 100644 --- a/diffcore.h +++ b/diffcore.h @@ -4,9 +4,11 @@ #ifndef DIFFCORE_H #define DIFFCORE_H -#include "cache.h" +#include "hash.h" struct diff_options; +struct mem_pool; +struct oid_array; struct repository; struct strintmap; struct strmap; diff --git a/hash.h b/hash.h index 351afc2ce3b..d39f73618cb 100644 --- a/hash.h +++ b/hash.h @@ -123,6 +123,40 @@ struct object_id { int algo; /* XXX requires 4-byte alignment */ }; +#define GET_OID_QUIETLY 01 +#define GET_OID_COMMIT 02 +#define GET_OID_COMMITTISH 04 +#define GET_OID_TREE 010 +#define GET_OID_TREEISH 020 +#define GET_OID_BLOB 040 +#define GET_OID_FOLLOW_SYMLINKS 0100 +#define GET_OID_RECORD_PATH 0200 +#define GET_OID_ONLY_TO_DIE 04000 +#define GET_OID_REQUIRE_PATH 010000 + +#define GET_OID_DISAMBIGUATORS \ + (GET_OID_COMMIT | GET_OID_COMMITTISH | \ + GET_OID_TREE | GET_OID_TREEISH | \ + GET_OID_BLOB) + +enum get_oid_result { + FOUND = 0, + MISSING_OBJECT = -1, /* The requested object is missing */ + SHORT_NAME_AMBIGUOUS = -2, + /* The following only apply when symlinks are followed */ + DANGLING_SYMLINK = -4, /* + * The initial symlink is there, but + * (transitively) points to a missing + * in-tree file + */ + SYMLINK_LOOP = -5, + NOT_DIR = -6, /* + * Somewhere along the symlink chain, a path is + * requested which contains a file as a + * non-final element. + */ +}; + /* A suitably aligned type for stack allocations of hash contexts. */ union git_hash_ctx { git_SHA_CTX sha1; diff --git a/line-log.h b/line-log.h index 82ae8d98a40..adff361b1bc 100644 --- a/line-log.h +++ b/line-log.h @@ -5,6 +5,7 @@ struct rev_info; struct commit; +struct string_list; /* A range [start,end]. Lines are numbered starting at 0, and the * ranges include start but exclude end. */ diff --git a/submodule-config.h b/submodule-config.h index 28a8ca6bf46..c2045875bbb 100644 --- a/submodule-config.h +++ b/submodule-config.h @@ -1,7 +1,6 @@ #ifndef SUBMODULE_CONFIG_CACHE_H #define SUBMODULE_CONFIG_CACHE_H -#include "cache.h" #include "config.h" #include "hashmap.h" #include "submodule.h" diff --git a/t/helper/test-submodule-nested-repo-config.c b/t/helper/test-submodule-nested-repo-config.c index dc1c14bde37..a3848a8b668 100644 --- a/t/helper/test-submodule-nested-repo-config.c +++ b/t/helper/test-submodule-nested-repo-config.c @@ -1,4 +1,5 @@ #include "test-tool.h" +#include "cache.h" #include "submodule-config.h" static void die_usage(const char **argv, const char *msg) diff --git a/tree-walk.h b/tree-walk.h index 6305d531503..25fe27e3529 100644 --- a/tree-walk.h +++ b/tree-walk.h @@ -1,7 +1,9 @@ #ifndef TREE_WALK_H #define TREE_WALK_H -#include "cache.h" +#include "hash.h" + +struct index_state; #define MAX_TRAVERSE_TREES 8 From patchwork Thu Feb 23 08:05:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13149921 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 99215C61DA4 for ; Thu, 23 Feb 2023 08:05:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233363AbjBWIFt (ORCPT ); Thu, 23 Feb 2023 03:05:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233224AbjBWIFl (ORCPT ); Thu, 23 Feb 2023 03:05:41 -0500 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 734E643467 for ; Thu, 23 Feb 2023 00:05:30 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id k37so4846656wms.0 for ; Thu, 23 Feb 2023 00:05:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=ZXQdDJPdCbRzie8PIOPazmdTtn6PMdJz2s3ttIu3+Qg=; b=iEqeAWoxHAl0mJJGT922pXxJIDv5J7mjyK7QQpAMZtoHQZspepopSuN95mTJE3sWQy RQMaUKqRFzKpRpnScVQGZYuy8JfcdXgfDZjBGg+Nt2eT9hMHz+zjApC+VG+9TmuZE24m SW2j7AfY4mBiPBJxV0mtMaGKmi+i9qGKCh29YLFOxd7abhuqNwDHUN34FaA9GDmqV8tK NhgOgpKGCjyUEqpRsQbEZVXKs4XUQghyFEIKMyyuHTxYSbtXcR+p46QDQWb7CehyguNw Zhylq4sRo0+pCLX240hXrmxVWzjRh55Co4YtkJXpF63/sAiPJzpwBNAmOyY+HbUFzTUd n5Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZXQdDJPdCbRzie8PIOPazmdTtn6PMdJz2s3ttIu3+Qg=; b=rmlbjREjBytWhCr41mTJJ7dHda7DG4czvHybkQCJYXJ9WK0RqyIUSUsJILYtCG47XS /1l7NpDupctfNNkvqd14URcMwRMNs3yVCfT0kQ2mTMUIFXfqVxH+3xuARQTiIc+8+KE+ 0grfnh034mM3BUyntbyJbTcjIlMwcoeH3mG0/Ofp7LoI+RMOSXrnx67ifnzZ1s6h/Nz8 HDNBFtOFKBSysZdarXwzoEJcfTyIzd7lZpuwUTj/hApExHp6t4ZYMXhDZsY+y4d8/ptc ZGIU16gmFEPaNFthJsBgv36at7R6jUkXAqyOsUGyDSHgqSD0BZkuoTTquwIwgULRSVkJ ZgeA== X-Gm-Message-State: AO0yUKVyLuw2xdUkqPSLY6pTTi3AlJxNrcubUteZ7J6EuzcnVbhN5jZH usVQxx7a7XQrViHfnLY7l92QZetbCP8= X-Google-Smtp-Source: AK7set/C0O2HCTIrYMVqKeUZQXtumdEp3VLJnbk+cAwMbSI8ecZ5oOle6QR1GWjogyicJG8UDNunOQ== X-Received: by 2002:a05:600c:2b45:b0:3df:85d2:c768 with SMTP id e5-20020a05600c2b4500b003df85d2c768mr8263663wmf.26.1677139528811; Thu, 23 Feb 2023 00:05:28 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t16-20020a5d5350000000b002c53cc7504csm6235755wrv.78.2023.02.23.00.05.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:05:28 -0800 (PST) Message-Id: In-Reply-To: References: Date: Thu, 23 Feb 2023 08:05:12 +0000 Subject: [PATCH 07/16] hex.h: move some hex-related declarations from cache.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren hex.c contains code for hex-related functions, but for some reason these functions were declared in the catch-all cache.h. Move the function declarations into a hex.h header instead. This also allows us to remove includes of cache.h from a few C files. Note that reviewing the header changes in this commit might be simplified via git log --no-walk -p --color-moved $COMMIT -- '*.h'` In particular, it highlights the simple movement of code in .h files rather nicely. Signed-off-by: Elijah Newren --- cache.h | 79 +------------------------------------------- git-compat-util.h | 1 + hex.c | 3 +- hex.h | 84 +++++++++++++++++++++++++++++++++++++++++++++++ mailinfo.c | 4 ++- oidset.c | 4 ++- wildmatch.c | 2 +- 7 files changed, 95 insertions(+), 82 deletions(-) create mode 100644 hex.h diff --git a/cache.h b/cache.h index daf6150bb3c..d0619ce2e63 100644 --- a/cache.h +++ b/cache.h @@ -13,6 +13,7 @@ #include "string-list.h" #include "pack-revindex.h" #include "hash.h" +#include "hex.h" #include "path.h" #include "oid-array.h" #include "repository.h" @@ -1325,22 +1326,6 @@ int finalize_object_file(const char *tmpfile, const char *filename); /* Helper to check and "touch" a file */ int check_and_freshen_file(const char *fn, int freshen); -extern const signed char hexval_table[256]; -static inline unsigned int hexval(unsigned char c) -{ - return hexval_table[c]; -} - -/* - * Convert two consecutive hexadecimal digits into a char. Return a - * negative value on error. Don't run over the end of short strings. - */ -static inline int hex2chr(const char *s) -{ - unsigned int val = hexval(s[0]); - return (val & ~0xf) ? val : (val << 4) | hexval(s[1]); -} - /* Convert to/from hex/sha1 representation */ #define MINIMUM_ABBREV minimum_abbrev #define DEFAULT_ABBREV default_abbrev @@ -1393,68 +1378,6 @@ int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_f int set_disambiguate_hint_config(const char *var, const char *value); -/* - * Try to read a SHA1 in hexadecimal format from the 40 characters - * starting at hex. Write the 20-byte result to sha1 in binary form. - * Return 0 on success. Reading stops if a NUL is encountered in the - * input, so it is safe to pass this function an arbitrary - * null-terminated string. - */ -int get_sha1_hex(const char *hex, unsigned char *sha1); -int get_oid_hex(const char *hex, struct object_id *sha1); - -/* Like get_oid_hex, but for an arbitrary hash algorithm. */ -int get_oid_hex_algop(const char *hex, struct object_id *oid, const struct git_hash_algo *algop); - -/* - * Read `len` pairs of hexadecimal digits from `hex` and write the - * values to `binary` as `len` bytes. Return 0 on success, or -1 if - * the input does not consist of hex digits). - */ -int hex_to_bytes(unsigned char *binary, const char *hex, size_t len); - -/* - * Convert a binary hash in "unsigned char []" or an object name in - * "struct object_id *" to its hex equivalent. The `_r` variant is reentrant, - * and writes the NUL-terminated output to the buffer `out`, which must be at - * least `GIT_MAX_HEXSZ + 1` bytes, and returns a pointer to out for - * convenience. - * - * The non-`_r` variant returns a static buffer, but uses a ring of 4 - * buffers, making it safe to make multiple calls for a single statement, like: - * - * printf("%s -> %s", hash_to_hex(one), hash_to_hex(two)); - * printf("%s -> %s", oid_to_hex(one), oid_to_hex(two)); - */ -char *hash_to_hex_algop_r(char *buffer, const unsigned char *hash, const struct git_hash_algo *); -char *oid_to_hex_r(char *out, const struct object_id *oid); -char *hash_to_hex_algop(const unsigned char *hash, const struct git_hash_algo *); /* static buffer result! */ -char *hash_to_hex(const unsigned char *hash); /* same static buffer */ -char *oid_to_hex(const struct object_id *oid); /* same static buffer */ - -/* - * Parse a 40-character hexadecimal object ID starting from hex, updating the - * pointer specified by end when parsing stops. The resulting object ID is - * stored in oid. Returns 0 on success. Parsing will stop on the first NUL or - * other invalid character. end is only updated on success; otherwise, it is - * unmodified. - */ -int parse_oid_hex(const char *hex, struct object_id *oid, const char **end); - -/* Like parse_oid_hex, but for an arbitrary hash algorithm. */ -int parse_oid_hex_algop(const char *hex, struct object_id *oid, const char **end, - const struct git_hash_algo *algo); - - -/* - * These functions work like get_oid_hex and parse_oid_hex, but they will parse - * a hex value for any algorithm. The algorithm is detected based on the length - * and the algorithm in use is returned. If this is not a hex object ID in any - * algorithm, returns GIT_HASH_UNKNOWN. - */ -int get_oid_hex_any(const char *hex, struct object_id *oid); -int parse_oid_hex_any(const char *hex, struct object_id *oid, const char **end); - /* * This reads short-hand syntax that not only evaluates to a commit * object name, but also can act as if the end user spelled the name diff --git a/git-compat-util.h b/git-compat-util.h index 4f0028ce60c..f77f986fbf1 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -1225,6 +1225,7 @@ extern const unsigned char tolower_trans_tbl[256]; #undef isxdigit extern const unsigned char sane_ctype[256]; +extern const signed char hexval_table[256]; #define GIT_SPACE 0x01 #define GIT_DIGIT 0x02 #define GIT_ALPHA 0x04 diff --git a/hex.c b/hex.c index 4f64d346963..0a1bddc1284 100644 --- a/hex.c +++ b/hex.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "hex.h" const signed char hexval_table[256] = { -1, -1, -1, -1, -1, -1, -1, -1, /* 00-07 */ diff --git a/hex.h b/hex.h new file mode 100644 index 00000000000..e2abfc56fae --- /dev/null +++ b/hex.h @@ -0,0 +1,84 @@ +#ifndef HEX_H +#define HEX_H + +#include "hash.h" + +extern const signed char hexval_table[256]; +static inline unsigned int hexval(unsigned char c) +{ + return hexval_table[c]; +} + +/* + * Convert two consecutive hexadecimal digits into a char. Return a + * negative value on error. Don't run over the end of short strings. + */ +static inline int hex2chr(const char *s) +{ + unsigned int val = hexval(s[0]); + return (val & ~0xf) ? val : (val << 4) | hexval(s[1]); +} + +/* + * Try to read a SHA1 in hexadecimal format from the 40 characters + * starting at hex. Write the 20-byte result to sha1 in binary form. + * Return 0 on success. Reading stops if a NUL is encountered in the + * input, so it is safe to pass this function an arbitrary + * null-terminated string. + */ +int get_sha1_hex(const char *hex, unsigned char *sha1); +int get_oid_hex(const char *hex, struct object_id *sha1); + +/* Like get_oid_hex, but for an arbitrary hash algorithm. */ +int get_oid_hex_algop(const char *hex, struct object_id *oid, const struct git_hash_algo *algop); + +/* + * Read `len` pairs of hexadecimal digits from `hex` and write the + * values to `binary` as `len` bytes. Return 0 on success, or -1 if + * the input does not consist of hex digits). + */ +int hex_to_bytes(unsigned char *binary, const char *hex, size_t len); + +/* + * Convert a binary hash in "unsigned char []" or an object name in + * "struct object_id *" to its hex equivalent. The `_r` variant is reentrant, + * and writes the NUL-terminated output to the buffer `out`, which must be at + * least `GIT_MAX_HEXSZ + 1` bytes, and returns a pointer to out for + * convenience. + * + * The non-`_r` variant returns a static buffer, but uses a ring of 4 + * buffers, making it safe to make multiple calls for a single statement, like: + * + * printf("%s -> %s", hash_to_hex(one), hash_to_hex(two)); + * printf("%s -> %s", oid_to_hex(one), oid_to_hex(two)); + */ +char *hash_to_hex_algop_r(char *buffer, const unsigned char *hash, const struct git_hash_algo *); +char *oid_to_hex_r(char *out, const struct object_id *oid); +char *hash_to_hex_algop(const unsigned char *hash, const struct git_hash_algo *); /* static buffer result! */ +char *hash_to_hex(const unsigned char *hash); /* same static buffer */ +char *oid_to_hex(const struct object_id *oid); /* same static buffer */ + +/* + * Parse a 40-character hexadecimal object ID starting from hex, updating the + * pointer specified by end when parsing stops. The resulting object ID is + * stored in oid. Returns 0 on success. Parsing will stop on the first NUL or + * other invalid character. end is only updated on success; otherwise, it is + * unmodified. + */ +int parse_oid_hex(const char *hex, struct object_id *oid, const char **end); + +/* Like parse_oid_hex, but for an arbitrary hash algorithm. */ +int parse_oid_hex_algop(const char *hex, struct object_id *oid, const char **end, + const struct git_hash_algo *algo); + + +/* + * These functions work like get_oid_hex and parse_oid_hex, but they will parse + * a hex value for any algorithm. The algorithm is detected based on the length + * and the algorithm in use is returned. If this is not a hex object ID in any + * algorithm, returns GIT_HASH_UNKNOWN. + */ +int get_oid_hex_any(const char *hex, struct object_id *oid); +int parse_oid_hex_any(const char *hex, struct object_id *oid, const char **end); + +#endif diff --git a/mailinfo.c b/mailinfo.c index 833d28612f7..9f1495ddcf1 100644 --- a/mailinfo.c +++ b/mailinfo.c @@ -1,5 +1,7 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" +#include "gettext.h" +#include "hex.h" #include "utf8.h" #include "strbuf.h" #include "mailinfo.h" diff --git a/oidset.c b/oidset.c index b36a2bae864..d1e5376316e 100644 --- a/oidset.c +++ b/oidset.c @@ -1,5 +1,7 @@ -#include "cache.h" +#include "git-compat-util.h" #include "oidset.h" +#include "hex.h" +#include "strbuf.h" void oidset_init(struct oidset *set, size_t initial_size) { diff --git a/wildmatch.c b/wildmatch.c index 7e5a7ea1eaa..42e38e34590 100644 --- a/wildmatch.c +++ b/wildmatch.c @@ -9,7 +9,7 @@ ** work differently than '*', and to fix the character-class code. */ -#include "cache.h" +#include "git-compat-util.h" #include "wildmatch.h" typedef unsigned char uchar; From patchwork Thu Feb 23 08:05:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13149924 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 495D2C6379F for ; Thu, 23 Feb 2023 08:06:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233454AbjBWIGA (ORCPT ); Thu, 23 Feb 2023 03:06:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233298AbjBWIFl (ORCPT ); Thu, 23 Feb 2023 03:05:41 -0500 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 5D16648E0F for ; Thu, 23 Feb 2023 00:05:31 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id t13so9841983wrv.13 for ; Thu, 23 Feb 2023 00:05:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=s4X8dIcN+pCagJlgAf6jZFO+KisEH6zY6nlgFheTPYw=; b=Jyy24hU+9EED0PxifpK+XRBMiD1K+AyHVEfjE10d0NiAyX/YeTnqiI/3BgtRipE0TS 3EGvXZMQfH2b6qUMqTfd2BWBCrVG2lj+ar9ttJEKMrmEpe6ffWiXdaqRY8trktcslpv6 iQP41P19izj1H7gt0uKwbWpEsb8Nw4YSIWX/B8eN4UOPz/QMl2yBRTdjbeYR3Xi9BtFb CFabJAYcdw96LbAUWprparzLr7lSuwXPLVmbdieNTzZ7t7LOariNvZS6EtgtAPsj8A/3 6niwptxPuTMhMokCJrPW9veTu9165HvRMXP56MafOZTWd3VvaQlFyrZLcFY1OF3BZMm4 uK7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s4X8dIcN+pCagJlgAf6jZFO+KisEH6zY6nlgFheTPYw=; b=6d47lkSjtZ9by1+PCN1efJ8oalXzv2LBpbShbPG3W9OROhECn6jx4y3MJy3QqUPKLe nYe+giHDBKMPx4m0wOKTf0LtsiND4rs9ervLHKRPf132HajMi9lXqVB5LBonUHN3pLq/ rcVdgmUKr/5ypIZTdphuy07EHnuh+cwtAAqWrRIvfb+nASuOgWaZPJ9b5FUgE+bXcJGW KSGmj0p+mKBBV7l5x6g3RqSVrdCZjwovZ3AF3ppYdeQCzz/vpjdX08zJhiZUYMXXPvSr wnFZeFYz48ZpYnd6yoBnqOgsn309TTgfH40wVA1mrilrPreCI+oDEGCoa0vnPuiIKfQm hgMA== X-Gm-Message-State: AO0yUKUOX0HeRNwWlWW4qULJEu2OE8ENkKaoO1D+sWYY/65JuaGjg+T/ j+6FIyQkJ+6ZR9tCmafQ9vbqcYzUV8A= X-Google-Smtp-Source: AK7set++20dqpm2YVMrEwbPY6oTxxVxEMRxvCZwL8qj6iyD9fwwg3UQXA3H4SJZojNPP73TT9J9caw== X-Received: by 2002:adf:cd8c:0:b0:2c5:4f2d:d9b4 with SMTP id q12-20020adfcd8c000000b002c54f2dd9b4mr8434295wrj.58.1677139529591; Thu, 23 Feb 2023 00:05:29 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 26-20020a05600c229a00b003de2fc8214esm10185103wmf.20.2023.02.23.00.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:05:29 -0800 (PST) Message-Id: In-Reply-To: References: Date: Thu, 23 Feb 2023 08:05:13 +0000 Subject: [PATCH 08/16] pretty.h: move has_non_ascii() declaration from commit.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren The function is defined in pretty.c, so this moves the declaration to a more logical place. Signed-off-by: Elijah Newren --- commit.h | 1 - diffcore-pickaxe.c | 4 ++-- pretty.h | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/commit.h b/commit.h index cc2c5da7bdb..06657b4c6e7 100644 --- a/commit.h +++ b/commit.h @@ -205,7 +205,6 @@ void free_commit_list(struct commit_list *list); struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */ -int has_non_ascii(const char *text); const char *logmsg_reencode(const struct commit *commit, char **commit_encoding, const char *output_encoding); diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c index 03fcbcb40ba..13c98a7b5e7 100644 --- a/diffcore-pickaxe.c +++ b/diffcore-pickaxe.c @@ -2,12 +2,12 @@ * Copyright (C) 2005 Junio C Hamano * Copyright (C) 2010 Google Inc. */ -#include "cache.h" +#include "git-compat-util.h" #include "diff.h" #include "diffcore.h" #include "xdiff-interface.h" #include "kwset.h" -#include "commit.h" +#include "pretty.h" #include "quote.h" typedef int (*pickaxe_fn)(mmfile_t *one, mmfile_t *two, diff --git a/pretty.h b/pretty.h index 9508c22f030..921dd6e0cae 100644 --- a/pretty.h +++ b/pretty.h @@ -153,6 +153,8 @@ int commit_format_is_empty(enum cmit_fmt); /* Make subject of commit message suitable for filename */ void format_sanitized_subject(struct strbuf *sb, const char *msg, size_t len); +int has_non_ascii(const char *text); + /* * Set values of fields in "struct process_trailer_options" * according to trailers arguments. From patchwork Thu Feb 23 08:05:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13149923 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 4F320C61DA4 for ; Thu, 23 Feb 2023 08:06:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233429AbjBWIF7 (ORCPT ); Thu, 23 Feb 2023 03:05:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233325AbjBWIFl (ORCPT ); Thu, 23 Feb 2023 03:05:41 -0500 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 E90A9474EB for ; Thu, 23 Feb 2023 00:05:30 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id i11so3745486wrp.5 for ; Thu, 23 Feb 2023 00:05:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=iWWm8CbRp9uMfCs48p03XwNCE2Dxkz76yt1Y40c/mqE=; b=EsyX1+Sv7/OTTpnfeVIIvddTgLwTd6o5EeWVcvt1OtJj5p8IfEKEZWluvrKHT2VS6O NL0I9OMGWysDT5dS5Jtn9QLaaxggcjFiuOisO7kAkqvtH1x7b2NcdOohmluweVobV4xn cHBQeCLEeVAfIzrhrktovkhH/EA9e0DbX/NVhIbxGq0iMbFlmDmAo11yqCfrcOoPf/77 TslwczNZetuwp7viOvam+onHCmJU4xWou7e6C3U5n+ohMch9D2JTJ/4jHsH+2VZumf3h vLrLWjQhISEIx2lFtgf0aqnvfAAwU46MZ4mx4qLolGCMJ+aWRM0lzADONcD5ExQs8bas wiug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iWWm8CbRp9uMfCs48p03XwNCE2Dxkz76yt1Y40c/mqE=; b=MR2P6ev/nkOtWFvexmdmUfKFftXk0NpzhEY9+elKb8of/a84Ffj85R4bZkL8Tb1zEc sRR/cjmVPBHZMqfs7fsp4QiqjGuj6mq3bFo/Fkv2v+DDCL2GQ6Q8YYkrCN/+cHgOQmbB E7ntlZnJ2LXN3+2DR3XtfmIzH1Y7WS0J2Ea7Icdb3ioJPvUfEtS4DPIP/cIzZYX2WPSW BsiIvljVYr3jipSefiPgkTCYU6EkNQ4cPlQ7iQfvPdgP2tRJRDkUJRsvvyF3bh6511a+ MKfrrsYMChyt9mv6Vhc+1hYfndwxvDQoNmlHTa4jh/GeFigfxPtGDczsacqeSqV3tfKV 7KCQ== X-Gm-Message-State: AO0yUKVmmrDBlZiHV3HbAL10lUP8u7pUnOuzwaJrfMeGs2JPf6WJGk7S w+xodSdU/GkXo59fXB+YZ8dxrThN3IM= X-Google-Smtp-Source: AK7set+w3lKJBw8inujnFZ/BmcTpsAdPlXmzfdbSPH4JPWPkLmMhirplrr+hXWgCOGV6biDJT72e4A== X-Received: by 2002:a5d:6549:0:b0:2c7:dad:5630 with SMTP id z9-20020a5d6549000000b002c70dad5630mr2869065wrv.27.1677139530179; Thu, 23 Feb 2023 00:05:30 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u11-20020adfdb8b000000b002c54fb024b2sm13080715wri.61.2023.02.23.00.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:05:29 -0800 (PST) Message-Id: <9fc48fe4844adb321817581999f593ef5c4201ac.1677139522.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 23 Feb 2023 08:05:14 +0000 Subject: [PATCH 09/16] ident.h: move ident-related declarations out of cache.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren These functions were all defined in a separate ident.c already, so create ident.h and move the declarations into that file. Signed-off-by: Elijah Newren --- builtin/cat-file.c | 1 + builtin/check-mailmap.c | 1 + builtin/config.c | 1 + builtin/var.c | 1 + cache.h | 58 ----------------------------------- config.c | 1 + gpg-interface.c | 1 + ident.c | 5 ++- ident.h | 67 +++++++++++++++++++++++++++++++++++++++++ refs/files-backend.c | 1 + revision.h | 1 + 11 files changed, 79 insertions(+), 59 deletions(-) create mode 100644 ident.h diff --git a/builtin/cat-file.c b/builtin/cat-file.c index 5b8be7cb63b..fe1b5bab05b 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -9,6 +9,7 @@ #include "config.h" #include "builtin.h" #include "diff.h" +#include "ident.h" #include "parse-options.h" #include "userdiff.h" #include "streaming.h" diff --git a/builtin/check-mailmap.c b/builtin/check-mailmap.c index 7dc47e47932..96db3ddb4bb 100644 --- a/builtin/check-mailmap.c +++ b/builtin/check-mailmap.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "config.h" +#include "ident.h" #include "mailmap.h" #include "parse-options.h" #include "string-list.h" diff --git a/builtin/config.c b/builtin/config.c index ca006e9cc15..49d832d4093 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -2,6 +2,7 @@ #include "alloc.h" #include "config.h" #include "color.h" +#include "ident.h" #include "parse-options.h" #include "urlmatch.h" #include "quote.h" diff --git a/builtin/var.c b/builtin/var.c index a80c1df86fd..d9943be9afd 100644 --- a/builtin/var.c +++ b/builtin/var.c @@ -5,6 +5,7 @@ */ #include "builtin.h" #include "config.h" +#include "ident.h" #include "refs.h" static const char var_usage[] = "git var (-l | )"; diff --git a/cache.h b/cache.h index d0619ce2e63..63ffd197a2a 100644 --- a/cache.h +++ b/cache.h @@ -1446,65 +1446,10 @@ struct object *repo_peel_to_type(struct repository *r, #define peel_to_type(name, namelen, obj, type) \ repo_peel_to_type(the_repository, name, namelen, obj, type) -#define IDENT_STRICT 1 -#define IDENT_NO_DATE 2 -#define IDENT_NO_NAME 4 - -enum want_ident { - WANT_BLANK_IDENT, - WANT_AUTHOR_IDENT, - WANT_COMMITTER_IDENT -}; - -const char *git_author_info(int); -const char *git_committer_info(int); -const char *fmt_ident(const char *name, const char *email, - enum want_ident whose_ident, - const char *date_str, int); -const char *fmt_name(enum want_ident); -const char *ident_default_name(void); -const char *ident_default_email(void); const char *git_editor(void); const char *git_sequence_editor(void); const char *git_pager(int stdout_is_tty); int is_terminal_dumb(void); -int git_ident_config(const char *, const char *, void *); -/* - * Prepare an ident to fall back on if the user didn't configure it. - */ -void prepare_fallback_ident(const char *name, const char *email); -void reset_ident_date(void); - -struct ident_split { - const char *name_begin; - const char *name_end; - const char *mail_begin; - const char *mail_end; - const char *date_begin; - const char *date_end; - const char *tz_begin; - const char *tz_end; -}; -/* - * Signals an success with 0, but time part of the result may be NULL - * if the input lacks timestamp and zone - */ -int split_ident_line(struct ident_split *, const char *, int); - -/* - * Given a commit or tag object buffer and the commit or tag headers, replaces - * the idents in the headers with their canonical versions using the mailmap mechanism. - */ -void apply_mailmap_to_header(struct strbuf *, const char **, struct string_list *); - -/* - * Compare split idents for equality or strict ordering. Note that we - * compare only the ident part of the line, ignoring any timestamp. - * - * Because there are two fields, we must choose one as the primary key; we - * currently arbitrarily pick the email. - */ -int ident_cmp(const struct ident_split *, const struct ident_split *); struct cache_def { struct strbuf path; @@ -1571,9 +1516,6 @@ int update_server_info(int); const char *get_log_output_encoding(void); const char *get_commit_output_encoding(void); -int committer_ident_sufficiently_given(void); -int author_ident_sufficiently_given(void); - extern const char *git_commit_encoding; extern const char *git_log_output_encoding; extern const char *git_mailmap_file; diff --git a/config.c b/config.c index 1d22f232516..d3ab9417a45 100644 --- a/config.c +++ b/config.c @@ -11,6 +11,7 @@ #include "branch.h" #include "config.h" #include "environment.h" +#include "ident.h" #include "repository.h" #include "lockfile.h" #include "exec-cmd.h" diff --git a/gpg-interface.c b/gpg-interface.c index 687236430bf..bd13fc92fef 100644 --- a/gpg-interface.c +++ b/gpg-interface.c @@ -4,6 +4,7 @@ #include "run-command.h" #include "strbuf.h" #include "dir.h" +#include "ident.h" #include "gpg-interface.h" #include "sigchain.h" #include "tempfile.h" diff --git a/ident.c b/ident.c index 6de76f9421d..8fad92d7007 100644 --- a/ident.c +++ b/ident.c @@ -5,10 +5,13 @@ * * Copyright (C) 2005 Linus Torvalds */ -#include "cache.h" +#include "git-compat-util.h" +#include "ident.h" #include "config.h" #include "date.h" +#include "gettext.h" #include "mailmap.h" +#include "strbuf.h" static struct strbuf git_default_name = STRBUF_INIT; static struct strbuf git_default_email = STRBUF_INIT; diff --git a/ident.h b/ident.h new file mode 100644 index 00000000000..96a64896a01 --- /dev/null +++ b/ident.h @@ -0,0 +1,67 @@ +#ifndef IDENT_H +#define IDENT_H + +#include "string-list.h" + +struct ident_split { + const char *name_begin; + const char *name_end; + const char *mail_begin; + const char *mail_end; + const char *date_begin; + const char *date_end; + const char *tz_begin; + const char *tz_end; +}; + +#define IDENT_STRICT 1 +#define IDENT_NO_DATE 2 +#define IDENT_NO_NAME 4 + +enum want_ident { + WANT_BLANK_IDENT, + WANT_AUTHOR_IDENT, + WANT_COMMITTER_IDENT +}; + +const char *ident_default_name(void); +const char *ident_default_email(void); +/* + * Prepare an ident to fall back on if the user didn't configure it. + */ +void prepare_fallback_ident(const char *name, const char *email); +void reset_ident_date(void); +/* + * Signals an success with 0, but time part of the result may be NULL + * if the input lacks timestamp and zone + */ +int split_ident_line(struct ident_split *, const char *, int); + +/* + * Given a commit or tag object buffer and the commit or tag headers, replaces + * the idents in the headers with their canonical versions using the mailmap mechanism. + */ +void apply_mailmap_to_header(struct strbuf *, const char **, struct string_list *); + +/* + * Compare split idents for equality or strict ordering. Note that we + * compare only the ident part of the line, ignoring any timestamp. + * + * Because there are two fields, we must choose one as the primary key; we + * currently arbitrarily pick the email. + */ +int ident_cmp(const struct ident_split *, const struct ident_split *); + +const char *git_author_info(int); +const char *git_committer_info(int); +const char *fmt_ident(const char *name, const char *email, + enum want_ident whose_ident, + const char *date_str, int); +const char *fmt_name(enum want_ident); + +int committer_ident_sufficiently_given(void); +int author_ident_sufficiently_given(void); + +int git_ident_config(const char *, const char *, void *); + +#endif diff --git a/refs/files-backend.c b/refs/files-backend.c index b89954355de..235fe1fdd12 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -4,6 +4,7 @@ #include "refs-internal.h" #include "ref-cache.h" #include "packed-backend.h" +#include "../ident.h" #include "../iterator.h" #include "../dir-iterator.h" #include "../lockfile.h" diff --git a/revision.h b/revision.h index 30febad09a1..ab71443696d 100644 --- a/revision.h +++ b/revision.h @@ -8,6 +8,7 @@ #include "pretty.h" #include "diff.h" #include "commit-slab-decl.h" +#include "ident.h" #include "list-objects-filter-options.h" /** From patchwork Thu Feb 23 08:05:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13149925 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 42FF2C636D7 for ; Thu, 23 Feb 2023 08:06:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233477AbjBWIGH (ORCPT ); Thu, 23 Feb 2023 03:06:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233371AbjBWIFm (ORCPT ); Thu, 23 Feb 2023 03:05:42 -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 C0815474E7 for ; Thu, 23 Feb 2023 00:05:32 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id bo30so9352637wrb.0 for ; Thu, 23 Feb 2023 00:05:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=4ylvBtxPelarqP9YBgjDVKOIx6WVg+C4F49t/eHOfTE=; b=lMo2kXG2FHLUScqM69wejA4wTQ7IECkhSFud6qBlldPb18jOP9H3SdXm8Uq8dB+NdL 2fdU9tqohDVelLWAulEq8yW+sYLUk7bgS+4Z2OIiJto/ehVgu84idTe1ywR9WZs6UnxZ uhn3IY5OLh+/Xf7hwUT2zzJbpoWsSovK4rZ8SsvUsHay8spdzttcql6Zmqgc9w9Igr3s hkiACz21gEKibTkPfx0AzvlsaYVocGgRfMFFShSAyZWpnWg6owOtcatxgFekgTwskis0 IDWx5fQ7JysEVLs+Zq4qADeueNgOCOowgpdQdYVLk4Ujhgapj5SzxHDSYYVFt4Ss0g9K ZbpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4ylvBtxPelarqP9YBgjDVKOIx6WVg+C4F49t/eHOfTE=; b=HAeP3jCSny1ESw+a0wgrozVwIpAx9xapn2N8k5kJqAhXSR/raXcisNrWP1bQe2CVrf ByNNQ0swWlPBLVjrguhwBq8cEzrC0Kx9gX7+ap46BFFrvn5GdEFjuo2XjDV1Xa47QANG UWSWvbxxjyJ5xlmjAosr8Ohl1HhAVsuBzgDETzmNpFY1i1WwLwM7qaYMW3b220OpcBq5 5OxLU8K1w5hMcVk8Dwc2HjfVbBuUoaq7RqvepKXZUPPvgOiR/x9+4rxlV59fmP3oCOxH w5Fhi+MukgK4CDo9cRh7DCcxjJPxX9U12gcx1AXo3hYpqf61TlF8lP4nqs+/xGhK8S5P 8ocA== X-Gm-Message-State: AO0yUKXqGVu7CYHstB/KMnOAqf7ZtfpvbheFQPL03X5wgeuYrKvhsWZR qizQxiHWXmLYgaBEhXoQ80xdxuN01Rs= X-Google-Smtp-Source: AK7set8gUsrj5dffn0NNmVEoLPmvuxETCLPiWH1GbGfXiSigQqzVXn8LRkpYcBGJrqEeyEW6YYqDiA== X-Received: by 2002:a5d:58d9:0:b0:2c5:5fb0:b215 with SMTP id o25-20020a5d58d9000000b002c55fb0b215mr9556866wrf.30.1677139530956; Thu, 23 Feb 2023 00:05:30 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z6-20020adfe546000000b002425be3c9e2sm9030326wrm.60.2023.02.23.00.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:05:30 -0800 (PST) Message-Id: <1357f18db5601cf4fc68a56a2e846d2aed6ad6b6.1677139522.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 23 Feb 2023 08:05:15 +0000 Subject: [PATCH 10/16] object.h: stop depending on cache.h; make cache.h depend on object.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Things should be able to depend on object.h without pulling in all of cache.h. Move an enum to allow this. Note that a couple files previously depended on things brought in through cache.h indirectly (revision.h -> commit.h -> object.h -> cache.h). As such, this change requires making existing dependencies more explicit in two files. Signed-off-by: Elijah Newren --- alloc.c | 2 +- blame.h | 1 - blob.c | 2 +- cache-tree.h | 1 - cache.h | 21 +-------------------- diff-merges.c | 1 + diff.h | 2 +- diffcore-delta.c | 2 +- fsck.h | 1 + help.c | 1 + list-objects-filter-options.h | 3 ++- negotiator/noop.c | 2 +- object.h | 22 +++++++++++++++++++++- shallow.h | 2 ++ t/helper/test-bloom.c | 2 +- t/helper/test-example-decorate.c | 2 +- worktree.h | 1 - 17 files changed, 36 insertions(+), 32 deletions(-) diff --git a/alloc.c b/alloc.c index 27f697e4c87..2886aa93543 100644 --- a/alloc.c +++ b/alloc.c @@ -8,7 +8,7 @@ * up with maximal alignment because it doesn't know what the object alignment * for the new allocation is. */ -#include "cache.h" +#include "git-compat-util.h" #include "object.h" #include "blob.h" #include "tree.h" diff --git a/blame.h b/blame.h index 38bde535b3d..b60d1d81e30 100644 --- a/blame.h +++ b/blame.h @@ -1,7 +1,6 @@ #ifndef BLAME_H #define BLAME_H -#include "cache.h" #include "commit.h" #include "xdiff-interface.h" #include "revision.h" diff --git a/blob.c b/blob.c index 8f83523b0cd..888e28a5594 100644 --- a/blob.c +++ b/blob.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "blob.h" #include "repository.h" #include "alloc.h" diff --git a/cache-tree.h b/cache-tree.h index bd97caa07b0..faae88be63c 100644 --- a/cache-tree.h +++ b/cache-tree.h @@ -1,7 +1,6 @@ #ifndef CACHE_TREE_H #define CACHE_TREE_H -#include "cache.h" #include "tree.h" #include "tree-walk.h" diff --git a/cache.h b/cache.h index 63ffd197a2a..af15701b063 100644 --- a/cache.h +++ b/cache.h @@ -15,6 +15,7 @@ #include "hash.h" #include "hex.h" #include "path.h" +#include "object.h" #include "oid-array.h" #include "repository.h" #include "mem-pool.h" @@ -454,26 +455,6 @@ void prefetch_cache_entries(const struct index_state *istate, extern struct index_state the_index; #endif -#define TYPE_BITS 3 - -/* - * Values in this enum (except those outside the 3 bit range) are part - * of pack file format. See gitformat-pack(5) for more information. - */ -enum object_type { - OBJ_BAD = -1, - OBJ_NONE = 0, - OBJ_COMMIT = 1, - OBJ_TREE = 2, - OBJ_BLOB = 3, - OBJ_TAG = 4, - /* 5 for future expansion */ - OBJ_OFS_DELTA = 6, - OBJ_REF_DELTA = 7, - OBJ_ANY, - OBJ_MAX -}; - static inline enum object_type object_type(unsigned int mode) { return S_ISDIR(mode) ? OBJ_TREE : diff --git a/diff-merges.c b/diff-merges.c index faa7bc73a34..ec97616db1d 100644 --- a/diff-merges.c +++ b/diff-merges.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "diff-merges.h" +#include "gettext.h" #include "revision.h" typedef void (*diff_merges_setup_func_t)(struct rev_info *); diff --git a/diff.h b/diff.h index 41eb2c3d428..b90036f5294 100644 --- a/diff.h +++ b/diff.h @@ -8,6 +8,7 @@ #include "pathspec.h" #include "object.h" #include "oidset.h" +#include "strbuf.h" /** * The diff API is for programs that compare two sets of files (e.g. two trees, @@ -71,7 +72,6 @@ struct oid_array; struct option; struct repository; struct rev_info; -struct strbuf; struct userdiff_driver; typedef int (*pathchange_fn_t)(struct diff_options *options, diff --git a/diffcore-delta.c b/diffcore-delta.c index 18d8f766d70..c30b56e983b 100644 --- a/diffcore-delta.c +++ b/diffcore-delta.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "diff.h" #include "diffcore.h" diff --git a/fsck.h b/fsck.h index 668330880ef..e17730e9da9 100644 --- a/fsck.h +++ b/fsck.h @@ -1,6 +1,7 @@ #ifndef GIT_FSCK_H #define GIT_FSCK_H +#include "object.h" #include "oidset.h" enum fsck_msg_type { diff --git a/help.c b/help.c index 5f84a50b948..216777d2bf4 100644 --- a/help.c +++ b/help.c @@ -5,6 +5,7 @@ #include "exec-cmd.h" #include "run-command.h" #include "levenshtein.h" +#include "gettext.h" #include "help.h" #include "command-list.h" #include "string-list.h" diff --git a/list-objects-filter-options.h b/list-objects-filter-options.h index 1fe393f4473..ef03b45132e 100644 --- a/list-objects-filter-options.h +++ b/list-objects-filter-options.h @@ -1,9 +1,10 @@ #ifndef LIST_OBJECTS_FILTER_OPTIONS_H #define LIST_OBJECTS_FILTER_OPTIONS_H -#include "cache.h" +#include "object.h" #include "parse-options.h" #include "string-list.h" +#include "strbuf.h" /* * The list of defined filters for list-objects. diff --git a/negotiator/noop.c b/negotiator/noop.c index 60569b83501..7b729376867 100644 --- a/negotiator/noop.c +++ b/negotiator/noop.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "noop.h" #include "../commit.h" #include "../fetch-negotiator.h" diff --git a/object.h b/object.h index 31ebe114585..fc45b158da0 100644 --- a/object.h +++ b/object.h @@ -1,7 +1,7 @@ #ifndef OBJECT_H #define OBJECT_H -#include "cache.h" +#include "hash.h" struct buffer_slab; @@ -81,6 +81,26 @@ struct object_array { */ #define FLAG_BITS 28 +#define TYPE_BITS 3 + +/* + * Values in this enum (except those outside the 3 bit range) are part + * of pack file format. See gitformat-pack(5) for more information. + */ +enum object_type { + OBJ_BAD = -1, + OBJ_NONE = 0, + OBJ_COMMIT = 1, + OBJ_TREE = 2, + OBJ_BLOB = 3, + OBJ_TAG = 4, + /* 5 for future expansion */ + OBJ_OFS_DELTA = 6, + OBJ_REF_DELTA = 7, + OBJ_ANY, + OBJ_MAX +}; + /* * The object type is stored in 3 bits. */ diff --git a/shallow.h b/shallow.h index aba6ff58294..e9ca7e4bc80 100644 --- a/shallow.h +++ b/shallow.h @@ -6,6 +6,8 @@ #include "repository.h" #include "strbuf.h" +struct oid_array; + void set_alternate_shallow_file(struct repository *r, const char *path, int override); int register_shallow(struct repository *r, const struct object_id *oid); int unregister_shallow(const struct object_id *oid); diff --git a/t/helper/test-bloom.c b/t/helper/test-bloom.c index 6c900ca6684..010ea5148e4 100644 --- a/t/helper/test-bloom.c +++ b/t/helper/test-bloom.c @@ -1,4 +1,4 @@ -#include "git-compat-util.h" +#include "cache.h" #include "bloom.h" #include "test-tool.h" #include "commit.h" diff --git a/t/helper/test-example-decorate.c b/t/helper/test-example-decorate.c index b9d1200eb98..7c7fc8efc13 100644 --- a/t/helper/test-example-decorate.c +++ b/t/helper/test-example-decorate.c @@ -1,5 +1,5 @@ #include "test-tool.h" -#include "cache.h" +#include "git-compat-util.h" #include "object.h" #include "decorate.h" diff --git a/worktree.h b/worktree.h index 9dcea6fc8c1..2baeca2a8a6 100644 --- a/worktree.h +++ b/worktree.h @@ -1,7 +1,6 @@ #ifndef WORKTREE_H #define WORKTREE_H -#include "cache.h" #include "refs.h" struct strbuf; From patchwork Thu Feb 23 08:05:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13149926 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 A330DC61DA4 for ; Thu, 23 Feb 2023 08:06:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233504AbjBWIGI (ORCPT ); Thu, 23 Feb 2023 03:06:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232470AbjBWIFn (ORCPT ); Thu, 23 Feb 2023 03:05:43 -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 BD24A46179 for ; Thu, 23 Feb 2023 00:05:33 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id j3so5872541wms.2 for ; Thu, 23 Feb 2023 00:05:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=nWH+lbvYbZJRfMscZUM14OjSDoGZkbcyJPYWEsglvgs=; b=oK4EC0gtOXu7+QwRQmmUB0a3UJ1ri3uEFSUbvoxaOrlviStBlqYcFrAnePT6rZ+miF +2p6ir12NctwMpC080Qqwoxb3UlMds7fZZkiUnL18pppFf8t+UGm8dHA9SMEw5kUswvV tqVmtAmXxxTdxFIIwDZNWBcEzF7boQ6CpD/g/Z8jJf+ZCM4SZeWY/12NuCbFJndWjph4 O8MWiy5r2l4UVL/ZhI3WIcr3y70iNSjD1hbIU1SJjjMhLm3tFpqxm6d+UIqUwU4X4uSw FRLxpV//ckmcNHsvnJ2pLinXsFxPOQ33T8PKYSx7Eldjr+2evZcJO6dHGBYZrk8rfXjE IQnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nWH+lbvYbZJRfMscZUM14OjSDoGZkbcyJPYWEsglvgs=; b=bak3dT45r85oUBL4mmOUhOPPTKwsOnkoEodBt/m0W0FVda5V4ltXdwd2u87MF+BiCF 4sBVTI5jr3TMl8AOKpGzu0NV64NNu9NEwj5U0KseF3T8qKYk2DAQmwKKn0rO9E+AIeLm UnsYp2fNrVcfOQfvLT5a1wQQE5wl+LQAQ5xFH+WOqCcwjrjOnnBq5CjarJd7wXe6UcrP K6IJEPv+QDMK4rlUztUFCDQA4icnBx/ZZQxQ8PyK1Wb3jbtiNK9aEmrfkOHjbvS4L+if 25Scl5wqpbH7TJDxy9WdheLJe/GZ3IasaUou/AIVBTCV1Nqvn+Y7ZTOWuX0oHUMksu94 27pQ== X-Gm-Message-State: AO0yUKV1wf4IjWtkeWXmdNb3c8rJu7RePZm8lTJxPpW8ovw/2oqAijnt u+4idVvikvFG6Ikg0ghkzuR7IYVW9eU= X-Google-Smtp-Source: AK7set8n6JvEWFZ04eS+UR04Zwj2aCHDT8IEOlYFJxKNc2pBd9P1E5/C5zn3B1/Oid+3bgIga2YScA== X-Received: by 2002:a05:600c:a695:b0:3df:f7db:9cdf with SMTP id ip21-20020a05600ca69500b003dff7db9cdfmr8354875wmb.0.1677139531682; Thu, 23 Feb 2023 00:05:31 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a5-20020a05600c224500b003dc1a525f22sm7669589wmm.25.2023.02.23.00.05.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:05:31 -0800 (PST) Message-Id: <0446ab61d6f1b72969aa6a5ee7fbbac4aee331cd.1677139522.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 23 Feb 2023 08:05:16 +0000 Subject: [PATCH 11/16] dir.h: refactor to no longer need to include cache.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Moving a few functions around allows us to make dir.h no longer need to include cache.h. This commit is best viewed with: git log -1 -p --color-moved Signed-off-by: Elijah Newren --- cache.h | 31 +++++++++++-------------------- dir.h | 16 ++-------------- pathspec.h | 5 +++++ statinfo.h | 24 ++++++++++++++++++++++++ trace2/tr2_sysenv.c | 2 +- 5 files changed, 43 insertions(+), 35 deletions(-) create mode 100644 statinfo.h diff --git a/cache.h b/cache.h index af15701b063..774d8c6bdfd 100644 --- a/cache.h +++ b/cache.h @@ -15,9 +15,11 @@ #include "hash.h" #include "hex.h" #include "path.h" +#include "pathspec.h" #include "object.h" #include "oid-array.h" #include "repository.h" +#include "statinfo.h" #include "mem-pool.h" typedef struct git_zstream { @@ -120,26 +122,6 @@ struct cache_header { #define INDEX_FORMAT_LB 2 #define INDEX_FORMAT_UB 4 -/* - * The "cache_time" is just the low 32 bits of the - * time. It doesn't matter if it overflows - we only - * check it for equality in the 32 bits we save. - */ -struct cache_time { - uint32_t sec; - uint32_t nsec; -}; - -struct stat_data { - struct cache_time sd_ctime; - struct cache_time sd_mtime; - unsigned int sd_dev; - unsigned int sd_ino; - unsigned int sd_uid; - unsigned int sd_gid; - unsigned int sd_size; -}; - struct cache_entry { struct hashmap_entry ent; struct stat_data ce_stat_data; @@ -295,6 +277,15 @@ static inline unsigned int canon_mode(unsigned int mode) return S_IFGITLINK; } +static inline int ce_path_match(struct index_state *istate, + const struct cache_entry *ce, + const struct pathspec *pathspec, + char *seen) +{ + return match_pathspec(istate, pathspec, ce->name, ce_namelen(ce), 0, seen, + S_ISDIR(ce->ce_mode) || S_ISGITLINK(ce->ce_mode)); +} + #define cache_entry_size(len) (offsetof(struct cache_entry,name) + (len) + 1) #define SOMETHING_CHANGED (1 << 0) /* unclassified changes go here */ diff --git a/dir.h b/dir.h index 8acfc044181..fc4386ae50e 100644 --- a/dir.h +++ b/dir.h @@ -1,8 +1,9 @@ #ifndef DIR_H #define DIR_H -#include "cache.h" #include "hashmap.h" +#include "pathspec.h" +#include "statinfo.h" #include "strbuf.h" /** @@ -363,10 +364,6 @@ int count_slashes(const char *s); int simple_length(const char *match); int no_wildcard(const char *string); char *common_prefix(const struct pathspec *pathspec); -int match_pathspec(struct index_state *istate, - const struct pathspec *pathspec, - const char *name, int namelen, - int prefix, char *seen, int is_dir); int report_path_error(const char *ps_matched, const struct pathspec *pathspec); int within_depth(const char *name, int namelen, int depth, int max_depth); @@ -533,15 +530,6 @@ int submodule_path_match(struct index_state *istate, const char *submodule_name, char *seen); -static inline int ce_path_match(struct index_state *istate, - const struct cache_entry *ce, - const struct pathspec *pathspec, - char *seen) -{ - return match_pathspec(istate, pathspec, ce->name, ce_namelen(ce), 0, seen, - S_ISDIR(ce->ce_mode) || S_ISGITLINK(ce->ce_mode)); -} - static inline int dir_path_match(struct index_state *istate, const struct dir_entry *ent, const struct pathspec *pathspec, diff --git a/pathspec.h b/pathspec.h index 41f6adfbb42..a5b38e0907a 100644 --- a/pathspec.h +++ b/pathspec.h @@ -171,6 +171,11 @@ int match_pathspec_attrs(struct index_state *istate, const char *name, int namelen, const struct pathspec_item *item); +int match_pathspec(struct index_state *istate, + const struct pathspec *pathspec, + const char *name, int namelen, + int prefix, char *seen, int is_dir); + /* * Determine whether a pathspec will match only entire index entries (non-sparse * files and/or entire sparse directories). If the pathspec has the potential to diff --git a/statinfo.h b/statinfo.h new file mode 100644 index 00000000000..e49e3054eaa --- /dev/null +++ b/statinfo.h @@ -0,0 +1,24 @@ +#ifndef STATINFO_H +#define STATINFO_H + +/* + * The "cache_time" is just the low 32 bits of the + * time. It doesn't matter if it overflows - we only + * check it for equality in the 32 bits we save. + */ +struct cache_time { + uint32_t sec; + uint32_t nsec; +}; + +struct stat_data { + struct cache_time sd_ctime; + struct cache_time sd_mtime; + unsigned int sd_dev; + unsigned int sd_ino; + unsigned int sd_uid; + unsigned int sd_gid; + unsigned int sd_size; +}; + +#endif diff --git a/trace2/tr2_sysenv.c b/trace2/tr2_sysenv.c index a380dcf9105..069786cb927 100644 --- a/trace2/tr2_sysenv.c +++ b/trace2/tr2_sysenv.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "dir.h" #include "tr2_sysenv.h" From patchwork Thu Feb 23 08:05:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13149927 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 0B79AC6379F for ; Thu, 23 Feb 2023 08:06:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233509AbjBWIGK (ORCPT ); Thu, 23 Feb 2023 03:06:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231493AbjBWIFp (ORCPT ); Thu, 23 Feb 2023 03:05:45 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 320CB497C9 for ; Thu, 23 Feb 2023 00:05:34 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id l7-20020a05600c4f0700b003e79fa98ce1so5424608wmq.2 for ; Thu, 23 Feb 2023 00:05:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=0J5ag7W8Qc7Fj5Xtx5vyk+neaYs5Q6+VWJ09EaED+KU=; b=fQvFwyCaO7CgB9XOUfvXQBLZw3HqLZitPXT4+m0pm8SI018udrpkBWoZT+QCFE+48V hvhQctqXl0Jy999d4uoYPMhyPwzmKTKKTmh1NTEjXwKocEIoWffrVb/nwWU3rFetX1oP L5hMd+mR1dr6eiaAexWfTKPidmItFDbktF2cFg13tLBYUSCZHTdB5iLScKx2Hwswf7ij mxTGs/cW3tL5wRB3zzHLsLKmtk9kceNGwuLD09fVd7NnjRfOSFaaFENkiJej4aGMtiGF IykH/cp1Hx4mSSjwPLIenwVrz0bkM6bHlZMopk/8GXe44JnBR28/+I2NS9F7ZNuBlOiW FUfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0J5ag7W8Qc7Fj5Xtx5vyk+neaYs5Q6+VWJ09EaED+KU=; b=oiwEM12r2mFf82bLQBnkxKwUV5sLl9/GlkharHfuT7yZqcsKOSc6GfrRnq6qRlGvEW SdwJl6Bqqp3ZBE8OQHttGpeJYmta+8CQRo0Jo/MYpTeWaY8x3EcSNbhD7RrJOHYbmJo1 Hp8UWunCJSblhBsf086uWlLA/27OgkPjTeoll7K6mCUCVqgpfKSr0F+vprWf73Qbb1ZK XujhBrG+AA3+SqUMMGmi0GMy+iK4So0qikfjsKztpdpaMOgWE8uxgQsEaIZhSFlD+2+I XTZK+MibSlXxFiNty1kTPbETCp27da6KQ+uu6kKEQGSzd1PjIG4L/0CHi0x4i9FRMkaC TPuQ== X-Gm-Message-State: AO0yUKU6BIA6hrRrSWUYNbabaTF5oMHYpSd8DHthi2tOs9klAVpBBHjp S5+UhVvrAvAoIwdEy2hJ9dfwlz4KXxQ= X-Google-Smtp-Source: AK7set+0oXNemmuIPvYcpg8N+IYk6B85Rh8EAKB+jcZtL+/G3g0uDEHDKymF39xW8psithjXN6xF3w== X-Received: by 2002:a05:600c:44c5:b0:3e2:cf0:4087 with SMTP id f5-20020a05600c44c500b003e20cf04087mr6571054wmo.32.1677139532449; Thu, 23 Feb 2023 00:05:32 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 1-20020a05600c274100b003dfe549da4fsm10916366wmw.18.2023.02.23.00.05.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:05:32 -0800 (PST) Message-Id: In-Reply-To: References: Date: Thu, 23 Feb 2023 08:05:17 +0000 Subject: [PATCH 12/16] object-store.h: move struct object_info from cache.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Move struct object_info, and a few related #define's from cache.h to object-store.h. Signed-off-by: Elijah Newren --- merge-blobs.c | 2 +- object-store.h | 128 +++++++++++++++++++++++------------------------ protocol-caps.c | 1 + replace-object.h | 1 + 4 files changed, 67 insertions(+), 65 deletions(-) diff --git a/merge-blobs.c b/merge-blobs.c index 8138090f81c..aedcab81138 100644 --- a/merge-blobs.c +++ b/merge-blobs.c @@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "run-command.h" #include "xdiff-interface.h" #include "ll-merge.h" diff --git a/object-store.h b/object-store.h index 1a713d89d7c..82201ec3e7b 100644 --- a/object-store.h +++ b/object-store.h @@ -1,7 +1,7 @@ #ifndef OBJECT_STORE_H #define OBJECT_STORE_H -#include "cache.h" +#include "object.h" #include "oidmap.h" #include "list.h" #include "oid-array.h" @@ -284,6 +284,69 @@ int pretend_object_file(void *, unsigned long, enum object_type, int force_object_loose(const struct object_id *oid, time_t mtime); +struct object_info { + /* Request */ + enum object_type *typep; + unsigned long *sizep; + off_t *disk_sizep; + struct object_id *delta_base_oid; + struct strbuf *type_name; + void **contentp; + + /* Response */ + enum { + OI_CACHED, + OI_LOOSE, + OI_PACKED, + OI_DBCACHED + } whence; + union { + /* + * struct { + * ... Nothing to expose in this case + * } cached; + * struct { + * ... Nothing to expose in this case + * } loose; + */ + struct { + struct packed_git *pack; + off_t offset; + unsigned int is_delta; + } packed; + } u; +}; + +/* + * Initializer for a "struct object_info" that wants no items. You may + * also memset() the memory to all-zeroes. + */ +#define OBJECT_INFO_INIT { 0 } + +/* Invoke lookup_replace_object() on the given hash */ +#define OBJECT_INFO_LOOKUP_REPLACE 1 +/* Allow reading from a loose object file of unknown/bogus type */ +#define OBJECT_INFO_ALLOW_UNKNOWN_TYPE 2 +/* Do not retry packed storage after checking packed and loose storage */ +#define OBJECT_INFO_QUICK 8 +/* + * Do not attempt to fetch the object if missing (even if fetch_is_missing is + * nonzero). + */ +#define OBJECT_INFO_SKIP_FETCH_OBJECT 16 +/* + * This is meant for bulk prefetching of missing blobs in a partial + * clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK + */ +#define OBJECT_INFO_FOR_PREFETCH (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK) + +/* Die if object corruption (not just an object being missing) was detected. */ +#define OBJECT_INFO_DIE_IF_CORRUPT 32 + +int oid_object_info_extended(struct repository *r, + const struct object_id *, + struct object_info *, unsigned flags); + /* * Open the loose object at path, check its hash, and return the contents, * use the "oi" argument to assert things about the object, or e.g. populate its @@ -381,69 +444,6 @@ static inline void obj_read_unlock(void) pthread_mutex_unlock(&obj_read_mutex); } -struct object_info { - /* Request */ - enum object_type *typep; - unsigned long *sizep; - off_t *disk_sizep; - struct object_id *delta_base_oid; - struct strbuf *type_name; - void **contentp; - - /* Response */ - enum { - OI_CACHED, - OI_LOOSE, - OI_PACKED, - OI_DBCACHED - } whence; - union { - /* - * struct { - * ... Nothing to expose in this case - * } cached; - * struct { - * ... Nothing to expose in this case - * } loose; - */ - struct { - struct packed_git *pack; - off_t offset; - unsigned int is_delta; - } packed; - } u; -}; - -/* - * Initializer for a "struct object_info" that wants no items. You may - * also memset() the memory to all-zeroes. - */ -#define OBJECT_INFO_INIT { 0 } - -/* Invoke lookup_replace_object() on the given hash */ -#define OBJECT_INFO_LOOKUP_REPLACE 1 -/* Allow reading from a loose object file of unknown/bogus type */ -#define OBJECT_INFO_ALLOW_UNKNOWN_TYPE 2 -/* Do not retry packed storage after checking packed and loose storage */ -#define OBJECT_INFO_QUICK 8 -/* - * Do not attempt to fetch the object if missing (even if fetch_is_missing is - * nonzero). - */ -#define OBJECT_INFO_SKIP_FETCH_OBJECT 16 -/* - * This is meant for bulk prefetching of missing blobs in a partial - * clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK - */ -#define OBJECT_INFO_FOR_PREFETCH (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK) - -/* Die if object corruption (not just an object being missing) was detected. */ -#define OBJECT_INFO_DIE_IF_CORRUPT 32 - -int oid_object_info_extended(struct repository *r, - const struct object_id *, - struct object_info *, unsigned flags); - /* * Iterate over the files in the loose-object parts of the object * directory "path", triggering the following callbacks: diff --git a/protocol-caps.c b/protocol-caps.c index bbde91810ac..29a5bc07bbe 100644 --- a/protocol-caps.c +++ b/protocol-caps.c @@ -4,6 +4,7 @@ #include "pkt-line.h" #include "strvec.h" #include "hash.h" +#include "hex.h" #include "object.h" #include "object-store.h" #include "string-list.h" diff --git a/replace-object.h b/replace-object.h index 3fbc32eb7b7..3c92ae94610 100644 --- a/replace-object.h +++ b/replace-object.h @@ -1,6 +1,7 @@ #ifndef REPLACE_OBJECT_H #define REPLACE_OBJECT_H +#include "cache.h" #include "oidmap.h" #include "repository.h" #include "object-store.h" From patchwork Thu Feb 23 08:05:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13149928 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 19542C636D7 for ; Thu, 23 Feb 2023 08:06:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233532AbjBWIGM (ORCPT ); Thu, 23 Feb 2023 03:06:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233393AbjBWIFq (ORCPT ); Thu, 23 Feb 2023 03:05:46 -0500 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 EDBBF497DA for ; Thu, 23 Feb 2023 00:05:34 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id bo30so9352705wrb.0 for ; Thu, 23 Feb 2023 00:05:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=xcas6uDeEQ3KKCbaXhL2sBiojmDEyxQdnL5NNqIrEDA=; b=PK1FgIieQOg6VNRklmZwFtYokeIz/fCeV2bm9Or60HX+2ggW+YkXLIDTLqMdzPpKDM Ttrw/AllHG97d5NFZTbg55WcPZ3Qra4/U5V+10gxrJ0HRE/onzSA7NyqrvDU1I/cLYHv dG/0WvXh+lb93ZRW0NzaZ4Kpfq652GPp4gB6IeF4PG4zF3l2Ek4/lhUZyPTS9u5hkG0z G15obyeoci/FrepinP9HqpnGInRIYPeS0uu7xKHi7zq1mV1OgHSD5qvD45DvuGbkvuqU Xf0K4mu2joIWDX4yamwBWkswzKTspaOpk7Xiy7XEFcs3Tmy5BSh1yhjJJavZom5Qazo0 ueaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xcas6uDeEQ3KKCbaXhL2sBiojmDEyxQdnL5NNqIrEDA=; b=xMtYkfWdYIRdPkQL8dZyl72oTdne1C2imobHMx0lNzIqLf/fgRfgRc7vQ2B5NwiWQx FrU45f+02fwO/zHoNSSsGkReS7p7ZvI5H7ifoEXczFfCsBxRphH+NpoctMharG0QTa0b svprEBk20HIBDDMM5Vma6TosbQrtGo8IsRYrMmTuQqiVUfYhlZ7HouuRKMTO2cHGBzSS z+s+PKQRHt0Y+1DYltn3FQBZIj++5WuJqc1ZR5dniZGqnDRn+EzENwg30qKHsN6LMHgx b8ExR7SVI2RobY2iR0DJdSqrKD0WaLG8gp/Twg/FORboPGRAKmyKXzaKZajF8icmMJC+ F8rg== X-Gm-Message-State: AO0yUKWwwwePuL63NvJkr4bvH9gjTDOrCkDF98OFzeP4sLsyYJN8wW+9 FxTAM/cxEu4M7qsBmSaqvTjBdbKevV8= X-Google-Smtp-Source: AK7set/4nLr9HbeU+S4khdN/0QOSE/fgD5eccwppOcrslrRoJf9SyiSDYPOXWJHi4Q5PEkEuSXBoGA== X-Received: by 2002:adf:e58f:0:b0:2c5:a07e:4bb6 with SMTP id l15-20020adfe58f000000b002c5a07e4bb6mr9082730wrm.33.1677139533103; Thu, 23 Feb 2023 00:05:33 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x13-20020a5d6b4d000000b002c6e8af1037sm12361449wrw.104.2023.02.23.00.05.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:05:32 -0800 (PST) Message-Id: <1abea7621eeef18ee08868373ad498d1dcc73231.1677139522.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 23 Feb 2023 08:05:18 +0000 Subject: [PATCH 13/16] replace-object.h: move read_replace_refs declaration from cache.h to here Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Adjust several files to be more explicit about their dependency on replace-objects to accommodate this change. Signed-off-by: Elijah Newren --- builtin/cat-file.c | 1 + builtin/commit-graph.c | 1 + builtin/fsck.c | 1 + builtin/index-pack.c | 1 + builtin/pack-objects.c | 1 + builtin/prune.c | 1 + builtin/replace.c | 1 + builtin/unpack-objects.c | 1 + builtin/upload-pack.c | 1 + cache.h | 8 -------- config.c | 1 + environment.c | 1 + git.c | 1 + log-tree.c | 1 + replace-object.h | 9 ++++++++- 15 files changed, 21 insertions(+), 9 deletions(-) diff --git a/builtin/cat-file.c b/builtin/cat-file.c index fe1b5bab05b..8349eecfa4a 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -17,6 +17,7 @@ #include "oid-array.h" #include "packfile.h" #include "object-store.h" +#include "replace-object.h" #include "promisor-remote.h" #include "mailmap.h" diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index 93704f95a9d..2a7d6ba4dda 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -7,6 +7,7 @@ #include "commit-graph.h" #include "object-store.h" #include "progress.h" +#include "replace-object.h" #include "tag.h" #define BUILTIN_COMMIT_GRAPH_VERIFY_USAGE \ diff --git a/builtin/fsck.c b/builtin/fsck.c index d207bd909b4..fc6b848a41a 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -19,6 +19,7 @@ #include "decorate.h" #include "packfile.h" #include "object-store.h" +#include "replace-object.h" #include "resolve-undo.h" #include "run-command.h" #include "worktree.h" diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 7e4b69f9a3e..febd756bc06 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -15,6 +15,7 @@ #include "thread-utils.h" #include "packfile.h" #include "object-store.h" +#include "replace-object.h" #include "promisor-remote.h" static const char index_pack_usage[] = diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 72c33fd739a..aa724974030 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -31,6 +31,7 @@ #include "list.h" #include "packfile.h" #include "object-store.h" +#include "replace-object.h" #include "dir.h" #include "midx.h" #include "trace2.h" diff --git a/builtin/prune.c b/builtin/prune.c index 27192201086..d0add18ac03 100644 --- a/builtin/prune.c +++ b/builtin/prune.c @@ -7,6 +7,7 @@ #include "parse-options.h" #include "progress.h" #include "prune-packed.h" +#include "replace-object.h" #include "object-store.h" #include "shallow.h" diff --git a/builtin/replace.c b/builtin/replace.c index a29e911d309..95f7a1f96d5 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -15,6 +15,7 @@ #include "parse-options.h" #include "run-command.h" #include "object-store.h" +#include "replace-object.h" #include "repository.h" #include "tag.h" diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c index 43789b8ef29..1557d2bbe1b 100644 --- a/builtin/unpack-objects.c +++ b/builtin/unpack-objects.c @@ -8,6 +8,7 @@ #include "pack.h" #include "blob.h" #include "commit.h" +#include "replace-object.h" #include "tag.h" #include "tree.h" #include "tree-walk.h" diff --git a/builtin/upload-pack.c b/builtin/upload-pack.c index 25b69da2bf2..7a3c68720f1 100644 --- a/builtin/upload-pack.c +++ b/builtin/upload-pack.c @@ -4,6 +4,7 @@ #include "pkt-line.h" #include "parse-options.h" #include "protocol.h" +#include "replace-object.h" #include "upload-pack.h" #include "serve.h" diff --git a/cache.h b/cache.h index 774d8c6bdfd..7172fbce7ac 100644 --- a/cache.h +++ b/cache.h @@ -887,14 +887,6 @@ void set_shared_repository(int value); int get_shared_repository(void); void reset_shared_repository(void); -/* - * Do replace refs need to be checked this run? This variable is - * initialized to true unless --no-replace-object is used or - * $GIT_NO_REPLACE_OBJECTS is set, but is set to false by some - * commands that do not want replace references to be active. - */ -extern int read_replace_refs; - /* * These values are used to help identify parts of a repository to fsync. * FSYNC_COMPONENT_NONE identifies data that will not be a persistent part of the diff --git a/config.c b/config.c index d3ab9417a45..d0aff55fa66 100644 --- a/config.c +++ b/config.c @@ -23,6 +23,7 @@ #include "utf8.h" #include "dir.h" #include "color.h" +#include "replace-object.h" #include "refs.h" #include "worktree.h" diff --git a/environment.c b/environment.c index 1ee3686fd8a..89d89110e41 100644 --- a/environment.c +++ b/environment.c @@ -17,6 +17,7 @@ #include "commit.h" #include "strvec.h" #include "object-store.h" +#include "replace-object.h" #include "tmp-objdir.h" #include "chdir-notify.h" #include "shallow.h" diff --git a/git.c b/git.c index 96b0a2837dc..389f46887e6 100644 --- a/git.c +++ b/git.c @@ -4,6 +4,7 @@ #include "help.h" #include "run-command.h" #include "alias.h" +#include "replace-object.h" #include "shallow.h" #define RUN_SETUP (1<<0) diff --git a/log-tree.c b/log-tree.c index 1dd5fcbf7be..b1344bd0080 100644 --- a/log-tree.c +++ b/log-tree.c @@ -12,6 +12,7 @@ #include "merge-ort.h" #include "reflog-walk.h" #include "refs.h" +#include "replace-object.h" #include "string-list.h" #include "color.h" #include "gpg-interface.h" diff --git a/replace-object.h b/replace-object.h index 3c92ae94610..500482b02b3 100644 --- a/replace-object.h +++ b/replace-object.h @@ -1,11 +1,18 @@ #ifndef REPLACE_OBJECT_H #define REPLACE_OBJECT_H -#include "cache.h" #include "oidmap.h" #include "repository.h" #include "object-store.h" +/* + * Do replace refs need to be checked this run? This variable is + * initialized to true unless --no-replace-object is used or + * $GIT_NO_REPLACE_OBJECTS is set, but is set to false by some + * commands that do not want replace references to be active. + */ +extern int read_replace_refs; + struct replace_object { struct oidmap_entry original; struct object_id replacement; From patchwork Thu Feb 23 08:05:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13149930 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 9688EC6379F for ; Thu, 23 Feb 2023 08:06:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233580AbjBWIGa (ORCPT ); Thu, 23 Feb 2023 03:06:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233411AbjBWIF7 (ORCPT ); Thu, 23 Feb 2023 03:05:59 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C724748E33 for ; Thu, 23 Feb 2023 00:05:35 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id m14-20020a7bce0e000000b003e00c739ce4so7284205wmc.5 for ; Thu, 23 Feb 2023 00:05:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=qix9SHwVkTq8khdXz/bs4Q47Ge9wVJIZWWzOWc5pnb4=; b=GGxCxmYb7ficoETpD3bP/iEPogXLAeho+bm9gKRmMyNm2rDBkWz7OEei1qw8efSFMb czzXsOEXwEyKYtEHsWtg1LTlN4aiSqSWsPZfuZ7R92cImc04XDh+q3Ic8b5W5CRdehP1 WlUKRTiMRXTacVx4asC2pTyFsCwikOj081kyTiGI4NYJyjkbr077ZE1HHNKray34w+Q7 6Lj9sZ9Bk4q4DQjY56IP6ob5BBIjK9zFYLu4PnvdirGxVUs2oAyR2JuyPrEfLO7u56vj gvHx8yTYmywtnR7xLfVIT/9oGEOf9I9GPA/40l9kew0T6LZwBvn6koK6IvMCsN7rbkh1 aX3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qix9SHwVkTq8khdXz/bs4Q47Ge9wVJIZWWzOWc5pnb4=; b=plCqKahWw7ARLKZ9PqA6pArhgG9vRlWTbHnOSehlXwTdF8TrR0X+6L1hFK/B/lkvzF pacNw2CMTpkfyWbK8WEqA2ZXTGcXJ2hQ18QiXe1N0FUaYUue7CQ+OFcH3/EKTi/xC4vc 8mtd+h7Rrt65VbQGH6mk8xYKoQGIv5WXnIYFcx3W2atk2d+7I+BGiEym7lcusDNLOgX+ zor93x3NaQjlOuKHJ6FkguIVlIVTTtRijg6QTpkyYwCApc59o93dzw9OkoufGwHns93X mlXWn3Od56B4Pc4D4i6VQqwAKZoV1KkPMYaQFb4cWyeO5StRmLAafddnw7GkImAFS4Ia o5WA== X-Gm-Message-State: AO0yUKVa+Pw0kuioh3RVUthdwleanAbBQs9GrnLMx26ZYfEbgvcBleM5 gbhajkeK2uDu+Kc+/JhqDN933e+z/V4= X-Google-Smtp-Source: AK7set+5Nna/0l78o6bH1TvXvJkaohAk4oj1wrkIXHMMFmGO0f1mxbJjfE5lxUoakDEj6mgNmI8mCA== X-Received: by 2002:a05:600c:755:b0:3e2:1fe9:8d1b with SMTP id j21-20020a05600c075500b003e21fe98d1bmr4304602wmn.6.1677139533958; Thu, 23 Feb 2023 00:05:33 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c22-20020a7bc856000000b003e01493b136sm10409670wml.43.2023.02.23.00.05.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:05:33 -0800 (PST) Message-Id: <3d99495aff38cf67dba6bb895c18c724fadc9251.1677139522.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 23 Feb 2023 08:05:19 +0000 Subject: [PATCH 14/16] treewide: replace cache.h with more direct headers, where possible Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Signed-off-by: Elijah Newren --- advice.c | 4 +++- decorate.c | 3 ++- diffcore-order.c | 3 ++- diffcore-rename.c | 6 +++++- diffcore-rotate.c | 3 ++- graph.c | 3 ++- hook.c | 5 ++++- quote.c | 1 + sha1dc_git.c | 4 +++- unix-socket.c | 3 ++- url.c | 4 +++- urlmatch.c | 5 ++++- 12 files changed, 33 insertions(+), 11 deletions(-) diff --git a/advice.c b/advice.c index fd189689437..a5ea460ab86 100644 --- a/advice.c +++ b/advice.c @@ -1,6 +1,8 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "advice.h" #include "config.h" #include "color.h" +#include "gettext.h" #include "help.h" #include "string-list.h" diff --git a/decorate.c b/decorate.c index 2036d159671..71e79daa825 100644 --- a/decorate.c +++ b/decorate.c @@ -2,7 +2,8 @@ * decorate.c - decorate a git object with some arbitrary * data. */ -#include "cache.h" +#include "git-compat-util.h" +#include "hashmap.h" #include "object.h" #include "decorate.h" diff --git a/diffcore-order.c b/diffcore-order.c index 19e73311f9c..57ccab28464 100644 --- a/diffcore-order.c +++ b/diffcore-order.c @@ -1,7 +1,8 @@ /* * Copyright (C) 2005 Junio C Hamano */ -#include "cache.h" +#include "git-compat-util.h" +#include "gettext.h" #include "diff.h" #include "diffcore.h" diff --git a/diffcore-rename.c b/diffcore-rename.c index 62c0299984e..7e9ff96d435 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -2,15 +2,19 @@ * * Copyright (C) 2005 Junio C Hamano */ -#include "cache.h" +#include "git-compat-util.h" #include "alloc.h" #include "diff.h" #include "diffcore.h" #include "object-store.h" #include "hashmap.h" +#include "mem-pool.h" +#include "oid-array.h" #include "progress.h" #include "promisor-remote.h" +#include "string-list.h" #include "strmap.h" +#include "trace2.h" /* Table of rename/copy destinations */ diff --git a/diffcore-rotate.c b/diffcore-rotate.c index 445f060ab00..533986cf632 100644 --- a/diffcore-rotate.c +++ b/diffcore-rotate.c @@ -2,7 +2,8 @@ * Copyright (C) 2021, Google LLC. * Based on diffcore-order.c, which is Copyright (C) 2005, Junio C Hamano */ -#include "cache.h" +#include "git-compat-util.h" +#include "gettext.h" #include "diff.h" #include "diffcore.h" diff --git a/graph.c b/graph.c index 568b6e7cd41..2a9dc430fae 100644 --- a/graph.c +++ b/graph.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "gettext.h" #include "config.h" #include "commit.h" #include "color.h" diff --git a/hook.c b/hook.c index 1a848318634..f6ddd790988 100644 --- a/hook.c +++ b/hook.c @@ -1,7 +1,10 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "advice.h" +#include "gettext.h" #include "hook.h" #include "run-command.h" #include "config.h" +#include "strbuf.h" const char *find_hook(const char *name) { diff --git a/quote.c b/quote.c index 2453397fbbd..7ccb5a06cd1 100644 --- a/quote.c +++ b/quote.c @@ -1,6 +1,7 @@ #include "cache.h" #include "alloc.h" #include "quote.h" +#include "strbuf.h" #include "strvec.h" int quote_path_fully = 1; diff --git a/sha1dc_git.c b/sha1dc_git.c index 5c300e812e0..9b675a046ee 100644 --- a/sha1dc_git.c +++ b/sha1dc_git.c @@ -1,4 +1,6 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "sha1dc_git.h" +#include "hex.h" #ifdef DC_SHA1_EXTERNAL /* diff --git a/unix-socket.c b/unix-socket.c index e0be1badb58..79800d80636 100644 --- a/unix-socket.c +++ b/unix-socket.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "strbuf.h" #include "unix-socket.h" #define DEFAULT_UNIX_STREAM_LISTEN_BACKLOG (5) diff --git a/url.c b/url.c index e04bd60b6be..2e1a9f6feec 100644 --- a/url.c +++ b/url.c @@ -1,4 +1,6 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "hex.h" +#include "strbuf.h" #include "url.h" int is_urlschemechar(int first_flag, int ch) diff --git a/urlmatch.c b/urlmatch.c index 620a648efc5..eba0bdd77fe 100644 --- a/urlmatch.c +++ b/urlmatch.c @@ -1,4 +1,7 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "gettext.h" +#include "hex.h" +#include "strbuf.h" #include "urlmatch.h" #define URL_ALPHA "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" From patchwork Thu Feb 23 08:05:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13149929 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 5AF04C636D7 for ; Thu, 23 Feb 2023 08:06:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233572AbjBWIG2 (ORCPT ); Thu, 23 Feb 2023 03:06:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233420AbjBWIF7 (ORCPT ); Thu, 23 Feb 2023 03:05:59 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47F644AFE1 for ; Thu, 23 Feb 2023 00:05:36 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id t13so9842136wrv.13 for ; Thu, 23 Feb 2023 00:05:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=kpBTRBD8Xz1Ta6W/i62HzAk3HPHLbKTtxp5fZopM4eU=; b=C8hIclw0JAqIDmUq0wmXLz6c6FMtbjcnNIDRtcs0aynrmQZrd45T3FtHdYECt7/f+M SAbDDd4VkOgkNbBCiD+wYZU1RlRLcu4gfcDwFHlw5Rhnyr66RB/7DuSZVBIg8urMv37V irmh0GqEWqsEpk9GWFutvML9fK/Hj6qk3PB4Tbo7IhfBuYT6F95TjYHPDDqRImzSCFCr LTgKnsEYreluy4VgFc/FDkpbNnjYAxw9TDgf5HbQu3U0BqnKr8H+YPEDgUOtNpNbp+6R NZ2FDmB29rcnoGQfHq218lX68L6y/JPp5rKqUS9vz7k8KniOshGchKz2kSnR8euLoiVn DB4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kpBTRBD8Xz1Ta6W/i62HzAk3HPHLbKTtxp5fZopM4eU=; b=Zd5Zb5a2xMUhUKPKmSBUXLovivNvJ0KC2kRZ+aYufwmzSd78ZprUCabr2NTzgG2+Kl dnCu+PTeSauvsk9ExCMp5EspzC9IPUUCHAiB0FfRsPcsbCk31cXG66Ntm83DKrS5d5T1 GTMxjvwGcglahnpRGojKaJtkp1MLvcu3T7PsQ612chfy0Igd3KnlkC4VYAWJkHA2OjM9 BINpvMICmhVKoRSvqBodBptcRNZ2kAqptpxKNJYiX0Z3wKK2j+wFBKldx3ZU9q1LGPFm cZaDKe7SZ4qLbugDszDaV7lsD3GEeJAJfZe23BI4MP9VQkVfDrVKbtKz/eTpzqqJNfwc LBmQ== X-Gm-Message-State: AO0yUKUcrEDr3iiAU07arkzaqh1CcTYycdl2baY41NweEN90JldJORfG aJBTFGfgXgaEAAfmuEz0h6DKK7egcA0= X-Google-Smtp-Source: AK7set9otiAJfLGyi/kzwTYZJbczdclHmmULDOPPZfnGyCEUkwgEAi07rUb0Lw2lQSSXXJZjU1uv4A== X-Received: by 2002:a05:6000:61e:b0:2c5:5916:e902 with SMTP id bn30-20020a056000061e00b002c55916e902mr10266884wrb.17.1677139534634; Thu, 23 Feb 2023 00:05:34 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j29-20020a05600c1c1d00b003e204fdb160sm4817970wms.3.2023.02.23.00.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:05:34 -0800 (PST) Message-Id: <2931a0a8c78edefde1b0b0335c6739e8ee98773e.1677139522.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 23 Feb 2023 08:05:20 +0000 Subject: [PATCH 15/16] Remove unnecessary includes of builtin.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Signed-off-by: Elijah Newren --- diff-no-index.c | 1 - merge-recursive.c | 1 - send-pack.c | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/diff-no-index.c b/diff-no-index.c index 05fafd0019b..a3cf358baf0 100644 --- a/diff-no-index.c +++ b/diff-no-index.c @@ -13,7 +13,6 @@ #include "diffcore.h" #include "revision.h" #include "log-tree.h" -#include "builtin.h" #include "parse-options.h" #include "string-list.h" #include "dir.h" diff --git a/merge-recursive.c b/merge-recursive.c index ae469f8cc81..29911d98701 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -10,7 +10,6 @@ #include "alloc.h" #include "attr.h" #include "blob.h" -#include "builtin.h" #include "cache-tree.h" #include "commit.h" #include "commit-reach.h" diff --git a/send-pack.c b/send-pack.c index f2e19838c9c..0b5157c726a 100644 --- a/send-pack.c +++ b/send-pack.c @@ -1,4 +1,4 @@ -#include "builtin.h" +#include "git-compat-util.h" #include "config.h" #include "commit.h" #include "refs.h" From patchwork Thu Feb 23 08:05:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13149931 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 04886C636D7 for ; Thu, 23 Feb 2023 08:06:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233445AbjBWIGc (ORCPT ); Thu, 23 Feb 2023 03:06:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233428AbjBWIF7 (ORCPT ); Thu, 23 Feb 2023 03:05:59 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FDBD4C6D7 for ; Thu, 23 Feb 2023 00:05:37 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id j3so5872797wms.2 for ; Thu, 23 Feb 2023 00:05:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=L9qzaDFEfBqpAh2RNG3iSiFMBaiPM1J9KlsUGohgR0g=; b=SelKdOkd5ubMuoJuCSS5cQspkRozeobFKHXbuZWzZg9aq9u7G3L1C9XsfHPvq7CBfZ /GoeWmRjwf0j6X7XVLiyRmdllnjXx2Ydzuha81T1kvTaDdzOvTK459V5iF43rYSNL52A HttHwH1G/ldFq+fjLBYqOnjBpaDjvgtJwLd8u67zDay4BHqukCPLVsT9SyWc4BkdA5ML es42Ws7OOHC8WeFl9v8UpVHXDYNzTbVxBUPOP4mGhMT1N/P5Y673xu0tJoXc78zt6y/0 l0sDi0cGHwOiS55lB22s8kPhVpnPFzhoUZKWZb/twOznFUi5YwIqPhIkn9NSkeazYzcr HG6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L9qzaDFEfBqpAh2RNG3iSiFMBaiPM1J9KlsUGohgR0g=; b=PZ6dYLXsIWQ/1WWfqFTDzhH/Xzq0/Zfmx6HLl9LrPibUKLMByXh7khtpVPC6700n4S LfZUScosO1l+BQy0F0ndUEHwJaMKpjY+ZEnGjkZF7e/ZSmXwcIBq2aRq+RJIHyvFS5ly bFARjg4pC5FNNNeR48G4vKtMLMlpY1XkgUQ+PfAnlTIRIXv1mueE3tD7txKG2WJlhhBS /NintQrNNrxim+ZI/52MTO5dCBrS/jxPTmJsG7QJ2QSTGy5mWpyIepIuJ7z6SRyx/ssE JZuCKn8GXWwA6/1vUNqsI31ScrHAZYDLcFVX2bQIR6/2R2RYisO3kRMtDFb5rqrWK5Pz IXrg== X-Gm-Message-State: AO0yUKUzu3Z4lUbctSTOLS0dWYfmJOQ4BsjIb38ik7Q/kXDPIdJA/qWe 0DsQqTzze+xFbRMn6K2K2EGBjzADEgs= X-Google-Smtp-Source: AK7set+UvICq4NQvKJrvFO6yXfSzfoypIe8qZTO/2qMTtdnzvworTaitRiwyw6uMBi5c0KDaZfzIcQ== X-Received: by 2002:a05:600c:755:b0:3da:fd07:1e3 with SMTP id j21-20020a05600c075500b003dafd0701e3mr2804168wmn.22.1677139535282; Thu, 23 Feb 2023 00:05:35 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z20-20020a7bc7d4000000b003e6efc0f91csm8807094wmk.42.2023.02.23.00.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 00:05:35 -0800 (PST) Message-Id: In-Reply-To: References: Date: Thu, 23 Feb 2023 08:05:21 +0000 Subject: [PATCH 16/16] diff.h: remove unnecessary include of object.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Signed-off-by: Elijah Newren --- diff.h | 1 - 1 file changed, 1 deletion(-) diff --git a/diff.h b/diff.h index b90036f5294..f80bd297ca5 100644 --- a/diff.h +++ b/diff.h @@ -6,7 +6,6 @@ #include "tree-walk.h" #include "pathspec.h" -#include "object.h" #include "oidset.h" #include "strbuf.h"