From patchwork Fri Feb 24 00:09: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: 13150840 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 85892C61DA4 for ; Fri, 24 Feb 2023 00:09:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229667AbjBXAJu (ORCPT ); Thu, 23 Feb 2023 19:09:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbjBXAJt (ORCPT ); Thu, 23 Feb 2023 19:09:49 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F08921CF7D for ; Thu, 23 Feb 2023 16:09:43 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id i11so6161983wrp.5 for ; Thu, 23 Feb 2023 16:09:43 -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=nshe89PN1gzPqJKThCoxAFxeErNIqBa+ZXWzAXdMVEc=; b=a6H8YHY1I7DqdQsclJGa+qb9VF5m1n6bkR4HijX75locl5VSv9TN0h1F8M88QKQ5KM A/K+g3lQFkHZreciowabyULvypvP3c9xVn+CyDS4PxfIdO3FWpPOoTq+BG60hPS+KHqn z/tAK/aTp0aI9LkR3rTY7X1XxLJWk5YyliUkQtpqTrPijChGS6gQdCVcIu/hwdsw3YKB HbQ0LPKc3uocPFuPY9MoyOCeWkWxPQKuusPw7BKt6XSeHIywo2Z1NKMFrLszBclzprvn FLV4UaiHZs6lMdB++Xu6JsoW7vwTpNLjozjc7JlLwa0PVADMwuNnDbp0pcNv9+cCseeO 277g== 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=nshe89PN1gzPqJKThCoxAFxeErNIqBa+ZXWzAXdMVEc=; b=2B1xBvQU2T+FlX71wITFJ9JaSCyBbJt6eD5o2imdsukzX9zgra7bbm1f/NBIdxM0R1 7kJFgtLAi5zjp+KGsrFl5VHCwqJqrqATCM8DgOKxZpcv0KAs0ISgoW2Subh+T0KRMCxv 6+SbQch2AdHTzxj+z+TD/w2Cv0Y398M4UkhyjDGr8mE9NJIZCokxNF4g+mAg2nqA9s2P 4bzGUQLs5F/IMa3HMxZPVakhWlpLGSPBNR5RHqiCX65K1dPJoTsy3XSo8hOOpOnrKb0z RVCh+vnK3YeNzgmj1A+/fsC6KCkdkAa2MZeqfJ2iaPKo4iocdMF0xky4k+aFBVe0Zh2a LeEA== X-Gm-Message-State: AO0yUKW0pb/VwzcdIzrcacOMHLzPSMLLuOSFZIbW2+02QIHvX38kgrMF j3H5PElyJV3zUMVDswn4syYaUckKXok= X-Google-Smtp-Source: AK7set+eN0jaTUZS+82Mz9oASLTvyMx1QUbqJlZ7tm0wMOTUWgBjn5Vs9JzU3/CwM3ESlMCjdivsng== X-Received: by 2002:adf:f6c5:0:b0:2c7:17b8:575b with SMTP id y5-20020adff6c5000000b002c717b8575bmr1628657wrp.46.1677197381981; Thu, 23 Feb 2023 16:09:41 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id fm16-20020a05600c0c1000b003dd1bd0b915sm867014wmb.22.2023.02.23.16.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 16:09:41 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 24 Feb 2023 00:09:20 +0000 Subject: [PATCH v2 01/17] treewide: ensure one of the appropriate headers is sourced first Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Derrick Stolee , Elijah Newren , 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 + compat/fsmonitor/fsm-ipc-win32.c | 1 + compat/fsmonitor/fsm-settings-darwin.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 + 14 files changed, 19 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/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/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 Fri Feb 24 00:09: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: 13150841 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 77CC0C64ED6 for ; Fri, 24 Feb 2023 00:09:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229674AbjBXAJz (ORCPT ); Thu, 23 Feb 2023 19:09:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbjBXAJt (ORCPT ); Thu, 23 Feb 2023 19:09:49 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64D6F1EBDF for ; Thu, 23 Feb 2023 16:09:44 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id c12so12328008wrw.1 for ; Thu, 23 Feb 2023 16:09:44 -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=rPVXunMyrvoTVyAMRQrkj2BUDcUjSagNUbc7lYlhj8E=; b=QOxtmHyVPQ/H70zBJ6O2SNQ4kkQm6tJ2CzuT9LINbRK/PTFLs+3PZH8ceUS6JayBN7 1nimPZlgT/hxuZS8hxtYNvsQgUor7GUW/HS0Wq4gvBwxoP4GP726rKgOv3Jt0hPiX4l/ 0TL/ARNK5q//dpMzX9PpqDwILtDLpUY7blu5Kj7ACkjF1VjjltCUhPlGCCrzDFVjjTyB zsKr1Edk5udpQwRZbukgUFkiVJ/AtlBvdzWCnLEDEgWkjRq+Bf3mTutjtVf0GY+B0zq2 wvchr+hSXy/UOJC3L+5x+ya/c9gcmC4P5KxrF4R/HnZNREwRTvTJM/0BjEylVnaEhtMV EXeQ== 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=rPVXunMyrvoTVyAMRQrkj2BUDcUjSagNUbc7lYlhj8E=; b=znpk03FrbUlN0Hml0rzsTRAJbf82bq1Zd1MQeOiSuVpEPfE4FOdDO5HN8v+HR8BM6/ k1NNdV8AfgOXNZRUrDjfJJ+jOC1Q+XC0sSLTtXD3eh+tHIAkKphhfgQHCiljXdRi2Gow 0v1FLK94+VRG/y6ISCO+Jka0MyzNTJHdq/fLjxaru6lEafbRz1PoRh9XDMoE9NtYmYyg DSDmmnIW2NRRvURjss77m7Kr3YDR67J7aPxxRW4OMKkBzRK1IqSIceDGaElpkdzkc498 wQyQ6miuqttkFTLzn3aK9bQYnUjYyHgHLgchYyVvbHx27JFc+mKV2UNXcpmUQVE5TjHD Fu5Q== X-Gm-Message-State: AO0yUKXbO4wQMsxEDWWJMWBFM46KWUc0wDSI3F4szQJpfDYhK0I/4e1x QnNJk/QJbMtqptaXtB16wm0xkFnSlF0= X-Google-Smtp-Source: AK7set+raQlJIy4vagSc0kN2YyK/38njKrDwW29F7zFWQR+5vPVukXW1ITOlaiFFb7tkExtlPVLIug== X-Received: by 2002:a05:6000:144e:b0:2c5:4ce5:2995 with SMTP id v14-20020a056000144e00b002c54ce52995mr12903951wrx.1.1677197382592; Thu, 23 Feb 2023 16:09:42 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g2-20020a5d4882000000b002c55521903bsm14546745wrq.51.2023.02.23.16.09.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 16:09:42 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 24 Feb 2023 00:09:21 +0000 Subject: [PATCH v2 02/17] treewide: remove unnecessary git-compat-util.h includes in headers Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Derrick Stolee , Elijah Newren , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren For sanity, we should probably do one of the following: (a) make C and header files both depend upon everything they need (b) consistently exclude git-compat-util.h from headers and require it be the first include in C files Currently, we have some of the headers following (a) and others following (b), which makes things messy. In the past I was pushed towards (b), as per [1] and [2]. Further, during this series I discovered that this mixture empirically will mean that we end up with C files that do not directly include git-compat-util.h, and do include headers that don't include git-compat-util.h, with the result that we likely have headers included before an indirect inclusion of git-compat-util.h. Since git-compat-util.h has tricky platform-specific stuff that is meant to be included before everything else, this state of affairs is risky and may lead to things breaking in subtle ways (and only on some platforms) as per [1] and [2]. Since including git-compat-util.h in existing header files makes it harder for us to catch C files that are missing that include, let's switch to (b) to make the enforcement of this rule easier. Remove the inclusion of git-compat-util.h from header files other than the ones that have been approved as alternate first includes. [1] https://lore.kernel.org/git/20180811173406.GA9119@sigill.intra.peff.net/ [2] https://lore.kernel.org/git/20180811174301.GA9287@sigill.intra.peff.net/ Signed-off-by: Elijah Newren --- advice.h | 2 -- cbtree.h | 2 -- chunk-format.h | 1 - commit-graph.h | 1 - commit-slab-impl.h | 2 -- hash.h | 1 - pack-mtimes.h | 2 -- pkt-line.h | 1 - repository.h | 1 - sub-process.h | 1 - trace.h | 1 - 11 files changed, 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/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 Fri Feb 24 00:09:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13150843 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 DF9DCC64ED6 for ; Fri, 24 Feb 2023 00:09:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229678AbjBXAJ5 (ORCPT ); Thu, 23 Feb 2023 19:09:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229672AbjBXAJv (ORCPT ); Thu, 23 Feb 2023 19:09:51 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05DE819F13 for ; Thu, 23 Feb 2023 16:09:45 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id p3-20020a05600c358300b003e206711347so730166wmq.0 for ; Thu, 23 Feb 2023 16:09:44 -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=ZF/B3ALsH3mz+4VtJ2SUoaXNl1wPqjUj7GFml8Xqo0HX3RLK7W9J87tzzbuM4Xbk6P an4rJgIAGZ+dk9BqGzHmn32k0ksikgfNKYysi5IEIMb3Gk9xYVANSMeIUaxHepcUesx8 DAwC3UelxxRZNvYK+Qy0VmNFt1ZdT19pey0Vu7yVmRWUfriDT/e10Jwc5vNbb0G0lY15 kHyHXFmI5tC24M0PMVwNJZyM/bKNxot3lDnrgUDqrOhR85dVQoalmBQQF7hI53H3H1kN mEOc5d5Kyly7HeZKGoLB4aFxspEcgrjCNR7jLefixjRW1OY0Ns/m3GL+3macN6RD8mrq sRIw== 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=tbzp2fJJ8zaBNzygQAdDNfqmtfa4Js2TneurGI/AZ3zaMptjnh/2mfFHwNyYP3/Je+ XRYovxhHWVeeNLy/hANAV4Y4ZVLmyWEVxgnINuIVmxPYz/FdD1GALcyAyb/i9YtJ0esY pFZSrztQSPw0C49oEmotwKLuNW36CbHkGtS4Czb3LFpfKGqhhrjpNUs98cVUYlq1dMbB YTJrN6YE+L7OxolrFyiBWL4MMWZlAAizEfUgTJfCZXM5Sm2q4QB9or3L+7Gz5TmMS/3A FpbTFTYEG503qM7a8CK2b+QoCd5+hOb7NWql/N0J59oy9HjbP/J4zYrZdBxRqVsF/he1 8TlQ== X-Gm-Message-State: AO0yUKUaLUBuRq7VeueTt6drOVxxei+Ip2Z2h24TK2rLI5ojm2cJBPhI 7si8FhcioSgIHv6sFPmoi+UPu82T/gE= X-Google-Smtp-Source: AK7set+oLfehecblq1rnE8mDf58T3AOhH14cqiAjzhqnA16q1rQvhfLBaa8mqSK10WhhcDmkYP9xWA== X-Received: by 2002:a05:600c:c8:b0:3d2:392e:905f with SMTP id u8-20020a05600c00c800b003d2392e905fmr10067086wmm.24.1677197383350; Thu, 23 Feb 2023 16:09:43 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bh22-20020a05600c3d1600b003e01493b136sm814926wmb.43.2023.02.23.16.09.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 16:09:42 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 24 Feb 2023 00:09:22 +0000 Subject: [PATCH v2 03/17] treewide: remove unnecessary cache.h includes Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Derrick Stolee , Elijah Newren , 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 Fri Feb 24 00:09:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13150844 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 A1066C64ED6 for ; Fri, 24 Feb 2023 00:10:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229720AbjBXAKA (ORCPT ); Thu, 23 Feb 2023 19:10:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229694AbjBXAJv (ORCPT ); Thu, 23 Feb 2023 19:09:51 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D064319F26 for ; Thu, 23 Feb 2023 16:09:45 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id l1so12041296wry.10 for ; Thu, 23 Feb 2023 16:09:45 -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=coPmoXLspFaU84IJ8OPd/w/0nquGi4RGrnv7a97XnLtrZHtnDql22rv+X5v1Pn7ZtF BFX4bAZMlH4gSQu8568NSURkHru+zGADmxA0ibrNqIPoFi1kL3jP5nTquMkgoj9WGySP 6Ak6M3z8ZDy5sRpUHaNJwK5BCKVc2EGEmh2/pFWEMqcBsV2pAP5skIqdZTisqvg9xJ0v nRm7sQ+MjwjdN+9pZPnw4xZMHMbZ6Kr7kSwFiPUj9V8Pyl0SLV3iIeXqbRTHZ1vEFzNy ONZkX+HPTItQNzcCmNmdiERl0gW32JPBY6djPXbU6iH1yP3QbEev+J1x2a4uag3cRf3j rrVg== 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=b1sT1SjYee7y9O9ZfIvIp3+dyp4SbsIaMAsLjULZi1ZQbotcdJyTDAmMm9cuVTR/0t fP/QITdstpHoEOMd/RmQOuLRVQcKzWSguwvCp0dTtfMa6Za8npXO7oIdYo4QXkiLq/J6 WPoKV/t3Z7XA7GFmOdbEeuU9RgzVDhsxQRAJeFje1sCnZ6JrLIbt5IKCAtSzf84ao8ml 253Et23PePBX+LSe9Th7PTN8AfQcvVP+uy+TZ2BfjCmQcH6gmMxW48XHANVnZnwg4KFf 9s2XEOQb7j2ylkSd8eadGWt0+eZmEJYXuxygDa+5Dcv93h9TNTPrHatIksppC2pfbtVx ondw== X-Gm-Message-State: AO0yUKX0iIoZrwjykwv/S3qHXTKOtVBRXmJD1pm3byBJnegz3q98Cq9y 3WsAzel+T3HNkXvxZ+QnIy+xuDzcFlA= X-Google-Smtp-Source: AK7set+hcfmSYtJQSj4JgRZasq8XiifyD9Tvx7sEpD7QycMK0cRJzUs76ifh68LdqG1I6epKokqcPg== X-Received: by 2002:a5d:4105:0:b0:2c5:5eff:5c81 with SMTP id l5-20020a5d4105000000b002c55eff5c81mr11481160wrp.38.1677197384117; Thu, 23 Feb 2023 16:09:44 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d9-20020a056000114900b002c5584d0e3dsm11368779wrx.24.2023.02.23.16.09.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 16:09:43 -0800 (PST) Message-Id: <00dceb5b4679ada9570a68e8a13ea154f5475979.1677197377.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 24 Feb 2023 00:09:23 +0000 Subject: [PATCH v2 04/17] treewide: remove unnecessary cache.h includes in source files Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Derrick Stolee , Elijah Newren , 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 Fri Feb 24 00:09:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13150848 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 6FA41C64ED8 for ; Fri, 24 Feb 2023 00:10:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229724AbjBXAKJ (ORCPT ); Thu, 23 Feb 2023 19:10:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229671AbjBXAJy (ORCPT ); Thu, 23 Feb 2023 19:09:54 -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 243FD1A4BB for ; Thu, 23 Feb 2023 16:09:47 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id i11so6162053wrp.5 for ; Thu, 23 Feb 2023 16:09:47 -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=cb6j7wBUkOCEnLCvXZkykQflIvfTvxXcIYDB/iHzWUM=; b=jnF7atqnBMuregfa67Jx0qdxScIUNtDpI5JLagORzUl9YtF8Ac0dQeN6Au/5dqne+j Vf5Niy8w9q3knqk/UKubWK0DdNUMSC0Sy0nktc95qJWvL2sCZ2MI6vc2AIO8k0OHAcTH 5ut2aefVFuzVqTQKVW5Tf/UW4Nkcajx7BiFnoECFR93lZJG4yQyvcdyU/fVNxq1mQxcU z4LhBGLrCSeQo4INRole5x/HlY0oCE425qFjc3mKtGkZgMZt2PhR5AO1nDk40IBxwSsl y+XqXUhRi4HrGHH8ns7FJMEg6uYQDfJ85cWmwv73sA6bYafOeFCwgC/EF59lyNBe1LJ4 S1yg== 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=cb6j7wBUkOCEnLCvXZkykQflIvfTvxXcIYDB/iHzWUM=; b=XLW/Rq3yDN7oXXnl2F/UgU0G6WRs/itauDx3bnr3+6s4M9UgDZma9kPsdZZV4WeI7g wbXyJ2R+PTyoq9FzINF109xS4vWBzXIvc7n+us52DDTnp4TQzTHbPDyvJQDxuyh8fhSc aYxXNxWkdcRWOrtK9EKuuGPWNAZd0i3T+7fxbTwAQ5ETEVy4e7+Vbd8wSt15xKKrZFXj FiDCGpeK+X10szKyjwr+kXdadc3KprDank5px2bNmHBHiHgZuAUhlupOjXM+mco15RZK XvMrNjQxJurorR7yBU1YhLeH/fWILw6l1EDnl8U5XQY6nXHRChEMGHDJBBe3S34i4x8u iZhQ== X-Gm-Message-State: AO0yUKXtcLD8DEAPur0jm786/1ijCbKKRG/0kzsI0IZ1s3oddhDrtBOy qBJFMRnIXvgOJCMXixggNPBJ/XPmhIU= X-Google-Smtp-Source: AK7set/4SPYhn/rdKuvWx+fGhxe03qBrtKbMqHBTyRC+y7SZTbMJZJPgXznen2ntSiLXoK+2W6UeoA== X-Received: by 2002:a05:6000:a17:b0:2c5:5938:e6d6 with SMTP id co23-20020a0560000a1700b002c55938e6d6mr11595623wrb.35.1677197384950; Thu, 23 Feb 2023 16:09:44 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id r13-20020adfdc8d000000b002c557f82e27sm9741493wrj.99.2023.02.23.16.09.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 16:09:44 -0800 (PST) Message-Id: <9344a94fd922919e513c308fed8130c56dac2504.1677197377.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 24 Feb 2023 00:09:24 +0000 Subject: [PATCH v2 05/17] alloc.h: move ALLOC_GROW() functions from cache.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Derrick Stolee , Elijah Newren , 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. It does mean that we also need to add includes of alloc.h in a number of C files. Signed-off-by: Elijah Newren --- add-patch.c | 1 + 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, 219 insertions(+), 134 deletions(-) diff --git a/add-patch.c b/add-patch.c index a86a92e1646..c6e451c136c 100644 --- a/add-patch.c +++ b/add-patch.c @@ -1,5 +1,6 @@ #include "cache.h" #include "add-interactive.h" +#include "alloc.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 Fri Feb 24 00:09:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13150845 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 6EC9FC61DA4 for ; Fri, 24 Feb 2023 00:10:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229534AbjBXAKD (ORCPT ); Thu, 23 Feb 2023 19:10:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229698AbjBXAJw (ORCPT ); Thu, 23 Feb 2023 19:09:52 -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 504661CAD5 for ; Thu, 23 Feb 2023 16:09:47 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id j2so12145846wrh.9 for ; Thu, 23 Feb 2023 16:09:47 -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=/oTd4oGYUWNeX1XfriPfzFZ4g6Fr/Lz3jalhXGhBz3I=; b=F/pIX9yu9A7ztEG+R94RBc7/KQnkAap4WPLDyLKK7qEVO3kCMiO7GCcAXGmLCa+X9e VZHm7n2VSuPGsurz1uqGeDkXTZgnxBJ/Ql7r39JmgYSIfmXBX57e74ARYscRD2Vl3wZO 7bE6ZnXi7dp0mbZTvHOtO97GtY+qclSnElLvpM8jBk+s/qD2EWqmhHMcVrheBJLxuNtq uOfol5KBi/4CA5W5JE7vM3vF7/f+Jo/tyqoOOhgyujS29ZZ9sh7z4CTUcXOFEXnegSch kxi9rERXXQD17i5FHEfwY+EsRkNMlc9vlzND9o63QRNzr6CIOl1SOMWQxlI6vr5y91cV jUOw== 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=/oTd4oGYUWNeX1XfriPfzFZ4g6Fr/Lz3jalhXGhBz3I=; b=RlOzewcDeI5LVJmuQZamJJ2X+6A8W43V9LbJFJrlw0e2DejTa86V0zUgc3MaI39wwa 0ybsCDZQhnhIm1YKrJLCD0REsh8J8eT5tuLV58lrCxNbsUxpbdGOjMpQ3IJ6ADixZrY2 JqLd8FT/SNr+dACJfr8LKbHJxaMj0xhq9prWJIy3dz48xnSdeTuB3FpRL2PEcNYYvYBv /TEIzWMv9f8qqrKBy24twYtJ9DrX+QN+vKnhgfN0dnpu/4Uk2rDv8unGKLO4bqEKprte XIvByJGZJ1kZX9IiRV6rGDUt86NfxDVKUDXd8HEWV3f0OgDLPhBnkGnhnAG85exrUpof ke6w== X-Gm-Message-State: AO0yUKU8Fd7RtlFSLY+OGk/n4eRRF5QXcN9M/TqtG2KTVPyDYSk027va QdNYZOmd5Xto9Zzdhqj9mXT0JfoO0Fc= X-Google-Smtp-Source: AK7set/bYoOAtko/5oSKVbBbBP9wucvaRcVXqz7nrM5hAnMdJrqPFI7XSELsOiozTkTzhEHIZOShBg== X-Received: by 2002:adf:fc84:0:b0:2c7:1c08:121a with SMTP id g4-20020adffc84000000b002c71c08121amr596433wrr.68.1677197385637; Thu, 23 Feb 2023 16:09:45 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 13-20020a05600c020d00b003dc1d668866sm852969wmi.10.2023.02.23.16.09.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 16:09:45 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 24 Feb 2023 00:09:25 +0000 Subject: [PATCH v2 06/17] hash.h: move some oid-related declarations from cache.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Derrick Stolee , Elijah Newren , 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. The change to line-log.h might look unrelated, but line-log.h includes diffcore.h, which previously included cache.h, which included the kitchen sink. Since this patch makes diffcore.h no longer include cache.h, the compiler complains about the 'struct string_list *' function parameter. Add a forward declaration for struct string_list to address this. 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 Fri Feb 24 00:09:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13150846 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 7E3A2C64ED8 for ; Fri, 24 Feb 2023 00:10:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229685AbjBXAKE (ORCPT ); Thu, 23 Feb 2023 19:10:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbjBXAJx (ORCPT ); Thu, 23 Feb 2023 19:09:53 -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 413C61CAF7 for ; Thu, 23 Feb 2023 16:09:48 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id h14so3657425wru.4 for ; Thu, 23 Feb 2023 16:09:48 -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=i+s0sHRFvNx18kn/Si3oEhtnyEV23sFKqpYR+O4c4J4=; b=idv/60gIFnjh104ckxvxX9Vj4T7IAx+ddLcQBD+eiuiluVTOGZX9qK7vy+bQh/LTfY hPBjyssOonlm496xFPOxjmd0qQtmHMBIEvjhKAA3mVq4vyfuGRdtpcvRxt2DXjjjt8Df oj6leWxYnycxvOx2sqxa9fEOl2xXcTnFzVIK0X/BZs7b6tyfZA42+3WS578NGHaPF/ot s59XKiwq3DcisgSFbyIcor0nyi72CyyyDkFguZd6hLUjCo3REeZqvtKBhttd8c8OG30A TvB2+SBvAxuOUgQ+KjS/kabuGXPvmQNE6nZQJQgK5dttM38/EZNxCK6Ko2PtUqzQ+w6Q bCjg== 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=i+s0sHRFvNx18kn/Si3oEhtnyEV23sFKqpYR+O4c4J4=; b=jcRw9Eh0oYH2meTnjxbvkG1DD/aIBMddh9wBrgKQ6//9Z8Gs32K7rR37WbNR3+Btfm gFxT9INp3R/aubV1m1SY2zMb13kxEQgPtn1rwE6W7aB2n+bDF2xFBqbHiU7SMjix1O1W U9FyNyhG7VFkmRTBJYLP46Rqx/WBCI2Ha/lf0z07rBo0coQfg8Uo7dqLjvDEBO4xRVi6 KtLdD3DMEmnMF4ezbUfVlpaM75NCWnNFSPYpA2bUpUFZP7khJ/Zlk8bO3TYvjTkA6dUq WKgz0dFeXUhLRuhFPQmZIXqDhS+u7vsbdr8Hhs6c2YQn2fhuOjQj0szSiEiGWxp/MhRn 6W3A== X-Gm-Message-State: AO0yUKXNdwfD4m7Wcpb4wDz+JTt7reG1mne1sNye+tuccJ+AJHRaLbnP eHhINhFayYjHqBRhSEFAu/T9gqYckaw= X-Google-Smtp-Source: AK7set/C+QoSCOGc7ifECfQ4F8Ht6OMtNFQBX5OVyrA1oCPNnj+sz5u2yBuJsnjjPlLfE46sybr2AQ== X-Received: by 2002:a05:6000:1f83:b0:2c3:f79a:7319 with SMTP id bw3-20020a0560001f8300b002c3f79a7319mr8899669wrb.17.1677197386338; Thu, 23 Feb 2023 16:09:46 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id w6-20020adff9c6000000b002c5493a17efsm8229225wrr.25.2023.02.23.16.09.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 16:09:45 -0800 (PST) Message-Id: <6d5c13c4693f4436dc8fc69d7a3fad00cdb08c59.1677197377.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 24 Feb 2023 00:09:26 +0000 Subject: [PATCH v2 07/17] hex.h: move some hex-related declarations from cache.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Derrick Stolee , Elijah Newren , 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. For now, we make cache.h include hex.h, so that it is easier to review the direct changes being made by this patch. In the next patch, we will remove that, and add the necessary direct '#include "hex.h"' in the hundreds of C files that need it. 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 Fri Feb 24 00:09:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13150856 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 853F4C61DA4 for ; Fri, 24 Feb 2023 00:10:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229755AbjBXAKY (ORCPT ); Thu, 23 Feb 2023 19:10:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229718AbjBXAKA (ORCPT ); Thu, 23 Feb 2023 19:10:00 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D2CD1CF7D for ; Thu, 23 Feb 2023 16:09:49 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id bt28so5664608wrb.8 for ; Thu, 23 Feb 2023 16:09:49 -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=26HEs082WRfvhiJBRDGp6nqymSNMKFyAoWJVRYFdNIk=; b=mlc7/B+QkCjhTrqWFsK1WGPnjR7+rO+5H10cci/OMFxO3lkL7ptW7wLCk8nvP/Q1FA YYfVge03g6x/SKTv3GrkU7E9NoImOGhHVUjZeO4Y9KLGrv/Iao0R2eSjpuV3i/E5Bk2S 7wV1CuqqVkMamp5G90mCD54CDMf8v/VJp1cnGMr96Ruiw/97abhsLzibrk0s0WpE+6LF RqfS/uAj77nLHmfMHpMP3Hdu9ZUHCmXEHVHoPmyREPPkHj0e+YF3mLilEJ1HSJ77v2OT WZHwmyXvTx1EBWCJTy6r0hagarqRpefWwesX2Nes322OExFcMytMziLQs+Dj3i5uqI6u trTg== 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=26HEs082WRfvhiJBRDGp6nqymSNMKFyAoWJVRYFdNIk=; b=UyiolR5aRDZAjSuZ2SNq/8J0ERLek3vwP48yKXD1ZIpAXqYK2gchKPh0JuHgTIi72X NPOFGRuRfZG4BBqx6/e36s97+LaRsqYDxnxHBbsCFA/KBmW0t1nEK+eM+qjAVZbI4vPn yBv0fAsX/t9ZVBAfzImdBYDC/5qwSIBYFwfuXLdNbKv7WBRjpUx83sG6syZEK/zSQcTf ym49yIRQ54j2Yl8wVZ8lcZmgAugxN9UlUMoJLnqB8SpLKd7oUxxI2kA++SclbhV4uyEz IwSvIQV+Tk8vIxbyh9n4XUTIGKo88+RI1Nblrq4c17YBax1dAqELcZaz8P3q/pO1epYm cpDw== X-Gm-Message-State: AO0yUKXOpeK04KzOu5DmCdo+bF33ld063EVmPCXNFCyHq41haQo94bXq N+hvBJObyzxJY6raIQFbVY4Tha5sA50= X-Google-Smtp-Source: AK7set+3Y3lHW46X+8pTftp67Jt133fX4WaSBjQeyujtZilQJ64cpJP5Ok87J6NFVURpJ63/jVNYxw== X-Received: by 2002:a5d:5253:0:b0:2c5:594b:10d6 with SMTP id k19-20020a5d5253000000b002c5594b10d6mr9654136wrc.29.1677197387256; Thu, 23 Feb 2023 16:09:47 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id q15-20020a05600000cf00b002c559843748sm12606416wrx.10.2023.02.23.16.09.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 16:09:46 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 24 Feb 2023 00:09:27 +0000 Subject: [PATCH v2 08/17] cache.h: remove dependence on hex.h; make other files include it explicitly Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Derrick Stolee , Elijah Newren , 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 --- add-interactive.c | 1 + apply.c | 1 + archive-tar.c | 1 + archive-zip.c | 1 + archive.c | 1 + bisect.c | 1 + blame.c | 1 + branch.c | 1 + builtin/am.c | 1 + builtin/bisect.c | 1 + builtin/blame.c | 1 + builtin/cat-file.c | 1 + builtin/checkout.c | 1 + builtin/clone.c | 1 + builtin/commit-graph.c | 1 + builtin/commit-tree.c | 1 + builtin/describe.c | 1 + builtin/diff-tree.c | 1 + builtin/difftool.c | 1 + builtin/fast-export.c | 1 + builtin/fast-import.c | 1 + builtin/fetch-pack.c | 1 + builtin/fetch.c | 1 + builtin/fsck.c | 1 + builtin/gc.c | 1 + builtin/grep.c | 1 + builtin/hash-object.c | 1 + builtin/index-pack.c | 1 + builtin/log.c | 1 + builtin/ls-remote.c | 1 + builtin/ls-tree.c | 1 + builtin/merge-base.c | 1 + builtin/merge-index.c | 1 + builtin/merge-tree.c | 1 + builtin/merge.c | 1 + builtin/mktag.c | 1 + builtin/mktree.c | 1 + builtin/name-rev.c | 1 + builtin/notes.c | 1 + builtin/pack-objects.c | 1 + builtin/pack-redundant.c | 1 + builtin/patch-id.c | 1 + builtin/prune.c | 1 + builtin/pull.c | 1 + builtin/read-tree.c | 1 + builtin/rebase.c | 1 + builtin/receive-pack.c | 1 + builtin/repack.c | 1 + builtin/replace.c | 1 + builtin/reset.c | 1 + builtin/rev-list.c | 1 + builtin/rev-parse.c | 1 + builtin/send-pack.c | 1 + builtin/show-branch.c | 1 + builtin/show-index.c | 1 + builtin/show-ref.c | 1 + builtin/stash.c | 1 + builtin/submodule--helper.c | 1 + builtin/tag.c | 1 + builtin/unpack-file.c | 1 + builtin/unpack-objects.c | 1 + builtin/update-index.c | 1 + builtin/worktree.c | 1 + builtin/write-tree.c | 1 + bulk-checkin.c | 1 + bundle.c | 1 + cache-tree.c | 1 + cache.h | 1 - color.c | 1 + combine-diff.c | 1 + commit-graph.c | 1 + commit-reach.c | 1 + commit.c | 1 + compat/fsmonitor/fsm-ipc-darwin.c | 1 + connect.c | 1 + connected.c | 1 + convert.c | 1 + delta-islands.c | 1 + diagnose.c | 1 + diff-lib.c | 1 + diff.c | 1 + entry.c | 1 + fetch-pack.c | 1 + fmt-merge-msg.c | 1 + fsck.c | 1 + grep.c | 1 + http-backend.c | 1 + http-fetch.c | 1 + http-push.c | 1 + http-walker.c | 1 + http.c | 1 + line-log.c | 1 + list-objects-filter.c | 1 + list-objects.c | 1 + log-tree.c | 1 + ls-refs.c | 1 + match-trees.c | 1 + merge-ort.c | 1 + merge-recursive.c | 1 + merge.c | 1 + midx.c | 1 + negotiator/skipping.c | 1 + notes-merge.c | 1 + notes.c | 1 + object-file.c | 1 + object-name.c | 1 + object.c | 1 + pack-bitmap-write.c | 1 + pack-bitmap.c | 1 + pack-check.c | 1 + pack-write.c | 1 + packfile.c | 1 + parallel-checkout.c | 1 + patch-ids.c | 1 + path.c | 1 + pkt-line.c | 1 + pretty.c | 1 + promisor-remote.c | 1 + protocol-caps.c | 1 + reachable.c | 1 + read-cache.c | 1 + ref-filter.c | 1 + refs.c | 1 + refs/debug.c | 1 + refs/files-backend.c | 1 + refs/packed-backend.c | 1 + refspec.c | 1 + remote-curl.c | 1 + remote.c | 1 + replace-object.c | 1 + rerere.c | 1 + reset.c | 1 + revision.c | 1 + send-pack.c | 1 + sequencer.c | 1 + server-info.c | 1 + sha1dc_git.c | 1 + shallow.c | 1 + strbuf.c | 1 + strvec.c | 1 + submodule-config.c | 1 + submodule.c | 1 + t/helper/test-bloom.c | 1 + t/helper/test-cache-tree.c | 1 + t/helper/test-dump-cache-tree.c | 1 + t/helper/test-dump-split-index.c | 1 + t/helper/test-dump-untracked-cache.c | 1 + t/helper/test-fast-rebase.c | 1 + t/helper/test-hash.c | 1 + t/helper/test-match-trees.c | 1 + t/helper/test-oid-array.c | 1 + t/helper/test-oidmap.c | 1 + t/helper/test-oidtree.c | 1 + t/helper/test-pack-mtimes.c | 1 + t/helper/test-partial-clone.c | 1 + t/helper/test-proc-receive.c | 1 + t/helper/test-reach.c | 1 + t/helper/test-read-midx.c | 1 + t/helper/test-ref-store.c | 1 + t/helper/test-repository.c | 1 + tag.c | 1 + trace2/tr2_sid.c | 1 + transport-helper.c | 1 + transport.c | 1 + tree-walk.c | 1 + tree.c | 1 + unpack-trees.c | 1 + upload-pack.c | 1 + url.c | 1 + urlmatch.c | 1 + walker.c | 1 + wt-status.c | 1 + xdiff-interface.c | 1 + 173 files changed, 172 insertions(+), 1 deletion(-) diff --git a/add-interactive.c b/add-interactive.c index 00a0f6f96f3..ae25ec50bce 100644 --- a/add-interactive.c +++ b/add-interactive.c @@ -3,6 +3,7 @@ #include "color.h" #include "config.h" #include "diffcore.h" +#include "hex.h" #include "revision.h" #include "refs.h" #include "string-list.h" diff --git a/apply.c b/apply.c index 7f12ebf04c5..8776ab939ad 100644 --- a/apply.c +++ b/apply.c @@ -15,6 +15,7 @@ #include "delta.h" #include "diff.h" #include "dir.h" +#include "hex.h" #include "xdiff-interface.h" #include "ll-merge.h" #include "lockfile.h" diff --git a/archive-tar.c b/archive-tar.c index 9406f03e804..ee27fa0b39b 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -4,6 +4,7 @@ #include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "tar.h" #include "archive.h" #include "object-store.h" diff --git a/archive-zip.c b/archive-zip.c index 0456f1ebf15..c5d1f72eb80 100644 --- a/archive-zip.c +++ b/archive-zip.c @@ -4,6 +4,7 @@ #include "cache.h" #include "config.h" #include "archive.h" +#include "hex.h" #include "streaming.h" #include "utf8.h" #include "object-store.h" diff --git a/archive.c b/archive.c index 35719e5e367..c7869ae906f 100644 --- a/archive.c +++ b/archive.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "refs.h" #include "object-store.h" #include "commit.h" diff --git a/bisect.c b/bisect.c index ef5ee5a6436..1409150c5c3 100644 --- a/bisect.c +++ b/bisect.c @@ -2,6 +2,7 @@ #include "config.h" #include "commit.h" #include "diff.h" +#include "hex.h" #include "revision.h" #include "refs.h" #include "list-objects.h" diff --git a/blame.c b/blame.c index 8bfeaa1c63a..e45d8a3bf92 100644 --- a/blame.c +++ b/blame.c @@ -5,6 +5,7 @@ #include "mergesort.h" #include "diff.h" #include "diffcore.h" +#include "hex.h" #include "tag.h" #include "blame.h" #include "alloc.h" diff --git a/branch.c b/branch.c index e5614b53b36..5aaf073dce1 100644 --- a/branch.c +++ b/branch.c @@ -2,6 +2,7 @@ #include "cache.h" #include "config.h" #include "branch.h" +#include "hex.h" #include "refs.h" #include "refspec.h" #include "remote.h" diff --git a/builtin/am.c b/builtin/am.c index e0848ddadfe..3b5ea50cc56 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -8,6 +8,7 @@ #include "config.h" #include "builtin.h" #include "exec-cmd.h" +#include "hex.h" #include "parse-options.h" #include "dir.h" #include "run-command.h" diff --git a/builtin/bisect.c b/builtin/bisect.c index 73017402671..e8ee4a4dc8d 100644 --- a/builtin/bisect.c +++ b/builtin/bisect.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "hex.h" #include "parse-options.h" #include "bisect.h" #include "refs.h" diff --git a/builtin/blame.c b/builtin/blame.c index 4d1609c9ac0..fdd9f0c0fc7 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -10,6 +10,7 @@ #include "config.h" #include "color.h" #include "builtin.h" +#include "hex.h" #include "repository.h" #include "commit.h" #include "diff.h" diff --git a/builtin/cat-file.c b/builtin/cat-file.c index 5b8be7cb63b..3040016e27a 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 "hex.h" #include "parse-options.h" #include "userdiff.h" #include "streaming.h" diff --git a/builtin/checkout.c b/builtin/checkout.c index a5155cf55c1..21a4335abb0 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -9,6 +9,7 @@ #include "config.h" #include "diff.h" #include "dir.h" +#include "hex.h" #include "hook.h" #include "ll-merge.h" #include "lockfile.h" diff --git a/builtin/clone.c b/builtin/clone.c index 65b5b7db6de..462c286274c 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -11,6 +11,7 @@ #define USE_THE_INDEX_VARIABLE #include "builtin.h" #include "config.h" +#include "hex.h" #include "lockfile.h" #include "parse-options.h" #include "fetch-pack.h" diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index 93704f95a9d..6dc83dc51b3 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -1,6 +1,7 @@ #include "builtin.h" #include "config.h" #include "dir.h" +#include "hex.h" #include "lockfile.h" #include "parse-options.h" #include "repository.h" diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c index cc8d584be2f..fefeed5d4bd 100644 --- a/builtin/commit-tree.c +++ b/builtin/commit-tree.c @@ -5,6 +5,7 @@ */ #include "cache.h" #include "config.h" +#include "hex.h" #include "object-store.h" #include "repository.h" #include "commit.h" diff --git a/builtin/describe.c b/builtin/describe.c index eea1e330c00..5b5930f5c8c 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -1,6 +1,7 @@ #define USE_THE_INDEX_VARIABLE #include "cache.h" #include "config.h" +#include "hex.h" #include "lockfile.h" #include "commit.h" #include "tag.h" diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c index 25b853b85ca..a393efa4f08 100644 --- a/builtin/diff-tree.c +++ b/builtin/diff-tree.c @@ -3,6 +3,7 @@ #include "config.h" #include "diff.h" #include "commit.h" +#include "hex.h" #include "log-tree.h" #include "builtin.h" #include "submodule.h" diff --git a/builtin/difftool.c b/builtin/difftool.c index dbbfb19f192..01681d0fb88 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -17,6 +17,7 @@ #include "builtin.h" #include "run-command.h" #include "exec-cmd.h" +#include "hex.h" #include "parse-options.h" #include "strvec.h" #include "strbuf.h" diff --git a/builtin/fast-export.c b/builtin/fast-export.c index 39a890fc005..78493c6d2bf 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -6,6 +6,7 @@ #include "builtin.h" #include "cache.h" #include "config.h" +#include "hex.h" #include "refs.h" #include "refspec.h" #include "object-store.h" diff --git a/builtin/fast-import.c b/builtin/fast-import.c index 7134683ab93..160e2eedb77 100644 --- a/builtin/fast-import.c +++ b/builtin/fast-import.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "hex.h" #include "repository.h" #include "config.h" #include "lockfile.h" diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c index 113f22c09dd..702c9a3397e 100644 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "alloc.h" +#include "hex.h" #include "pkt-line.h" #include "fetch-pack.h" #include "remote.h" diff --git a/builtin/fetch.c b/builtin/fetch.c index a21ce89312d..a77099ba885 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -3,6 +3,7 @@ */ #include "cache.h" #include "config.h" +#include "hex.h" #include "repository.h" #include "refs.h" #include "refspec.h" diff --git a/builtin/fsck.c b/builtin/fsck.c index d207bd909b4..af0fab660dc 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -1,6 +1,7 @@ #define USE_THE_INDEX_VARIABLE #include "builtin.h" #include "cache.h" +#include "hex.h" #include "repository.h" #include "config.h" #include "commit.h" diff --git a/builtin/gc.c b/builtin/gc.c index 02455fdcd73..67c7fe8a6ea 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -11,6 +11,7 @@ */ #include "builtin.h" +#include "hex.h" #include "repository.h" #include "config.h" #include "tempfile.h" diff --git a/builtin/grep.c b/builtin/grep.c index a08e5841ddb..c590fcb19dd 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -5,6 +5,7 @@ */ #include "cache.h" #include "alloc.h" +#include "hex.h" #include "repository.h" #include "config.h" #include "blob.h" diff --git a/builtin/hash-object.c b/builtin/hash-object.c index 44db83f07fd..1848768b97c 100644 --- a/builtin/hash-object.c +++ b/builtin/hash-object.c @@ -6,6 +6,7 @@ */ #include "builtin.h" #include "config.h" +#include "hex.h" #include "object-store.h" #include "blob.h" #include "quote.h" diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 7e4b69f9a3e..21c0e109dd2 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -2,6 +2,7 @@ #include "alloc.h" #include "config.h" #include "delta.h" +#include "hex.h" #include "pack.h" #include "csum-file.h" #include "blob.h" diff --git a/builtin/log.c b/builtin/log.c index 85540963d95..99489bcb644 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -7,6 +7,7 @@ #include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "refs.h" #include "object-store.h" #include "color.h" diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c index 65161773489..2dfbd8ed9b9 100644 --- a/builtin/ls-remote.c +++ b/builtin/ls-remote.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "hex.h" #include "transport.h" #include "ref-filter.h" #include "remote.h" diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c index 8cc8c995df9..64d8e54318c 100644 --- a/builtin/ls-tree.c +++ b/builtin/ls-tree.c @@ -5,6 +5,7 @@ */ #include "cache.h" #include "config.h" +#include "hex.h" #include "object-store.h" #include "blob.h" #include "tree.h" diff --git a/builtin/merge-base.c b/builtin/merge-base.c index 6f3941f2a49..be8f3b221c9 100644 --- a/builtin/merge-base.c +++ b/builtin/merge-base.c @@ -2,6 +2,7 @@ #include "cache.h" #include "config.h" #include "commit.h" +#include "hex.h" #include "refs.h" #include "diff.h" #include "revision.h" diff --git a/builtin/merge-index.c b/builtin/merge-index.c index 452f833ac46..c875f5d37ee 100644 --- a/builtin/merge-index.c +++ b/builtin/merge-index.c @@ -1,5 +1,6 @@ #define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "hex.h" #include "run-command.h" static const char *pgm; diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index 828dc81c426..e7825181648 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -3,6 +3,7 @@ #include "tree-walk.h" #include "xdiff-interface.h" #include "help.h" +#include "hex.h" #include "commit.h" #include "commit-reach.h" #include "merge-ort.h" diff --git a/builtin/merge.c b/builtin/merge.c index 716a23f880d..7347b738e50 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -10,6 +10,7 @@ #include "cache.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "parse-options.h" #include "builtin.h" #include "lockfile.h" diff --git a/builtin/mktag.c b/builtin/mktag.c index 5d22909122d..42c2457c705 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "hex.h" #include "parse-options.h" #include "tag.h" #include "replace-object.h" diff --git a/builtin/mktree.c b/builtin/mktree.c index ec721ffb947..848c7b47476 100644 --- a/builtin/mktree.c +++ b/builtin/mktree.c @@ -5,6 +5,7 @@ */ #include "builtin.h" #include "alloc.h" +#include "hex.h" #include "quote.h" #include "tree.h" #include "parse-options.h" diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 29752e7afe6..723ba616a88 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "alloc.h" +#include "hex.h" #include "repository.h" #include "config.h" #include "commit.h" diff --git a/builtin/notes.c b/builtin/notes.c index 80d9dfd25ca..bba4c2e39f8 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -10,6 +10,7 @@ #include "cache.h" #include "config.h" #include "builtin.h" +#include "hex.h" #include "notes.h" #include "object-store.h" #include "repository.h" diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 72c33fd739a..2b5e85988c9 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "alloc.h" +#include "hex.h" #include "repository.h" #include "config.h" #include "attr.h" diff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c index ecd49ca268f..82115c5808c 100644 --- a/builtin/pack-redundant.c +++ b/builtin/pack-redundant.c @@ -7,6 +7,7 @@ */ #include "builtin.h" +#include "hex.h" #include "repository.h" #include "packfile.h" #include "object-store.h" diff --git a/builtin/patch-id.c b/builtin/patch-id.c index f840fbf1c7e..338b15cd7b0 100644 --- a/builtin/patch-id.c +++ b/builtin/patch-id.c @@ -2,6 +2,7 @@ #include "builtin.h" #include "config.h" #include "diff.h" +#include "hex.h" #include "parse-options.h" static void flush_current_id(int patchlen, struct object_id *id, struct object_id *result) diff --git a/builtin/prune.c b/builtin/prune.c index 27192201086..db767b7a8fa 100644 --- a/builtin/prune.c +++ b/builtin/prune.c @@ -1,6 +1,7 @@ #include "cache.h" #include "commit.h" #include "diff.h" +#include "hex.h" #include "revision.h" #include "builtin.h" #include "reachable.h" diff --git a/builtin/pull.c b/builtin/pull.c index 1ab4de0005d..963a47f0b82 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -9,6 +9,7 @@ #include "cache.h" #include "config.h" #include "builtin.h" +#include "hex.h" #include "parse-options.h" #include "exec-cmd.h" #include "run-command.h" diff --git a/builtin/read-tree.c b/builtin/read-tree.c index 3ce75417833..018fa9cde2f 100644 --- a/builtin/read-tree.c +++ b/builtin/read-tree.c @@ -7,6 +7,7 @@ #define USE_THE_INDEX_VARIABLE #include "cache.h" #include "config.h" +#include "hex.h" #include "lockfile.h" #include "object.h" #include "tree.h" diff --git a/builtin/rebase.c b/builtin/rebase.c index 6635f10d529..ef8ce2f72cd 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -6,6 +6,7 @@ #define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "hex.h" #include "run-command.h" #include "exec-cmd.h" #include "strvec.h" diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index cd5c7a28eff..3d2b4c8b4fc 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -1,6 +1,7 @@ #include "builtin.h" #include "repository.h" #include "config.h" +#include "hex.h" #include "lockfile.h" #include "pack.h" #include "refs.h" diff --git a/builtin/repack.c b/builtin/repack.c index 545b368168f..966430a465f 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -2,6 +2,7 @@ #include "alloc.h" #include "config.h" #include "dir.h" +#include "hex.h" #include "parse-options.h" #include "run-command.h" #include "sigchain.h" diff --git a/builtin/replace.c b/builtin/replace.c index a29e911d309..cdcb39f737c 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -11,6 +11,7 @@ #include "cache.h" #include "config.h" #include "builtin.h" +#include "hex.h" #include "refs.h" #include "parse-options.h" #include "run-command.h" diff --git a/builtin/reset.c b/builtin/reset.c index 0697fa89de2..58f567afd3e 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -10,6 +10,7 @@ #define USE_THE_INDEX_VARIABLE #include "builtin.h" #include "config.h" +#include "hex.h" #include "lockfile.h" #include "tag.h" #include "object.h" diff --git a/builtin/rev-list.c b/builtin/rev-list.c index d42db0b0cc9..e4c9b747625 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -2,6 +2,7 @@ #include "config.h" #include "commit.h" #include "diff.h" +#include "hex.h" #include "revision.h" #include "list-objects.h" #include "list-objects-filter.h" diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index fd4f59ff2b9..e1fa9c6348c 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -8,6 +8,7 @@ #include "alloc.h" #include "config.h" #include "commit.h" +#include "hex.h" #include "refs.h" #include "quote.h" #include "builtin.h" diff --git a/builtin/send-pack.c b/builtin/send-pack.c index 4c5d125fa0a..127ced435dc 100644 --- a/builtin/send-pack.c +++ b/builtin/send-pack.c @@ -1,6 +1,7 @@ #include "builtin.h" #include "config.h" #include "commit.h" +#include "hex.h" #include "refs.h" #include "pkt-line.h" #include "sideband.h" diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 358ac3e519a..8342b68aef7 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -1,5 +1,6 @@ #include "cache.h" #include "config.h" +#include "hex.h" #include "pretty.h" #include "refs.h" #include "builtin.h" diff --git a/builtin/show-index.c b/builtin/show-index.c index 0e0b9fb95bc..98ec40ddf46 100644 --- a/builtin/show-index.c +++ b/builtin/show-index.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "hex.h" #include "pack.h" #include "parse-options.h" diff --git a/builtin/show-ref.c b/builtin/show-ref.c index 3af6a53ee97..1f28d7fe4b9 100644 --- a/builtin/show-ref.c +++ b/builtin/show-ref.c @@ -1,6 +1,7 @@ #include "builtin.h" #include "cache.h" #include "config.h" +#include "hex.h" #include "refs.h" #include "object-store.h" #include "object.h" diff --git a/builtin/stash.c b/builtin/stash.c index 3a4f9fd566d..6a12fed2713 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -1,6 +1,7 @@ #define USE_THE_INDEX_VARIABLE #include "builtin.h" #include "config.h" +#include "hex.h" #include "parse-options.h" #include "refs.h" #include "lockfile.h" diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 9edc785d8d2..2bbabbb28e3 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1,6 +1,7 @@ #define USE_THE_INDEX_VARIABLE #include "builtin.h" #include "alloc.h" +#include "hex.h" #include "repository.h" #include "cache.h" #include "config.h" diff --git a/builtin/tag.c b/builtin/tag.c index d428c45dc8d..be094882d0f 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -9,6 +9,7 @@ #include "cache.h" #include "config.h" #include "builtin.h" +#include "hex.h" #include "refs.h" #include "object-store.h" #include "tag.h" diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c index 88de32b7d7e..e9b105a5397 100644 --- a/builtin/unpack-file.c +++ b/builtin/unpack-file.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "config.h" +#include "hex.h" #include "object-store.h" static char *create_temp_file(struct object_id *oid) diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c index 43789b8ef29..e125b121883 100644 --- a/builtin/unpack-objects.c +++ b/builtin/unpack-objects.c @@ -2,6 +2,7 @@ #include "cache.h" #include "bulk-checkin.h" #include "config.h" +#include "hex.h" #include "object-store.h" #include "object.h" #include "delta.h" diff --git a/builtin/update-index.c b/builtin/update-index.c index bf38885d546..11dc1352716 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -7,6 +7,7 @@ #include "cache.h" #include "bulk-checkin.h" #include "config.h" +#include "hex.h" #include "lockfile.h" #include "quote.h" #include "cache-tree.h" diff --git a/builtin/worktree.c b/builtin/worktree.c index 254283aa6f5..80d05e246d8 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -3,6 +3,7 @@ #include "config.h" #include "builtin.h" #include "dir.h" +#include "hex.h" #include "parse-options.h" #include "strvec.h" #include "branch.h" diff --git a/builtin/write-tree.c b/builtin/write-tree.c index 078010315f0..7ad0d059453 100644 --- a/builtin/write-tree.c +++ b/builtin/write-tree.c @@ -7,6 +7,7 @@ #include "builtin.h" #include "cache.h" #include "config.h" +#include "hex.h" #include "tree.h" #include "cache-tree.h" #include "parse-options.h" diff --git a/bulk-checkin.c b/bulk-checkin.c index 62ed104c7e6..d64cd5c52d0 100644 --- a/bulk-checkin.c +++ b/bulk-checkin.c @@ -4,6 +4,7 @@ #include "git-compat-util.h" #include "alloc.h" #include "bulk-checkin.h" +#include "hex.h" #include "lockfile.h" #include "repository.h" #include "csum-file.h" diff --git a/bundle.c b/bundle.c index 6ab6cd7378d..99d7de97f6c 100644 --- a/bundle.c +++ b/bundle.c @@ -1,6 +1,7 @@ #include "cache.h" #include "lockfile.h" #include "bundle.h" +#include "hex.h" #include "object-store.h" #include "repository.h" #include "object.h" diff --git a/cache-tree.c b/cache-tree.c index 256f98c3c33..9d46ecef091 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "alloc.h" +#include "hex.h" #include "lockfile.h" #include "tree.h" #include "tree-walk.h" diff --git a/cache.h b/cache.h index d0619ce2e63..0c631e75b55 100644 --- a/cache.h +++ b/cache.h @@ -13,7 +13,6 @@ #include "string-list.h" #include "pack-revindex.h" #include "hash.h" -#include "hex.h" #include "path.h" #include "oid-array.h" #include "repository.h" diff --git a/color.c b/color.c index f05d8a81d72..6b577ce0a75 100644 --- a/color.c +++ b/color.c @@ -1,6 +1,7 @@ #include "cache.h" #include "config.h" #include "color.h" +#include "hex.h" static int git_use_color_default = GIT_COLOR_AUTO; int color_stdout_is_tty = -1; diff --git a/combine-diff.c b/combine-diff.c index 1a39b5dde09..91051dc3258 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -4,6 +4,7 @@ #include "blob.h" #include "diff.h" #include "diffcore.h" +#include "hex.h" #include "quote.h" #include "xdiff-interface.h" #include "xdiff/xmacros.h" diff --git a/commit-graph.c b/commit-graph.c index c11b59f28b3..5e6098ff356 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "config.h" +#include "hex.h" #include "lockfile.h" #include "pack.h" #include "packfile.h" diff --git a/commit-reach.c b/commit-reach.c index 1f0ddc5c883..5ba822a7200 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -3,6 +3,7 @@ #include "commit.h" #include "commit-graph.h" #include "decorate.h" +#include "hex.h" #include "prio-queue.h" #include "tree.h" #include "ref-filter.h" diff --git a/commit.c b/commit.c index e433c33bb01..cb683a6df5d 100644 --- a/commit.c +++ b/commit.c @@ -2,6 +2,7 @@ #include "tag.h" #include "commit.h" #include "commit-graph.h" +#include "hex.h" #include "repository.h" #include "object-store.h" #include "pkt-line.h" diff --git a/compat/fsmonitor/fsm-ipc-darwin.c b/compat/fsmonitor/fsm-ipc-darwin.c index d67b0ee50d3..eb25123fa12 100644 --- a/compat/fsmonitor/fsm-ipc-darwin.c +++ b/compat/fsmonitor/fsm-ipc-darwin.c @@ -1,5 +1,6 @@ #include "cache.h" #include "config.h" +#include "hex.h" #include "strbuf.h" #include "fsmonitor.h" #include "fsmonitor-ipc.h" diff --git a/connect.c b/connect.c index 63e59641c0d..134069574a2 100644 --- a/connect.c +++ b/connect.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "cache.h" #include "config.h" +#include "hex.h" #include "pkt-line.h" #include "quote.h" #include "refs.h" diff --git a/connected.c b/connected.c index b90fd61790c..39cb1e1074d 100644 --- a/connected.c +++ b/connected.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "hex.h" #include "object-store.h" #include "run-command.h" #include "sigchain.h" diff --git a/convert.c b/convert.c index a54d1690c08..349c7e4af15 100644 --- a/convert.c +++ b/convert.c @@ -1,5 +1,6 @@ #include "cache.h" #include "config.h" +#include "hex.h" #include "object-store.h" #include "attr.h" #include "run-command.h" diff --git a/delta-islands.c b/delta-islands.c index 1cfdc2cc040..c3785135fb9 100644 --- a/delta-islands.c +++ b/delta-islands.c @@ -4,6 +4,7 @@ #include "object.h" #include "blob.h" #include "commit.h" +#include "hex.h" #include "tag.h" #include "tree.h" #include "delta.h" diff --git a/diagnose.c b/diagnose.c index 8f265698966..4a8ee4e5cff 100644 --- a/diagnose.c +++ b/diagnose.c @@ -4,6 +4,7 @@ #include "archive.h" #include "dir.h" #include "help.h" +#include "hex.h" #include "strvec.h" #include "object-store.h" #include "packfile.h" diff --git a/diff-lib.c b/diff-lib.c index dec040c366c..70b3578b907 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -6,6 +6,7 @@ #include "commit.h" #include "diff.h" #include "diffcore.h" +#include "hex.h" #include "revision.h" #include "cache-tree.h" #include "unpack-trees.h" diff --git a/diff.c b/diff.c index 3c3565995d9..ec911bdf18c 100644 --- a/diff.c +++ b/diff.c @@ -9,6 +9,7 @@ #include "diff.h" #include "diffcore.h" #include "delta.h" +#include "hex.h" #include "xdiff-interface.h" #include "color.h" #include "attr.h" diff --git a/entry.c b/entry.c index 971ab268714..c97cfa833bb 100644 --- a/entry.c +++ b/entry.c @@ -2,6 +2,7 @@ #include "blob.h" #include "object-store.h" #include "dir.h" +#include "hex.h" #include "streaming.h" #include "submodule.h" #include "progress.h" diff --git a/fetch-pack.c b/fetch-pack.c index 271e2a6fbd6..95a992bcd43 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -2,6 +2,7 @@ #include "alloc.h" #include "repository.h" #include "config.h" +#include "hex.h" #include "lockfile.h" #include "refs.h" #include "pkt-line.h" diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c index d4d6fd3d9d9..9609eb3cef1 100644 --- a/fmt-merge-msg.c +++ b/fmt-merge-msg.c @@ -5,6 +5,7 @@ #include "object-store.h" #include "diff.h" #include "diff-merges.h" +#include "hex.h" #include "revision.h" #include "tag.h" #include "string-list.h" diff --git a/fsck.c b/fsck.c index 20e1aac39a9..871c0a9a252 100644 --- a/fsck.c +++ b/fsck.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "alloc.h" +#include "hex.h" #include "object-store.h" #include "repository.h" #include "object.h" diff --git a/grep.c b/grep.c index cee44a78d04..68e9328dfd4 100644 --- a/grep.c +++ b/grep.c @@ -1,6 +1,7 @@ #include "cache.h" #include "config.h" #include "grep.h" +#include "hex.h" #include "object-store.h" #include "userdiff.h" #include "xdiff-interface.h" diff --git a/http-backend.c b/http-backend.c index d756d120dc9..45290031e00 100644 --- a/http-backend.c +++ b/http-backend.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "repository.h" #include "refs.h" #include "pkt-line.h" diff --git a/http-fetch.c b/http-fetch.c index 258fec20682..8db35b9767d 100644 --- a/http-fetch.c +++ b/http-fetch.c @@ -1,6 +1,7 @@ #include "cache.h" #include "config.h" #include "exec-cmd.h" +#include "hex.h" #include "http.h" #include "walker.h" #include "strvec.h" diff --git a/http-push.c b/http-push.c index 7f71316456c..88aa045ecba 100644 --- a/http-push.c +++ b/http-push.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "hex.h" #include "repository.h" #include "commit.h" #include "tag.h" diff --git a/http-walker.c b/http-walker.c index b8f0f98ae14..c3e902c40e6 100644 --- a/http-walker.c +++ b/http-walker.c @@ -1,6 +1,7 @@ #include "cache.h" #include "repository.h" #include "commit.h" +#include "hex.h" #include "walker.h" #include "http.h" #include "list.h" diff --git a/http.c b/http.c index c4b6ddef287..86b0745af90 100644 --- a/http.c +++ b/http.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "git-curl-compat.h" +#include "hex.h" #include "http.h" #include "config.h" #include "pack.h" diff --git a/line-log.c b/line-log.c index 4956eae748e..1bf89c9acc1 100644 --- a/line-log.c +++ b/line-log.c @@ -2,6 +2,7 @@ #include "alloc.h" #include "line-range.h" #include "cache.h" +#include "hex.h" #include "tag.h" #include "blob.h" #include "tree.h" diff --git a/list-objects-filter.c b/list-objects-filter.c index e40ea9b0a8f..5d7b3316608 100644 --- a/list-objects-filter.c +++ b/list-objects-filter.c @@ -1,6 +1,7 @@ #include "cache.h" #include "alloc.h" #include "dir.h" +#include "hex.h" #include "tag.h" #include "commit.h" #include "tree.h" diff --git a/list-objects.c b/list-objects.c index 7528fe1db2c..ab5745bbfe4 100644 --- a/list-objects.c +++ b/list-objects.c @@ -1,6 +1,7 @@ #include "cache.h" #include "tag.h" #include "commit.h" +#include "hex.h" #include "tree.h" #include "blob.h" #include "diff.h" diff --git a/log-tree.c b/log-tree.c index 1dd5fcbf7be..ee3dfb6b659 100644 --- a/log-tree.c +++ b/log-tree.c @@ -2,6 +2,7 @@ #include "commit-reach.h" #include "config.h" #include "diff.h" +#include "hex.h" #include "object-store.h" #include "repository.h" #include "tmp-objdir.h" diff --git a/ls-refs.c b/ls-refs.c index 697d4beb8de..f4c6b9b7621 100644 --- a/ls-refs.c +++ b/ls-refs.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "hex.h" #include "repository.h" #include "refs.h" #include "remote.h" diff --git a/match-trees.c b/match-trees.c index 49398e599fe..c38dcbac7c6 100644 --- a/match-trees.c +++ b/match-trees.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "hex.h" #include "tree.h" #include "tree-walk.h" #include "object-store.h" diff --git a/merge-ort.c b/merge-ort.c index d1611ca400a..4c5be8ed910 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -26,6 +26,7 @@ #include "diff.h" #include "diffcore.h" #include "dir.h" +#include "hex.h" #include "entry.h" #include "ll-merge.h" #include "object-store.h" diff --git a/merge-recursive.c b/merge-recursive.c index ae469f8cc81..ee144676b76 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -18,6 +18,7 @@ #include "diff.h" #include "diffcore.h" #include "dir.h" +#include "hex.h" #include "ll-merge.h" #include "lockfile.h" #include "object-store.h" diff --git a/merge.c b/merge.c index 445b4f19aa8..2c8b8456842 100644 --- a/merge.c +++ b/merge.c @@ -1,6 +1,7 @@ #include "cache.h" #include "diff.h" #include "diffcore.h" +#include "hex.h" #include "lockfile.h" #include "commit.h" #include "run-command.h" diff --git a/midx.c b/midx.c index 84d7a53d66d..24799bef511 100644 --- a/midx.c +++ b/midx.c @@ -3,6 +3,7 @@ #include "config.h" #include "csum-file.h" #include "dir.h" +#include "hex.h" #include "lockfile.h" #include "packfile.h" #include "object-store.h" diff --git a/negotiator/skipping.c b/negotiator/skipping.c index 0f5ac48e876..28f8769bd40 100644 --- a/negotiator/skipping.c +++ b/negotiator/skipping.c @@ -2,6 +2,7 @@ #include "skipping.h" #include "../commit.h" #include "../fetch-negotiator.h" +#include "../hex.h" #include "../prio-queue.h" #include "../refs.h" #include "../tag.h" diff --git a/notes-merge.c b/notes-merge.c index b4cc594a790..5b1a9ff13f7 100644 --- a/notes-merge.c +++ b/notes-merge.c @@ -5,6 +5,7 @@ #include "repository.h" #include "diff.h" #include "diffcore.h" +#include "hex.h" #include "xdiff-interface.h" #include "ll-merge.h" #include "dir.h" diff --git a/notes.c b/notes.c index f2805d51bb1..c9e4b8b4a55 100644 --- a/notes.c +++ b/notes.c @@ -1,5 +1,6 @@ #include "cache.h" #include "config.h" +#include "hex.h" #include "notes.h" #include "object-store.h" #include "blob.h" diff --git a/object-file.c b/object-file.c index 18d65220d70..43a39dd8d31 100644 --- a/object-file.c +++ b/object-file.c @@ -9,6 +9,7 @@ #include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "string-list.h" #include "lockfile.h" #include "delta.h" diff --git a/object-name.c b/object-name.c index 2dd1a0f56e1..97bb94d226c 100644 --- a/object-name.c +++ b/object-name.c @@ -1,5 +1,6 @@ #include "cache.h" #include "config.h" +#include "hex.h" #include "tag.h" #include "commit.h" #include "tree.h" diff --git a/object.c b/object.c index 344087de4de..609fed1b73d 100644 --- a/object.c +++ b/object.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "hex.h" #include "object.h" #include "replace-object.h" #include "object-store.h" diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c index 155939e77b2..891d9d2772e 100644 --- a/pack-bitmap-write.c +++ b/pack-bitmap-write.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "alloc.h" +#include "hex.h" #include "object-store.h" #include "commit.h" #include "tag.h" diff --git a/pack-bitmap.c b/pack-bitmap.c index 5a978341200..a321d6fae83 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "alloc.h" #include "commit.h" +#include "hex.h" #include "strbuf.h" #include "tag.h" #include "diff.h" diff --git a/pack-check.c b/pack-check.c index bfb593ba726..7ed594d6679 100644 --- a/pack-check.c +++ b/pack-check.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "hex.h" #include "repository.h" #include "pack.h" #include "pack-revindex.h" diff --git a/pack-write.c b/pack-write.c index 33637297487..041e573bc16 100644 --- a/pack-write.c +++ b/pack-write.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "hex.h" #include "pack.h" #include "csum-file.h" #include "remote.h" diff --git a/packfile.c b/packfile.c index 3e3063de445..4088735a7da 100644 --- a/packfile.c +++ b/packfile.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "alloc.h" +#include "hex.h" #include "list.h" #include "pack.h" #include "repository.h" diff --git a/parallel-checkout.c b/parallel-checkout.c index decdc8d8a1e..2455aa356db 100644 --- a/parallel-checkout.c +++ b/parallel-checkout.c @@ -2,6 +2,7 @@ #include "alloc.h" #include "config.h" #include "entry.h" +#include "hex.h" #include "parallel-checkout.h" #include "pkt-line.h" #include "progress.h" diff --git a/patch-ids.c b/patch-ids.c index 31534466266..a4473a88fa2 100644 --- a/patch-ids.c +++ b/patch-ids.c @@ -2,6 +2,7 @@ #include "diff.h" #include "commit.h" #include "hash-lookup.h" +#include "hex.h" #include "patch-ids.h" static int patch_id_defined(struct commit *commit) diff --git a/path.c b/path.c index 492e17ad121..97561c3b14d 100644 --- a/path.c +++ b/path.c @@ -2,6 +2,7 @@ * Utilities for paths and pathnames */ #include "cache.h" +#include "hex.h" #include "repository.h" #include "strbuf.h" #include "string-list.h" diff --git a/pkt-line.c b/pkt-line.c index ce4e73b6833..1ea7f8600ec 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -1,5 +1,6 @@ #include "cache.h" #include "pkt-line.h" +#include "hex.h" #include "run-command.h" char packet_buffer[LARGE_PACKET_MAX]; diff --git a/pretty.c b/pretty.c index b6080844498..2401e3ed36b 100644 --- a/pretty.c +++ b/pretty.c @@ -2,6 +2,7 @@ #include "alloc.h" #include "config.h" #include "commit.h" +#include "hex.h" #include "utf8.h" #include "diff.h" #include "revision.h" diff --git a/promisor-remote.c b/promisor-remote.c index faa7612941c..1db566982ec 100644 --- a/promisor-remote.c +++ b/promisor-remote.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "hex.h" #include "object-store.h" #include "promisor-remote.h" #include "config.h" diff --git a/protocol-caps.c b/protocol-caps.c index bbde91810ac..f9bc2a8b90b 100644 --- a/protocol-caps.c +++ b/protocol-caps.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "protocol-caps.h" #include "gettext.h" +#include "hex.h" #include "pkt-line.h" #include "strvec.h" #include "hash.h" diff --git a/reachable.c b/reachable.c index aba63ebeb3b..be9d40923de 100644 --- a/reachable.c +++ b/reachable.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "hex.h" #include "refs.h" #include "tag.h" #include "commit.h" diff --git a/read-cache.c b/read-cache.c index 3cc8e312dce..1bcf6732718 100644 --- a/read-cache.c +++ b/read-cache.c @@ -8,6 +8,7 @@ #include "config.h" #include "diff.h" #include "diffcore.h" +#include "hex.h" #include "tempfile.h" #include "lockfile.h" #include "cache-tree.h" diff --git a/ref-filter.c b/ref-filter.c index c8230a08589..d8627185089 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "alloc.h" +#include "hex.h" #include "parse-options.h" #include "refs.h" #include "wildmatch.h" diff --git a/refs.c b/refs.c index f90f953551b..f22adf6d45a 100644 --- a/refs.c +++ b/refs.c @@ -6,6 +6,7 @@ #include "alloc.h" #include "config.h" #include "hashmap.h" +#include "hex.h" #include "lockfile.h" #include "iterator.h" #include "refs.h" diff --git a/refs/debug.c b/refs/debug.c index ff7766bc636..adc34c836fc 100644 --- a/refs/debug.c +++ b/refs/debug.c @@ -1,4 +1,5 @@ #include "git-compat-util.h" +#include "hex.h" #include "refs-internal.h" #include "trace.h" diff --git a/refs/files-backend.c b/refs/files-backend.c index b89954355de..6f257c70054 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -1,5 +1,6 @@ #include "../cache.h" #include "../config.h" +#include "../hex.h" #include "../refs.h" #include "refs-internal.h" #include "ref-cache.h" diff --git a/refs/packed-backend.c b/refs/packed-backend.c index 186dcafcd00..b665d0f7d9b 100644 --- a/refs/packed-backend.c +++ b/refs/packed-backend.c @@ -1,6 +1,7 @@ #include "../git-compat-util.h" #include "../alloc.h" #include "../config.h" +#include "../hex.h" #include "../refs.h" #include "refs-internal.h" #include "packed-backend.h" diff --git a/refspec.c b/refspec.c index ec336ec5e9c..28d90911aa5 100644 --- a/refspec.c +++ b/refspec.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "alloc.h" +#include "hex.h" #include "strvec.h" #include "refs.h" #include "refspec.h" diff --git a/remote-curl.c b/remote-curl.c index 380ef3fccfb..ed7e3a043ac 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "remote.h" #include "connect.h" #include "strbuf.h" diff --git a/remote.c b/remote.c index daade49a6f6..b04e5da3383 100644 --- a/remote.c +++ b/remote.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "remote.h" #include "urlmatch.h" #include "refs.h" diff --git a/replace-object.c b/replace-object.c index 320be2522d8..0cf056c4fbf 100644 --- a/replace-object.c +++ b/replace-object.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "hex.h" #include "oidmap.h" #include "object-store.h" #include "replace-object.h" diff --git a/rerere.c b/rerere.c index d4bcb908531..a67abaab077 100644 --- a/rerere.c +++ b/rerere.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "lockfile.h" #include "string-list.h" #include "rerere.h" diff --git a/reset.c b/reset.c index 5ded23611f3..58b3829ff73 100644 --- a/reset.c +++ b/reset.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "cache-tree.h" +#include "hex.h" #include "lockfile.h" #include "refs.h" #include "reset.h" diff --git a/revision.c b/revision.c index b8f925f088c..e356bc4aae7 100644 --- a/revision.c +++ b/revision.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "object-store.h" #include "tag.h" #include "blob.h" diff --git a/send-pack.c b/send-pack.c index f2e19838c9c..954104673f3 100644 --- a/send-pack.c +++ b/send-pack.c @@ -1,6 +1,7 @@ #include "builtin.h" #include "config.h" #include "commit.h" +#include "hex.h" #include "refs.h" #include "object-store.h" #include "pkt-line.h" diff --git a/sequencer.c b/sequencer.c index fcf8740ce1c..af1e07fe765 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1,6 +1,7 @@ #include "cache.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "lockfile.h" #include "dir.h" #include "object-store.h" diff --git a/server-info.c b/server-info.c index f07daa16f36..40436892023 100644 --- a/server-info.c +++ b/server-info.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "alloc.h" #include "dir.h" +#include "hex.h" #include "repository.h" #include "refs.h" #include "object.h" diff --git a/sha1dc_git.c b/sha1dc_git.c index 5c300e812e0..72709606fdf 100644 --- a/sha1dc_git.c +++ b/sha1dc_git.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "hex.h" #ifdef DC_SHA1_EXTERNAL /* diff --git a/shallow.c b/shallow.c index 7dc73fb8989..1cbb05ba0e4 100644 --- a/shallow.c +++ b/shallow.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "alloc.h" +#include "hex.h" #include "repository.h" #include "tempfile.h" #include "lockfile.h" diff --git a/strbuf.c b/strbuf.c index bc4c2c09e60..1c57ac6574f 100644 --- a/strbuf.c +++ b/strbuf.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "alloc.h" +#include "hex.h" #include "refs.h" #include "string-list.h" #include "utf8.h" diff --git a/strvec.c b/strvec.c index 94d504e3805..17d54b6c3bc 100644 --- a/strvec.c +++ b/strvec.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "strvec.h" #include "alloc.h" +#include "hex.h" #include "strbuf.h" const char *empty_strvec[] = { NULL }; diff --git a/submodule-config.c b/submodule-config.c index bb7c35fc317..89a7bf0a93d 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -1,6 +1,7 @@ #include "cache.h" #include "alloc.h" #include "dir.h" +#include "hex.h" #include "repository.h" #include "config.h" #include "submodule-config.h" diff --git a/submodule.c b/submodule.c index 340ffad1c29..9d89299772e 100644 --- a/submodule.c +++ b/submodule.c @@ -7,6 +7,7 @@ #include "dir.h" #include "diff.h" #include "commit.h" +#include "hex.h" #include "revision.h" #include "run-command.h" #include "diffcore.h" diff --git a/t/helper/test-bloom.c b/t/helper/test-bloom.c index 6c900ca6684..787fd524557 100644 --- a/t/helper/test-bloom.c +++ b/t/helper/test-bloom.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "bloom.h" +#include "hex.h" #include "test-tool.h" #include "commit.h" diff --git a/t/helper/test-cache-tree.c b/t/helper/test-cache-tree.c index 9159a173015..615e648e555 100644 --- a/t/helper/test-cache-tree.c +++ b/t/helper/test-cache-tree.c @@ -1,6 +1,7 @@ #define USE_THE_INDEX_VARIABLE #include "test-tool.h" #include "cache.h" +#include "hex.h" #include "tree.h" #include "cache-tree.h" #include "parse-options.h" diff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c index 454f17b1a0c..92dfc1aa8c4 100644 --- a/t/helper/test-dump-cache-tree.c +++ b/t/helper/test-dump-cache-tree.c @@ -1,6 +1,7 @@ #define USE_THE_INDEX_VARIABLE #include "test-tool.h" #include "cache.h" +#include "hex.h" #include "tree.h" #include "cache-tree.h" diff --git a/t/helper/test-dump-split-index.c b/t/helper/test-dump-split-index.c index 0ea97b84072..813d0a38fae 100644 --- a/t/helper/test-dump-split-index.c +++ b/t/helper/test-dump-split-index.c @@ -1,6 +1,7 @@ #define USE_THE_INDEX_VARIABLE #include "test-tool.h" #include "cache.h" +#include "hex.h" #include "split-index.h" #include "ewah/ewok.h" diff --git a/t/helper/test-dump-untracked-cache.c b/t/helper/test-dump-untracked-cache.c index 6d53683f13b..af953fabe87 100644 --- a/t/helper/test-dump-untracked-cache.c +++ b/t/helper/test-dump-untracked-cache.c @@ -2,6 +2,7 @@ #include "test-tool.h" #include "cache.h" #include "dir.h" +#include "hex.h" static int compare_untracked(const void *a_, const void *b_) { diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c index efc82dd80c5..b1edb92a032 100644 --- a/t/helper/test-fast-rebase.c +++ b/t/helper/test-fast-rebase.c @@ -15,6 +15,7 @@ #include "cache-tree.h" #include "commit.h" +#include "hex.h" #include "lockfile.h" #include "merge-ort.h" #include "refs.h" diff --git a/t/helper/test-hash.c b/t/helper/test-hash.c index 5860dab0ffa..016248106a7 100644 --- a/t/helper/test-hash.c +++ b/t/helper/test-hash.c @@ -1,5 +1,6 @@ #include "test-tool.h" #include "cache.h" +#include "hex.h" int cmd_hash_impl(int ac, const char **av, int algo) { diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c index 4079fdee067..04bc2563f3e 100644 --- a/t/helper/test-match-trees.c +++ b/t/helper/test-match-trees.c @@ -1,5 +1,6 @@ #include "test-tool.h" #include "cache.h" +#include "hex.h" #include "tree.h" int cmd__match_trees(int ac, const char **av) diff --git a/t/helper/test-oid-array.c b/t/helper/test-oid-array.c index d1324d086a2..0906993ad59 100644 --- a/t/helper/test-oid-array.c +++ b/t/helper/test-oid-array.c @@ -1,5 +1,6 @@ #include "test-tool.h" #include "cache.h" +#include "hex.h" #include "oid-array.h" static int print_oid(const struct object_id *oid, void *data) diff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c index 0acf99931ee..883d40efd45 100644 --- a/t/helper/test-oidmap.c +++ b/t/helper/test-oidmap.c @@ -1,5 +1,6 @@ #include "test-tool.h" #include "cache.h" +#include "hex.h" #include "oidmap.h" #include "strbuf.h" diff --git a/t/helper/test-oidtree.c b/t/helper/test-oidtree.c index d48a409f4e4..0b82431a70f 100644 --- a/t/helper/test-oidtree.c +++ b/t/helper/test-oidtree.c @@ -1,5 +1,6 @@ #include "test-tool.h" #include "cache.h" +#include "hex.h" #include "oidtree.h" static enum cb_next print_oid(const struct object_id *oid, void *data) diff --git a/t/helper/test-pack-mtimes.c b/t/helper/test-pack-mtimes.c index f7b79daf4c0..f68b3761b68 100644 --- a/t/helper/test-pack-mtimes.c +++ b/t/helper/test-pack-mtimes.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "test-tool.h" +#include "hex.h" #include "strbuf.h" #include "object-store.h" #include "packfile.h" diff --git a/t/helper/test-partial-clone.c b/t/helper/test-partial-clone.c index 3f102cfddd3..da17fd37eb1 100644 --- a/t/helper/test-partial-clone.c +++ b/t/helper/test-partial-clone.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "hex.h" #include "test-tool.h" #include "repository.h" #include "object-store.h" diff --git a/t/helper/test-proc-receive.c b/t/helper/test-proc-receive.c index a4b305f4947..7e12d4f9aa2 100644 --- a/t/helper/test-proc-receive.c +++ b/t/helper/test-proc-receive.c @@ -1,5 +1,6 @@ #include "cache.h" #include "connect.h" +#include "hex.h" #include "parse-options.h" #include "pkt-line.h" #include "sigchain.h" diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c index 883d8e20a8e..de8f26639d4 100644 --- a/t/helper/test-reach.c +++ b/t/helper/test-reach.c @@ -3,6 +3,7 @@ #include "commit.h" #include "commit-reach.h" #include "config.h" +#include "hex.h" #include "parse-options.h" #include "ref-filter.h" #include "string-list.h" diff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c index 27072ba94d7..0a883cdf26b 100644 --- a/t/helper/test-read-midx.c +++ b/t/helper/test-read-midx.c @@ -1,5 +1,6 @@ #include "test-tool.h" #include "cache.h" +#include "hex.h" #include "midx.h" #include "repository.h" #include "object-store.h" diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index ae8a5648daf..1745b088b7c 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -1,5 +1,6 @@ #include "test-tool.h" #include "cache.h" +#include "hex.h" #include "refs.h" #include "worktree.h" #include "object-store.h" diff --git a/t/helper/test-repository.c b/t/helper/test-repository.c index 56f0e3c1bef..10a6dfc2160 100644 --- a/t/helper/test-repository.c +++ b/t/helper/test-repository.c @@ -3,6 +3,7 @@ #include "commit-graph.h" #include "commit.h" #include "config.h" +#include "hex.h" #include "object-store.h" #include "object.h" #include "repository.h" diff --git a/tag.c b/tag.c index dfbcd7fcc24..18b718cca66 100644 --- a/tag.c +++ b/tag.c @@ -6,6 +6,7 @@ #include "blob.h" #include "alloc.h" #include "gpg-interface.h" +#include "hex.h" #include "packfile.h" const char *tag_type = "tag"; diff --git a/trace2/tr2_sid.c b/trace2/tr2_sid.c index dc6e75ef131..5f1ce6f85cf 100644 --- a/trace2/tr2_sid.c +++ b/trace2/tr2_sid.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "hex.h" #include "trace2/tr2_tbuf.h" #include "trace2/tr2_sid.h" diff --git a/transport-helper.c b/transport-helper.c index 3ea7c2bb5ad..82ac63e2609 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -4,6 +4,7 @@ #include "run-command.h" #include "commit.h" #include "diff.h" +#include "hex.h" #include "revision.h" #include "remote.h" #include "string-list.h" diff --git a/transport.c b/transport.c index ac9e06a6cea..906dbad5a08 100644 --- a/transport.c +++ b/transport.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "transport.h" #include "hook.h" #include "pkt-line.h" diff --git a/tree-walk.c b/tree-walk.c index d22f3fe5b05..0e2f5ceb71d 100644 --- a/tree-walk.c +++ b/tree-walk.c @@ -2,6 +2,7 @@ #include "tree-walk.h" #include "alloc.h" #include "dir.h" +#include "hex.h" #include "object-store.h" #include "tree.h" #include "pathspec.h" diff --git a/tree.c b/tree.c index 410e3b477e5..76a6534f678 100644 --- a/tree.c +++ b/tree.c @@ -1,5 +1,6 @@ #include "cache.h" #include "cache-tree.h" +#include "hex.h" #include "tree.h" #include "object-store.h" #include "blob.h" diff --git a/unpack-trees.c b/unpack-trees.c index 3d05e45a279..9c1f2a14b45 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -3,6 +3,7 @@ #include "repository.h" #include "config.h" #include "dir.h" +#include "hex.h" #include "tree.h" #include "tree-walk.h" #include "cache-tree.h" diff --git a/upload-pack.c b/upload-pack.c index 551f22ffa5d..fa4bb61e4f1 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1,5 +1,6 @@ #include "cache.h" #include "config.h" +#include "hex.h" #include "refs.h" #include "pkt-line.h" #include "sideband.h" diff --git a/url.c b/url.c index e04bd60b6be..bf318c05205 100644 --- a/url.c +++ b/url.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "hex.h" #include "url.h" int is_urlschemechar(int first_flag, int ch) diff --git a/urlmatch.c b/urlmatch.c index 620a648efc5..2965cbe774f 100644 --- a/urlmatch.c +++ b/urlmatch.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "hex.h" #include "urlmatch.h" #define URL_ALPHA "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" diff --git a/walker.c b/walker.c index 99d0e0eae04..c0469363789 100644 --- a/walker.c +++ b/walker.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "hex.h" #include "walker.h" #include "repository.h" #include "object-store.h" diff --git a/wt-status.c b/wt-status.c index 3162241a570..90525bd26fd 100644 --- a/wt-status.c +++ b/wt-status.c @@ -4,6 +4,7 @@ #include "dir.h" #include "commit.h" #include "diff.h" +#include "hex.h" #include "revision.h" #include "diffcore.h" #include "quote.h" diff --git a/xdiff-interface.c b/xdiff-interface.c index e87950de32e..5baf6ceb947 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -1,5 +1,6 @@ #include "cache.h" #include "config.h" +#include "hex.h" #include "object-store.h" #include "xdiff-interface.h" #include "xdiff/xtypes.h" From patchwork Fri Feb 24 00:09:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13150847 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 36E71C61DA4 for ; Fri, 24 Feb 2023 00:10:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229722AbjBXAKH (ORCPT ); Thu, 23 Feb 2023 19:10:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229644AbjBXAJx (ORCPT ); Thu, 23 Feb 2023 19:09:53 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 729921E2B5 for ; Thu, 23 Feb 2023 16:09:49 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id az36so733177wmb.1 for ; Thu, 23 Feb 2023 16:09:49 -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=aOetjYVTgxj2h+uPlcZBDYI/t2iORD8zZa/JYmEx1sY/tmCb93gYJ5PMC4mkUtSJkS oY1Vq8Wf83MCfAhtZDCq3AhBSboTOFjzlz0BwxQNBfnObMmx+F2iiGQE0hPowRAFH9Ra c6jT3f/mMr32wp7OojoG2IdGN3VhxpgrxoyAlsmIa2vgZgVMbMSOsQbW+fNx18qtXQWk +eJukHJDGnMku6isFDZdRKASQY8pXYUPKzMDOE5QuaY9U8RdITkHTHn0WIJsLv0OuPdN s+3z8q91sBPPRCh9Dz1rnjloAZMPhzs9AAdeMGkiCR7jgfBDQ8QY44j+652yuLNagmB6 jQuQ== 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=dyd3vIK4dSWmHD7CBGKUa9YvCQdYw7HPVeLkZBF7gwz9gnFWWqntCoAqGB9pHSMjSI oD4l+t9amFO2jnV+z62q9JhgHlIE9WVnZMeasf0wNjCBZUKOD+fO2mwOGrRMD3hndJNA YLRqpjBMaAz3Ua67QRPCEHlLHrMyHlD97aWln1qvi/E6exApYpm7n8Bjvvd+SEl09xmo ZS49VUdn+vJa8ZZJ252QtAs3MY1eu4Mj7q1xj/A/c1ivFc4+7PhURO9MwhOWe1SfXdG5 /kEBzDZLY2C/oRsZ89BjTmxPmON8i4CO5CibPsKoVbKuRfju6jjYsKM2aRgK1W5AcptJ ncSg== X-Gm-Message-State: AO0yUKUb2FDJ4EyknBcnIQH7aAe8Dq+5n9Qm6mmEEY3S81jwa03XXohW oVMHKWxvMGEgN7Sh+zYiainwrGZerhM= X-Google-Smtp-Source: AK7set/l0hu+GbZl8rN3u1uZ2NN/IEPGtLjFUHqDIbfnnJPF7uO4nfLkyyIAXtrkOyPsrtP1kHxsTA== X-Received: by 2002:a05:600c:1609:b0:3e2:1592:ccf5 with SMTP id m9-20020a05600c160900b003e21592ccf5mr8218087wmn.8.1677197387907; Thu, 23 Feb 2023 16:09:47 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bd12-20020a05600c1f0c00b003e0015c8618sm905561wmb.6.2023.02.23.16.09.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 16:09:47 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 24 Feb 2023 00:09:28 +0000 Subject: [PATCH v2 09/17] pretty.h: move has_non_ascii() declaration from commit.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Derrick Stolee , Elijah Newren , 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 Fri Feb 24 00:09:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13150849 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 45537C61DA4 for ; Fri, 24 Feb 2023 00:10:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229727AbjBXAKL (ORCPT ); Thu, 23 Feb 2023 19:10:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229686AbjBXAJ4 (ORCPT ); Thu, 23 Feb 2023 19:09:56 -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 52A05206BE for ; Thu, 23 Feb 2023 16:09:50 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id bw19so1693863wrb.13 for ; Thu, 23 Feb 2023 16:09:50 -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=hs0Kirh6Ks9gVzZeeD7dB9V705dm6hE6h+AnSX3of9A=; b=FbiJzsR8TX8Y23Rja8HqADr929sk5qDdSlLRYNN52EwrmU6YBz/n5FLhIk+JlFlr7L GBjgBGf9DTk8SzDt8Q8d6TH3ljl+Bn8WiRvN7DdXfYcUQnlTm36CVvl8dydQO8Xl4jRL HtRPTLLKLsrfC3bewWAEH2eZwNQUTYJxMl5+9kL7U5DaPlbY3baO6XSPS/RyhR8Pyb9/ mAeJ1Fw05Sq2hH3P2Nyb4BrESBoIFbwHCVnLF5M5PbaKhOI2HHdt9T4kX6fQP1loHRPM h2RC9uJ6ceKYhIwMfgZOz6ynoP69HKIvtAfMQ91EWkk223KUCzXj1BaBguou3ZIlO65X M1oA== 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=hs0Kirh6Ks9gVzZeeD7dB9V705dm6hE6h+AnSX3of9A=; b=msUC8K6/t9XqvO9BlKerLUGnRNTgSwOJetwMcEhmppDoKK6/LXXD/Ol63sF3x3F8If gK9gfH2X7u3Sx43iTv3UzigCmOAY+vWxJ95XxvBIGvzMR0i8fspE8nv+d/x8N1XBPpjj taHXD+i6bFOInPh3vhSgt7v6JV787qA4nZFYDCG1yQPUm8+jaZsvdWgcT7AXsxhlm+Es mn8pMsTukRjO7VuhnXHfiBiUy5C7N2dOVe4eoTMM17Vg7NVMyK7pJLeSn0nulc80He7I +26S8ZBWzfXl4Y+aGRS78+Y03KPuDZ1Ct/+cwcx+JMpW8Hm/w5atPOFphbQFtd+KQMcz N44Q== X-Gm-Message-State: AO0yUKVdeSy22SD6UJ6ay91Q5xnSMaEVelMUNWtrJdcM9PRkPJoysF0y 2Cxr/sbdTpfLpOqWTw2m5iVLic/meI8= X-Google-Smtp-Source: AK7set9QNMptZ6FB3GjKSWaJKSDpMXa0Lw5f1BMcaOcyIRcqP23jDM2/K+2bptELanVdx95Ka8L+yQ== X-Received: by 2002:adf:f082:0:b0:2c5:8736:c022 with SMTP id n2-20020adff082000000b002c58736c022mr10637913wro.62.1677197388641; Thu, 23 Feb 2023 16:09:48 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id y6-20020a056000108600b002c53f6c7599sm9880969wrw.29.2023.02.23.16.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 16:09:48 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 24 Feb 2023 00:09:29 +0000 Subject: [PATCH v2 10/17] ident.h: move ident-related declarations out of cache.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Derrick Stolee , Elijah Newren , 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 3040016e27a..88c5ea8b267 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -10,6 +10,7 @@ #include "builtin.h" #include "diff.h" #include "hex.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 0c631e75b55..4e0d9bccc06 100644 --- a/cache.h +++ b/cache.h @@ -1445,65 +1445,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; @@ -1570,9 +1515,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 6f257c70054..31bc5c45ee6 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -5,6 +5,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 Fri Feb 24 00:09:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13150850 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 C56D2C64ED8 for ; Fri, 24 Feb 2023 00:10:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229735AbjBXAKO (ORCPT ); Thu, 23 Feb 2023 19:10:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229578AbjBXAJ4 (ORCPT ); Thu, 23 Feb 2023 19:09:56 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D2E21EBDF for ; Thu, 23 Feb 2023 16:09:51 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id c12so12328180wrw.1 for ; Thu, 23 Feb 2023 16:09:51 -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=hRGiaNzBj7nodwrMzKkhTZw7QTtRHjysFfK16UOgRjc=; b=Rc0k83t1BZMRqKI6CFRQRKBzTWrQxIw6ok8jlIadXeqZxl0dXpmOYCyr3t/igztfuQ k/OBJNfyHNAeN/2+F+nfDFt90IiJXJ5BrmD2NlVRiCDuAFFzKX7ic568bWH5QMwoKYKi Yzyu7Qpyec5+sA/SW3lJQ3SY395NYDMVYzTT7KAgHqVAlLRIbtD1xy99l/XSKiST/k2i 6GgDyTYfUY45jYDenfTKRgQ9HhvBT/w3J32NRuNaI5fb6IWxp0QtwZOmlZQ6uuKY+G/N APUHHAFLJqrAPJhIlxUrvAFkx6HlVieijNL/EfSiej4mcBl644nUc0ZmOdEq5J6FL1Xf 3o8Q== 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=hRGiaNzBj7nodwrMzKkhTZw7QTtRHjysFfK16UOgRjc=; b=PLYeojwhC4zcs/pUkw5mF5wGhCeM3FZHNIEkhi3cOBc73EjvUxt79sNpf+BO1TVnfy QaS7KxSSAZEogLuiQXniFm6inkQyGMg6C2fWuhBReLstM+TJFhprFZ6tjcfaVRrKAr6u W5FWxj43K3Gz7F9y6R8uxaFCSr65hLAJeH9lUE2x3GiNA6fdsBy2J5XWwt2zYQBhWzQ6 zOOrzQXf+UAgw+hTaBIDH/m8LvxhwsG6abwNRcEab0xZT9gbxJL41YhY/Vt091Oph8q8 2o+u/fS+IVWDI7SIHQ+5IcXMvlJFxQi8AOAtiQHpcSExdE7JcUJWIw2y2/6ZhKA5j6CH vXnw== X-Gm-Message-State: AO0yUKVjLQW5jajpFRbS3C91hx8OSMuvSmNyE0Vrw/Dkjwm4/lmz4116 NHbMoTJ/GH9P/Mmt2WXGCbq3ZymNuDM= X-Google-Smtp-Source: AK7set/UamXuX898L+b4Ctg4VMFrjmiEAN+JLRZwvBMSeWHLbMblYdDO35UfS6lGumUNoMrXdGIOdw== X-Received: by 2002:adf:fe06:0:b0:2c5:a48e:8623 with SMTP id n6-20020adffe06000000b002c5a48e8623mr12141480wrr.64.1677197389399; Thu, 23 Feb 2023 16:09:49 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id be6-20020a05600c1e8600b003e89e3284fasm851705wmb.36.2023.02.23.16.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 16:09:49 -0800 (PST) Message-Id: <1636615ca73c0a9999a7ada6be08c2c0743698a0.1677197378.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 24 Feb 2023 00:09:30 +0000 Subject: [PATCH v2 11/17] 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 , Derrick Stolee , Elijah Newren , 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 half a dozen files. The inclusion of strbuf.h in some headers if of particular note: these headers directly embedded a strbuf in some new structs, meaning they should have been including strbuf.h all along but were indirectly getting the necessary definitions. 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 4e0d9bccc06..d0e105ec58f 100644 --- a/cache.h +++ b/cache.h @@ -14,6 +14,7 @@ #include "pack-revindex.h" #include "hash.h" #include "path.h" +#include "object.h" #include "oid-array.h" #include "repository.h" #include "mem-pool.h" @@ -453,26 +454,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 787fd524557..127f134a2a6 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 "hex.h" #include "test-tool.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 Fri Feb 24 00:09:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13150851 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 40388C64ED6 for ; Fri, 24 Feb 2023 00:10:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229549AbjBXAKQ (ORCPT ); Thu, 23 Feb 2023 19:10:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbjBXAJ5 (ORCPT ); Thu, 23 Feb 2023 19:09:57 -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 B90CC23674 for ; Thu, 23 Feb 2023 16:09:51 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id bw19so1693895wrb.13 for ; Thu, 23 Feb 2023 16:09:51 -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=LjiROEw7t4k/UK8LW1YqtV8umnY5OClakiSdQxpUmY0=; b=GMOV94nyXfgBbjNT85xsK6Vk951i1qfay55iuHXPi/xO4Bwx0E3oKFrt143/HgYoXf MYEjnheUv/sdnnbOBU7AvY8bk8BEmdl+EWVWEBRBmac6bKfONdKFs8jbwhVVHpvaAs0f miwWT/k63bb/i5S/aasx1XtFgXV3fsDhEGOVHbENKqhEITznP2XrJZtfVAXnsEf00q6k Tji3h1voyfViGDVoi6nyZLN+zG6l2hwl6+fghMQr7QoPoHgsCIhjfKt7lX9lWmCFNlOO Qo0DbIee8OleNwjqrDvLWBs5c0Ci+Tu6Irl0hoHVyZJN9NU7OyIuClXTKSdYAQatfMsp SH0g== 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=LjiROEw7t4k/UK8LW1YqtV8umnY5OClakiSdQxpUmY0=; b=PK160sYqEGDQIbuIcc2/dkQJh+UN2o6L4ofSnMTpmI5kr4LEG3G7nZImr8h0WWKZwM em0oifzs00yq4sN84yiXq9xCAgNDhAPyI5XRgjQ4eu+sIRIRlfoY4e1T+bK09hzkF8OX bDHPsRZfiNe/R1NmsLiKsuovWTwS2DCpoVjhVoYb4ns4Zbb+GfMdEv0aDCVVugaIpA/b rTnEGHcI7c4tuKJMzH+/xP373dmQDSrfY/y0jj1f0mc6+bTGs49GqMmRqk0JMhcgg755 3rJQniErJq0ZCfhg0cwQ5p9U6rWet1sn1EEl3U4JSEO/KLwNQqiFoyCqhk0UiWmlwaNJ AXFw== X-Gm-Message-State: AO0yUKVNlY6x1zsk1htE4xvoarvGG5C/lsjUraxxsCdgwVDfscfTg/uH g2PxRcGe+RqcK/xThaMvpRuax7/xQ2Y= X-Google-Smtp-Source: AK7set8eIrvTEhtcxWMoHm+aOVnjzGE4T2d3IXLYls6izJDfxjY3dQOp9yjADH35I4GBk6ytFW4FJQ== X-Received: by 2002:adf:e889:0:b0:2bf:ae19:d8e4 with SMTP id d9-20020adfe889000000b002bfae19d8e4mr13095268wrm.16.1677197390131; Thu, 23 Feb 2023 16:09:50 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x15-20020a1c7c0f000000b003e20a6fd604sm852967wmc.4.2023.02.23.16.09.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 16:09:49 -0800 (PST) Message-Id: <856d3dbcc6e91ae46af8db8596c6a222b6d60e4a.1677197378.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 24 Feb 2023 00:09:31 +0000 Subject: [PATCH v2 12/17] 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 , Derrick Stolee , Elijah Newren , 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 d0e105ec58f..fdb3125f00d 100644 --- a/cache.h +++ b/cache.h @@ -14,9 +14,11 @@ #include "pack-revindex.h" #include "hash.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 { @@ -119,26 +121,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; @@ -294,6 +276,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 Fri Feb 24 00:09:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13150852 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 43182C61DA4 for ; Fri, 24 Feb 2023 00:10:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229741AbjBXAKR (ORCPT ); Thu, 23 Feb 2023 19:10:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229669AbjBXAJ5 (ORCPT ); Thu, 23 Feb 2023 19:09:57 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75FC019F13 for ; Thu, 23 Feb 2023 16:09:51 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id c12so12328210wrw.1 for ; Thu, 23 Feb 2023 16:09:51 -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=Z/xn+HgvYrS95jt13hJGU0co0KYRBMbn2u24VFc0FfQ=; b=hND76v3RFTMK4Vrn1nzMIPBB4+tpXdyneecV5d+QAcYm29o3JIcO/c/vPEIwB8PdYv vO9d4EOrOTDSR9gGZrG7Hi+x3UWXcZyp0uVufOHbi9/uM1KjKogoHrxZEH5v0aSiGFoJ R/xs8dzJJZ2MhsvozmJIPKOOxLUwVTLdbDBUau8ILUxUGOVbRNuRSFrOf8Iw9w7gsNoO GM9z3FY31YMuu6PhWWAbrGIxFel/1MhVA4V7XsA4pwfRYsHjm5KypGeWBXdCFtVDvflV yg+LsPCLWEeNtmlMYSunpuGZObPsqgiQhIETXwQ2OimCq5ntLFUztWG8G+pjmfS4rgu6 o2Xw== 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=Z/xn+HgvYrS95jt13hJGU0co0KYRBMbn2u24VFc0FfQ=; b=vUaS8BolLjRgX/opU0C8/vx/B2PgBHLFmCAUJ2kuuO86nN/bUqw8UvbQRkwa+UgCym BE/ld9kPYYP1W2w63F88uYMEbu1NWhgxgJUiPYooImc99f41UE34NK+wm4YSKXILPEMQ uqYI0AWDaaYOBAGxfYag2DJgr6/nFRb752v7Ws+Spn1xAnuGcr3LXEtzkw0yikl5Dm5Q 0MSWHxxTw3ohFdC1IphPRCNPmJyG3I38uhUT51oOndDzVdWCwobOQ3DkGpRkXmzMHY9t Sr0GAAvtkjmMTSPTyiv8fD/GSvwONcyocnmB9vrgMQgExKzxyLfptVtXqSz80J06Mcmz f4BQ== X-Gm-Message-State: AO0yUKXpTPholrN5sMNTCsKFtOibldP1znZA4TxzFIV+ItWVp102jjNS XBhCqFyCLdfGXYlCJcjkhr+h5HztK08= X-Google-Smtp-Source: AK7set97jS84ANFqlwN5kcv3HH8KLQBOzMTOb13WZVYCmEHrTAMhnDva1cynB+pB24jNnsEHQNN2GA== X-Received: by 2002:adf:f010:0:b0:2c7:5ad:9c69 with SMTP id j16-20020adff010000000b002c705ad9c69mr8664909wro.71.1677197390791; Thu, 23 Feb 2023 16:09:50 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t8-20020a0560001a4800b002c54e26bca5sm1586324wry.49.2023.02.23.16.09.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 16:09:50 -0800 (PST) Message-Id: <12eb68b1ba36fcdcb5d97c6119db5581477a742c.1677197378.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 24 Feb 2023 00:09:32 +0000 Subject: [PATCH v2 13/17] object-store.h: move struct object_info from cache.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Derrick Stolee , Elijah Newren , 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. A surprising effect of this change is that replace-object.h, which includes object-store.h, now needs to directly include cache.h since that is where read_replace_refs is declared and that variable is used in one of its inline functions. The next commit will move that declaration and fix that unfortunate new direct inclusion of cache.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 f9bc2a8b90b..874bc815b4f 100644 --- a/protocol-caps.c +++ b/protocol-caps.c @@ -5,6 +5,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 Fri Feb 24 00:09:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13150855 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 C8EE7C678D5 for ; Fri, 24 Feb 2023 00:10:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229598AbjBXAKU (ORCPT ); Thu, 23 Feb 2023 19:10:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229697AbjBXAKA (ORCPT ); Thu, 23 Feb 2023 19:10:00 -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 5DB282FCCD for ; Thu, 23 Feb 2023 16:09:53 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id r7so12165165wrz.6 for ; Thu, 23 Feb 2023 16:09:53 -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=m0zLeEp1uFK+VIIA7ZOUbuDLTStK4YGoCS8zeyeoGf0=; b=iiJgQgLJxoUGldfYzUH41XG7qUSnPzrBJAvsGH3q00BXLq86RibqJj8WIYRLZHpCwy YBGHzmxi5PFad95kO6Kgu+KnrxgSkgnd/JTbvgdJymQceaL+dXIcssOZbLTTNsUqVyei 2VnNpeGCQTyUadC8llBjcj8/OBQX68KSmN6ogq4WY19ms04c37eZ4j2nm9xMwWKpz/0x PEV3Kts3cp3Pbu6PGsaVwNz5ws6lpMjncqAu/VsG0/u+dQO9ZPtWdSlVjA7/4PFo2pfm zM6uWNDm0rjfCVkAhkwm1FQEmJU9S+mIDy4DbBy8zcrehqZ+iZtnaQ8glcNHHA5j3rTC p2ig== 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=m0zLeEp1uFK+VIIA7ZOUbuDLTStK4YGoCS8zeyeoGf0=; b=g6GEKsXRd7AJg5Hplt9p25joIQgjKX02DE1Ir5zM1AVMfoLgj1WbaW/2y9eDtkolMU ndvor52jDCohVAp0hA7RgH7syOvhvHky15rgmi8LuDBt477eJcT5QcP3DtC03Dsbxvaq vIpEDBpHqeyo1fJg5oetHt7wfHVnM9K6ZCupQ9vvk5KWnXnsQVEDvcOiMHHSPTj/i38f LrsJyE5doBKCiASJxRaOYmD0WcSsSB5d4Q+CsVVhTaqFiPImKQEnXhqWE0cPW/zDXVGU JufioWA+6GieIto8zGQ4HluuvfTlRcH9pB0Qfc47O1r2uHxLDdSd17KNZjuWzZrVuvay 0LUQ== X-Gm-Message-State: AO0yUKVRcDMz9t9yKciG8NaXxE11ePuTQdvMiTLkyBLz8KvjAwQ5dfNk nNZ5UIQkb/cdwIG4yHsu/Bd7uD9cv1M= X-Google-Smtp-Source: AK7set+fMVRwidMZNd0K38czWBopDxhtkKlW5lTQTsFpsR8gwF6Td+ml6+nOSwKz6oxiMqT5c33eug== X-Received: by 2002:a05:6000:1f83:b0:2c5:642f:1550 with SMTP id bw3-20020a0560001f8300b002c5642f1550mr9961282wrb.15.1677197391485; Thu, 23 Feb 2023 16:09:51 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id p20-20020a05600c359400b003daf7721bb3sm901704wmq.12.2023.02.23.16.09.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 16:09:51 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 24 Feb 2023 00:09:33 +0000 Subject: [PATCH v2 14/17] 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 , Derrick Stolee , Elijah Newren , 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 88c5ea8b267..b7a73acb074 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -18,6 +18,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 6dc83dc51b3..d3be7f3b318 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -8,6 +8,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 af0fab660dc..134b0bd18cd 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -20,6 +20,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 21c0e109dd2..b451755f405 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -16,6 +16,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 2b5e85988c9..2e73284f107 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -32,6 +32,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 db767b7a8fa..f2ed45ccf03 100644 --- a/builtin/prune.c +++ b/builtin/prune.c @@ -8,6 +8,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 cdcb39f737c..71d8e949e35 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -16,6 +16,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 e125b121883..1908dcfcffb 100644 --- a/builtin/unpack-objects.c +++ b/builtin/unpack-objects.c @@ -9,6 +9,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 fdb3125f00d..0221bc6d5c9 100644 --- a/cache.h +++ b/cache.h @@ -886,14 +886,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 ee3dfb6b659..043e0df685b 100644 --- a/log-tree.c +++ b/log-tree.c @@ -13,6 +13,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 Fri Feb 24 00:09:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13150853 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 18A80C64ED6 for ; Fri, 24 Feb 2023 00:10:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229711AbjBXAKS (ORCPT ); Thu, 23 Feb 2023 19:10:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbjBXAJ5 (ORCPT ); Thu, 23 Feb 2023 19:09:57 -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 D44BC2C665 for ; Thu, 23 Feb 2023 16:09:52 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id j2so12146007wrh.9 for ; Thu, 23 Feb 2023 16:09:52 -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=/exVLOfyJ821kcaMlsfzPXkBPgu2DlOOQJ132O2GD98=; b=RT/RBJVbQPqRuQWia64fGD0FwwGlgDonryjz8fEDUEqOtQzCotHknfZQAK7tSWk+Vr O66h5PXQLhmacHn4Ch+BO+i/Olu/Xsr3oSIWwzfyVNrlnlUhONsw1uH73rRhI5Mt8OfO aDOs+B8Ljq9rlEI2xhr8FU17CJn4NsNA7YlBv/7Q3JDsvRo4UK84drQ+aR/BbCHlkMBw t403by4XucJgAR7qw0gWSojmGirS5E1DQRrv8GqsqZDW/I3K+fmHIa4kp7W8uwzHx8su CW0nDpHuC5P1DPdJBRCLoAzvnpfCYk2vTDBWXthuPc1Sp97EmKadVV3RvhXZO61IqOrU 0KOQ== 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=/exVLOfyJ821kcaMlsfzPXkBPgu2DlOOQJ132O2GD98=; b=bn3NCL4G8Lm/iJJ4C3REl9WplCgQcgZuyfxbj1LUBLNSjJfgYIozvnTtbf1hIve2kd P9Asv7eUL0Sbke+Jg9oeaox/YHCytISsnn4AKZwye4LzvDQ0ZbhaEXD2inkNQGth8HbS 6qaHP1y7qYZjJ9f9sWUfqJdo3VJFqz50xLBH+PCQRgq2HiX4H71TP7Bi31eLDUQkRwL1 uSYfaFvZIUi4UFywq8q4mVHmcQBtF1upUD9rj5UfOQRyCEUR9vPAbIhmTa6l2iKYgUYx 119C/Z6opqvZgvxx+ZICLUSPr3PUPfEi4fT3p+EFAI/dHcA/qeBQehuoURgE2IfUf/uQ RR4Q== X-Gm-Message-State: AO0yUKU67ZBUzaDF0xPH0/WjkC/B40z3H6dqYQ8PJQhuWEORwvPYc+ni aETJ5igXwyM0LAPtTkvaxCg/Hr2ynTs= X-Google-Smtp-Source: AK7set9wfRy9w4cIFafxD5w4TBRI6Jv4mV2I0C2l36iKtjzYUnUGacZxgFN/4SPDs6w15/ENMg7/cg== X-Received: by 2002:a5d:6645:0:b0:2c3:db87:977c with SMTP id f5-20020a5d6645000000b002c3db87977cmr10493261wrw.12.1677197392208; Thu, 23 Feb 2023 16:09:52 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id q2-20020adff502000000b002c573a6216fsm9788665wro.37.2023.02.23.16.09.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 16:09:51 -0800 (PST) Message-Id: <814d60ec94ef56071becb4ea03d2524e088a75f7.1677197378.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 24 Feb 2023 00:09:34 +0000 Subject: [PATCH v2 15/17] treewide: replace cache.h with more direct headers, where possible Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Derrick Stolee , Elijah Newren , 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 | 3 ++- unix-socket.c | 3 ++- url.c | 3 ++- urlmatch.c | 4 +++- 12 files changed, 30 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 72709606fdf..9b675a046ee 100644 --- a/sha1dc_git.c +++ b/sha1dc_git.c @@ -1,4 +1,5 @@ -#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 bf318c05205..2e1a9f6feec 100644 --- a/url.c +++ b/url.c @@ -1,5 +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 2965cbe774f..eba0bdd77fe 100644 --- a/urlmatch.c +++ b/urlmatch.c @@ -1,5 +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 Fri Feb 24 00:09:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13150854 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 30C4BC64ED8 for ; Fri, 24 Feb 2023 00:10:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229754AbjBXAKV (ORCPT ); Thu, 23 Feb 2023 19:10:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229721AbjBXAKA (ORCPT ); Thu, 23 Feb 2023 19:10:00 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63602302AE for ; Thu, 23 Feb 2023 16:09:54 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id k37so7327275wms.0 for ; Thu, 23 Feb 2023 16:09:54 -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=irEOlEc1lU4vJhiELaNbnA1GkGfzGfif8QJhz74IucQ=; b=cdVFjYeMFV5jjcKBNwSkHTyW5yTUvved+E89Y37gWIhzbQLLmCGKR9EOqUQg1hkcoW 81RTw7QFgQxwBHDeeYSE+BkpWnab8wiD5bgMW3Up54FzgGAiy13c31Jlkv4ZD5tFT/Vd WJabfy+bE94ZQ4UhZr5h19BvlIhxwd1HwTIio/Y657aZ6UPlgkNIyZbXGvDK4fJFXSct ESJHZ5aao2Fl52Yi3QL13eqd8Qzd+mXS1I3K5KFoDg4lVMHuPMVFL4qLPN1hJYtkeWzm nbNUmKywCnhGmgqMegB5cPw9Mxhq9s+oe7jJnIeI2l7/JN9kNRR4YQkKUaQaDS5d3jtT 7xjA== 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=irEOlEc1lU4vJhiELaNbnA1GkGfzGfif8QJhz74IucQ=; b=A3lWNEHzQj4y2vlN+DELEwwZF/o25Wj4cjcllf3aA6MEes0KXccKiJP4xJggTekL+a j+k6oDE69ngX2w0j752jbEH/WRKtJZoD7ZGnXg2RbxyCA7feB92rYWoFdY4fDrlwFRRv Q71baHkD5g9z+sUWrmwUy9qLJqBMPbBlNEc+80po3eGhJ/zhfeIA2IuVsPVHxYoUb9r5 IAuHbIarPt2pNMj5haklLELg3dtI/Uwhm3jVc3BX2wzC8RG6A2tGuo9RHCOcOGmRCJ+k yc2uf8M2PGnHH43dlRxIvbYUJl9oVJGfaKhqI+jXlbyRSIo4ClkBeyXu17XXYu0eWicq qPVg== X-Gm-Message-State: AO0yUKVirST0ozB+L9qKPn9Nv9pjOSTdL7fIZZyC//WeqsIsMmQB0Bcv TLi164exeCYfAuEGEMgS7NTvCN+rKcM= X-Google-Smtp-Source: AK7set/8SF52LTgKpP+W0zy5loWcpPhgqbJoJtsWyWMVqWKCwzzWX0ld1YkQFWWMLR3J9b4RP9CYMw== X-Received: by 2002:a05:600c:1c8e:b0:3ea:e677:5017 with SMTP id k14-20020a05600c1c8e00b003eae6775017mr1293807wms.8.1677197392876; Thu, 23 Feb 2023 16:09:52 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id ja20-20020a05600c557400b003dfefe115b9sm899765wmb.0.2023.02.23.16.09.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 16:09:52 -0800 (PST) Message-Id: <97d3032346fc669b2cc7cd5e22a37c522bca8916.1677197378.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 24 Feb 2023 00:09:35 +0000 Subject: [PATCH v2 16/17] Remove unnecessary includes of builtin.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Derrick Stolee , Elijah Newren , 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 ee144676b76..89731f40908 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 954104673f3..423a5cfe22d 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 "hex.h" From patchwork Fri Feb 24 00:09:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 13150857 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 46D51C64ED6 for ; Fri, 24 Feb 2023 00:10:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229775AbjBXAKs (ORCPT ); Thu, 23 Feb 2023 19:10:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229731AbjBXAKO (ORCPT ); Thu, 23 Feb 2023 19:10:14 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FA194614D for ; Thu, 23 Feb 2023 16:09:55 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id j2so12146031wrh.9 for ; Thu, 23 Feb 2023 16:09:54 -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=RvznWZKBCa76p4i2hyaUqC8KKMcaXD979tN1OAkNNniCMMIzl9SL7ORlFVPAPhmA/7 81SSp3l4B2Z6u6CebVBiGPKSclcbWXg3KB9ntiq+h4M5zWVcMXt/r24q/nxbS32OGk2+ //pk6L/WkOIlucbrfGsC1bm+OeFzNJ1FUwRei1XRxRTfhc/wotl7Twz4zdmbYi8BFiUJ TTpKCQUXr/SrO+wBAEGIWAmV7TnjDSCBKIBnZlWczsnCtpCuAioxTlTp8k5Vhrr9nkhS 9CgmwyRRh9KNPs+eX400rB2tEDhNeizGUB2Wn3FyBBoRouEO8Z2MdNioYjLU6HzDnSm4 eqCw== 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=Jm0eKu4Gvj3XAq7zf+rCVnvvforMPQ7oVfLzpVJ7F0qCWjaR4VhLz2KTD5NJGTFuUM mnuTeJmUbI9lvmGc/aYywZ78WkTk+rzYzoRplAYHiWGAv1RnpwoisdVNGxGuUbaGzHFE IFFKkgUWNhkPEs5ZAaALiSJWK9kROMMxOS7tdlm19gxPs/g8eDCxtEEL9R/PtqUQFqsa 3W32DYOlGnM8Q2ZQsd6CV9rUXH1jwzJKKAX/PEWBxJ4iKga+JeouLk1IIw/rn9b1U31V mNK/eXZ+k1LeHjIAEf7XA8CO2o8JIzIZrY51UnHqbTfPuV5+HulcGTmTLt2bYOG2Behl isew== X-Gm-Message-State: AO0yUKWIcDzi0xF4rMNbTFekROlMwebOhSjb9/ucAukSFtv/Ekeo7nna QyI2A9bktohHYu6lRzYTKyK1/NLRhrc= X-Google-Smtp-Source: AK7set8QBJZMwMLtLQKYhv3yRqMzQQOiOSWqR/mqyMeW32gQMZbkv3iyVfg/2jyDoHACS54jsFxmnw== X-Received: by 2002:a5d:440c:0:b0:2c7:778:5da6 with SMTP id z12-20020a5d440c000000b002c707785da6mr8312110wrq.42.1677197393482; Thu, 23 Feb 2023 16:09:53 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g2-20020a5d4882000000b002c55521903bsm14546972wrq.51.2023.02.23.16.09.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 16:09:53 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 24 Feb 2023 00:09:36 +0000 Subject: [PATCH v2 17/17] diff.h: remove unnecessary include of object.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Emily Shaffer , Derrick Stolee , Elijah Newren , 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"