From patchwork Tue Mar 23 14:19:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares X-Patchwork-Id: 12158151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0D77C433DB for ; Tue, 23 Mar 2021 14:21:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A913E619A9 for ; Tue, 23 Mar 2021 14:21:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232148AbhCWOVD (ORCPT ); Tue, 23 Mar 2021 10:21:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231980AbhCWOU0 (ORCPT ); Tue, 23 Mar 2021 10:20:26 -0400 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5215DC061574 for ; Tue, 23 Mar 2021 07:20:26 -0700 (PDT) Received: by mail-qt1-x82d.google.com with SMTP id s2so14992233qtx.10 for ; Tue, 23 Mar 2021 07:20:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KP8FuX2CGg2Ar0PYLslZ4LneJHEVXrslFdqU4j7m3eE=; b=Si5v5jwkTsRGr2S/Mrf6yxtA1YHwVuhZy1tOVMCGZe0J/ncqw5QjGUyTKzG/OiN6B4 s2eAk4eKbYzGCRwjGLxNf5Am5HBN7vToQ9Y4Js+T4cWzmP9RAKL5ChE9RyvG9VJ45ITd C3S28r7/uCGzAHSvgrlUyBHKftwjjeu6y3yHDIPF/g5SQMks6yGheE5VOg+9lkg8eUub m3sHOJI+0KSXOVjr39tyZWwfW6XjnADM2zViVcFR0N+LNr/JjEPo1KdKiNN2RnRQ4YjT MAD3fq3zHCs/Je7zK/oBhztv0/pUs9uBqrxAjd2mcgc4FbnngxFL32TYgADjjp8/5UZs xSkQ== 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=KP8FuX2CGg2Ar0PYLslZ4LneJHEVXrslFdqU4j7m3eE=; b=k7VlpViChFZDZ8Wkwp12zo1bx7i+w0zsO0g/sm0dBWrOnTSm5sg99o7iRxI1+UUcs1 aOuSpwjRPeEaEPx5JleV8bcdTyDEGSidjiBEJpGlCO2lzo/yNWbhm/vFptw+3PT8H24u sKPrV1tpVAW+7taU4ljvMuymjGVbvtFgUuMK6SZSIxcvj6Fmsno7tpSa+jK352FGxqWy erXCth5c0orAYJB3OrkrrS+y7ClcpEmjslHGXbdl+Bw+AiKyT0/KkM35MwiMgdS9MACC KDMGVA6Ao3oNrYFXPR8nb0jZfRQdv6bjK8sMXB2NpKrbZktf5QRNYlO11z3YQhPU3ani HMgw== X-Gm-Message-State: AOAM533t2fkBAk3EFNGFhPfoOkuxn+Fa/Nf+t9369hW9PiDcbTOrelVX QwYp8H9fo01oAK2DHQmrSkSX17S1dskJuw== X-Google-Smtp-Source: ABdhPJwmlh/wKjwsxZBq8VQBx4yVT3IETJWxLEb2IkEHYwB8i+1t9449RbJMjtfmM8lmsthWtjmcHQ== X-Received: by 2002:ac8:7b8d:: with SMTP id p13mr4486896qtu.367.1616509225553; Tue, 23 Mar 2021 07:20:25 -0700 (PDT) Received: from mango.meuintelbras.local ([177.32.118.149]) by smtp.gmail.com with ESMTPSA id j12sm11011690qtn.36.2021.03.23.07.20.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:20:25 -0700 (PDT) From: Matheus Tavares To: gitster@pobox.com Cc: git@vger.kernel.org, Jeff Hostetler Subject: [PATCH v6 1/9] convert: make convert_attrs() and convert structs public Date: Tue, 23 Mar 2021 11:19:28 -0300 Message-Id: <5e8a1b6a1cb612dd5012a2d8866f16535e1edbf5.1616508954.git.matheus.bernardino@usp.br> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff Hostetler Move convert_attrs() declaration from convert.c to convert.h, together with the conv_attrs struct and the crlf_action enum. This function and the data structures will be used outside convert.c in the upcoming parallel checkout implementation. Note that crlf_action is renamed to convert_crlf_action, which is more appropriate for the global namespace. Signed-off-by: Jeff Hostetler Signed-off-by: Matheus Tavares --- convert.c | 35 ++++++++--------------------------- convert.h | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/convert.c b/convert.c index 2d3a5a713c..d0a1a4ad9b 100644 --- a/convert.c +++ b/convert.c @@ -24,17 +24,6 @@ #define CONVERT_STAT_BITS_TXT_CRLF 0x2 #define CONVERT_STAT_BITS_BIN 0x4 -enum crlf_action { - CRLF_UNDEFINED, - CRLF_BINARY, - CRLF_TEXT, - CRLF_TEXT_INPUT, - CRLF_TEXT_CRLF, - CRLF_AUTO, - CRLF_AUTO_INPUT, - CRLF_AUTO_CRLF -}; - struct text_stat { /* NUL, CR, LF and CRLF counts */ unsigned nul, lonecr, lonelf, crlf; @@ -172,7 +161,7 @@ static int text_eol_is_crlf(void) return 0; } -static enum eol output_eol(enum crlf_action crlf_action) +static enum eol output_eol(enum convert_crlf_action crlf_action) { switch (crlf_action) { case CRLF_BINARY: @@ -246,7 +235,7 @@ static int has_crlf_in_index(const struct index_state *istate, const char *path) } static int will_convert_lf_to_crlf(struct text_stat *stats, - enum crlf_action crlf_action) + enum convert_crlf_action crlf_action) { if (output_eol(crlf_action) != EOL_CRLF) return 0; @@ -499,7 +488,7 @@ static int encode_to_worktree(const char *path, const char *src, size_t src_len, static int crlf_to_git(const struct index_state *istate, const char *path, const char *src, size_t len, struct strbuf *buf, - enum crlf_action crlf_action, int conv_flags) + enum convert_crlf_action crlf_action, int conv_flags) { struct text_stat stats; char *dst; @@ -585,8 +574,8 @@ static int crlf_to_git(const struct index_state *istate, return 1; } -static int crlf_to_worktree(const char *src, size_t len, - struct strbuf *buf, enum crlf_action crlf_action) +static int crlf_to_worktree(const char *src, size_t len, struct strbuf *buf, + enum convert_crlf_action crlf_action) { char *to_free = NULL; struct text_stat stats; @@ -1247,7 +1236,7 @@ static const char *git_path_check_encoding(struct attr_check_item *check) return value; } -static enum crlf_action git_path_check_crlf(struct attr_check_item *check) +static enum convert_crlf_action git_path_check_crlf(struct attr_check_item *check) { const char *value = check->value; @@ -1297,18 +1286,10 @@ static int git_path_check_ident(struct attr_check_item *check) return !!ATTR_TRUE(value); } -struct conv_attrs { - struct convert_driver *drv; - enum crlf_action attr_action; /* What attr says */ - enum crlf_action crlf_action; /* When no attr is set, use core.autocrlf */ - int ident; - const char *working_tree_encoding; /* Supported encoding or default encoding if NULL */ -}; - static struct attr_check *check; -static void convert_attrs(const struct index_state *istate, - struct conv_attrs *ca, const char *path) +void convert_attrs(const struct index_state *istate, + struct conv_attrs *ca, const char *path) { struct attr_check_item *ccheck = NULL; diff --git a/convert.h b/convert.h index e29d1026a6..5678e99922 100644 --- a/convert.h +++ b/convert.h @@ -63,6 +63,30 @@ struct checkout_metadata { struct object_id blob; }; +enum convert_crlf_action { + CRLF_UNDEFINED, + CRLF_BINARY, + CRLF_TEXT, + CRLF_TEXT_INPUT, + CRLF_TEXT_CRLF, + CRLF_AUTO, + CRLF_AUTO_INPUT, + CRLF_AUTO_CRLF +}; + +struct convert_driver; + +struct conv_attrs { + struct convert_driver *drv; + enum convert_crlf_action attr_action; /* What attr says */ + enum convert_crlf_action crlf_action; /* When no attr is set, use core.autocrlf */ + int ident; + const char *working_tree_encoding; /* Supported encoding or default encoding if NULL */ +}; + +void convert_attrs(const struct index_state *istate, + struct conv_attrs *ca, const char *path); + extern enum eol core_eol; extern char *check_roundtrip_encoding; const char *get_cached_convert_stats_ascii(const struct index_state *istate, From patchwork Tue Mar 23 14:19:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares X-Patchwork-Id: 12158153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47E1BC433C1 for ; Tue, 23 Mar 2021 14:21:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 14CFA619A9 for ; Tue, 23 Mar 2021 14:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232271AbhCWOVH (ORCPT ); Tue, 23 Mar 2021 10:21:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232305AbhCWOU2 (ORCPT ); Tue, 23 Mar 2021 10:20:28 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 458A4C061763 for ; Tue, 23 Mar 2021 07:20:28 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id y2so12556837qtw.13 for ; Tue, 23 Mar 2021 07:20:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6XeZ2/dOOH2e1H7LrW9YirBFZV9NINSOgSh+1C3VxPw=; b=YffQ4TIjKmug4ijEQVb9tSwgOQJ7rNXDiaZQbT2iKeX0mmBviRWGmkcr6FnrAbf4+J DsxovUmVLxlargn0NMaCncxrqjqrC/JxaqIn9nj16pchHumLGbbg3rHkzIeDPfB9EIoZ cEmH674s2SoUEgC9shbVRVTVz/aPbTNibjExh1WISVSx7sADqDUyzri9EL8xENYHX9en aHHfcBiqr9ECw4VL3O+5L/5Rxwd8BHbLtVmIocboXvcBCywMvSIkirv6BGq542RUEaZZ qSO5sVrCcf3JWMdDYKGI2DvQ0MAdVirVab9MICSxeNsbC2BX/Q82ZgmXCzsSQR2MrfAQ VWGg== 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=6XeZ2/dOOH2e1H7LrW9YirBFZV9NINSOgSh+1C3VxPw=; b=kru59sYkxdyxhEql4BJI1febf63bOF58yWG3qeMfTj3ysD9rsUE3cG42zY+eIxBC10 Uo3+0v69IIaAM467h834Dk6EvL5kyI5Vm6xP8ZsBWwMeTG1ToITYA3We9hJDzqYLaG7d dl4GaFsOe1iVQJueH5Buu7BGDpH/goN9PHv14s2Kic99AADKRywXBrBkC4qxoe0JGV9d EP9D5XpQZNuvxcShGMfmOHiYG45gRzkc3so19z1qnMm+1Z+2GXjKddd1wEPk41tX07fz QH/OPSAWzWknU33o96XYlVdkmP+vUfWdrKrgLkC0sDMYHT2F7tbIlf7GzBQ/78JDQdM4 fBig== X-Gm-Message-State: AOAM533JFLJWi3PBYqvv05CaUEXAlIK1xY563KjlsLZPIosJ/L+WX7oh TAK+SOhckJC5ZrMPXrKYfOR+kxO9RO45/Q== X-Google-Smtp-Source: ABdhPJzukAqzTz5vQzB1WrEKQjw23LLK2i0lDYNocqi7olNGeSRbPcQXJa4StQUqegdiI1y3SN/HXQ== X-Received: by 2002:ac8:4755:: with SMTP id k21mr4565641qtp.102.1616509227414; Tue, 23 Mar 2021 07:20:27 -0700 (PDT) Received: from mango.meuintelbras.local ([177.32.118.149]) by smtp.gmail.com with ESMTPSA id j12sm11011690qtn.36.2021.03.23.07.20.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:20:27 -0700 (PDT) From: Matheus Tavares To: gitster@pobox.com Cc: git@vger.kernel.org, Jeff Hostetler Subject: [PATCH v6 2/9] convert: add [async_]convert_to_working_tree_ca() variants Date: Tue, 23 Mar 2021 11:19:29 -0300 Message-Id: <91d1a3063b05de58eeecfdf1f7bb7931974156b3.1616508954.git.matheus.bernardino@usp.br> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff Hostetler Separate the attribute gathering from the actual conversion by adding _ca() variants of the conversion functions. These variants receive a precomputed 'struct conv_attrs', not relying, thus, on an index state. They will be used in a future patch adding parallel checkout support, for two reasons: - We will already load the conversion attributes in checkout_entry(), before conversion, to decide whether a path is eligible for parallel checkout. Therefore, it would be wasteful to load them again later, for the actual conversion. - The parallel workers will be responsible for reading, converting and writing blobs to the working tree. They won't have access to the main process' index state, so they cannot load the attributes. Instead, they will receive the preloaded ones and call the _ca() variant of the conversion functions. Furthermore, the attributes machinery is optimized to handle paths in sequential order, so it's better to leave it for the main process, anyway. Signed-off-by: Jeff Hostetler Signed-off-by: Matheus Tavares --- convert.c | 60 +++++++++++++++++++++++++++++-------------------------- convert.h | 37 +++++++++++++++++++++++++--------- 2 files changed, 60 insertions(+), 37 deletions(-) diff --git a/convert.c b/convert.c index d0a1a4ad9b..f2be014af8 100644 --- a/convert.c +++ b/convert.c @@ -1446,19 +1446,16 @@ void convert_to_git_filter_fd(const struct index_state *istate, ident_to_git(dst->buf, dst->len, dst, ca.ident); } -static int convert_to_working_tree_internal(const struct index_state *istate, - const char *path, const char *src, - size_t len, struct strbuf *dst, - int normalizing, - const struct checkout_metadata *meta, - struct delayed_checkout *dco) +static int convert_to_working_tree_ca_internal(const struct conv_attrs *ca, + const char *path, const char *src, + size_t len, struct strbuf *dst, + int normalizing, + const struct checkout_metadata *meta, + struct delayed_checkout *dco) { int ret = 0, ret_filter = 0; - struct conv_attrs ca; - - convert_attrs(istate, &ca, path); - ret |= ident_to_worktree(src, len, dst, ca.ident); + ret |= ident_to_worktree(src, len, dst, ca->ident); if (ret) { src = dst->buf; len = dst->len; @@ -1468,49 +1465,56 @@ static int convert_to_working_tree_internal(const struct index_state *istate, * is a smudge or process filter (even if the process filter doesn't * support smudge). The filters might expect CRLFs. */ - if ((ca.drv && (ca.drv->smudge || ca.drv->process)) || !normalizing) { - ret |= crlf_to_worktree(src, len, dst, ca.crlf_action); + if ((ca->drv && (ca->drv->smudge || ca->drv->process)) || !normalizing) { + ret |= crlf_to_worktree(src, len, dst, ca->crlf_action); if (ret) { src = dst->buf; len = dst->len; } } - ret |= encode_to_worktree(path, src, len, dst, ca.working_tree_encoding); + ret |= encode_to_worktree(path, src, len, dst, ca->working_tree_encoding); if (ret) { src = dst->buf; len = dst->len; } ret_filter = apply_filter( - path, src, len, -1, dst, ca.drv, CAP_SMUDGE, meta, dco); - if (!ret_filter && ca.drv && ca.drv->required) - die(_("%s: smudge filter %s failed"), path, ca.drv->name); + path, src, len, -1, dst, ca->drv, CAP_SMUDGE, meta, dco); + if (!ret_filter && ca->drv && ca->drv->required) + die(_("%s: smudge filter %s failed"), path, ca->drv->name); return ret | ret_filter; } -int async_convert_to_working_tree(const struct index_state *istate, - const char *path, const char *src, - size_t len, struct strbuf *dst, - const struct checkout_metadata *meta, - void *dco) +int async_convert_to_working_tree_ca(const struct conv_attrs *ca, + const char *path, const char *src, + size_t len, struct strbuf *dst, + const struct checkout_metadata *meta, + void *dco) { - return convert_to_working_tree_internal(istate, path, src, len, dst, 0, meta, dco); + return convert_to_working_tree_ca_internal(ca, path, src, len, dst, 0, + meta, dco); } -int convert_to_working_tree(const struct index_state *istate, - const char *path, const char *src, - size_t len, struct strbuf *dst, - const struct checkout_metadata *meta) +int convert_to_working_tree_ca(const struct conv_attrs *ca, + const char *path, const char *src, + size_t len, struct strbuf *dst, + const struct checkout_metadata *meta) { - return convert_to_working_tree_internal(istate, path, src, len, dst, 0, meta, NULL); + return convert_to_working_tree_ca_internal(ca, path, src, len, dst, 0, + meta, NULL); } int renormalize_buffer(const struct index_state *istate, const char *path, const char *src, size_t len, struct strbuf *dst) { - int ret = convert_to_working_tree_internal(istate, path, src, len, dst, 1, NULL, NULL); + struct conv_attrs ca; + int ret; + + convert_attrs(istate, &ca, path); + ret = convert_to_working_tree_ca_internal(&ca, path, src, len, dst, 1, + NULL, NULL); if (ret) { src = dst->buf; len = dst->len; diff --git a/convert.h b/convert.h index 5678e99922..a4838b5e5c 100644 --- a/convert.h +++ b/convert.h @@ -99,15 +99,34 @@ const char *get_convert_attr_ascii(const struct index_state *istate, int convert_to_git(const struct index_state *istate, const char *path, const char *src, size_t len, struct strbuf *dst, int conv_flags); -int convert_to_working_tree(const struct index_state *istate, - const char *path, const char *src, - size_t len, struct strbuf *dst, - const struct checkout_metadata *meta); -int async_convert_to_working_tree(const struct index_state *istate, - const char *path, const char *src, - size_t len, struct strbuf *dst, - const struct checkout_metadata *meta, - void *dco); +int convert_to_working_tree_ca(const struct conv_attrs *ca, + const char *path, const char *src, + size_t len, struct strbuf *dst, + const struct checkout_metadata *meta); +int async_convert_to_working_tree_ca(const struct conv_attrs *ca, + const char *path, const char *src, + size_t len, struct strbuf *dst, + const struct checkout_metadata *meta, + void *dco); +static inline int convert_to_working_tree(const struct index_state *istate, + const char *path, const char *src, + size_t len, struct strbuf *dst, + const struct checkout_metadata *meta) +{ + struct conv_attrs ca; + convert_attrs(istate, &ca, path); + return convert_to_working_tree_ca(&ca, path, src, len, dst, meta); +} +static inline int async_convert_to_working_tree(const struct index_state *istate, + const char *path, const char *src, + size_t len, struct strbuf *dst, + const struct checkout_metadata *meta, + void *dco) +{ + struct conv_attrs ca; + convert_attrs(istate, &ca, path); + return async_convert_to_working_tree_ca(&ca, path, src, len, dst, meta, dco); +} int async_query_available_blobs(const char *cmd, struct string_list *available_paths); int renormalize_buffer(const struct index_state *istate, From patchwork Tue Mar 23 14:19:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares X-Patchwork-Id: 12158157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EB6DC433E1 for ; Tue, 23 Mar 2021 14:21:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BEB4619C1 for ; Tue, 23 Mar 2021 14:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232281AbhCWOVJ (ORCPT ); Tue, 23 Mar 2021 10:21:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232231AbhCWOUb (ORCPT ); Tue, 23 Mar 2021 10:20:31 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 222E8C061574 for ; Tue, 23 Mar 2021 07:20:30 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id o5so14431895qkb.0 for ; Tue, 23 Mar 2021 07:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8wqRHpX/Y/qBjqxPYaRa5qF+S1sSb08MDfuRqljXIkA=; b=T/f1/irC+mnAHbDVv1KW9sdjvDA55Np+reEzD3xUG4V3U5F7u2o7irLo/aJBJMloVT GDz49+zgAlR0Mp95F1w8zuQsWPNm7XVWca5LvVHGO9KDFWqagF/Tk/8H9XIDuVIgdk5A IMAAEYzupVl4Fa6rycg9opjeUjkBpoDA8nTkFfB8vfxlmYa7tQWCmHFitAjWAUjKhWYi sDKYNVjcCiqoIa5OyN1j9rl6iMtv6s0YbI4ZYHu214kWNQwZMusKzeGtMhPxk/W8Urlc D/RysPpw6JbZYgOMRlvluJ6Y0ImmK5awjxTP/o06ERDBLqE8Ezgj2GqKbjX+9sLjqA3F m4bQ== 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=8wqRHpX/Y/qBjqxPYaRa5qF+S1sSb08MDfuRqljXIkA=; b=N6CH858T/R8lCn+rt2gduHSnha6W92qf5nkjf/PdcHnoxuD+qaVaaWZdxJx/wvhWNM mN1oFv2rlbwaBlpP5Kc1qFri8TFt7JDFStZTsDJxSFZVyXYdEL4TuAcSIYTlihugFn5P DiPMCRMt5njZlgOaV4fSI7wnqpHEPrZbrtfeJQJyH14bB/SP28V0UUUe399Q9Dk/WRL2 SQyK25bfDi4qB02OEDxkgrrHj4rG7vYInY5P+DaTbI8PjZ/QSOZii62G/BD07QWiiKNn fgktgZP9QkOsu4c8MgEdvhCJX62buL06zOKQwgnrs/WDRPW411iIzuP7uXK4mF7VC2d1 +rRA== X-Gm-Message-State: AOAM5311AjAJ6zLi+Mj0b3xdz9SI44EHa6mns1JGSstPFndAti++OpO1 /HVCDbsbu/wPXh+mr/3E6Yq9cKMFsG2Jeg== X-Google-Smtp-Source: ABdhPJz3hfzrTNw2fejBJMOdGah+nllkthPKjpYoDvyQuFXAR0y61fhOdrTMyh+kUlNFGHYlyNymJw== X-Received: by 2002:a05:620a:40e:: with SMTP id 14mr5572413qkp.200.1616509229323; Tue, 23 Mar 2021 07:20:29 -0700 (PDT) Received: from mango.meuintelbras.local ([177.32.118.149]) by smtp.gmail.com with ESMTPSA id j12sm11011690qtn.36.2021.03.23.07.20.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:20:28 -0700 (PDT) From: Matheus Tavares To: gitster@pobox.com Cc: git@vger.kernel.org, Jeff Hostetler Subject: [PATCH v6 3/9] convert: add get_stream_filter_ca() variant Date: Tue, 23 Mar 2021 11:19:30 -0300 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff Hostetler Like the previous patch, we will also need to call get_stream_filter() with a precomputed `struct conv_attrs`, when we add support for parallel checkout workers. So add the _ca() variant which takes the conversion attributes struct as a parameter. Signed-off-by: Jeff Hostetler Signed-off-by: Matheus Tavares --- convert.c | 28 +++++++++++++++++----------- convert.h | 2 ++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/convert.c b/convert.c index f2be014af8..3f39c62cac 100644 --- a/convert.c +++ b/convert.c @@ -1941,34 +1941,31 @@ static struct stream_filter *ident_filter(const struct object_id *oid) } /* - * Return an appropriately constructed filter for the path, or NULL if + * Return an appropriately constructed filter for the given ca, or NULL if * the contents cannot be filtered without reading the whole thing * in-core. * * Note that you would be crazy to set CRLF, smudge/clean or ident to a * large binary blob you would want us not to slurp into the memory! */ -struct stream_filter *get_stream_filter(const struct index_state *istate, - const char *path, - const struct object_id *oid) +struct stream_filter *get_stream_filter_ca(const struct conv_attrs *ca, + const struct object_id *oid) { - struct conv_attrs ca; struct stream_filter *filter = NULL; - convert_attrs(istate, &ca, path); - if (ca.drv && (ca.drv->process || ca.drv->smudge || ca.drv->clean)) + if (ca->drv && (ca->drv->process || ca->drv->smudge || ca->drv->clean)) return NULL; - if (ca.working_tree_encoding) + if (ca->working_tree_encoding) return NULL; - if (ca.crlf_action == CRLF_AUTO || ca.crlf_action == CRLF_AUTO_CRLF) + if (ca->crlf_action == CRLF_AUTO || ca->crlf_action == CRLF_AUTO_CRLF) return NULL; - if (ca.ident) + if (ca->ident) filter = ident_filter(oid); - if (output_eol(ca.crlf_action) == EOL_CRLF) + if (output_eol(ca->crlf_action) == EOL_CRLF) filter = cascade_filter(filter, lf_to_crlf_filter()); else filter = cascade_filter(filter, &null_filter_singleton); @@ -1976,6 +1973,15 @@ struct stream_filter *get_stream_filter(const struct index_state *istate, return filter; } +struct stream_filter *get_stream_filter(const struct index_state *istate, + const char *path, + const struct object_id *oid) +{ + struct conv_attrs ca; + convert_attrs(istate, &ca, path); + return get_stream_filter_ca(&ca, oid); +} + void free_stream_filter(struct stream_filter *filter) { filter->vtbl->free(filter); diff --git a/convert.h b/convert.h index a4838b5e5c..484b50965d 100644 --- a/convert.h +++ b/convert.h @@ -179,6 +179,8 @@ struct stream_filter; /* opaque */ struct stream_filter *get_stream_filter(const struct index_state *istate, const char *path, const struct object_id *); +struct stream_filter *get_stream_filter_ca(const struct conv_attrs *ca, + const struct object_id *oid); void free_stream_filter(struct stream_filter *); int is_null_stream_filter(struct stream_filter *); From patchwork Tue Mar 23 14:19:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares X-Patchwork-Id: 12158155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DEE4C433E2 for ; Tue, 23 Mar 2021 14:21:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F3D2619B6 for ; Tue, 23 Mar 2021 14:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232294AbhCWOVK (ORCPT ); Tue, 23 Mar 2021 10:21:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232100AbhCWOUc (ORCPT ); Tue, 23 Mar 2021 10:20:32 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 066B0C061763 for ; Tue, 23 Mar 2021 07:20:32 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id y18so14447543qky.11 for ; Tue, 23 Mar 2021 07:20:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xkNBVxGhUVdZi5AryzEvRhzyuhydecYpjQdE3C579No=; b=vUdlOd3smiXhQt1gBxZiRjSxzshVwhkPaGJrMPxZzdg/lNMojlgPYsPAqfAAUwMFA4 ljkviNI70k22bXMpQNaR/EASYQ3fd6NwsKXYOdj5fhmE6X1sgw5LvQtKJSCcAZHyUFc+ FdBD8XtldSG5CEBxg+QRmlviuEykaBtOWwxJ75WBRnCpad+zYrjEK1HOuB640/dpd6vQ un5AMJpsgyrnrpuYLYvB0PRZdmX9caSr1PQ/SjJGKQIYTKaj93uDzdIJrbQobITAeFL2 SHbxCj/UolDMpmCoYZ5VQIwhndRP/+0OSeTiz8CG4hDlNW65YEqzq6vtaHZLPbTPkVXU fKnA== 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=xkNBVxGhUVdZi5AryzEvRhzyuhydecYpjQdE3C579No=; b=cFBCLO1m6KhOSP3wtShXzzFqVEJfEPws+6NJhAf6urzt2XxQvbdoNAjc8CIbZHJ+vO R0kFyAJ/gQ+y0L5u9TwPR5M0MuaVsGehc3vmVuAN7Lz5N4mGvcj+qnfbjsb7znB8bz2t 2GwgjiG+RAw/N6KWR+wzkRg9j4EUks+39ywPWkFXgPBaeJsgQ/HBke4BYwInQUUlxlyG WZtVBLIPV9RkAKmH7dfhp3KmekKHQaIiBZXFzC2TSk1vxcXcMLgPjE3fHWV+Zmsv8qRQ gaK+EXkTH+WrVBL6ypZ+yAYOAMWCXR93wSuXxm9Ov5pI7GNYjHBf/8Q1hzoaGQmFByJU ZsSg== X-Gm-Message-State: AOAM532Yijc4exwJO5vEb+Ff2tDt1yW2knS59PWs/ktgiEu6ZS3YTKKD Zy/s18bAvKXQT/zUHkc6pYybvA== X-Google-Smtp-Source: ABdhPJyf2kP/n22RFUjyQUOVnDiW/7MaF2e9aeZOvGjl9B08KI3dfgBYbLEDh6GaO9v1PSyoW00+pg== X-Received: by 2002:ae9:e113:: with SMTP id g19mr5422178qkm.480.1616509231224; Tue, 23 Mar 2021 07:20:31 -0700 (PDT) Received: from mango.meuintelbras.local ([177.32.118.149]) by smtp.gmail.com with ESMTPSA id j12sm11011690qtn.36.2021.03.23.07.20.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:20:30 -0700 (PDT) From: Matheus Tavares To: gitster@pobox.com Cc: git@vger.kernel.org, Jeff Hostetler Subject: [PATCH v6 4/9] convert: add classification for conv_attrs struct Date: Tue, 23 Mar 2021 11:19:31 -0300 Message-Id: <01ac6176ccd8fb20372cf72b6aee33d5ed98c54f.1616508954.git.matheus.bernardino@usp.br> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff Hostetler Create `enum conv_attrs_classification` to express the different ways that attributes are handled for a blob during checkout. This will be used in a later commit when deciding whether to add a file to the parallel or delayed queue during checkout. For now, we can also use it in get_stream_filter_ca() to simplify the function (as the classifying logic is the same). Signed-off-by: Jeff Hostetler Signed-off-by: Matheus Tavares --- convert.c | 26 +++++++++++++++++++------- convert.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/convert.c b/convert.c index 3f39c62cac..3298e4acff 100644 --- a/convert.c +++ b/convert.c @@ -1953,13 +1953,7 @@ struct stream_filter *get_stream_filter_ca(const struct conv_attrs *ca, { struct stream_filter *filter = NULL; - if (ca->drv && (ca->drv->process || ca->drv->smudge || ca->drv->clean)) - return NULL; - - if (ca->working_tree_encoding) - return NULL; - - if (ca->crlf_action == CRLF_AUTO || ca->crlf_action == CRLF_AUTO_CRLF) + if (classify_conv_attrs(ca) != CA_CLASS_STREAMABLE) return NULL; if (ca->ident) @@ -2015,3 +2009,21 @@ void clone_checkout_metadata(struct checkout_metadata *dst, if (blob) oidcpy(&dst->blob, blob); } + +enum conv_attrs_classification classify_conv_attrs(const struct conv_attrs *ca) +{ + if (ca->drv) { + if (ca->drv->process) + return CA_CLASS_INCORE_PROCESS; + if (ca->drv->smudge || ca->drv->clean) + return CA_CLASS_INCORE_FILTER; + } + + if (ca->working_tree_encoding) + return CA_CLASS_INCORE; + + if (ca->crlf_action == CRLF_AUTO || ca->crlf_action == CRLF_AUTO_CRLF) + return CA_CLASS_INCORE; + + return CA_CLASS_STREAMABLE; +} diff --git a/convert.h b/convert.h index 484b50965d..43e567a59b 100644 --- a/convert.h +++ b/convert.h @@ -200,4 +200,37 @@ int stream_filter(struct stream_filter *, const char *input, size_t *isize_p, char *output, size_t *osize_p); +enum conv_attrs_classification { + /* + * The blob must be loaded into a buffer before it can be + * smudged. All smudging is done in-proc. + */ + CA_CLASS_INCORE, + + /* + * The blob must be loaded into a buffer, but uses a + * single-file driver filter, such as rot13. + */ + CA_CLASS_INCORE_FILTER, + + /* + * The blob must be loaded into a buffer, but uses a + * long-running driver process, such as LFS. This might or + * might not use delayed operations. (The important thing is + * that there is a single subordinate long-running process + * handling all associated blobs and in case of delayed + * operations, may hold per-blob state.) + */ + CA_CLASS_INCORE_PROCESS, + + /* + * The blob can be streamed and smudged without needing to + * completely read it into a buffer. + */ + CA_CLASS_STREAMABLE, +}; + +enum conv_attrs_classification classify_conv_attrs( + const struct conv_attrs *ca); + #endif /* CONVERT_H */ From patchwork Tue Mar 23 14:19:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matheus Tavares X-Patchwork-Id: 12158163 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9657DC433E0 for ; Tue, 23 Mar 2021 14:21:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 64E65619C1 for ; Tue, 23 Mar 2021 14:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232191AbhCWOVO (ORCPT ); Tue, 23 Mar 2021 10:21:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232276AbhCWOUe (ORCPT ); Tue, 23 Mar 2021 10:20:34 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2B4AC061764 for ; Tue, 23 Mar 2021 07:20:33 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id i9so14435559qka.2 for ; Tue, 23 Mar 2021 07:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EkfRpfTpn+NS3vzQdXi7TfSATsSh7Zg5oSwIvKlVtfQ=; b=ZgpxvlWudioaPNaqRjhdCigZ9Ltsoz2o2ra1JGK1vIYDstWqvPKaQ0Es961//chc6r mU595ZIo9egAV9dN9JP/P9xc/bktj3SLRjtfoH69V1212UAzFI/cA/QuWvSFZpRPo9wz ObTHUuPtkOY/XEciumYCdbB6tJ6HvQ1z91dTzqOfYXjsY11KYhPJCirOcEqjrcsOYAub AN7IEiZXR5t4Wfc0MGznDx+rK3xn89Er337lvzXdKBl983eo6v33EXTrvcGqmVZw6Ajo PVFO4703adLB3V3QMZiFVcRRZhAX/ZWoyoCeWjtjzpsZ8a3wVlV0EGLfxtOggecJ5Pvj FxRw== 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=EkfRpfTpn+NS3vzQdXi7TfSATsSh7Zg5oSwIvKlVtfQ=; b=ujRqnpBwfIszDxS9ve80JCDMPp1Fs3h0gMPxEKHOAG+UqE019FPy6/jkFgd2TGS+Bs zm2B0Jd+FHV6b3cyK1Tpp/UCddD1DGjbCQdHZ/e5BSQMSqKdJJYlkK9Armzm4enI7Ycx TDaw1b1Ev7U1+NCgj+hVVW0h8hH63c8j3o2plVGD5IPBpG4gGxg02LSjSB+FR7VJB8vY wDXefW9Isp/WwQgkrmYfFT4oSM3n0fUSAk1d31fW+UNEFgD5wS0jmI/2z4hDBpjlpQfq Y+lnl2kpMDmDArixQ8DkxsNv3wjTIMu1eQnrGHiRHDAWiV4JWChotdyKsVqkunu336Mf 4ZbA== X-Gm-Message-State: AOAM531D967danQzREp0tcl0qeDvamDijU1JofvLOcH1ghlNQiQKiAEy Wk2EQTybSaZLXscvzfJRFfbw6KM/wztKdQ== X-Google-Smtp-Source: ABdhPJwcowOKPUmgevrq3YFlxRzowrtKMogNvl46JAHs9UZdQsZPQ5TrpM/9ZyfRYPHTFIdTw/5T7g== X-Received: by 2002:a05:620a:2216:: with SMTP id m22mr5819572qkh.73.1616509232962; Tue, 23 Mar 2021 07:20:32 -0700 (PDT) Received: from mango.meuintelbras.local ([177.32.118.149]) by smtp.gmail.com with ESMTPSA id j12sm11011690qtn.36.2021.03.23.07.20.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:20:32 -0700 (PDT) From: Matheus Tavares To: gitster@pobox.com Cc: git@vger.kernel.org Subject: [PATCH v6 5/9] entry: extract a header file for entry.c functions Date: Tue, 23 Mar 2021 11:19:32 -0300 Message-Id: <4d85af1579738a3f2f5f3815007c3f8bfd1a31f8.1616508954.git.matheus.bernardino@usp.br> X-Mailer: git-send-email 2.30.1 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. While at it let's also move a comment related to checkout_entry() from entry.c to entry.h as it's more useful to describe the function there. 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 + builtin/stash.c | 1 + cache.h | 24 ----------------------- entry.c | 9 +-------- entry.h | 42 ++++++++++++++++++++++++++++++++++++++++ unpack-trees.c | 1 + 9 files changed, 49 insertions(+), 32 deletions(-) create mode 100644 entry.h diff --git a/apply.c b/apply.c index 6695a931e9..466f880d73 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 023e49e271..c0bf4ac1b2 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 2d6550bc3c..06c90d76e8 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 6e18e623fd..ef25729d49 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/builtin/stash.c b/builtin/stash.c index 3477e940e3..0cdcc75618 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -15,6 +15,7 @@ #include "log-tree.h" #include "diffcore.h" #include "exec-cmd.h" +#include "entry.h" #define INCLUDE_ALL_FILES 2 diff --git a/cache.h b/cache.h index 6fda8091f1..5d45d145fa 100644 --- a/cache.h +++ b/cache.h @@ -1621,30 +1621,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 7b9f43716f..c3e511bfb3 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..acbbb90220 --- /dev/null +++ b/entry.h @@ -0,0 +1,42 @@ +#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 9af8e796b3..f6cc6a8117 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 From patchwork Tue Mar 23 14:19:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares X-Patchwork-Id: 12158159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75975C433E3 for ; Tue, 23 Mar 2021 14:21:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51F22619A9 for ; Tue, 23 Mar 2021 14:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232295AbhCWOVM (ORCPT ); Tue, 23 Mar 2021 10:21:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232139AbhCWOUg (ORCPT ); Tue, 23 Mar 2021 10:20:36 -0400 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 714AFC061765 for ; Tue, 23 Mar 2021 07:20:35 -0700 (PDT) Received: by mail-qv1-xf2d.google.com with SMTP id d10so10525178qve.7 for ; Tue, 23 Mar 2021 07:20:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o3ECagYgvOeZ3IfgS2wYqyttLxn1HpoK5ooW9+lNVTM=; b=btZqkr03lVOh4Ib9NEPS+DR5huPkSVbIWoMTX4KRuWAd/UE6ldrwr/y+q93H7x7PHA LDSCuBSbUC3BgRLHpE+gE0NaAzyLiRZ88U9d5vu1gFXF27KHHyXCDn6UI3yWGMaWPbg2 l+ZWh1B5JrqIhyc5OBDNfW9crMs2q7S3RysQxJllVfZLYDOC6xsrCjrv963Cdxz00d9/ rFqaNLhl4KXN5zo47EnByccklxWlE5z11oF+RTnla6E7TTnHRu7rL9ascFKTZX1+EWtR Pz5EqaZai1LIeZE4dFPEFC1an43eNslUsVrOm+9OfIVdDGrnXqoZGp+AfJP/3UetQ2YH hNiA== 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=o3ECagYgvOeZ3IfgS2wYqyttLxn1HpoK5ooW9+lNVTM=; b=Rd6QYtaJTaD+O8lMZaJaetTd1qjfJMR+BP9QILoOU22T/njkVdu2hkxCFSVQIS1WSG 7XIqfaADWmuH9DIR8l5NFxcae6lgJ3tSO/cS9mcOuroKk61ULG4GszvhmhLoiYVI6vyz RyulRNp8P/Q0sQyO8093aCTljOE2ODtekU3lqWDgmSa3jt/We6htXN7+SHCLAcs8zEPF V5xhZV0i+mCahx9VGXZ3McwP1ASodr3U2ExLKVkZxSaMaPLa6hjTxdYorNYSETqAB/87 kYmsMLwUsaNEhInWv98hIbibb7D7Fym7hogZJMGXedFLU1UMTr57F97UT5X/n28kGdRl stwQ== X-Gm-Message-State: AOAM532P8cTNSPafgDOJQ7YpfGah/2CKq/ni9N4bGIZvmRjrEF0mBpTG R1d7j6vhQHn/1HA7sfMvDkRt4Q== X-Google-Smtp-Source: ABdhPJywQmXMA8HZ0JQ+mMpWdcQl7ePAAdLVpR5W/Moo9QERfNC2ghE73fbiFViRNBuA2hN8jR8ujQ== X-Received: by 2002:a0c:fa0d:: with SMTP id q13mr4936419qvn.15.1616509234655; Tue, 23 Mar 2021 07:20:34 -0700 (PDT) Received: from mango.meuintelbras.local ([177.32.118.149]) by smtp.gmail.com with ESMTPSA id j12sm11011690qtn.36.2021.03.23.07.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:20:34 -0700 (PDT) From: Matheus Tavares To: gitster@pobox.com Cc: git@vger.kernel.org Subject: [PATCH v6 6/9] entry: make fstat_output() and read_blob_entry() public Date: Tue, 23 Mar 2021 11:19:33 -0300 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org These two functions will be used by the parallel checkout code, so let's make them public. Note: fstat_output() is renamed to fstat_checkout_output(), now that it has become public, seeking to avoid future name collisions. Signed-off-by: Matheus Tavares --- entry.c | 8 ++++---- entry.h | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/entry.c b/entry.c index c3e511bfb3..1e2d9f7baa 100644 --- a/entry.c +++ b/entry.c @@ -84,7 +84,7 @@ static int create_file(const char *path, unsigned int mode) return open(path, O_WRONLY | O_CREAT | O_EXCL, mode); } -static void *read_blob_entry(const struct cache_entry *ce, unsigned long *size) +void *read_blob_entry(const struct cache_entry *ce, unsigned long *size) { enum object_type type; void *blob_data = read_object_file(&ce->oid, &type, size); @@ -109,7 +109,7 @@ static int open_output_fd(char *path, const struct cache_entry *ce, int to_tempf } } -static int fstat_output(int fd, const struct checkout *state, struct stat *st) +int fstat_checkout_output(int fd, const struct checkout *state, struct stat *st) { /* use fstat() only when path == ce->name */ if (fstat_is_reliable() && @@ -132,7 +132,7 @@ static int streaming_write_entry(const struct cache_entry *ce, char *path, return -1; result |= stream_blob_to_fd(fd, &ce->oid, filter, 1); - *fstat_done = fstat_output(fd, state, statbuf); + *fstat_done = fstat_checkout_output(fd, state, statbuf); result |= close(fd); if (result) @@ -346,7 +346,7 @@ static int write_entry(struct cache_entry *ce, wrote = write_in_full(fd, new_blob, size); if (!to_tempfile) - fstat_done = fstat_output(fd, state, &st); + fstat_done = fstat_checkout_output(fd, state, &st); close(fd); free(new_blob); if (wrote < 0) diff --git a/entry.h b/entry.h index acbbb90220..60df93ca78 100644 --- a/entry.h +++ b/entry.h @@ -39,4 +39,7 @@ int finish_delayed_checkout(struct checkout *state, int *nr_checkouts); */ void unlink_entry(const struct cache_entry *ce); +void *read_blob_entry(const struct cache_entry *ce, unsigned long *size); +int fstat_checkout_output(int fd, const struct checkout *state, struct stat *st); + #endif /* ENTRY_H */ From patchwork Tue Mar 23 14:19:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares X-Patchwork-Id: 12158167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6DADC433E4 for ; Tue, 23 Mar 2021 14:21:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9B0E7619A9 for ; Tue, 23 Mar 2021 14:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232301AbhCWOVR (ORCPT ); Tue, 23 Mar 2021 10:21:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231668AbhCWOUi (ORCPT ); Tue, 23 Mar 2021 10:20:38 -0400 Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E43BC0613D8 for ; Tue, 23 Mar 2021 07:20:37 -0700 (PDT) Received: by mail-qt1-x832.google.com with SMTP id u7so14974578qtq.12 for ; Tue, 23 Mar 2021 07:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IPJSgn4necOpC7KyHqJCuJGW3R+FVfxbiTb2ySPlXtI=; b=UwcKyPXUz/MaTCXw/R6cUVddGHT4mL3/hsSMde9OkpUHRFN6zz7RGiXRY1KP+9xqMn Cx0gkRTQXo/Np2HcdSvpk/w9QSFhSDlMIwkKQimpt/F6C7WLGPlZf15qR2goqjNsWDm2 E8XD8IlilqsKLUYotSSsXRbhRSRLa16F6pgBSc4DqWekB6CNFE4ZpDNQhQ6wxaY7tGS5 5A0DJ2A211R1ZxjtOG2nWEcoTw159CVyMukD7G7l5/HNLW6WX1urM2Ieyo9hTpNFJTwo HpcI9OZ/4mq5n06mv8RYljMogKYMBJcBiZ4v26aNzXUr81ec1F+se82RZ1Y+YK+jVII2 rreA== 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=IPJSgn4necOpC7KyHqJCuJGW3R+FVfxbiTb2ySPlXtI=; b=jKidG/EaC0U0j3aCN2nuXv2dDTMDf13HBr2IT5NSPpjGUv4/GVd4pRK5/snGA+5sxs PO8SCjTDj3DijYmQVcdXpHJBamBZ18yBLFRj0J+7vm8HUXjuFPWLWay6CDCfrJMzBWOR YsMUFi5+UWCKMcvq8LiPZKQMFuxFwtqj9j45c4e7kc5NFk6cSkwHJ+2H9jrZJD5zqjiR xRBRrA5zjjAiZhHMr+eWOSoZ7pqEHWjA6foWg26PeFjycJL3wGVbPxe40Pf1E3fcoJhM Ojc5zy7UpkAiXc9h+warbD+eBn3BEf84GAn+2cdtMiYRRlNguIRSOnSQnvVejet9XTSD eK+Q== X-Gm-Message-State: AOAM5336UTHqL1B02CckpC+QgpLfJaVTjvdLRx6n0O3RJuLnil99IsWc ztID05ruurDmCjeHGSKYsP028w== X-Google-Smtp-Source: ABdhPJzYIcXXsI5OWlmkIviy7OrYrxzQIdnD3QCzM1msNRPS30Mh5atYoWOyJ80pNjN6UQSSWrVLHw== X-Received: by 2002:a05:622a:1342:: with SMTP id w2mr4445704qtk.163.1616509236423; Tue, 23 Mar 2021 07:20:36 -0700 (PDT) Received: from mango.meuintelbras.local ([177.32.118.149]) by smtp.gmail.com with ESMTPSA id j12sm11011690qtn.36.2021.03.23.07.20.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:20:35 -0700 (PDT) From: Matheus Tavares To: gitster@pobox.com Cc: git@vger.kernel.org Subject: [PATCH v6 7/9] entry: extract update_ce_after_write() from write_entry() Date: Tue, 23 Mar 2021 11:19:34 -0300 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The code that updates the in-memory index information after an entry is written currently resides in write_entry(). Extract it to a public function so that it can be called by the parallel checkout functions, outside entry.c, in a later patch. Signed-off-by: Matheus Tavares --- entry.c | 25 ++++++++++++++++--------- entry.h | 2 ++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/entry.c b/entry.c index 1e2d9f7baa..4cf0db352f 100644 --- a/entry.c +++ b/entry.c @@ -251,6 +251,18 @@ int finish_delayed_checkout(struct checkout *state, int *nr_checkouts) return errs; } +void update_ce_after_write(const struct checkout *state, struct cache_entry *ce, + struct stat *st) +{ + if (state->refresh_cache) { + assert(state->istate); + fill_stat_cache_info(state->istate, ce, st); + ce->ce_flags |= CE_UPDATE_IN_BASE; + mark_fsmonitor_invalid(state->istate, ce); + state->istate->cache_changed |= CE_ENTRY_CHANGED; + } +} + static int write_entry(struct cache_entry *ce, char *path, const struct checkout *state, int to_tempfile) { @@ -371,15 +383,10 @@ static int write_entry(struct cache_entry *ce, finish: if (state->refresh_cache) { - assert(state->istate); - if (!fstat_done) - if (lstat(ce->name, &st) < 0) - return error_errno("unable to stat just-written file %s", - ce->name); - fill_stat_cache_info(state->istate, ce, &st); - ce->ce_flags |= CE_UPDATE_IN_BASE; - mark_fsmonitor_invalid(state->istate, ce); - state->istate->cache_changed |= CE_ENTRY_CHANGED; + if (!fstat_done && lstat(ce->name, &st) < 0) + return error_errno("unable to stat just-written file %s", + ce->name); + update_ce_after_write(state, ce , &st); } delayed: return 0; diff --git a/entry.h b/entry.h index 60df93ca78..ea7290bcd5 100644 --- a/entry.h +++ b/entry.h @@ -41,5 +41,7 @@ void unlink_entry(const struct cache_entry *ce); void *read_blob_entry(const struct cache_entry *ce, unsigned long *size); int fstat_checkout_output(int fd, const struct checkout *state, struct stat *st); +void update_ce_after_write(const struct checkout *state, struct cache_entry *ce, + struct stat *st); #endif /* ENTRY_H */ From patchwork Tue Mar 23 14:19:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares X-Patchwork-Id: 12158161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A484FC433E5 for ; Tue, 23 Mar 2021 14:21:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 745FF619C8 for ; Tue, 23 Mar 2021 14:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232299AbhCWOVQ (ORCPT ); Tue, 23 Mar 2021 10:21:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232249AbhCWOUj (ORCPT ); Tue, 23 Mar 2021 10:20:39 -0400 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFA9BC061574 for ; Tue, 23 Mar 2021 07:20:38 -0700 (PDT) Received: by mail-qv1-xf33.google.com with SMTP id g8so10532292qvx.1 for ; Tue, 23 Mar 2021 07:20:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5AYz7ut44wcIEufw6pWX/rHGikuU1vsfANE/W4QSw+k=; b=cTEnza6PQo4zFUfvVbebVe6JEG8Yv8emIsp+T7F6/OdBBTEHnS37QQ8sW458P4R6k0 JGtCrzOgIl6onxtr1zSpiIM/qF1g2fy+9cW2DMzJP/X5nEGqfX2rbNwWIDZ7XyBxd5ZQ lzKS7RsVy7GdsgmJ0g9Ae3uTDXJDAVqYcXjIA/yYAPq7KeyXPWe1Zg54r2vAtF3FLSvp R1PU4ChM/i5o9h0WbFg9z1AbzCsXYNah6k/o1gb47l8znJWwaLl0Y2ejF91LRfkbEARN W9ScVuHaA5/U67p5YBVKheLf8JulcnaDfp9K0LoJYxy7DpD5LaTn7K2erX03HOwROaww ZTkQ== 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=5AYz7ut44wcIEufw6pWX/rHGikuU1vsfANE/W4QSw+k=; b=Qe8g53G0Uv/qrh1tipWmlblBcBDDluiH1UXskipz5CoS4R9vKtBPhw0hDKBEAZ3cHs vCVFei9eqw8js+ZzNtUG0tVl+kkxnEJwRU1RpGU4rALEZg5PbTBW+tr0lCxOzPrfj4ns Dm3i6mt6U9C01dugdf4zJ4qgkpebtGaB8M0JMoOpINNsGMogVIDvpQbkoDGA6DdD1x9Q K3w3OMJ0ygIOE3TPqaYobHECVBfI8JAq5hNGQKD3zuUPCz1vD52ibwHmg2JsKqDtLMRM Exc4jS+8zMkabwjG6vvjF0Kl24+Avoa30If5jSYgVD+iqPRzBBQy6OvDrMPi5H5HBoha JFZw== X-Gm-Message-State: AOAM5335VTNuxAnv8DbsXOPohGwTosNNhIsAbhrs5A9Da5f6+ogUoeaw FME0Z8Yf7npcFYWHHq9IvMJi1w== X-Google-Smtp-Source: ABdhPJyx4yNaq58aOGdj2IVlqRk8oZ38T/X6b6njRM+/O5NWnZnD1hEYgMlDjhfxaQqCDNRi9NZIVg== X-Received: by 2002:a0c:c248:: with SMTP id w8mr5380782qvh.58.1616509238143; Tue, 23 Mar 2021 07:20:38 -0700 (PDT) Received: from mango.meuintelbras.local ([177.32.118.149]) by smtp.gmail.com with ESMTPSA id j12sm11011690qtn.36.2021.03.23.07.20.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:20:37 -0700 (PDT) From: Matheus Tavares To: gitster@pobox.com Cc: git@vger.kernel.org Subject: [PATCH v6 8/9] entry: move conv_attrs lookup up to checkout_entry() Date: Tue, 23 Mar 2021 11:19:35 -0300 Message-Id: <87b9d4590aa182d4c4467ea9ee3a87bb53940a66.1616508954.git.matheus.bernardino@usp.br> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In a following patch, checkout_entry() will use conv_attrs to decide whether an entry should be enqueued for parallel checkout or not. But the attributes lookup only happens lower in this call stack. To avoid the unnecessary work of loading the attributes twice, let's move it up to checkout_entry(), and pass the loaded struct down to write_entry(). Signed-off-by: Matheus Tavares --- entry.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/entry.c b/entry.c index 4cf0db352f..6339d54843 100644 --- a/entry.c +++ b/entry.c @@ -263,8 +263,9 @@ void update_ce_after_write(const struct checkout *state, struct cache_entry *ce, } } -static int write_entry(struct cache_entry *ce, - char *path, const struct checkout *state, int to_tempfile) +/* Note: ca is used (and required) iff the entry refers to a regular file. */ +static int write_entry(struct cache_entry *ce, char *path, struct conv_attrs *ca, + const struct checkout *state, int to_tempfile) { unsigned int ce_mode_s_ifmt = ce->ce_mode & S_IFMT; struct delayed_checkout *dco = state->delayed_checkout; @@ -281,8 +282,7 @@ static int write_entry(struct cache_entry *ce, clone_checkout_metadata(&meta, &state->meta, &ce->oid); if (ce_mode_s_ifmt == S_IFREG) { - struct stream_filter *filter = get_stream_filter(state->istate, ce->name, - &ce->oid); + struct stream_filter *filter = get_stream_filter_ca(ca, &ce->oid); if (filter && !streaming_write_entry(ce, path, filter, state, to_tempfile, @@ -329,14 +329,17 @@ static int write_entry(struct cache_entry *ce, * Convert from git internal format to working tree format */ if (dco && dco->state != CE_NO_DELAY) { - ret = async_convert_to_working_tree(state->istate, ce->name, new_blob, - size, &buf, &meta, dco); + ret = async_convert_to_working_tree_ca(ca, ce->name, + new_blob, size, + &buf, &meta, dco); if (ret && string_list_has_string(&dco->paths, ce->name)) { free(new_blob); goto delayed; } - } else - ret = convert_to_working_tree(state->istate, ce->name, new_blob, size, &buf, &meta); + } else { + ret = convert_to_working_tree_ca(ca, ce->name, new_blob, + size, &buf, &meta); + } if (ret) { free(new_blob); @@ -442,6 +445,7 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, { static struct strbuf path = STRBUF_INIT; struct stat st; + struct conv_attrs ca_buf, *ca = NULL; if (ce->ce_flags & CE_WT_REMOVE) { if (topath) @@ -454,8 +458,13 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, return 0; } - if (topath) - return write_entry(ce, topath, state, 1); + if (topath) { + if (S_ISREG(ce->ce_mode)) { + convert_attrs(state->istate, &ca_buf, ce->name); + ca = &ca_buf; + } + return write_entry(ce, topath, ca, state, 1); + } strbuf_reset(&path); strbuf_add(&path, state->base_dir, state->base_dir_len); @@ -517,9 +526,16 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, return 0; create_directories(path.buf, path.len, state); + if (nr_checkouts) (*nr_checkouts)++; - return write_entry(ce, path.buf, state, 0); + + if (S_ISREG(ce->ce_mode)) { + convert_attrs(state->istate, &ca_buf, ce->name); + ca = &ca_buf; + } + + return write_entry(ce, path.buf, ca, state, 0); } void unlink_entry(const struct cache_entry *ce) From patchwork Tue Mar 23 14:19:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares X-Patchwork-Id: 12158165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA5A6C433E8 for ; Tue, 23 Mar 2021 14:21:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF92A619BB for ; Tue, 23 Mar 2021 14:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232305AbhCWOVV (ORCPT ); Tue, 23 Mar 2021 10:21:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232263AbhCWOUk (ORCPT ); Tue, 23 Mar 2021 10:20:40 -0400 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4539C061763 for ; Tue, 23 Mar 2021 07:20:40 -0700 (PDT) Received: by mail-qk1-x734.google.com with SMTP id y5so12905226qkl.9 for ; Tue, 23 Mar 2021 07:20:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ElDwQ3bqz1JzL9xCCcMy5fFosYhACGySz8GGdbUeG68=; b=DfeuhWss7c9hACJJfx9XEg+lsCSa+avniCkv3MnDfnVBLgZfCWS+qbpHADpqI9UHzv 4GGEf+Vh1S7JO0dF4U4KlgWsDgGrOj4lcwTNQGx/IocfWMjEfYg4rQVL3XSouV90OJA4 2cv3Ufo2pEPPVj0wEQM7e+CjYNv2P33z0+MdMFENlWF6Q2uMti+3Ojg0y4uXERppObZa N/4gSiEFoof/kCeeoMVZwjfA2wqL2CIL/8QAS2uXtbD7FMZOou0l3JaolTq6pZDlNAIO Fg4c4qJdzddcd/itSvIBuB3D5FsGBW4gMpORAnVd1GlasA46rfbWEXu50zYEpa+7oIwL qHow== 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=ElDwQ3bqz1JzL9xCCcMy5fFosYhACGySz8GGdbUeG68=; b=srxKURADV2h3v43P7KmpoYjkGrc56G1qddKhE/karrxMEswaAWG11PBG32DR9JN4nB QP/hChri9pg1kS1ZfVo3R/qgcu+RCG87CCR2lPVdUAPB56s5RhC4+eCMtcsCysRsbs7i TaXBtcGNjy2QgeKmkxjfEo6chOM0XW3al+9uMV/DbSAacny49RKalUljzlcYRXzgE1ps 3Jzm06KVWaMaTGmbhmFyugttohU+OfOkZnj4gst2qhLLqVmF/2VS4X3TGrWGcM/E6cI0 NEj7IX32f0OtjVc/y9fGYKZlXMOUmJKg7emDNNt6SOcSUOPodCjYMrtXtMlKwHpcom0C pu1w== X-Gm-Message-State: AOAM532SnxBXNfb235bFAVf53S+F0t+3txRDdI8Le7l5J8tfIulbvPBw 5c3FWilWrlTaRZ8+F/iasMi4Zqq/j6yKmQ== X-Google-Smtp-Source: ABdhPJw7sZpF68arM+5VEhKRue0bkiGJFwU70mTekFKi6upTMaHnsOUVpZJXLt3v3TSJsFRHz4DGHg== X-Received: by 2002:a05:620a:12da:: with SMTP id e26mr5273998qkl.92.1616509239907; Tue, 23 Mar 2021 07:20:39 -0700 (PDT) Received: from mango.meuintelbras.local ([177.32.118.149]) by smtp.gmail.com with ESMTPSA id j12sm11011690qtn.36.2021.03.23.07.20.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:20:39 -0700 (PDT) From: Matheus Tavares To: gitster@pobox.com Cc: git@vger.kernel.org Subject: [PATCH v6 9/9] entry: add checkout_entry_ca() taking preloaded conv_attrs Date: Tue, 23 Mar 2021 11:19:36 -0300 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The parallel checkout machinery will call checkout_entry() for entries that could not be written in parallel due to path collisions. At this point, we will already be holding the conversion attributes for each entry, and it would be wasteful to let checkout_entry() load these again. Instead, let's add the checkout_entry_ca() variant, which optionally takes a preloaded conv_attrs struct. Signed-off-by: Matheus Tavares --- entry.c | 11 ++++++----- entry.h | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/entry.c b/entry.c index 6339d54843..2ce16414a7 100644 --- a/entry.c +++ b/entry.c @@ -440,12 +440,13 @@ static void mark_colliding_entries(const struct checkout *state, } } -int checkout_entry(struct cache_entry *ce, const struct checkout *state, - char *topath, int *nr_checkouts) +int checkout_entry_ca(struct cache_entry *ce, struct conv_attrs *ca, + const struct checkout *state, char *topath, + int *nr_checkouts) { static struct strbuf path = STRBUF_INIT; struct stat st; - struct conv_attrs ca_buf, *ca = NULL; + struct conv_attrs ca_buf; if (ce->ce_flags & CE_WT_REMOVE) { if (topath) @@ -459,7 +460,7 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, } if (topath) { - if (S_ISREG(ce->ce_mode)) { + if (S_ISREG(ce->ce_mode) && !ca) { convert_attrs(state->istate, &ca_buf, ce->name); ca = &ca_buf; } @@ -530,7 +531,7 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, if (nr_checkouts) (*nr_checkouts)++; - if (S_ISREG(ce->ce_mode)) { + if (S_ISREG(ce->ce_mode) && !ca) { convert_attrs(state->istate, &ca_buf, ce->name); ca = &ca_buf; } diff --git a/entry.h b/entry.h index ea7290bcd5..b8c0e170dc 100644 --- a/entry.h +++ b/entry.h @@ -26,9 +26,21 @@ struct checkout { * 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. + * + * With checkout_entry_ca(), callers can optionally pass a preloaded + * conv_attrs struct (to avoid reloading it), when ce refers to a + * regular file. If ca is NULL, the attributes will be loaded + * internally when (and if) needed. */ -int checkout_entry(struct cache_entry *ce, const struct checkout *state, - char *topath, int *nr_checkouts); +int checkout_entry_ca(struct cache_entry *ce, struct conv_attrs *ca, + const struct checkout *state, char *topath, + int *nr_checkouts); +static inline int checkout_entry(struct cache_entry *ce, + const struct checkout *state, char *topath, + int *nr_checkouts) +{ + return checkout_entry_ca(ce, NULL, state, topath, nr_checkouts); +} void enable_delayed_checkout(struct checkout *state); int finish_delayed_checkout(struct checkout *state, int *nr_checkouts);