From patchwork Tue Sep 22 22:49:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matheus Tavares X-Patchwork-Id: 11793507 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 624FD59D for ; Tue, 22 Sep 2020 22:50:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B0122076E for ; Tue, 22 Sep 2020 22:50:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=usp-br.20150623.gappssmtp.com header.i=@usp-br.20150623.gappssmtp.com header.b="G+4tElQy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726787AbgIVWut (ORCPT ); Tue, 22 Sep 2020 18:50:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726637AbgIVWut (ORCPT ); Tue, 22 Sep 2020 18:50:49 -0400 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED1E4C061755 for ; Tue, 22 Sep 2020 15:50:48 -0700 (PDT) Received: by mail-qt1-x841.google.com with SMTP id k25so17062528qtu.4 for ; Tue, 22 Sep 2020 15:50:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp-br.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G8k64ZCfnLfypepuOf25OgupUF4UnPCEHqXyUVVuwAw=; b=G+4tElQygG8bF808U2ggOZdDrC1dcRvZ267WkIKIW1HVSpk+WEJlX6W40rgsc8VcWf zrToBk+JkJKeG0hJavJGXHTpgPXtyht+5et4JHHd1nBRrjP42ge0b8rWewoiOBZsRW9b Bjx/TNyU/D/ZK2ksA87UfDc3r5XNc6yTVj5eRf1gTRKvYgbCYka7zRcxCzV9A6c6SsOE fm9ZPpv6RGcfmfvELCCO0MNsp9yy91BqsiK2cSlFL/xnh37JU9hXkGL85yOXp+MzbH3Z SlNuDyK0HlgMv5lYphoxdhyti1kGlNLft5tNWQ145KTo5Lm8nikVokTXimhYB+byJ2Ez pn1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G8k64ZCfnLfypepuOf25OgupUF4UnPCEHqXyUVVuwAw=; b=oYxLmUHzZi7AMT+ugGLF4MhJa8Ku6eCVXyIxbNFDYTPTJ7wyyWK5izf2RwsHLfCYYJ uMiTcFzB8ZKm6fR1TmYzghHlGvqMw/9uus/uzf/VklblVNpUDI2rvErc0BehmPeyvjkz c++DiWPt84hXkgtr2CCg7HRgFvUL8xQoiEWF+1Ynr/H/tzNFXbpyooIGK16DoNb82tpa q5TucuKonSwM4GUrSNyQwiX8d2Tp34TCv6KP5oExdfX/CVMLBYUPcG0hyb1pUzc4PQZ2 CgZam6kvymuHy3QAirdJm4nlpOZ/H9MMOH86qXo92nn134i/YhtL6b4fbsdJamh5ORgl M8Cw== X-Gm-Message-State: AOAM5339HmjCE+4YfuOagSAlUuSWhy5eSge7N07IqkvRDD0vuJ9epCO1 TgvG3xEx38C0WRE1Z1J/HzbyKTQF8IDiJw== X-Google-Smtp-Source: ABdhPJy9tg3GD27MMvuisPvP2c1rzjIPDS4ZEtCdosW68zMFYxYJESfYWZjF98gstPGvnLIdKaL4IA== X-Received: by 2002:ac8:1b92:: with SMTP id z18mr6940413qtj.265.1600815047737; Tue, 22 Sep 2020 15:50:47 -0700 (PDT) Received: from mango.meuintelbras.local ([177.32.96.45]) by smtp.gmail.com with ESMTPSA id p187sm12342359qkd.129.2020.09.22.15.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 15:50:47 -0700 (PDT) From: Matheus Tavares To: git@vger.kernel.org Cc: jeffhost@microsoft.com, chriscool@tuxfamily.org, peff@peff.net, t.gummerer@gmail.com, newren@gmail.com Subject: [PATCH v2 05/19] entry: extract a header file for entry.c functions Date: Tue, 22 Sep 2020 19:49:19 -0300 Message-Id: <25b311745aac7aaf43335a754ac8af3b79b65404.1600814153.git.matheus.bernardino@usp.br> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The declarations of entry.c's public functions and structures currently reside in cache.h. Although not many, they contribute to the size of cache.h and, when changed, cause the unnecessary recompilation of modules that don't really use these functions. So let's move them to a new entry.h header. Original-patch-by: Nguyễn Thái Ngọc Duy Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Matheus Tavares --- apply.c | 1 + builtin/checkout-index.c | 1 + builtin/checkout.c | 1 + builtin/difftool.c | 1 + cache.h | 24 ----------------------- entry.c | 9 +-------- entry.h | 41 ++++++++++++++++++++++++++++++++++++++++ unpack-trees.c | 1 + 8 files changed, 47 insertions(+), 32 deletions(-) create mode 100644 entry.h diff --git a/apply.c b/apply.c index 76dba93c97..ddec80b4b0 100644 --- a/apply.c +++ b/apply.c @@ -21,6 +21,7 @@ #include "quote.h" #include "rerere.h" #include "apply.h" +#include "entry.h" struct gitdiff_data { struct strbuf *root; diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c index a854fd16e7..0f1ff73129 100644 --- a/builtin/checkout-index.c +++ b/builtin/checkout-index.c @@ -11,6 +11,7 @@ #include "quote.h" #include "cache-tree.h" #include "parse-options.h" +#include "entry.h" #define CHECKOUT_ALL 4 static int nul_term_line; diff --git a/builtin/checkout.c b/builtin/checkout.c index 0951f8fee5..b18b9d6f3c 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -26,6 +26,7 @@ #include "unpack-trees.h" #include "wt-status.h" #include "xdiff-interface.h" +#include "entry.h" static const char * const checkout_usage[] = { N_("git checkout [] "), diff --git a/builtin/difftool.c b/builtin/difftool.c index 7ac432b881..dfa22b67eb 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -23,6 +23,7 @@ #include "lockfile.h" #include "object-store.h" #include "dir.h" +#include "entry.h" static int trust_exit_code; diff --git a/cache.h b/cache.h index cee8aa5dc3..17350cafa2 100644 --- a/cache.h +++ b/cache.h @@ -1706,30 +1706,6 @@ const char *show_ident_date(const struct ident_split *id, */ int ident_cmp(const struct ident_split *, const struct ident_split *); -struct checkout { - struct index_state *istate; - const char *base_dir; - int base_dir_len; - struct delayed_checkout *delayed_checkout; - struct checkout_metadata meta; - unsigned force:1, - quiet:1, - not_new:1, - clone:1, - refresh_cache:1; -}; -#define CHECKOUT_INIT { NULL, "" } - -#define TEMPORARY_FILENAME_LENGTH 25 -int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath, int *nr_checkouts); -void enable_delayed_checkout(struct checkout *state); -int finish_delayed_checkout(struct checkout *state, int *nr_checkouts); -/* - * Unlink the last component and schedule the leading directories for - * removal, such that empty directories get removed. - */ -void unlink_entry(const struct cache_entry *ce); - struct cache_def { struct strbuf path; int flags; diff --git a/entry.c b/entry.c index a0532f1f00..b0b8099699 100644 --- a/entry.c +++ b/entry.c @@ -6,6 +6,7 @@ #include "submodule.h" #include "progress.h" #include "fsmonitor.h" +#include "entry.h" static void create_directories(const char *path, int path_len, const struct checkout *state) @@ -429,14 +430,6 @@ static void mark_colliding_entries(const struct checkout *state, } } -/* - * Write the contents from ce out to the working tree. - * - * When topath[] is not NULL, instead of writing to the working tree - * file named by ce, a temporary file is created by this function and - * its name is returned in topath[], which must be able to hold at - * least TEMPORARY_FILENAME_LENGTH bytes long. - */ int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath, int *nr_checkouts) { diff --git a/entry.h b/entry.h new file mode 100644 index 0000000000..2d69185448 --- /dev/null +++ b/entry.h @@ -0,0 +1,41 @@ +#ifndef ENTRY_H +#define ENTRY_H + +#include "cache.h" +#include "convert.h" + +struct checkout { + struct index_state *istate; + const char *base_dir; + int base_dir_len; + struct delayed_checkout *delayed_checkout; + struct checkout_metadata meta; + unsigned force:1, + quiet:1, + not_new:1, + clone:1, + refresh_cache:1; +}; +#define CHECKOUT_INIT { NULL, "" } + +#define TEMPORARY_FILENAME_LENGTH 25 + +/* + * Write the contents from ce out to the working tree. + * + * When topath[] is not NULL, instead of writing to the working tree + * file named by ce, a temporary file is created by this function and + * its name is returned in topath[], which must be able to hold at + * least TEMPORARY_FILENAME_LENGTH bytes long. + */ +int checkout_entry(struct cache_entry *ce, const struct checkout *state, + char *topath, int *nr_checkouts); +void enable_delayed_checkout(struct checkout *state); +int finish_delayed_checkout(struct checkout *state, int *nr_checkouts); +/* + * Unlink the last component and schedule the leading directories for + * removal, such that empty directories get removed. + */ +void unlink_entry(const struct cache_entry *ce); + +#endif /* ENTRY_H */ diff --git a/unpack-trees.c b/unpack-trees.c index 323280dd48..a511fadd89 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -16,6 +16,7 @@ #include "fsmonitor.h" #include "object-store.h" #include "promisor-remote.h" +#include "entry.h" /* * Error messages expected by scripts out of plumbing commands such as