From patchwork Tue May 11 18:34:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12251805 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,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 39129C433ED for ; Tue, 11 May 2021 18:34:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F13D86188B for ; Tue, 11 May 2021 18:34:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231992AbhEKSfW (ORCPT ); Tue, 11 May 2021 14:35:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231454AbhEKSfU (ORCPT ); Tue, 11 May 2021 14:35:20 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA5F6C061574 for ; Tue, 11 May 2021 11:34:12 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id n17-20020a7bc5d10000b0290169edfadac9so1229652wmk.1 for ; Tue, 11 May 2021 11:34:12 -0700 (PDT) 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=GfEP0VwpNXUghSEELZYFdkKw6ca5DFWDqADqqUFPglA=; b=pKKxvc6Y8lzHYT0lNUYPubkZ+rhvbvFJ2/gktcSNj/9HogBXDJ+ovvdU4qKZitbhvy S5UD8eLdL8OqHdbUWHVbpq0dDPud2NgqqdxeVwedNIfmhdqgPioTvmpFp76y26jOMIek mfSqgdFQKRLrF05MJuy3qSciJYcYV0W8uJE8dyFms5RMIc0Z3HQf4eZ5wWPhlQjFeSJi gfkf7h1vVN4A7ZhUt2k81mzIDyXD+s6xI7i81j2p9fS1p8GukL1kUgW1Mf5+h6TwoGK8 2cm2Op2qKpam7BSX/Ej6wfksss0Z6Oy7tIJksTJmXK1evzlSM+PZ5UeMv+krOyi+COJR 3gGA== 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=GfEP0VwpNXUghSEELZYFdkKw6ca5DFWDqADqqUFPglA=; b=jqvc9VOlTlMw6ZeLH3uz8STmod+CmT3NDsnCStxQMhArX4/rAsztwskxeBuOzDZ+XV 0fHVx3YruoeCAHd8XCez4QH0SSrUwu8q57cWe7vngFguEjU8gfuPT8MW+M+lOMd2UNoo /7NmIJLdGhDFG3PbbXvHEouu2mAeiS9g8Fwt2K/0iZruBL1+2iTSI8F8JYCGkA65QMmQ dcFvWAU0EC9hAYnmW4HqNkrB57Mfk0z8E3KfbaPZpDNQJ0v04SGf3OiksnF9zl/wfiSH 8YqSmsGIzoyAx+bSN2V9Lo5R4MqQSUnIcIXmlrpE4g4hO1yaz/1WaUgojy70TWiC6tzc 1LGg== X-Gm-Message-State: AOAM533QGkyEbbKAPKN8Z0qRBTsZbg/Wk7B1HUAugb+4sUARcGLidhza AQ27ZsYxb9l4Pe5ezOhtnfFYDr5n6aU= X-Google-Smtp-Source: ABdhPJwJB4NnivfbOw46Ptw7hMrVpe0yr5TD9AVautoDeQl2xY+zcwff4vYsjDNodE30tVIxrNx5WA== X-Received: by 2002:a1c:9842:: with SMTP id a63mr7016994wme.125.1620758051551; Tue, 11 May 2021 11:34:11 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z7sm27711056wrl.11.2021.05.11.11.34.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:34:11 -0700 (PDT) Message-Id: <9204e36b7e9035c4cdda018d7ced8e8ca7acc8bc.1620758049.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 11 May 2021 18:34:01 +0000 Subject: [PATCH v4 1/8] dir: convert trace calls to trace2 equivalents Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Eric Sunshine , Elijah Newren , Derrick Stolee , Jeff King , Philip Oakley , Jeff Hostetler , Josh Steadmon , Jeff Hostetler , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Signed-off-by: Elijah Newren --- dir.c | 43 +++++-- t/t7063-status-untracked-cache.sh | 205 ++++++++++++++++++------------ t/t7519-status-fsmonitor.sh | 8 +- 3 files changed, 155 insertions(+), 101 deletions(-) diff --git a/dir.c b/dir.c index 3474e67e8f3c..122fcbffdf89 100644 --- a/dir.c +++ b/dir.c @@ -2760,15 +2760,34 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d return root; } +static void trace2_read_directory_statistics(struct dir_struct *dir, + struct repository *repo, + const char *path) +{ + if (!dir->untracked) + return; + trace2_data_string("read_directory", repo, "path", path); + trace2_data_intmax("read_directory", repo, + "node-creation", dir->untracked->dir_created); + trace2_data_intmax("read_directory", repo, + "gitignore-invalidation", + dir->untracked->gitignore_invalidated); + trace2_data_intmax("read_directory", repo, + "directory-invalidation", + dir->untracked->dir_invalidated); + trace2_data_intmax("read_directory", repo, + "opendir", dir->untracked->dir_opened); +} + int read_directory(struct dir_struct *dir, struct index_state *istate, const char *path, int len, const struct pathspec *pathspec) { struct untracked_cache_dir *untracked; - trace_performance_enter(); + trace2_region_enter("dir", "read_directory", istate->repo); if (has_symlink_leading_path(path, len)) { - trace_performance_leave("read directory %.*s", len, path); + trace2_region_leave("dir", "read_directory", istate->repo); return dir->nr; } @@ -2784,23 +2803,20 @@ int read_directory(struct dir_struct *dir, struct index_state *istate, QSORT(dir->entries, dir->nr, cmp_dir_entry); QSORT(dir->ignored, dir->ignored_nr, cmp_dir_entry); - trace_performance_leave("read directory %.*s", len, path); + if (trace2_is_enabled()) { + struct strbuf tmp = STRBUF_INIT; + strbuf_add(&tmp, path, len); + trace2_read_directory_statistics(dir, istate->repo, tmp.buf); + strbuf_release(&tmp); + } + + trace2_region_leave("dir", "read_directory", istate->repo); if (dir->untracked) { static int force_untracked_cache = -1; - static struct trace_key trace_untracked_stats = TRACE_KEY_INIT(UNTRACKED_STATS); if (force_untracked_cache < 0) force_untracked_cache = git_env_bool("GIT_FORCE_UNTRACKED_CACHE", 0); - trace_printf_key(&trace_untracked_stats, - "node creation: %u\n" - "gitignore invalidation: %u\n" - "directory invalidation: %u\n" - "opendir: %u\n", - dir->untracked->dir_created, - dir->untracked->gitignore_invalidated, - dir->untracked->dir_invalidated, - dir->untracked->dir_opened); if (force_untracked_cache && dir->untracked == istate->untracked && (dir->untracked->dir_opened || @@ -2811,6 +2827,7 @@ int read_directory(struct dir_struct *dir, struct index_state *istate, FREE_AND_NULL(dir->untracked); } } + return dir->nr; } diff --git a/t/t7063-status-untracked-cache.sh b/t/t7063-status-untracked-cache.sh index accefde72fb1..9710d33b3cd6 100755 --- a/t/t7063-status-untracked-cache.sh +++ b/t/t7063-status-untracked-cache.sh @@ -57,6 +57,19 @@ iuc () { return $ret } +get_relevant_traces () { + # From the GIT_TRACE2_PERF data of the form + # $TIME $FILE:$LINE | d0 | main | data | r1 | ? | ? | read_directo | $RELEVANT_STAT + # extract the $RELEVANT_STAT fields. We don't care about region_enter + # or region_leave, or stats for things outside read_directory. + INPUT_FILE=$1 + OUTPUT_FILE=$2 + grep data.*read_directo $INPUT_FILE | + cut -d "|" -f 9 \ + >"$OUTPUT_FILE" +} + + test_lazy_prereq UNTRACKED_CACHE ' { git update-index --test-untracked-cache; ret=$?; } && test $ret -ne 1 @@ -129,19 +142,21 @@ EOF test_expect_success 'status first time (empty cache)' ' avoid_racy && - : >../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../actual && iuc status --porcelain >../status.iuc && test_cmp ../status.expect ../status.iuc && test_cmp ../status.expect ../actual && + get_relevant_traces ../trace.output ../trace.relevant && cat >../trace.expect <../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../actual && iuc status --porcelain >../status.iuc && test_cmp ../status.expect ../status.iuc && test_cmp ../status.expect ../actual && + get_relevant_traces ../trace.output ../trace.relevant && cat >../trace.expect <four && - : >../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../actual && iuc status --porcelain >../status.iuc && cat >../status.expect <../trace.expect <.gitignore && - : >../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../actual && iuc status --porcelain >../status.iuc && cat >../status.expect <../trace.expect <>.git/info/exclude && - : >../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../actual && iuc status --porcelain >../status.iuc && cat >../status.expect <../trace.expect <../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../actual && iuc status --porcelain >../status.iuc && cat >../status.expect <../trace.expect <../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../actual && iuc status --porcelain >../status.iuc && cat >../status.expect <../trace.expect <../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../actual && iuc status --porcelain >../status.iuc && cat >../status.expect <../trace.expect <../trace && + : >../trace.output && avoid_racy && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../status.actual && iuc status --porcelain >../status.iuc && cat >../status.expect <../trace.expect <../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../status.actual && iuc status --porcelain >../status.iuc && cat >../status.expect <../trace.expect <../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../status.actual && iuc status --porcelain >../status.iuc && cat >../status.expect <../trace.expect <../trace && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + : >../trace.output && + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ git status --porcelain >../status.actual && iuc status --porcelain >../status.iuc && test_cmp ../status.expect ../status.iuc && test_cmp ../status.expect ../status.actual && + get_relevant_traces ../trace.output ../trace.relevant && cat >../trace.expect <../before ) && @@ -346,12 +346,12 @@ test_expect_success UNTRACKED_CACHE 'ignore .git changes when invalidating UNTR' EOF ( cd dot-git && - GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace-after" \ + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace-after" \ git status && test-tool dump-untracked-cache >../after ) && - grep "directory invalidation" trace-before >>before && - grep "directory invalidation" trace-after >>after && + grep "directory-invalidation" trace-before | cut -d"|" -f 9 >>before && + grep "directory-invalidation" trace-after | cut -d"|" -f 9 >>after && # UNTR extension unchanged, dir invalidation count unchanged test_cmp before after ' From patchwork Tue May 11 18:34:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12251809 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,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 86C1EC43461 for ; Tue, 11 May 2021 18:34:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E9C06188B for ; Tue, 11 May 2021 18:34:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232006AbhEKSfX (ORCPT ); Tue, 11 May 2021 14:35:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231825AbhEKSfW (ORCPT ); Tue, 11 May 2021 14:35:22 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76D38C06174A for ; Tue, 11 May 2021 11:34:13 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id x5so21103665wrv.13 for ; Tue, 11 May 2021 11:34:13 -0700 (PDT) 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=sTx9lSBDuZng0Z3nvmpUgnf6o5I0UJrmkdo4kHUxzlI=; b=sYTdNbSu5pX0jTTh9/BgPWU3/hVz6kU4+HnnnjJr6YoWgyV6iqh2ZoRggZzOwiIVuU 1dseCL4EUI5RrwGXFdB9F/TqVQP53RpckkpOv0J9BV3dZWIk2OjuWBWSOEU0noNYzJmq n9zkfLcFpu7VJ7FMHxn7yQWZFoBvzugHKrd7r4EmD2sPlX+CzJQ5RTchwiu5VR6/A3L/ g26Tn+DPEdqVpELcC3SjNA/xOUMckFip1+V0xbrf+yAuLfKM9qYAVaZqilMpr3SUdtQf KMncIOV7Vxjg0U//RxJfucJqIuH3OwmrGkeK4z1QuKeehZNy8j94ngNtwJ9vPLTIhZ7S 5h3g== 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=sTx9lSBDuZng0Z3nvmpUgnf6o5I0UJrmkdo4kHUxzlI=; b=PYb6yeBA2jLh1r1yBpKfrBGYjYc9Omkx9DZldPNmX6XQKZENtvBgsTcWKJ/fVtSBCG HpyC4iH6EsCtRaoiUrHsecwBev13cIBFr8ZfUEomG2ewbtGKFlOb8eXQRB5cmXz3kfDI 5I661s04XHZAvIkHXABmkjZXBGG/9wbb7PZXDVZpHW/v4fII2BXfB4eW+eL35/1TpjfR fYw+IzehePeo9WBb1dVx038HGqCQrkjZDk2MOroJuhzzO6LFABu7gyjVPAbfKMHuB1HR WePmcvIjjXMlxwLw4ze+dY+V2WyswqTafgXFxukootckf/89Fr3l42/6Y6MT+h/HAY8H VePQ== X-Gm-Message-State: AOAM532D6TKW+845EG/PukiNqcXlNvqoH3G7wP4IjpIWZytM1zIrNxNb YObxb7UovHJF+A6wdfE7Dj9ruT7jZF0= X-Google-Smtp-Source: ABdhPJy3MNV9TOlZdH3h/VVmAJvFI2RrW+qWkuFpl4eNgSSTv4cu9YhmMJDhdwJjW3Kgpx+eYNNwYA== X-Received: by 2002:a05:6000:cb:: with SMTP id q11mr40337268wrx.13.1620758052260; Tue, 11 May 2021 11:34:12 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h9sm24580467wmb.35.2021.05.11.11.34.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:34:11 -0700 (PDT) Message-Id: <6939253be825f7c79dc5fb5fa13e420b876950d7.1620758049.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 11 May 2021 18:34:02 +0000 Subject: [PATCH v4 2/8] dir: report number of visited directories and paths with trace2 Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Eric Sunshine , Elijah Newren , Derrick Stolee , Jeff King , Philip Oakley , Jeff Hostetler , Josh Steadmon , Jeff Hostetler , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Provide more statistics in trace2 output that include the number of directories and total paths visited by the directory traversal logic. Subsequent patches will take advantage of this to ensure we do not unnecessarily traverse into ignored directories. Signed-off-by: Elijah Newren --- dir.c | 8 ++++++++ dir.h | 4 ++++ t/t7063-status-untracked-cache.sh | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dir.c b/dir.c index 122fcbffdf89..69b8c9d7f9fb 100644 --- a/dir.c +++ b/dir.c @@ -2440,6 +2440,7 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir, if (open_cached_dir(&cdir, dir, untracked, istate, &path, check_only)) goto out; + dir->visited_directories++; if (untracked) untracked->check_only = !!check_only; @@ -2448,6 +2449,7 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir, /* check how the file or directory should be treated */ state = treat_path(dir, untracked, &cdir, istate, &path, baselen, pathspec); + dir->visited_paths++; if (state > dir_state) dir_state = state; @@ -2764,6 +2766,10 @@ static void trace2_read_directory_statistics(struct dir_struct *dir, struct repository *repo, const char *path) { + trace2_data_intmax("read_directory", repo, + "directories-visited", dir->visited_directories); + trace2_data_intmax("read_directory", repo, + "paths-visited", dir->visited_paths); if (!dir->untracked) return; trace2_data_string("read_directory", repo, "path", path); @@ -2785,6 +2791,8 @@ int read_directory(struct dir_struct *dir, struct index_state *istate, struct untracked_cache_dir *untracked; trace2_region_enter("dir", "read_directory", istate->repo); + dir->visited_paths = 0; + dir->visited_directories = 0; if (has_symlink_leading_path(path, len)) { trace2_region_leave("dir", "read_directory", istate->repo); diff --git a/dir.h b/dir.h index 04d886cfce75..22c67907f689 100644 --- a/dir.h +++ b/dir.h @@ -336,6 +336,10 @@ struct dir_struct { struct oid_stat ss_info_exclude; struct oid_stat ss_excludes_file; unsigned unmanaged_exclude_files; + + /* Stats about the traversal */ + unsigned visited_paths; + unsigned visited_directories; }; /*Count the number of slashes for string s*/ diff --git a/t/t7063-status-untracked-cache.sh b/t/t7063-status-untracked-cache.sh index 9710d33b3cd6..a0c123b0a77a 100755 --- a/t/t7063-status-untracked-cache.sh +++ b/t/t7063-status-untracked-cache.sh @@ -65,7 +65,8 @@ get_relevant_traces () { INPUT_FILE=$1 OUTPUT_FILE=$2 grep data.*read_directo $INPUT_FILE | - cut -d "|" -f 9 \ + cut -d "|" -f 9 | + grep -v visited \ >"$OUTPUT_FILE" } From patchwork Tue May 11 18:34:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12251807 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,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 C002DC433B4 for ; Tue, 11 May 2021 18:34:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DD9E61919 for ; Tue, 11 May 2021 18:34:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231841AbhEKSfX (ORCPT ); Tue, 11 May 2021 14:35:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231789AbhEKSfV (ORCPT ); Tue, 11 May 2021 14:35:21 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16EBEC06175F for ; Tue, 11 May 2021 11:34:14 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id a4so21126073wrr.2 for ; Tue, 11 May 2021 11:34:13 -0700 (PDT) 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=MB7H5JuJEysZqOtYGFNJ+Q3PBPxGokFYW3/0nzpVPpQ=; b=JBSywS05/hRihNnpo65YGlBVjG5Kph9c+THSvTnHqhVf8KJwmz2pEaBkLItA0zfxJ5 h9F0nsZqUYTxk9maFsoWGgKc/iHOXQog+Hvhy2dmuNhZvMDJEOkIAivg5QClxT6i3AcW 9RwS6SSrM/G5stS3izZekkx9S7NO7NIQ53A7iXS7xD8HVzyhVR/YrQXmBfXNj7Ck3sNl C5D0UGO7TxP/pY/ReiaS4i8eL1zlZDYTWYkjCAr8p43IKgON6XnwEPSxJJC40CiNJqtk wndcsBzU16yxIJTJH3kgHPQ0vGDcDdSj7DmBcioYKnA1IPjP25NHBbqz13kYvVuQ+jfC +uaQ== 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=MB7H5JuJEysZqOtYGFNJ+Q3PBPxGokFYW3/0nzpVPpQ=; b=t7CEOBt7oD7UZkTpV8lh9w0avfibkK2L2P1yFiXq2yxGQTP3dQ34X7xG6yThGbf1uV 4Ef1GsS6lIiQzIWCQjwCQM4i+od3cZUdXV5Ww5O4Niqw2lIqyKffw4SyRkSrfyOFiFSC QNn76bHw23AmDk7X7me2j7TKmKGXLSRr2pvV4lWHZTLY8Vdl/9yfzwQm3vfAF2GwVaCS SUqzfwdr7Kc3B0lgvYV/4kwrw/PMNjrAEQgtmBy0PKCbVi0To7SYpBGbuVemUynUkoOx GvU8ANbMsv/pNlFIkb5OOzjI5lz1lIlPOMqNgel3HvVC8bUGoEkZ4afEGP+wuOxgvUzZ /Ufg== X-Gm-Message-State: AOAM533GuOQSw6HyeRTXEpjgpnaHzh9i50NtXPvVowsOA1rMtLSmRZcS VnqmvviqE+EerN0wq4GcaDIvbW30Aec= X-Google-Smtp-Source: ABdhPJw7jHGjsaCqd+zV2FS40GTyMrH7HJq/MfuOHXHm313zepLOvo57SWRwDaH1H+tWlpjF+8i0Cg== X-Received: by 2002:adf:fd0b:: with SMTP id e11mr39429776wrr.402.1620758052861; Tue, 11 May 2021 11:34:12 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a126sm4212294wmh.37.2021.05.11.11.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:34:12 -0700 (PDT) Message-Id: <8d0ca8104be628d02b30065009427062887b5e0a.1620758049.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 11 May 2021 18:34:03 +0000 Subject: [PATCH v4 3/8] ls-files: error out on -i unless -o or -c are specified Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Eric Sunshine , Elijah Newren , Derrick Stolee , Jeff King , Philip Oakley , Jeff Hostetler , Josh Steadmon , Jeff Hostetler , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren ls-files --ignored can be used together with either --others or --cached. After being perplexed for a bit and digging in to the code, I assumed that ls-files -i was just broken and not printing anything and I had a nice patch ready to submit when I finally realized that -i can be used with --cached to find tracked ignores. While that was a mistake on my part, and a careful reading of the documentation could have made this more clear, I suspect this is an error others are likely to make as well. In fact, of two uses in our testsuite, I believe one of the two did make this error. In t1306.13, there are NO tracked files, and all the excludes built up and used in that test and in previous tests thus have to be about untracked files. However, since they were looking for an empty result, the mistake went unnoticed as their erroneous command also just happened to give an empty answer. -i will most the time be used with -o, which would suggest we could just make -i imply -o in the absence of either a -o or -c, but that would be a backward incompatible break. Instead, let's just flag -i without either a -o or -c as an error, and update the two relevant testcases to specify their intent. Signed-off-by: Elijah Newren --- builtin/ls-files.c | 3 +++ t/t1306-xdg-files.sh | 2 +- t/t3003-ls-files-exclude.sh | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/builtin/ls-files.c b/builtin/ls-files.c index 60a2913a01e9..e8e25006c647 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -748,6 +748,9 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) if (pathspec.nr && error_unmatch) ps_matched = xcalloc(pathspec.nr, 1); + if ((dir.flags & DIR_SHOW_IGNORED) && !show_others && !show_cached) + die("ls-files -i must be used with either -o or -c"); + if ((dir.flags & DIR_SHOW_IGNORED) && !exc_given) die("ls-files --ignored needs some exclude pattern"); diff --git a/t/t1306-xdg-files.sh b/t/t1306-xdg-files.sh index dd87b43be1a6..40d3c42618c0 100755 --- a/t/t1306-xdg-files.sh +++ b/t/t1306-xdg-files.sh @@ -116,7 +116,7 @@ test_expect_success 'Exclusion in a non-XDG global ignore file' ' test_expect_success 'Checking XDG ignore file when HOME is unset' ' (sane_unset HOME && git config --unset core.excludesfile && - git ls-files --exclude-standard --ignored >actual) && + git ls-files --exclude-standard --ignored --others >actual) && test_must_be_empty actual ' diff --git a/t/t3003-ls-files-exclude.sh b/t/t3003-ls-files-exclude.sh index d5ec333131f9..c41c4f046abf 100755 --- a/t/t3003-ls-files-exclude.sh +++ b/t/t3003-ls-files-exclude.sh @@ -29,11 +29,11 @@ test_expect_success 'add file to gitignore' ' ' check_all_output -test_expect_success 'ls-files -i lists only tracked-but-ignored files' ' +test_expect_success 'ls-files -i -c lists only tracked-but-ignored files' ' echo content >other-file && git add other-file && echo file >expect && - git ls-files -i --exclude-standard >output && + git ls-files -i -c --exclude-standard >output && test_cmp expect output ' From patchwork Tue May 11 18:34:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12251811 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,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 A0913C43470 for ; Tue, 11 May 2021 18:34:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 554FE6191C for ; Tue, 11 May 2021 18:34:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232031AbhEKSfZ (ORCPT ); Tue, 11 May 2021 14:35:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231956AbhEKSfW (ORCPT ); Tue, 11 May 2021 14:35:22 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C924FC061761 for ; Tue, 11 May 2021 11:34:14 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id l2so21113427wrm.9 for ; Tue, 11 May 2021 11:34:14 -0700 (PDT) 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=4KsZA2I7CfIgjH08T88TsFhRmAHld7iU15QGXlFPnMM=; b=KmFgWt3nB4nOPyfMYUdFuVNfSsqd0D3J+O9VdPFZjcQJba1TbPfqDlFVH3xQxgZ6aQ TbWL8V1ijVVZ8SIPY3ATEpvfPbBYzQOM6ztCo8YQtnNIkzLOBiWOZy0azn5cCgTyWzB7 fW1/K4NsbHRhdhJPTj58qhoeoON0EX9tnkooCdljdo9TNOXZijBZdAKoTnt8Muaj9bBH CtqOAy7YzACv6k2l8QH06rUdIE982536JGRcl2Yg8g2tk77SzbQAzu4/S2d8WRKsv4K6 GdeC9ZzH7HtJAWuKL36pRRiSiZCXsTKgT84mw59ITEz8WDE1TDBeFeABUIF9nMmd262u 2A1g== 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=4KsZA2I7CfIgjH08T88TsFhRmAHld7iU15QGXlFPnMM=; b=a6D8OkypcVfMUGW2KRKrHFa/HVwqaZct4RbkU9Sov/jQsewfjmlw3L46q0vJcCThqn fV5n/EAZyzLbudi0AyXK3q8dTtZ/0Fve7Edc4vv8Myrwfgz0BakQwLo4vOYdX5dWiAcx ikhj94lOFbH5H8HyMixsO6hNj0KQx641GmtOvFHIfHDWunhW+JpsXL1XESpcJziZdks7 fURWLridgzb4d872DbwNYt9UlhYrrAxIg0MKTPDoGCREEoMiGpHV9w5IaYhL/Fd9E+a+ KHPtz9q/OEUJi/utu5CF6lu2eLQ3lBiprogiJcuF75oJTeuREj3lG6Nl2U9PIScNVbzL FcLQ== X-Gm-Message-State: AOAM530gBaq8f2P4e+Ycia8R+OwQFficN4gYmZ5tXjBXIP7sywqjzTbz j5VIR5c5kcXtKja/PVvFBtTPmDhp63E= X-Google-Smtp-Source: ABdhPJxqRXxoCkZ4cXyCJSJL1+JE/e1LgL/PvFELmUoLusW8r5y33wYuJpSPQZwG+UraoQ6SVd33nQ== X-Received: by 2002:a5d:590a:: with SMTP id v10mr39669694wrd.306.1620758053653; Tue, 11 May 2021 11:34:13 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id y15sm28169592wrh.8.2021.05.11.11.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:34:13 -0700 (PDT) Message-Id: <317abab3571e69394cf0a0dbe971440bca16964b.1620758049.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 11 May 2021 18:34:04 +0000 Subject: [PATCH v4 4/8] t7300: add testcase showing unnecessary traversal into ignored directory Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Eric Sunshine , Elijah Newren , Derrick Stolee , Jeff King , Philip Oakley , Jeff Hostetler , Josh Steadmon , Jeff Hostetler , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren The PNPM package manager is apparently creating deeply nested (but ignored) directory structures; traversing them is costly performance-wise, unnecessary, and in some cases is even throwing warnings/errors because the paths are too long to handle on various platforms. Add a testcase that checks for such unnecessary directory traversal. Signed-off-by: Elijah Newren --- t/t7300-clean.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh index a74816ca8b46..07e8ba2d4b85 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -746,4 +746,27 @@ test_expect_success 'clean untracked paths by pathspec' ' test_must_be_empty actual ' +test_expect_failure 'avoid traversing into ignored directories' ' + test_when_finished rm -f output error trace.* && + test_create_repo avoid-traversing-deep-hierarchy && + ( + cd avoid-traversing-deep-hierarchy && + + mkdir -p untracked/subdir/with/a && + >untracked/subdir/with/a/random-file.txt && + + GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \ + git clean -ffdxn -e untracked + ) && + + # Make sure we only visited into the top-level directory, and did + # not traverse into the "untracked" subdirectory since it was excluded + grep data.*read_directo.*directories-visited trace.output | + cut -d "|" -f 9 >trace.relevant && + cat >trace.expect <<-EOF && + ..directories-visited:1 + EOF + test_cmp trace.expect trace.relevant +' + test_done From patchwork Tue May 11 18:34:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12251813 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,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 1DC45C43460 for ; Tue, 11 May 2021 18:34:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9EFB61919 for ; Tue, 11 May 2021 18:34:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232029AbhEKSfY (ORCPT ); Tue, 11 May 2021 14:35:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231877AbhEKSfW (ORCPT ); Tue, 11 May 2021 14:35:22 -0400 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 8A15FC061763 for ; Tue, 11 May 2021 11:34:15 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id y124-20020a1c32820000b029010c93864955so125991wmy.5 for ; Tue, 11 May 2021 11:34:15 -0700 (PDT) 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=/W8yKM0Iad+GJsfgHty7FstnK4TOTYBb4J7fdM1ZrAQ=; b=ZUP9buW3WKRjS9+RvSMA9P0Kb3Dztlf4HGC0m5Vnf85YarZW/oe4q/sTrUe6uwLx/Z vmL4aX8v8b+l6/jKqbTMap+ZgSNFAPDkfrB7EcAZPJuJXMeY6woQUzjKRXXubXAYamSS Bg+/gNy6m9j3A6AHUiTz5x6JwgDbtcnzZzprjDcQsEig9w6o27hAJXX3c/qH+oSyQ7hM R0YyfENSEIFa6/vPxma89JrXZ1KgMijfWhRSyLzRrUGYeXo5wuzx2j0tNe2rO+3YEwqd w019TVu6AFt78t125eu1JFBLvGfu6h5L0p9QYS/7ayV/cfL+NZNnFZ+c3abH+nxf3/XI mmwg== 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=/W8yKM0Iad+GJsfgHty7FstnK4TOTYBb4J7fdM1ZrAQ=; b=p/4G2xjFD4v10tufVs28AAiigkyKDNG2D6p605js1Revr9qrH+9VGUdOzw0mbg5uwi v/r1Yrm7z9G4C36N5mjV8b7O/q973mqeMRgTW2Pu7/wCqKdQbeqHO7zEtghiNhLhapMx K5BNnc/wMI72YN1STcSUf9aUjgrHPFEEXRU++I6m2gC9+WXRTAw2Vng09sv+MYUAHuei /avtZfM4nBDG41L6VnMv4cydskjg6WxYfaBNU6xtc7Oykcefg9wZ7BAvx9/SbuN+FgOs 7W1/wEyysnJIh5MFCfSwWf19K3r3mPziR491r4yEG2dbMYTBy/Ggu5DQqVBqII0K8EqD NQEw== X-Gm-Message-State: AOAM533Lw4oi9ZhFoS0grudFYKMb7UDSqjBvnIiEpFvYgPFEkLbyrMcV kchiOwqqopEJMXebeOSQBM09AvsMTEQ= X-Google-Smtp-Source: ABdhPJzsEIdvJ+A32y9vXL3TYGwey3FF29JCZ8HzoVo2iKGuxPcC2mC2IiWtaesrqTC8eCwu+AWLvw== X-Received: by 2002:a7b:c312:: with SMTP id k18mr34443255wmj.89.1620758054287; Tue, 11 May 2021 11:34:14 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f7sm32175138wrg.34.2021.05.11.11.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:34:13 -0700 (PDT) Message-Id: <5eb019327b57e710de976301ae3ec7a022645a95.1620758049.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 11 May 2021 18:34:05 +0000 Subject: [PATCH v4 5/8] t3001, t7300: add testcase showcasing missed directory traversal Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Eric Sunshine , Elijah Newren , Derrick Stolee , Jeff King , Philip Oakley , Jeff Hostetler , Josh Steadmon , Jeff Hostetler , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren In the last commit, we added a testcase showing that the directory traversal machinery sometimes traverses into directories unnecessarily. Here we show that there are cases where it does the opposite: it does not traverse into directories, despite those directories having important files that need to be flagged. Add a testcase showing that `git ls-files -o -i --directory` can omit some of the files it should be listing, and another showing that `git clean -fX` can fail to clean out some of the expected files. Signed-off-by: Elijah Newren --- t/t3001-ls-files-others-exclude.sh | 5 +++++ t/t7300-clean.sh | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index 1ec7cb57c7a8..ac05d1a17931 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -292,6 +292,11 @@ EOF test_cmp expect actual ' +test_expect_failure 'ls-files with "**" patterns and --directory' ' + # Expectation same as previous test + git ls-files --directory -o -i --exclude "**/a.1" >actual && + test_cmp expect actual +' test_expect_success 'ls-files with "**" patterns and no slashes' ' git ls-files -o -i --exclude "one**a.1" >actual && diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh index 07e8ba2d4b85..34c08c325407 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -769,4 +769,23 @@ test_expect_failure 'avoid traversing into ignored directories' ' test_cmp trace.expect trace.relevant ' +test_expect_failure 'traverse into directories that may have ignored entries' ' + test_when_finished rm -f output && + test_create_repo need-to-traverse-into-hierarchy && + ( + cd need-to-traverse-into-hierarchy && + mkdir -p modules/foobar/src/generated && + > modules/foobar/src/generated/code.c && + > modules/foobar/Makefile && + echo "/modules/**/src/generated/" >.gitignore && + + git clean -fX modules/foobar >../output && + + grep Removing ../output && + + test_path_is_missing modules/foobar/src/generated/code.c && + test_path_is_file modules/foobar/Makefile + ) +' + test_done From patchwork Tue May 11 18:34:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12251817 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,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 A4B52C433B4 for ; Tue, 11 May 2021 18:34:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 751A46190A for ; Tue, 11 May 2021 18:34:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232037AbhEKSf1 (ORCPT ); Tue, 11 May 2021 14:35:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232010AbhEKSfY (ORCPT ); Tue, 11 May 2021 14:35:24 -0400 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 5D528C061574 for ; Tue, 11 May 2021 11:34:16 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id b19-20020a05600c06d3b029014258a636e8so1764628wmn.2 for ; Tue, 11 May 2021 11:34:16 -0700 (PDT) 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=kYoPmQnGkGlNvf0JIRvpu+yrQPRAvCwnx1xTTLmq7wI=; b=fCqH99WpMyF6Au0oIkynWQckl4TdWDEaEthic+dvAawuq0VPAT53pXQvYE4RXHWGry vHf+lmP+FDDYyDSb9Ny2BTjTtHRjwNLHmCBCRrmtGAcrKSbCg+SB8fb9KYPQThd2LyCO hvNozXDFL0xbyyiBVS+8QRSqNk2Xuww6n4VdXRDeeZLmFYrjjXYyAPI7uEKTlWq/+Pa2 dYfUTRFBMK6P1p6fpPtsJnhC62xhmnDQMQp/Zb0hGLZHeocYnE8tyUVQlMVvjJTwimww +rOfr7+GIAd2EcfOP1U3dvULmChu51z08ZZlk4Xv3WkXOveiZ5biOJ5gxoL0YRRLF+9C u/Cg== 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=kYoPmQnGkGlNvf0JIRvpu+yrQPRAvCwnx1xTTLmq7wI=; b=nCbUMA0nwGOsf+3lZLD12GcJfjEjVJMOZSnx/40Sz8/Hyq15fFAyY0Loz2WQvNUosa 9hIGO0QjhdppVsr/9+lPo4YgIeCBqMpogUBxUytgHxnNVazp3PWobEOG+e2XFD1MXrJ3 Ci+27HO7i0ZPdvGwwpYluytjjT8d3RC/DppuINVPNMuQiTIXGXsZWLjngphHG8nyGfOX YKq4CvjejV2hY51KHiEhnryHBcbU5yzy+i3DU2o+7HNujaMzQ+/57v9gao5CWk25/Zb2 fexoCugCjExslF7dop+n5Ly16GLg0gnQiWubvBxjf/+479tybnT8u+9QDYGz363ePGZ4 GfEA== X-Gm-Message-State: AOAM5330YuP68WbeH5/JDeXO13EGTj4foIEJaebGSToNwA7/bwBAaDs2 pcV7E/U4kaWWsyA1qv4E6qSXmRgK3wA= X-Google-Smtp-Source: ABdhPJyktqKqzkwPLUX4R93GTIbiwc8+AGpKLaBadJJXjXEciRTbrgcoL8Ps2EkhDkohBOioI6C15A== X-Received: by 2002:a1c:7209:: with SMTP id n9mr34297008wmc.60.1620758055074; Tue, 11 May 2021 11:34:15 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c5sm23967081wml.2.2021.05.11.11.34.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:34:14 -0700 (PDT) Message-Id: <89cc01ef8598b5faa529a4aea7e1e296465ef8e3.1620758049.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 11 May 2021 18:34:06 +0000 Subject: [PATCH v4 6/8] dir: avoid unnecessary traversal into ignored directory Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Eric Sunshine , Elijah Newren , Derrick Stolee , Jeff King , Philip Oakley , Jeff Hostetler , Josh Steadmon , Jeff Hostetler , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren The show_other_directories case in treat_directory() tried to handle both excludes and untracked files with the same logic, and mishandled both the excludes and the untracked files in the process, in different ways. Split that logic apart, and then focus on the logic for the excludes; a subsequent commit will address the logic for untracked files. For show_other_directories, an excluded directory means that every path underneath that directory will also be excluded. Given that the calling code requested to just show directories when everything under a directory had the same state (that's what the "DIR_SHOW_OTHER_DIRECTORIES" flag means), we generally do not need to traverse into such directories and can just immediately mark them as ignored (i.e. as path_excluded). The only reason we cannot just immediately return path_excluded is the DIR_HIDE_EMPTY_DIRECTORIES flag and the possibility that the ignored directory is an empty directory. The code previously treated DIR_SHOW_IGNORED_TOO in most cases as an exception as well, which was wrong. It can sometimes reduce the number of cases where we need to recurse (namely if DIR_SHOW_IGNORED_TOO_MODE_MATCHING is also set), but should not be able to increase the number of cases where we need to recurse. Fix the logic accordingly. Some sidenotes about possible confusion with dir.c: * "ignored" often refers to an untracked ignore", i.e. a file which is not tracked which matches one of the ignore/exclusion rules. But you can also have a "tracked ignore", a tracked file that happens to match one of the ignore/exclusion rules and which dir.c has to worry about since "git ls-files -c -i" is supposed to list them. * The dir code often uses "ignored" and "excluded" interchangeably, which you need to keep in mind while reading the code. * "exclude" is used multiple ways in the code: * As noted above, "exclude" is often a synonym for "ignored". * The logic for parsing .gitignore files was re-used in .git/info/sparse-checkout, except there it is used to mark paths that the user wants to *keep*. This was mostly addressed by commit 65edd96aec ("treewide: rename 'exclude' methods to 'pattern'", 2019-09-03), but every once in a while you'll find a comment about "exclude" referring to these patterns that might in fact be in use by the sparse-checkout machinery for inclusion rules. * The word "EXCLUDE" is also used for pathspec negation, as in (pathspec->items[3].magic & PATHSPEC_EXCLUDE) Thus if a user had a .gitignore file containing *~ *.log !settings.log And then ran git add -- 'settings.*' ':^settings.log' Then :^settings.log is a pathspec negation making settings.log not be requested to be added even though all other settings.* files are being added. Also, !settings.log in the gitignore file is a negative exclude pattern meaning that settings.log is normally a file we want to track even though all other *.log files are ignored. Sometimes it feels like dir.c needs its own glossary with its many definitions, including the multiply-defined terms. Reported-by: Jason Gore Signed-off-by: Elijah Newren --- dir.c | 44 +++++++++++++++++++++++++++++--------------- t/t7300-clean.sh | 2 +- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/dir.c b/dir.c index 69b8c9d7f9fb..0126e2f08af7 100644 --- a/dir.c +++ b/dir.c @@ -1844,6 +1844,7 @@ static enum path_treatment treat_directory(struct dir_struct *dir, } /* This is the "show_other_directories" case */ + assert(dir->flags & DIR_SHOW_OTHER_DIRECTORIES); /* * If we have a pathspec which could match something _below_ this @@ -1854,27 +1855,40 @@ static enum path_treatment treat_directory(struct dir_struct *dir, if (matches_how == MATCHED_RECURSIVELY_LEADING_PATHSPEC) return path_recurse; + /* Special cases for where this directory is excluded/ignored */ + if (excluded) { + /* + * In the show_other_directories case, if we're not + * hiding empty directories, there is no need to + * recurse into an ignored directory. + */ + if (!(dir->flags & DIR_HIDE_EMPTY_DIRECTORIES)) + return path_excluded; + + /* + * Even if we are hiding empty directories, we can still avoid + * recursing into ignored directories for DIR_SHOW_IGNORED_TOO + * if DIR_SHOW_IGNORED_TOO_MODE_MATCHING is also set. + */ + if ((dir->flags & DIR_SHOW_IGNORED_TOO) && + (dir->flags & DIR_SHOW_IGNORED_TOO_MODE_MATCHING)) + return path_excluded; + } + /* - * Other than the path_recurse case immediately above, we only need - * to recurse into untracked/ignored directories if either of the - * following bits is set: + * Other than the path_recurse case above, we only need to + * recurse into untracked directories if either of the following + * bits is set: * - DIR_SHOW_IGNORED_TOO (because then we need to determine if * there are ignored entries below) * - DIR_HIDE_EMPTY_DIRECTORIES (because we have to determine if * the directory is empty) */ - if (!(dir->flags & (DIR_SHOW_IGNORED_TOO | DIR_HIDE_EMPTY_DIRECTORIES))) - return excluded ? path_excluded : path_untracked; - - /* - * ...and even if DIR_SHOW_IGNORED_TOO is set, we can still avoid - * recursing into ignored directories if the path is excluded and - * DIR_SHOW_IGNORED_TOO_MODE_MATCHING is also set. - */ - if (excluded && - (dir->flags & DIR_SHOW_IGNORED_TOO) && - (dir->flags & DIR_SHOW_IGNORED_TOO_MODE_MATCHING)) - return path_excluded; + if (!excluded && + !(dir->flags & (DIR_SHOW_IGNORED_TOO | + DIR_HIDE_EMPTY_DIRECTORIES))) { + return path_untracked; + } /* * Even if we don't want to know all the paths under an untracked or diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh index 34c08c325407..21e48b3ba591 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -746,7 +746,7 @@ test_expect_success 'clean untracked paths by pathspec' ' test_must_be_empty actual ' -test_expect_failure 'avoid traversing into ignored directories' ' +test_expect_success 'avoid traversing into ignored directories' ' test_when_finished rm -f output error trace.* && test_create_repo avoid-traversing-deep-hierarchy && ( From patchwork Tue May 11 18:34:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12251815 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,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 1451AC433ED for ; Tue, 11 May 2021 18:34:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD1DB6190A for ; Tue, 11 May 2021 18:34:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232040AbhEKSf0 (ORCPT ); Tue, 11 May 2021 14:35:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232003AbhEKSfX (ORCPT ); Tue, 11 May 2021 14:35:23 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 168CBC06174A for ; Tue, 11 May 2021 11:34:17 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id o26-20020a1c4d1a0000b0290146e1feccdaso118244wmh.0 for ; Tue, 11 May 2021 11:34:17 -0700 (PDT) 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=JYOIWhcU1wWE09XHgXzMLhLiGJ0m9k3vSdMWS9bT/FQ=; b=gHIwZIiorzYLKqTVVOuPU8z7x58fs86myfIsBRiW/PHUc5uuwK7YdAqcf0Lz0v2H7l 3lmgO1GyMVXXhrey3557XeWUTEDgknQO8ESaTSjABXVzHP4kyrk+ZGevnBiFmIpttO2j D1tV84gS/+BgbV2+72/mJ6rrSv2hewMvBj0V85L/sDp5NbOs2tFu0+ih77OTNd+8iXjh 7c9XQ5mx6ohKq7wzM+/487I6SmBs7Zo3W+J17n+zZBNIuJH5+G53XNp7xbGTeylBySNd 69MvIQTPZYH4bwLjce5qsj7WFwLJlVmxOBgP8PMlgmDF5dt1AHf4QvxCaZC4IUywOlU2 hckg== 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=JYOIWhcU1wWE09XHgXzMLhLiGJ0m9k3vSdMWS9bT/FQ=; b=pLbD4P9bIK+RX4V2gLMSG7EphiHnVrUBs9SW9KPa3KPgowqzjZfJF7HbFPy9Nvn/k3 nsBfvzaxnCRuVFePjBEpEinVGOoJr2ZNNcm3OOzbkeZHfMfSVDbkYb+2KbKAc5x1gztQ KsThUy6jR1oJ1X8Q2DZ5z5lWfjkOntu9DPBivhyn+95UBKega5mDZkb04nONNfkz60MA EiTxEswfqOnTfpfgrIRC2rYEdiHOBvyNPT8rNy6c+vOxfPi6iaolsSQC/Kn8rRXSCF91 K3gouKQ63h5fxTVOEujI2aXwOlNT7c4By5pIYwmP6dlVsb8dq14aLKC2w5nh36qFUpvI w5HA== X-Gm-Message-State: AOAM531EinkPy7WGiEi6nZldNzEfAx59bEemJiEcEbiHP77GcbOxTtzS 0a3QcSX/h2FV32t4rXXBIxgxcBGvf9s= X-Google-Smtp-Source: ABdhPJy0CQKsZ4N+efDB3yg1Mhm9HNdm7Dbp7/yRg3NrsfCiV7LmZB71v2yFNKPnAyMO8jl+C/T7Pw== X-Received: by 2002:a05:600c:4fd6:: with SMTP id o22mr12290196wmq.83.1620758055916; Tue, 11 May 2021 11:34:15 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k10sm5462686wmf.0.2021.05.11.11.34.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:34:15 -0700 (PDT) Message-Id: <4a561e1229e46124030856530258d6a89ce5e938.1620758049.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 11 May 2021 18:34:07 +0000 Subject: [PATCH v4 7/8] dir: traverse into untracked directories if they may have ignored subfiles Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Eric Sunshine , Elijah Newren , Derrick Stolee , Jeff King , Philip Oakley , Jeff Hostetler , Josh Steadmon , Jeff Hostetler , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren A directory that is untracked does not imply that all files under it should be categorized as untracked; in particular, if the caller is interested in ignored files, many files or directories underneath the untracked directory may be ignored. We previously partially handled this right with DIR_SHOW_IGNORED_TOO, but missed DIR_SHOW_IGNORED. It was not obvious, though, because the logic for untracked and excluded files had been fused together making it harder to reason about. The previous commit split that logic out, making it easier to notice that DIR_SHOW_IGNORED was missing. Add it. Signed-off-by: Elijah Newren --- dir.c | 10 ++++++---- t/t3001-ls-files-others-exclude.sh | 2 +- t/t7300-clean.sh | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/dir.c b/dir.c index 0126e2f08af7..deeff1a58319 100644 --- a/dir.c +++ b/dir.c @@ -1877,15 +1877,17 @@ static enum path_treatment treat_directory(struct dir_struct *dir, /* * Other than the path_recurse case above, we only need to - * recurse into untracked directories if either of the following + * recurse into untracked directories if any of the following * bits is set: - * - DIR_SHOW_IGNORED_TOO (because then we need to determine if - * there are ignored entries below) + * - DIR_SHOW_IGNORED (because then we need to determine if + * there are ignored entries below) + * - DIR_SHOW_IGNORED_TOO (same as above) * - DIR_HIDE_EMPTY_DIRECTORIES (because we have to determine if * the directory is empty) */ if (!excluded && - !(dir->flags & (DIR_SHOW_IGNORED_TOO | + !(dir->flags & (DIR_SHOW_IGNORED | + DIR_SHOW_IGNORED_TOO | DIR_HIDE_EMPTY_DIRECTORIES))) { return path_untracked; } diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index ac05d1a17931..516c95ea0e82 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -292,7 +292,7 @@ EOF test_cmp expect actual ' -test_expect_failure 'ls-files with "**" patterns and --directory' ' +test_expect_success 'ls-files with "**" patterns and --directory' ' # Expectation same as previous test git ls-files --directory -o -i --exclude "**/a.1" >actual && test_cmp expect actual diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh index 21e48b3ba591..0399701e6276 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -769,7 +769,7 @@ test_expect_success 'avoid traversing into ignored directories' ' test_cmp trace.expect trace.relevant ' -test_expect_failure 'traverse into directories that may have ignored entries' ' +test_expect_success 'traverse into directories that may have ignored entries' ' test_when_finished rm -f output && test_create_repo need-to-traverse-into-hierarchy && ( From patchwork Tue May 11 18:34:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12251819 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 7C6C0C43460 for ; Tue, 11 May 2021 18:34:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44B936191D for ; Tue, 11 May 2021 18:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232041AbhEKSf2 (ORCPT ); Tue, 11 May 2021 14:35:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231956AbhEKSfZ (ORCPT ); Tue, 11 May 2021 14:35:25 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBCCCC06175F for ; Tue, 11 May 2021 11:34:17 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id q5so1655690wrs.4 for ; Tue, 11 May 2021 11:34:17 -0700 (PDT) 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=IE8SjTUl16Ijhet7Y6rmh5P+LTw/2tHjkI++3IHg7vg=; b=PrPgx68ozNOmOblHWW2w0zhCDw+N8N0eAQMoF61glB4OxPuf0RlvSOMxRjWipbJTmV LUC6CKlfDlzPdluHoMwtV3xge620BJT1BwC4MdXGskumxNaJySaghsF0ech01kCTRcYU N1jGo5ANRGgBpPXon8s0ZemcMq9Si733nQ0FvIhHg46GNViaSv4MVqNwEE3EXvhHSq6R AMUOmelm5cmKuCcQop+4mP9zI1/+4Q5CDSy78YFyEHuFQ4yud0W/nz/bI1i1en5BmMGv /ccVWvOxBtIqC0rJHqR5Ejk/jIUhLvSAEa+p6AkUD3D18R4UJ5nm28LvUt8uAh4bhfoK vObQ== 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=IE8SjTUl16Ijhet7Y6rmh5P+LTw/2tHjkI++3IHg7vg=; b=cNk9K/3D0WrrJwW+8RXRLwnZMf+gaXwXxNlANyQEE5EZFHbo+LbcTynq3QddGGsquz z0E0iDg+WqZrnCBbP/JF8mi3eqkTWcX0JDVjpytBU/avUlUPkOM+1y3bz3jlcuG+oKsV eaJQNSk0bMuDt3A6hbOQtABGMgwt8Fjn9/HAv8MJRu8MavmVrQp0Rg7+XtnADrYyUg5p cIMUN9cU4hWs8VU67gERhjluflkRiyhSn0XsDkD9dZn7ctQCbdon1n+EYBg2U1onmP2/ PNw6zVq7QWhSz8Zubv0bmi/noKnVcSUEe+cUj7JF2JyHt8WutdDIOoeUIl1141wG7pCV TnzQ== X-Gm-Message-State: AOAM532HiKIbtTbFUUeXD/dxeMzmotwFXHRoQa55+GA2vcmmRrGNAkLv SqsvzJGZOwYcuzc7qIJzHX1Cii05JMw= X-Google-Smtp-Source: ABdhPJzb6eEcaVvFHb4pWh3X39ARDYRjwiP0hECgSL0KrqUvONT1pOrk0UM1In001GpSTfyVeWxobQ== X-Received: by 2002:a05:6000:1290:: with SMTP id f16mr39505107wrx.52.1620758056632; Tue, 11 May 2021 11:34:16 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id b8sm29420049wrx.15.2021.05.11.11.34.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:34:16 -0700 (PDT) Message-Id: <2945e749f5e398ead58a1e97c653145c2cf7cca5.1620758049.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 11 May 2021 18:34:08 +0000 Subject: [PATCH v4 8/8] dir: update stale description of treat_directory() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Eric Sunshine , Elijah Newren , Derrick Stolee , Jeff King , Philip Oakley , Jeff Hostetler , Josh Steadmon , Jeff Hostetler , Elijah Newren , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee The documentation comment for treat_directory() was originally written in 095952 (Teach directory traversal about subprojects, 2007-04-11) which was before the 'struct dir_struct' split its bitfield of named options into a 'flags' enum in 7c4c97c0 (Turn the flags in struct dir_struct into a single variable, 2009-02-16). When those flags changed, the comment became stale, since members like 'show_other_directories' transitioned into flags like DIR_SHOW_OTHER_DIRECTORIES. Update the comments for treat_directory() to use these flag names rather than the old member names. Signed-off-by: Derrick Stolee Reviewed-by: Elijah Newren --- dir.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/dir.c b/dir.c index deeff1a58319..993a12145f9d 100644 --- a/dir.c +++ b/dir.c @@ -1749,13 +1749,13 @@ static enum exist_status directory_exists_in_index(struct index_state *istate, * Case 3: if we didn't have it in the index previously, we * have a few sub-cases: * - * (a) if "show_other_directories" is true, we show it as - * just a directory, unless "hide_empty_directories" is + * (a) if DIR_SHOW_OTHER_DIRECTORIES flag is set, we show it as + * just a directory, unless DIR_HIDE_EMPTY_DIRECTORIES is * also true, in which case we need to check if it contains any * untracked and / or ignored files. - * (b) if it looks like a git directory, and we don't have - * 'no_gitlinks' set we treat it as a gitlink, and show it - * as a directory. + * (b) if it looks like a git directory and we don't have the + * DIR_NO_GITLINKS flag, then we treat it as a gitlink, and + * show it as a directory. * (c) otherwise, we recurse into it. */ static enum path_treatment treat_directory(struct dir_struct *dir, @@ -1843,7 +1843,6 @@ static enum path_treatment treat_directory(struct dir_struct *dir, return path_recurse; } - /* This is the "show_other_directories" case */ assert(dir->flags & DIR_SHOW_OTHER_DIRECTORIES); /* @@ -1858,7 +1857,7 @@ static enum path_treatment treat_directory(struct dir_struct *dir, /* Special cases for where this directory is excluded/ignored */ if (excluded) { /* - * In the show_other_directories case, if we're not + * If DIR_SHOW_OTHER_DIRECTORIES is set and we're not * hiding empty directories, there is no need to * recurse into an ignored directory. */