From patchwork Fri Jan 22 13:03:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12039433 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 0C014C433DB for ; Fri, 22 Jan 2021 13:10:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C93D5206A4 for ; Fri, 22 Jan 2021 13:10:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726794AbhAVNKf (ORCPT ); Fri, 22 Jan 2021 08:10:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728009AbhAVNEu (ORCPT ); Fri, 22 Jan 2021 08:04:50 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CDBBC061786 for ; Fri, 22 Jan 2021 05:04:03 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id o10so6674209wmc.1 for ; Fri, 22 Jan 2021 05:04:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=DnyYrk3xRM3urTEzb/6aSNWait4NhVd0JL69VV/BPEg=; b=Whvh/bQ/urjrF8Ja+CDUEyIucySpGtPRafxojU7g5UNl8z1busP8a4mnrI00HLycyG ibml/KV8XCBnBqY9QiPAnwh+ud3/04CziccOkyRYp5LmK8ZJqK8fADLnSe1XNzALxfqe UjeMDf6Trx8jWN40EZ9priwm9m0laoPX0nnGlUuO5inAiOh3CJswWnipamgm+2E4X9rf jLPy+OqUREiig8yMIebp19aWvOo8OAvwXK/hi7+E3+xOSEQNxY94uAoiH4pgCW0Id568 Pgy70srq8QJiQjl1V+0yf8g67yoxP/IyX1+82TNwRwmV14gfKuzCviuLUhXhURG2fwQA 1hUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=DnyYrk3xRM3urTEzb/6aSNWait4NhVd0JL69VV/BPEg=; b=nOuxUCXJ8u9lwek54FbjeO0u+BqBwQr5zXOdDtely7uJk05meUS7RT0unkJC7kX9p1 ApYRqEPM4Ne2BIkKmzIyu1qdhqwnQT6bJ8X4oDG5RGtr52xkFrAe9h5SSbT8LcOFAYHD qJn8Ho68zxIBSqG3WD69dtcyUGv5CQsnwC01ZXy9QaDBBg8T5jARN4VOje3+EhL3ql/V VVd3wrA1sxvhK8bBLumWzGbXXCBfC4N7hVvT+Wq6H7rTBroLIM5yd+SVQI+VfePxOiuZ FSDqXdWcyVUEOSaJzY3wU2VopO2pA0of2e2k+CBpclS1R0ZDegNNAzb76GHRQgVsWAmi d+ew== X-Gm-Message-State: AOAM533dRYQkgRpD6v00xJfLYlb3CHnojXdXtpLIiIga7OJExx9gq1HS zvj0ss8gozjO8TPZJceR3SDYUVrhePQ= X-Google-Smtp-Source: ABdhPJy3Ea35bL5YLjJODnY2WVKg9r7Ev5t/dXbCi7a/xCAhvGLMo3PpblPUxdKZ+9E3ElhlT+lRwA== X-Received: by 2002:a05:600c:1986:: with SMTP id t6mr3950237wmq.92.1611320642280; Fri, 22 Jan 2021 05:04:02 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a27sm12412372wrc.94.2021.01.22.05.04.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 05:04:01 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 22 Jan 2021 13:03:52 +0000 Subject: [PATCH v2 1/8] cache-tree: clean up cache_tree_update() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, Derrick Stolee , gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Make the method safer by allocating a cache_tree member for the given index_state if it is not already present. This is preferrable to a BUG() statement or returning with an error because future callers will want to populate an empty cache-tree using this method. Also drop local variables that are used exactly once and can be found directly from the 'istate' parameter. Signed-off-by: Derrick Stolee --- cache-tree.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cache-tree.c b/cache-tree.c index 3f1a8d4f1b7..c1e49901c17 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -436,16 +436,20 @@ static int update_one(struct cache_tree *it, int cache_tree_update(struct index_state *istate, int flags) { - struct cache_tree *it = istate->cache_tree; - struct cache_entry **cache = istate->cache; - int entries = istate->cache_nr; - int skip, i = verify_cache(cache, entries, flags); + int skip, i; + + i = verify_cache(istate->cache, istate->cache_nr, flags); if (i) return i; + + if (!istate->cache_tree) + istate->cache_tree = cache_tree(); + trace_performance_enter(); trace2_region_enter("cache_tree", "update", the_repository); - i = update_one(it, cache, entries, "", 0, &skip, flags); + i = update_one(istate->cache_tree, istate->cache, istate->cache_nr, + "", 0, &skip, flags); trace2_region_leave("cache_tree", "update", the_repository); trace_performance_leave("cache_tree_update"); if (i < 0) From patchwork Fri Jan 22 13:03:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12039431 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 50C90C43381 for ; Fri, 22 Jan 2021 13:10:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1DC34206A4 for ; Fri, 22 Jan 2021 13:10:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728020AbhAVNK3 (ORCPT ); Fri, 22 Jan 2021 08:10:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727478AbhAVNEu (ORCPT ); Fri, 22 Jan 2021 08:04:50 -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 94CFBC061788 for ; Fri, 22 Jan 2021 05:04:04 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id a9so5009639wrt.5 for ; Fri, 22 Jan 2021 05:04:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=11GVRZ1uX92OrDukLEJw+fr6Pd0hb/0vgREeqfoK+sw=; b=LexsxBUYxXIRzQITs9K3PVyrxAw5n1pYwrLjcNuD2IHw3Kikc2YLS1P16tec9ZtPzN eGE6wkkiZey7c/wl9ngmLq6ktSHO7fv0wITBEQRlJfBNX30ognN/cfDxIk/bHQInD/eH C4FpkrtF29G0EBH+v0WkFjf8H8os6mJD8dM+uTRKi1NX908GwRc8byezOlg+fpnzNk8l 5pMjvSQG+o+Lx/P4T8bBXmFXc2OvpRju11vb8tT7mqoUXEKEIjCEP/C7nii221a9o2T5 n+drI/dnVFUknr3QDEvSwGYsiUiIh82WUglaoKGK2ouqv+rN2YuxS9iTkMABXZLwXt5a P32Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=11GVRZ1uX92OrDukLEJw+fr6Pd0hb/0vgREeqfoK+sw=; b=QLg0/hFPc1VenQ7qb59hmZXiW4h2wxgzj3kIjl3NMfToSIkPRkKb0um2jb96vnA0SP EYy37zUCIlZIcgB4hXPJQBZ+4geOQHquBGgnP3+gOV795D3RAd4vlmVT+mtkLMN0vsCJ /PI0v1sdXtPJSInHuytz8hybpN7M/8CPyT1kbaYD+K7+kqZyTZqYcLjBzNuRHCFu4ErR yCSwuK1/SaOKcbnv9PQmPsS6vKNO+9ovmbOfFdEciZ1p2SPFFZiPS0tkk/gajPNZP3O/ 32zKqNcImLQrIQGHk+8a2iJl2BxTzHGKl2EZjJEsvyPdoZ/UvkpY7ItF0B6EmuKR5ZqK P8xA== X-Gm-Message-State: AOAM532wtCpAs15Qd4+yqiMFcRdg3/tNjMC2mIjg/yY1uv+eTy38lgmB wX9R+OQrEpuOflVNypQLgR5kgP8GYYA= X-Google-Smtp-Source: ABdhPJwosK/dppfEmlt8qvOAhM/IPMTiYWVwO4AZYBYoqcarcmeAZu7Ik961oryEsfrHuBnthD20gQ== X-Received: by 2002:a05:6000:104d:: with SMTP id c13mr4370463wrx.127.1611320643139; Fri, 22 Jan 2021 05:04:03 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a184sm11980021wme.35.2021.01.22.05.04.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 05:04:02 -0800 (PST) Message-Id: <84323e04d0885d2bb12329e7bd16582d66989c7f.1611320639.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 22 Jan 2021 13:03:53 +0000 Subject: [PATCH v2 2/8] cache-tree: extract subtree_pos() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, Derrick Stolee , gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee This method will be helpful to use outside of cache-tree.c in a later feature. The implementation is subtle due to subtree_name_cmp() sorting by length and then lexicographically. Signed-off-by: Derrick Stolee --- cache-tree.c | 6 +++--- cache-tree.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cache-tree.c b/cache-tree.c index c1e49901c17..2b130dd5e19 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -45,7 +45,7 @@ static int subtree_name_cmp(const char *one, int onelen, return memcmp(one, two, onelen); } -static int subtree_pos(struct cache_tree *it, const char *path, int pathlen) +int cache_tree_subtree_pos(struct cache_tree *it, const char *path, int pathlen) { struct cache_tree_sub **down = it->down; int lo, hi; @@ -72,7 +72,7 @@ static struct cache_tree_sub *find_subtree(struct cache_tree *it, int create) { struct cache_tree_sub *down; - int pos = subtree_pos(it, path, pathlen); + int pos = cache_tree_subtree_pos(it, path, pathlen); if (0 <= pos) return it->down[pos]; if (!create) @@ -123,7 +123,7 @@ static int do_invalidate_path(struct cache_tree *it, const char *path) it->entry_count = -1; if (!*slash) { int pos; - pos = subtree_pos(it, path, namelen); + pos = cache_tree_subtree_pos(it, path, namelen); if (0 <= pos) { cache_tree_free(&it->down[pos]->cache_tree); free(it->down[pos]); diff --git a/cache-tree.h b/cache-tree.h index 639bfa5340e..8efeccebfc9 100644 --- a/cache-tree.h +++ b/cache-tree.h @@ -27,6 +27,8 @@ void cache_tree_free(struct cache_tree **); void cache_tree_invalidate_path(struct index_state *, const char *); struct cache_tree_sub *cache_tree_sub(struct cache_tree *, const char *); +int cache_tree_subtree_pos(struct cache_tree *it, const char *path, int pathlen); + void cache_tree_write(struct strbuf *, struct cache_tree *root); struct cache_tree *cache_tree_read(const char *buffer, unsigned long size); From patchwork Fri Jan 22 13:03:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12039429 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 1091DC433E6 for ; Fri, 22 Jan 2021 13:10:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D320023106 for ; Fri, 22 Jan 2021 13:10:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727047AbhAVNKT (ORCPT ); Fri, 22 Jan 2021 08:10:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728020AbhAVNEz (ORCPT ); Fri, 22 Jan 2021 08:04:55 -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 6318BC06178B for ; Fri, 22 Jan 2021 05:04:05 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id 7so5032172wrz.0 for ; Fri, 22 Jan 2021 05:04:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=3tMIyV1e5H7KibNfv8wSK28+QZ3PH8wQIwxwCCv8pUg=; b=Boy8cQm8ptlsJIrilo/AHMAgYpnh+eHBoYH+tLfKqYkSHjBFokU22gNEKGd71k1Cgw HrVNeeJWTlUZwtycQ54uxODNem6yWttl9eyRbHcLDkQSu4MlDKNG4N/F07zNzCtdfJ4k /CjulU9OlDxjF07TBSa4yzDh2TjSH148ZVhk1jWUh3qx6hJLRg7uUj8/+coUetiSnRIq cI4aIqY1qH7ukrap7pX4D2X0nq880CoGwWub52v90IX1VjrPdMafFRlBE2xPuVt+BcQc ULJ+PkW14HI19662T/D30Yh3PAFWCPPkLRPqQ6DbvICoYsiKodQ9VXLTtLUJOUiUDF7P R78w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=3tMIyV1e5H7KibNfv8wSK28+QZ3PH8wQIwxwCCv8pUg=; b=ebgbzoBrBNWDhl5Vn56QmM8oQtKq8jROpF2uOLuINMoksOq6K0eR9ukm/YyBFyOn2E yG8azK4njvNllopR4u65koAfZzceiGfpokglTwJVeMN3p6PbiULTEIBIdcCEA294gOmw JBW/V8xwwxD8trw6CKA7eMTSIEX6dBeVqIXQ8D5aOsExOcPAUgtd5RIGJKd3PgwAoY23 aAW7nqI+fzHwUJNiWcOjYMqbREBQla244kXzWzvH06sWvK5TGnN84gbR65cLWLdbHunV z+n5msmbZ6Z9DdLwblPmQz8eb7H2feIHMENT5yKqTBMbEEQs3QbPUU/32zezPJxutw1j S+JQ== X-Gm-Message-State: AOAM532aGJiGCDDACi3Y9bJcu09tMZB/uznPz3R3io21ZxxwDXRCnRm+ SrpK4cFTLADgyV3eXj2YBk4KqxJiotw= X-Google-Smtp-Source: ABdhPJw7UURN4Sb2m670+T+DSg2IikPKf/7YziMExqRSv00Bd8TbBqjGUg5aID79Q1J75Td0XRRJwg== X-Received: by 2002:adf:eecc:: with SMTP id a12mr4440179wrp.312.1611320644028; Fri, 22 Jan 2021 05:04:04 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x25sm11532321wmk.20.2021.01.22.05.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 05:04:03 -0800 (PST) Message-Id: <31095f9aa0ecd29193cc4d612d1953653c04b8ae.1611320639.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 22 Jan 2021 13:03:54 +0000 Subject: [PATCH v2 3/8] fsmonitor: de-duplicate BUG()s around dirty bits Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, Derrick Stolee , gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee The index has an fsmonitor_dirty bitmap that records which index entries are "dirty" based on the response from the FSMonitor. If this bitmap ever grows larger than the index, then there was an error in how it was constructed, and it was probably a developer's bug. There are several BUG() statements that are very similar, so replace these uses with a simpler assert_index_minimum(). Since there is one caller that uses a custom 'pos' value instead of the bit_size member, we cannot simplify it too much. However, the error string is identical in each, so this simplifies things. The end result is that the code is simpler to read while also preserving these assertions for developers in the FSMonitor space. Signed-off-by: Derrick Stolee --- fsmonitor.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/fsmonitor.c b/fsmonitor.c index ca031c3abb8..52a50a9545a 100644 --- a/fsmonitor.c +++ b/fsmonitor.c @@ -13,14 +13,19 @@ struct trace_key trace_fsmonitor = TRACE_KEY_INIT(FSMONITOR); +static void assert_index_minimum(struct index_state *istate, size_t pos) +{ + if (pos > istate->cache_nr) + BUG("fsmonitor_dirty has more entries than the index (%"PRIuMAX" > %u)", + (uintmax_t)pos, istate->cache_nr); +} + static void fsmonitor_ewah_callback(size_t pos, void *is) { struct index_state *istate = (struct index_state *)is; struct cache_entry *ce; - if (pos >= istate->cache_nr) - BUG("fsmonitor_dirty has more entries than the index (%"PRIuMAX" >= %u)", - (uintmax_t)pos, istate->cache_nr); + assert_index_minimum(istate, pos); ce = istate->cache[pos]; ce->ce_flags &= ~CE_FSMONITOR_VALID; @@ -82,10 +87,8 @@ int read_fsmonitor_extension(struct index_state *istate, const void *data, } istate->fsmonitor_dirty = fsmonitor_dirty; - if (!istate->split_index && - istate->fsmonitor_dirty->bit_size > istate->cache_nr) - BUG("fsmonitor_dirty has more entries than the index (%"PRIuMAX" > %u)", - (uintmax_t)istate->fsmonitor_dirty->bit_size, istate->cache_nr); + if (!istate->split_index) + assert_index_minimum(istate, istate->fsmonitor_dirty->bit_size); trace_printf_key(&trace_fsmonitor, "read fsmonitor extension successful"); return 0; @@ -110,10 +113,8 @@ void write_fsmonitor_extension(struct strbuf *sb, struct index_state *istate) uint32_t ewah_size = 0; int fixup = 0; - if (!istate->split_index && - istate->fsmonitor_dirty->bit_size > istate->cache_nr) - BUG("fsmonitor_dirty has more entries than the index (%"PRIuMAX" > %u)", - (uintmax_t)istate->fsmonitor_dirty->bit_size, istate->cache_nr); + if (!istate->split_index) + assert_index_minimum(istate, istate->fsmonitor_dirty->bit_size); put_be32(&hdr_version, INDEX_EXTENSION_VERSION2); strbuf_add(sb, &hdr_version, sizeof(uint32_t)); @@ -335,9 +336,7 @@ void tweak_fsmonitor(struct index_state *istate) } /* Mark all previously saved entries as dirty */ - if (istate->fsmonitor_dirty->bit_size > istate->cache_nr) - BUG("fsmonitor_dirty has more entries than the index (%"PRIuMAX" > %u)", - (uintmax_t)istate->fsmonitor_dirty->bit_size, istate->cache_nr); + assert_index_minimum(istate, istate->fsmonitor_dirty->bit_size); ewah_each_bit(istate->fsmonitor_dirty, fsmonitor_ewah_callback, istate); refresh_fsmonitor(istate); From patchwork Fri Jan 22 13:03:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12039425 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 127B6C433E6 for ; Fri, 22 Jan 2021 13:08:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D4DF623106 for ; Fri, 22 Jan 2021 13:08:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728071AbhAVNIK (ORCPT ); Fri, 22 Jan 2021 08:08:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726277AbhAVNFQ (ORCPT ); Fri, 22 Jan 2021 08:05:16 -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 548CAC061793 for ; Fri, 22 Jan 2021 05:04:06 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id v184so4284474wma.1 for ; Fri, 22 Jan 2021 05:04:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=y598NcID+pvqCAZAY/Tm1DdS/4I5fOF8T0v3YIlcS0c=; b=tRv+KnY9IMk/900tlcusmB1LZHuII9jfi526kwBxAMCDIbcGFMr8EoG/5SgPOvGu/6 lEyNhlF5yh4M3bNeHC35Vs+V6N/3eBdeZy/N76lFhf9O8Z3BIMUXkFWUbhrrhp4Ps6Pu D8Gj6XR8Aoop/8972nl9y8FcSgby/QpTfWLb7KloM2eKB5T9ybr6gZolPQvFLezXIC4V DF34L2gzS3dt9V7D3RjCbO0XXpB11VYxiCfVyx3L+YOly5HY082Oq7S3OZqU3Nh7oDV5 0POeIPCNycxNv4KNvZcvzlVB3egOUc+W6LDTlehLLZO0fVUYnNGDq6sBDJifETd/yKLx AkXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=y598NcID+pvqCAZAY/Tm1DdS/4I5fOF8T0v3YIlcS0c=; b=jtUuvPkEAiHhVIy16fP5jKauvvGyzxWg0IOXlbQKX1wjoUUVuwPpsIc4OAtgXYqfmj htpVUsFwcCmMBSSBx35W4PylLtmSL3jjm3LvzWxjuYgMKhSR27yFvKk1Q5wWDifJJq1e RIICMuCePAnqIg+w5aFQ1WfuPZdln2pYT/J0o+u+vmc28PFqV4Hd2fc/KD6T9/H8oujE GZdFFTutTdbrHF7hk32bzvHJhbGIUtxtq0cdv5gtIXLFN7pWHUp7oYIjiZNOP95wkFVZ k0Jgj0WWm2a4NrOTQAGLh3XXeO51Cy8EWYDa8GIPmj2IMqXCDByCpraC7iav2TyGWQzL ijAA== X-Gm-Message-State: AOAM532n6RCmCNfb8lO4BZILI8O+Tc2d2MA/B3MYIRsTYPwU8y/25dJJ xtODlq+1CWKKW38akBQBo1TnQHSzNcc= X-Google-Smtp-Source: ABdhPJx4SEC3Vgx8proET5JS8qsdAnAoHAbvz0xrMsMxisEvZBVMUVRii178clmc3CsRE0BLoQn7cA== X-Received: by 2002:a7b:c210:: with SMTP id x16mr3769137wmi.105.1611320644986; Fri, 22 Jan 2021 05:04:04 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u83sm11353027wmu.12.2021.01.22.05.04.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 05:04:04 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 22 Jan 2021 13:03:55 +0000 Subject: [PATCH v2 4/8] repository: add repo reference to index_state Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, Derrick Stolee , gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee It will be helpful to add behavior to index operations that might trigger an object lookup. Since each index belongs to a specific repository, add a 'repo' pointer to struct index_state that allows access to this repository. This will prevent future changes from needing to pass an additional 'struct repository *repo' parameter and instead rely only on the 'struct index_state *istate' parameter. Signed-off-by: Derrick Stolee --- cache.h | 1 + repository.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/cache.h b/cache.h index 71097657489..f9c7a603841 100644 --- a/cache.h +++ b/cache.h @@ -328,6 +328,7 @@ struct index_state { struct ewah_bitmap *fsmonitor_dirty; struct mem_pool *ce_mem_pool; struct progress *progress; + struct repository *repo; }; /* Name hashing */ diff --git a/repository.c b/repository.c index a4174ddb062..67a4c1da2d9 100644 --- a/repository.c +++ b/repository.c @@ -264,6 +264,10 @@ int repo_read_index(struct repository *repo) if (!repo->index) repo->index = xcalloc(1, sizeof(*repo->index)); + /* Complete the double-reference */ + if (!repo->index->repo) + repo->index->repo = repo; + return read_index_from(repo->index, repo->index_file, repo->gitdir); } From patchwork Fri Jan 22 13:03:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12039427 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 96A4CC433DB for ; Fri, 22 Jan 2021 13:09:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 60754206A4 for ; Fri, 22 Jan 2021 13:09:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727732AbhAVNIi (ORCPT ); Fri, 22 Jan 2021 08:08:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726777AbhAVNFQ (ORCPT ); Fri, 22 Jan 2021 08:05:16 -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 58DEFC061794 for ; Fri, 22 Jan 2021 05:04:07 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id c12so5012182wrc.7 for ; Fri, 22 Jan 2021 05:04:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=3LC/1eestJjR+EOcwKHsjfdOZknum6kvDyZ7fg9I1AA=; b=tyeQV6bHGmmjZIKVtirkUJiUWKnHekp8hWW48RIaM+z4wk3DazKa/gk5w7D82igmNV TSDMwvnWPE6dC6NEsd4K2ShE+eJzpoHL0kksCX14hjhxgH/6YXQ0cv690CY+7mk0UuE1 WSY/jaJ6h46DHBvOeCzykvKtKv5VsSqYamw8sLsk24oqEd3YFb2qIQ73QMj8oc9eLhok ZFs28J53sPH+FgNN7thJwnOKbKBb65ynDepdZZz8TGUj68bTQir9XfRik0SbMQvF59hL lqtauVGYHh0v17+Kmoi0OTP1l14fuK79MBWlzKJOKmYxa2KjCvzbe2lwSOuxjVfON4ZF QjaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=3LC/1eestJjR+EOcwKHsjfdOZknum6kvDyZ7fg9I1AA=; b=eI83GB4IJJZwwRIkDkbkQIiswN+GhjPAX7uudRydY7zSZDK5Ur56pFn/aJUguRK1XQ mr77WcW39Wmg93t3U3EdsZyE+K+boIgR0T07HyV5W2J7iEMfuvjnsW0vBzQYvtITmOQ/ MIA/49suurdmKSH1fvof+ZKhcJiF4DUqSJipjoH/zLpIfFxE0dnsLIQYKdFQMnnuPP/K q/IV/F1XADVhw0A/w2eFq11Q0HZI82aRppsBoGcKayXPt+cKScb4DJ7N5pvwZflYjJhf 264S35CFFHEb82xy2prJsNT65H7lELrXsQQamkrUXdgRPRWj59LJAdveZI41QeOBm0yS kAqQ== X-Gm-Message-State: AOAM532F8qZ8lbas4tnqG0zCVW5IsB4e19RO+f4+Egws3IYv4S3rPnZb uYjDlTJHOaqy4SEeekmCYGTFsN6myQM= X-Google-Smtp-Source: ABdhPJyx9mqjErmWk0GaOz50XY3KQGJ7U79eeKNTqySDmioaSxniubLg5oTFzwCBMrsfoiG+7a4vZg== X-Received: by 2002:adf:e84c:: with SMTP id d12mr4681430wrn.382.1611320645797; Fri, 22 Jan 2021 05:04:05 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id r2sm12467995wrn.83.2021.01.22.05.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 05:04:05 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 22 Jan 2021 13:03:56 +0000 Subject: [PATCH v2 5/8] name-hash: use trace2 regions for init Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, Derrick Stolee , gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee The lazy_init_name_hash() populates a hashset with all filenames and another with all directories represented in the index. This is run only if we need to use the hashsets to check for existence or case-folding renames. Place trace2 regions where there is already a performance trace. Signed-off-by: Derrick Stolee --- name-hash.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/name-hash.c b/name-hash.c index 5d3c7b12c18..4e03fac9bb1 100644 --- a/name-hash.c +++ b/name-hash.c @@ -7,6 +7,7 @@ */ #include "cache.h" #include "thread-utils.h" +#include "trace2.h" struct dir_entry { struct hashmap_entry ent; @@ -577,6 +578,7 @@ static void lazy_init_name_hash(struct index_state *istate) if (istate->name_hash_initialized) return; trace_performance_enter(); + trace2_region_enter("index", "name-hash-init", istate->repo); hashmap_init(&istate->name_hash, cache_entry_cmp, NULL, istate->cache_nr); hashmap_init(&istate->dir_hash, dir_entry_cmp, NULL, istate->cache_nr); @@ -597,6 +599,7 @@ static void lazy_init_name_hash(struct index_state *istate) } istate->name_hash_initialized = 1; + trace2_region_leave("index", "name-hash-init", istate->repo); trace_performance_leave("initialize name hash"); } From patchwork Fri Jan 22 13:03:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12039423 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 5583DC433E6 for ; Fri, 22 Jan 2021 13:06:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C7C52054F for ; Fri, 22 Jan 2021 13:06:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727923AbhAVNGg (ORCPT ); Fri, 22 Jan 2021 08:06:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727497AbhAVNFj (ORCPT ); Fri, 22 Jan 2021 08:05:39 -0500 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CF9FC061797 for ; Fri, 22 Jan 2021 05:04:08 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id c124so4239851wma.5 for ; Fri, 22 Jan 2021 05:04:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=i6bsGcr92iaw2mbWyW6jBWtwOPrpstDD1S5j/W6nyDk=; b=pM2QzjPRufDyG510czEwrEfr++iizOLmzW+G47TjWKBqGmd1tsbu7dK9KF90bG5lQi 4MshwBPwsHtiq24fs1y9OPQQQsl/yYBwGIdCpvG35MQ7bNKcKHIu/evJyX5emZpg6w7I Jfrjhi2H3zQAUpSVaOsjpxcBUBWAGwR8W36Eyws/wi/4osS3pYc6tyOFKEQ1jYxu1nVs VPo1A2gL2DKHvJy7ox3CLODQqYbzHcrmT0tI59fcrgmsLHYH/Wgur5yyKv9BH6rE/cwB mOLlQcwCFCCIdrPvDTnNO7PW825Thfk7cjw3sFR8p02XbnERndek9UmcW5CryDVb3Urk IweA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=i6bsGcr92iaw2mbWyW6jBWtwOPrpstDD1S5j/W6nyDk=; b=aFcYGHBA5CLPwuR5+Eyvl/6WboHEbp+4WQYYpwFXtlbzd4FTjI0+eLStRXc3j7TSfm p3oCpOmSzXVMnvBhPOUloBpVkeST05k9MeVJyMacS4c6HqwwJ1Mf/YXBeRRCZswcPDV4 iyjqNcqmTfGuZ1FbyyOxFXFJ8Flr1EAzwGepa69ugaYL15MWqIiA91bVdqQ6p5Y+Nqhw YXBRLqyGfv23lJR45aO+M1+BoVmD+1gsdaYMbr1fctyu8aXewpZWdCq3eCMD5odb5HdB gIehtmXjUIKNpaFoJsRZhV8pUwsPKbf83hPcicnUbqgZccyP7Z2FaT7ewJe9HK9BFyc6 tSnw== X-Gm-Message-State: AOAM532pS/bkErfoWz3Eb2+B3GbEvLFSdR1Z+oPWmEO+783ylPzv143y FqvX8wWHetwgCQlOADr8efqpPvxhaiw= X-Google-Smtp-Source: ABdhPJzR/+6aV3t0xwSyXDenvRR2uNtrQ7TUqvw6lRBRCC4HUP6FOgFNgVSOeRIU3XQ8lCc8/HA1cg== X-Received: by 2002:a1c:9d8b:: with SMTP id g133mr3928204wme.44.1611320646849; Fri, 22 Jan 2021 05:04:06 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id b11sm6562940wrp.60.2021.01.22.05.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 05:04:06 -0800 (PST) Message-Id: <04d1daf7222e16f07f9c1eb92a7ecd020667da3c.1611320639.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 22 Jan 2021 13:03:57 +0000 Subject: [PATCH v2 6/8] sparse-checkout: load sparse-checkout patterns Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, Derrick Stolee , gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee A future feature will want to load the sparse-checkout patterns into a pattern_list, but the current mechanism to do so is a bit complicated. This is made difficult due to needing to find the sparse-checkout file in different ways throughout the codebase. The logic implemented in the new get_sparse_checkout_patterns() was duplicated in populate_from_existing_patterns() in unpack-trees.c. Use the new method instead, keeping the logic around handling the struct unpack_trees_options. The callers to get_sparse_checkout_filename() in builtin/sparse-checkout.c manipulate the sparse-checkout file directly, so it is not appropriate to replace logic in that file with get_sparse_checkout_patterns(). Signed-off-by: Derrick Stolee --- builtin/sparse-checkout.c | 5 ----- dir.c | 17 +++++++++++++++++ dir.h | 2 ++ unpack-trees.c | 6 +----- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index e3140db2a0a..2306a9ad98e 100644 --- a/builtin/sparse-checkout.c +++ b/builtin/sparse-checkout.c @@ -22,11 +22,6 @@ static char const * const builtin_sparse_checkout_usage[] = { NULL }; -static char *get_sparse_checkout_filename(void) -{ - return git_pathdup("info/sparse-checkout"); -} - static void write_patterns_to_file(FILE *fp, struct pattern_list *pl) { int i; diff --git a/dir.c b/dir.c index d637461da5c..d153a63bbd1 100644 --- a/dir.c +++ b/dir.c @@ -2998,6 +2998,23 @@ void setup_standard_excludes(struct dir_struct *dir) } } +char *get_sparse_checkout_filename(void) +{ + return git_pathdup("info/sparse-checkout"); +} + +int get_sparse_checkout_patterns(struct pattern_list *pl) +{ + int res; + char *sparse_filename = get_sparse_checkout_filename(); + + pl->use_cone_patterns = core_sparse_checkout_cone; + res = add_patterns_from_file_to_list(sparse_filename, "", 0, pl, NULL); + + free(sparse_filename); + return res; +} + int remove_path(const char *name) { char *slash; diff --git a/dir.h b/dir.h index a3c40dec516..facfae47402 100644 --- a/dir.h +++ b/dir.h @@ -448,6 +448,8 @@ int is_empty_dir(const char *dir); void setup_standard_excludes(struct dir_struct *dir); +char *get_sparse_checkout_filename(void); +int get_sparse_checkout_patterns(struct pattern_list *pl); /* Constants for remove_dir_recursively: */ diff --git a/unpack-trees.c b/unpack-trees.c index af6e9b9c2fd..837b8bb42fb 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1549,14 +1549,10 @@ static void mark_new_skip_worktree(struct pattern_list *pl, static void populate_from_existing_patterns(struct unpack_trees_options *o, struct pattern_list *pl) { - char *sparse = git_pathdup("info/sparse-checkout"); - - pl->use_cone_patterns = core_sparse_checkout_cone; - if (add_patterns_from_file_to_list(sparse, "", 0, pl, NULL) < 0) + if (get_sparse_checkout_patterns(pl) < 0) o->skip_sparse_checkout = 1; else o->pl = pl; - free(sparse); } From patchwork Fri Jan 22 13:03:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12039403 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=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 AD293C433DB for ; Fri, 22 Jan 2021 13:06:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66E5F235F7 for ; Fri, 22 Jan 2021 13:06:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727354AbhAVNFv (ORCPT ); Fri, 22 Jan 2021 08:05:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727517AbhAVNFj (ORCPT ); Fri, 22 Jan 2021 08:05:39 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C449C0617A7 for ; Fri, 22 Jan 2021 05:04:09 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id m2so4248337wmm.1 for ; Fri, 22 Jan 2021 05:04:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=8JFIK/fvNqDmX4Q3vEfnZadxvVhFeB1bH+XL9LjdH2g=; b=Z6jh/vU/Gg7PuTfZ1mGfAoXu2vN8wezgYJpOTbGZkmPFPqj2sTJic3ZUoDSbEUFnHZ zZUsnnKIuVQ/+cKsvstrdYN7yDUWIXjHDeedE8ZEIfZilykC/wOPO2klrEyv6OswYW1v 4wxfYfmgW7QseyDgU7hBm1wgkeJaeyvtVRFkaPuHe2jhlt4Umm5ekXh98XI58zmIme1i E69YQ+S3ZiDIlDlPCsAafljLVIJ498BEkSj8B6vYBlA5XZ5yYfCBMrAMPv2omv00a40+ Idqj46rBFseHKO46s/zXjyTxcv4v5PNgP9phhNq4MN+gOwKS9lbol79pSZ7SOGMAAoke ALjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=8JFIK/fvNqDmX4Q3vEfnZadxvVhFeB1bH+XL9LjdH2g=; b=Y1FnjaPuHW8WY4ZJaodslM8YwCgmJFKqdKfPCgF6Z/DoaSv+9kEi/EOy2yNs9Ydhgl s5nXh3WwhGBsLdkgpEzBBFTrJ+2T6CIQS77x0hDb+98KsR/czH/JvTQwnSIrai30tncS mEPg41ouJd8tacL/UTblffPCAEjfO8hrHzFXszrVmDIKBM12NYNwDmlv+Pma5Bxm9DwA GahkVrKV4m5DiwDSqp4S8gkTD+LnP83MQ5XzYpgKxFGynFqjdL87BqEdTk8ctQSYe4sb 5k24rLKwndCNGzLcLXstAQAempJ/LfbiO2H5nwOH/4XOCXshTOiunQL5kiVyaJMqC62C kefA== X-Gm-Message-State: AOAM533sr6N7/8jgl+xiwZBh++BqGsdTQe74MPXvw1PZX9ivI7ZQH6Os e+BZA3kTylDrwPOzRLaFg39hzkCuhwk= X-Google-Smtp-Source: ABdhPJytcXw77808nVZxPVdrDSq9msFiuevCb3gb4qdorkLJWJfb6g+CmwV50wsoihVGjbtD/rrZrA== X-Received: by 2002:a1c:68c5:: with SMTP id d188mr4030993wmc.64.1611320647815; Fri, 22 Jan 2021 05:04:07 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u205sm11179966wme.42.2021.01.22.05.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 05:04:07 -0800 (PST) Message-Id: <8832ce84623e9c74a88b14a05b1c303ed8aa809b.1611320640.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 22 Jan 2021 13:03:58 +0000 Subject: [PATCH v2 7/8] test-lib: test_region looks for trace2 regions Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, Derrick Stolee , gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Most test cases can verify Git's behavior using input/output expectations or changes to the .git directory. However, sometimes we want to check that Git did or did not run a certain section of code. This is particularly important for performance-only features that we want to ensure have been enabled in certain cases. Add a new 'test_region' function that checks if a trace2 region was entered and left in a given trace2 event log. There is one existing test (t0500-progress-display.sh) that performs this check already, so use the helper function instead. Note that this changes the expectations slightly. The old test (incorrectly) used two patterns for the 'grep' invocation, but this performs an OR of the patterns, not an AND. This means that as long as one region_enter event was logged, the test would succeed, even if it was not due to the progress category. More uses will be added in a later change. t6423-merge-rename-directories.sh also greps for region_enter lines, but it verifies the number of such lines, which is not the same as an existence check. Signed-off-by: Derrick Stolee --- t/t0500-progress-display.sh | 3 +-- t/test-lib-functions.sh | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/t/t0500-progress-display.sh b/t/t0500-progress-display.sh index 1ed1df351cb..84cce345e7d 100755 --- a/t/t0500-progress-display.sh +++ b/t/t0500-progress-display.sh @@ -303,8 +303,7 @@ test_expect_success 'progress generates traces' ' "Working hard" stderr && # t0212/parse_events.perl intentionally omits regions and data. - grep -e "region_enter" -e "\"category\":\"progress\"" trace.event && - grep -e "region_leave" -e "\"category\":\"progress\"" trace.event && + test_region progress "Working hard" trace.event && grep "\"key\":\"total_objects\",\"value\":\"40\"" trace.event && grep "\"key\":\"total_bytes\",\"value\":\"409600\"" trace.event ' diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 999982fe4a9..1170f7108ac 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1655,3 +1655,43 @@ test_subcommand () { grep "\[$expr\]" fi } + +# Check that the given command was invoked as part of the +# trace2-format trace on stdin. +# +# test_region [!]