From patchwork Sat May 8 19:58:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12246217 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 1AE8EC433B4 for ; Sat, 8 May 2021 19:59:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E88FF6128C for ; Sat, 8 May 2021 19:59:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229662AbhEHUAO (ORCPT ); Sat, 8 May 2021 16:00:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbhEHUAN (ORCPT ); Sat, 8 May 2021 16:00:13 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1CC9C061574 for ; Sat, 8 May 2021 12:59:09 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id l18-20020a1ced120000b029014c1adff1edso8929983wmh.4 for ; Sat, 08 May 2021 12:59:09 -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=6RnEBmLtP707mDl8t3fYDFJNKtd8kt+D8i5clmpf6ZU=; b=uPFcfMDCM68deSUIWrcSgotJvC9gjHcQUGjGj0ipKAl+aMARGFj0SoQE+SsRLQP0bX Ilt8pAOvcmDZ4OIwkGzdZESkF+43l0aioTDdMN1BfEDwG/ykdH3VIU6kv6g8Qc+xFyZm 3spbKcYkYv6HsfelsbecP56OIVVPj987VTe2zZOXP68TZtwTKfTFNRULnCf+uNxpKdIO zi/SxMIwhLXyp0zv5wTi/z7o1lP8yir0hhtg1IA0HNwc9+AYfyGR/u7v6pb1GmdUTrNH uRT3gDQeS4YLbcFByHuBs7SJRUAoCEr5ZlChvyqiv80lqnSQnViI8NwEXzn5dJzjHAAw oVBQ== 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=6RnEBmLtP707mDl8t3fYDFJNKtd8kt+D8i5clmpf6ZU=; b=jh5TjmzeXL1aF4ZkJ1BR2ym82yt0nA3CHwe1B4mimGiY5u9wM8cynsI6QHtGEj9V9r 7v/nH8E+o/L40wEnz9hJpfHJ1HZ2NsBSOXcpca01fWzXrWufkc1gWLQghGRpqEwtLC1A HHQicJ9mUKy8DgWyS8tR8sEIo9VYtIdKiEBR6h2PC+4FxBRFFWN+4l5L/RgGvU5ChQ9p YsW1fQ76qFFJ7WdCSaa62KFyiIzT4pZh0/qeoEXw1dDxDGDkIFbFc5uMy1y322sp3S8N 4aJC5KC7PR3ithTuAQ1wpoBDoxmNfwzDWE4ZRhlRaMz/wjIgYFuSlvRtuRqDPqZoa1a4 +yrQ== X-Gm-Message-State: AOAM533D7Eo5Bk7StdsXS4BS4PcuB4PBiCwJlp+64lgYwZJkqR20Dumy /DCeycRH/7Sk92hxhLHVNGqvntZYlnY= X-Google-Smtp-Source: ABdhPJyLyfVFcdDrowN3q6sIbDFa/G56EjVUxmJN4QQoMv0BeKzDvh6B8pOB4mfrrIw80K+rr4gEAA== X-Received: by 2002:a05:600c:22c9:: with SMTP id 9mr17702205wmg.85.1620503948618; Sat, 08 May 2021 12:59:08 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o17sm14472853wrs.48.2021.05.08.12.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 May 2021 12:59:08 -0700 (PDT) Message-Id: <9f1c0d78d739cc1da8517eea92e81a7bd162578f.1620503945.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sat, 08 May 2021 19:58:57 +0000 Subject: [PATCH v3 1/8] [RFC] 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 , 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 | 34 ++++-- t/t7063-status-untracked-cache.sh | 193 +++++++++++++++++------------- t/t7519-status-fsmonitor.sh | 8 +- 3 files changed, 135 insertions(+), 100 deletions(-) diff --git a/dir.c b/dir.c index 3474e67e8f3c..9f7c8debeab3 100644 --- a/dir.c +++ b/dir.c @@ -2760,12 +2760,29 @@ 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) +{ + if (!dir->untracked) + return; + 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); @@ -2784,23 +2801,13 @@ 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); + 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 +2818,9 @@ int read_directory(struct dir_struct *dir, struct index_state *istate, FREE_AND_NULL(dir->untracked); } } + + if (trace2_is_enabled()) + trace2_read_directory_statistics(dir, istate->repo); return dir->nr; } diff --git a/t/t7063-status-untracked-cache.sh b/t/t7063-status-untracked-cache.sh index accefde72fb1..6bce65b439e3 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,20 @@ 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 Sat May 8 19:58:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12246219 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 AC9CCC433ED for ; Sat, 8 May 2021 19:59:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8776C613CE for ; Sat, 8 May 2021 19:59:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229685AbhEHUAP (ORCPT ); Sat, 8 May 2021 16:00:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229619AbhEHUAN (ORCPT ); Sat, 8 May 2021 16:00:13 -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 7ED8DC06175F for ; Sat, 8 May 2021 12:59:10 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id o6-20020a05600c4fc6b029015ec06d5269so278383wmq.0 for ; Sat, 08 May 2021 12:59:10 -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=jfg7DtvxwaYxLLEO3mU5FjVoM0D5rAkthKhgOWMvmfs=; b=TSAFUkYD0pSw6I5D5sxkfUgGxOopYhwHsb7uKN2r+1wMJgafby/CaqMmsPmDQxU6XM AmJyGeT9gF44VQqDJmoMWrphlas5nDFlYNGMc2fjmTAQTOB0CxTWq0K6+MEnrlhlweaS dWQEDs9FvioHTT5PvyX9fXV9gqt/FGnHPYM0x4yvG7A4JnSWte7hadYMMNPfjnTRaeLM 6pq3CVO6RqjTsdnW0UXiOkukL+ww7Ay2cOZXMJVB0v3bu//GBogAn2/14GIZc0Kxl4bP T9FzgejsaUe5scir0Md/wwHeYhHoxpCMMamOtHzkcDpmcQPQPHsivVK0sDzGWsXO2Z4j mS4w== 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=jfg7DtvxwaYxLLEO3mU5FjVoM0D5rAkthKhgOWMvmfs=; b=CPHo52KfxaE6zvbP5f9fVo5QXsIH8HbtLS1pXtuvNgOqItINKCzCSzCKwCOytTgimV fnb+fjwA5Cw07FwxnS8m0Lz7zSDWRV+03yv9SIcKe6KM9qg9wHYos79LjBA/8SgkGgoG 1+2gEDUFJdelph4xr7M2yp6Rqk279K7XhglFSASQkxjkxMapeauT1xUebsaIaq+SbQ5g 3usVEbs7DrSRjQ1yjBuxlHvdCbbK7vk8SxaB/LTRZI/9Qs6a/6fEXuMqQ4mF9HUX5YP0 9sC87Dis9NWXK0eI5/XidfEYWGF77uQgLKhK3TMH3obsBSoJ+DFNxuURBnsvKb5A+EBi Lpmw== X-Gm-Message-State: AOAM533idrQvaysag973m64VvgyhWjpPmGScQUFLgNlSynN79+wNeRDD nf6HTruVE8DHuZSs5Pugnhb/OGEnz5I= X-Google-Smtp-Source: ABdhPJwFT8Y3Iko0Ui2k3TcMQ6Q9uoqvht1g4WS8Zbs5WdqKFEifUWFY7DSN8dEwA25Lwjx20XS1Mg== X-Received: by 2002:a7b:c1c5:: with SMTP id a5mr28227658wmj.63.1620503949265; Sat, 08 May 2021 12:59:09 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id w25sm12179032wmk.39.2021.05.08.12.59.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 May 2021 12:59:08 -0700 (PDT) Message-Id: <8b511f228af8e047d8b38159da658b10174c40e8.1620503945.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sat, 08 May 2021 19:58:58 +0000 Subject: [PATCH v3 2/8] [RFC] 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 , 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 | 1 + 3 files changed, 13 insertions(+) diff --git a/dir.c b/dir.c index 9f7c8debeab3..dfb174227b36 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; @@ -2763,6 +2765,10 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d static void trace2_read_directory_statistics(struct dir_struct *dir, struct repository *repo) { + 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_intmax("read_directory", repo, @@ -2783,6 +2789,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)) { trace_performance_leave("read directory %.*s", len, path); 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 6bce65b439e3..1517c316892f 100755 --- a/t/t7063-status-untracked-cache.sh +++ b/t/t7063-status-untracked-cache.sh @@ -65,6 +65,7 @@ get_relevant_traces() { INPUT_FILE=$1 OUTPUT_FILE=$2 grep data.*read_directo $INPUT_FILE \ + | grep -v visited \ | cut -d "|" -f 9 \ >$OUTPUT_FILE } From patchwork Sat May 8 19:58:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12246221 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 6DA6AC43461 for ; Sat, 8 May 2021 19:59:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4CC3F613CE for ; Sat, 8 May 2021 19:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229698AbhEHUAQ (ORCPT ); Sat, 8 May 2021 16:00:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229667AbhEHUAO (ORCPT ); Sat, 8 May 2021 16:00:14 -0400 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 1C973C061760 for ; Sat, 8 May 2021 12:59:11 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id v12so12546352wrq.6 for ; Sat, 08 May 2021 12:59:11 -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=0e4RrCJuKuAV6s9KmC98iAx1qWZSkyg2U2VQQvqOO0E=; b=fvpoERXfhPE+XbH3H2SbhwBW1ExMCIPqS9MLV5ZuvWPiQt3NUJ+6sRXEocAOiI/ihe MLf/eAKFzDMbbpkEq4C0oRNRbOK9uhhrmTlsHmOD8/h5B4kjMTzGZHyNTGpVwzC/4NeL riuuCvpx4QDIstsYrzIDIjAoLTaLmQHhlb2W1i1632oTkp1srrmfolBA0nD9HIGdPEFI mmxoi+amO2JIFYpsy/b6ltm9m/c81BW7u3Aj+uE3bmi68Q6tluYYX0CT2lz/NB05KQc1 xATlUPLvWO/wVngTiZEHhvRlp2ZYSry8rHa6I3mzcfPv6+Nvq39YiVtHhdB1XV7T1So+ 43ig== 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=0e4RrCJuKuAV6s9KmC98iAx1qWZSkyg2U2VQQvqOO0E=; b=muizO9FqVcuPHA1K/b4pJBkTGh7gd/Af/vygUwEQ26XI9T/pb1mAKmSC38HQxtC92h iDdsnx6dRfLGyYFm6qfciwrpnqCz9lXtmPygXm7rEMov95zDh6flQBHxNCM553moTH8E bKDQJcYwiQbHw0qb1GSjxOScqCBRj87iyLHcCaauGVPhZUIkgOzcTT0lwKJibgqBUYfH wjnefcn6/FZUTTPOsQMcessC+3pzgnyj/vLvnqOU7+vU8kpHMV81bMGYFrkCExMnnWVu A9JdG54eGEx28rY52VeGfeUO+SBWip9nmDmA4hEgKQfRQc+efZfJyJXwcvcs0Vn67f0+ iI2Q== X-Gm-Message-State: AOAM533CmrnhEU6+OLdlcwDZ3lp3zgDShtL8vsakLfLQwdAO+dc1QYXN L4fdKKieAdkq/pqgTAMDpLooHpARr6s= X-Google-Smtp-Source: ABdhPJzm/H6x6kV42K4od/w0Tg3kATLHqedX94q5Cwnv1pYum2fAOtz9Y3bjpczY6+kxub1J13S9DQ== X-Received: by 2002:adf:f991:: with SMTP id f17mr20308029wrr.160.1620503949877; Sat, 08 May 2021 12:59:09 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f6sm16409352wru.72.2021.05.08.12.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 May 2021 12:59:09 -0700 (PDT) Message-Id: <44a1322c44026e675ea254a00f3b50d4955ac56e.1620503945.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sat, 08 May 2021 19:58:59 +0000 Subject: [PATCH v3 3/8] [RFC] 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 , 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 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..9f74b1ab2e69 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 --ignored is usually used with --others, but --cached is the default. Please specify which you want."); + 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 Sat May 8 19:59:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12246223 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 76276C433B4 for ; Sat, 8 May 2021 19:59:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5897F613CE for ; Sat, 8 May 2021 19:59:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229709AbhEHUAR (ORCPT ); Sat, 8 May 2021 16:00:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229673AbhEHUAO (ORCPT ); Sat, 8 May 2021 16:00:14 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADE37C061761 for ; Sat, 8 May 2021 12:59:11 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id n205so7014867wmf.1 for ; Sat, 08 May 2021 12:59:11 -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=0IcNdyy+P1E9kfy1TvyMMUfCIsm+EFtiBPGU4jbxVqE=; b=DSwhZQnr/Y/SvMyi0QtAo7YXb8TMWM6L68Nzkhg0pPYf4ZM2HjaKrENBx6LWnSdxUB jXw4NoUTjSlDbwIy11tIRIA7mS44C0J9zfStr3Wzu9wlbPF4bDeogM1Ab0ctHa5/+PZd 9G3AqlfOAS+yoIzIpBuQJJ699gR09Ak25vZMcetXJHWA3lvFzXQMWVARMV7Fnogjt41/ V38Mro7V6crNvGWSCkzHvMg2/mwxKbBdicLqSTdw7dlop4eLD8Zx4tJcGbRT0M+0GqO/ mZiZpE5fnrCcqw7QoEOzbn+TVzBMoDcrSccyE8GqZnnKORYljkm0qKiK+hNp4wmHbXx/ 69yQ== 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=0IcNdyy+P1E9kfy1TvyMMUfCIsm+EFtiBPGU4jbxVqE=; b=f+734AJQ2PD6pfCAlswG7IY89vIdEywmWk2Ie3P1MQu5RYfBDmOzeud5faQofMA4tc daPIy++2TKw9Hbz5pjQLYgzJp7qzc71ZcrbycY+gm0zWsv3O+MqDJeG0CG4KB7yV8qTs LK0F2NbQ4yg/hNX+h0IdeQCEil8/+QEDCBmENxcU25Idcf73jfM+jWVHDbRJHzpMgUSG keoAORASI3ctFN8ARsq2nriXLTr0ZfNwu1BXp5fvf9nX9on80H0dIUmPmwlLE2NfmDj9 GeZbeJ6VfvIAHTkxSRIiSc1cBijrXphEg/y4szRnaBGIMiZcCaeN1wsaVmxJPaDt8PhM uX3g== X-Gm-Message-State: AOAM532LYcC+ovtq0fx7b0Zd9M+cU89mOV+40yIGgxT9Zfjls106kuat z4fvM8lE3Gmsg1eEE/VqOb499z+5YO4= X-Google-Smtp-Source: ABdhPJxAJ6DvfuRZzpxwQ30P+40q/sNnWS6Yl6iwOqe97CPFh/NLjesbuScBv090tj8Dabzc4snNzQ== X-Received: by 2002:a1c:6a04:: with SMTP id f4mr16859848wmc.131.1620503950458; Sat, 08 May 2021 12:59:10 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id y21sm19246904wmc.46.2021.05.08.12.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 May 2021 12:59:10 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Sat, 08 May 2021 19:59:00 +0000 Subject: [PATCH v3 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 , 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 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh index a74816ca8b46..b7c9898fac5b 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -746,4 +746,26 @@ 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 + ) && + + grep data.*read_directo.*visited trace.output \ + | cut -d "|" -f 9 >trace.relevant && + cat >trace.expect <<-EOF && + directories-visited:1 + paths-visited:4 + EOF + test_cmp trace.expect trace.relevant +' + test_done From patchwork Sat May 8 19:59: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: 12246225 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 7ABFBC433ED for ; Sat, 8 May 2021 19:59:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F079613DD for ; Sat, 8 May 2021 19:59:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229721AbhEHUAU (ORCPT ); Sat, 8 May 2021 16:00:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbhEHUAO (ORCPT ); Sat, 8 May 2021 16:00:14 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51D66C061574 for ; Sat, 8 May 2021 12:59:12 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id b11-20020a7bc24b0000b0290148da0694ffso8943261wmj.2 for ; Sat, 08 May 2021 12:59: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=FcvYj/0NhHKLtpTAsYPf5K0U/h63ZzfMQ7TJJTRKLdY=; b=l/JSdqsZGDgp/377EYtzoj9npbYhBrUcIywWDOm8YAsFtCfBH02wwkHunx+PE0KIlQ N+A2dtS9HJvXDy8hgY3vzMfslCYag1jBOagq6LUsy0tqQ4mr9dmXhX7vk4Pb9bHajDNT SjurkE018tFhDHeZnWCaPjxNY6oFQ2eFVKMPwwFYREUkcnA4REBPvMOJWZ83FvKN53Ee Fob/ZJksIjSVHlwBEvBV1T8KWQDnMBUJZD1AJw0cv02m2OlmF/Bc/V2TSDTuk997lOdQ rVb+on+iP63nQJzTfwmwOZ6ruaolNUtFrgXy+i2t4PxRi90Vd44mI0tr67/jsHmPYzW/ 0HjA== 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=FcvYj/0NhHKLtpTAsYPf5K0U/h63ZzfMQ7TJJTRKLdY=; b=fDDadAimBDAgeY92sEPGTFRjYNp/UITt/kNYkE+WPvmOaF8y91neHGjLfI6PSNRHVS xhUq6qpnNAWhSdhXkm/47iART4/jt+RLMMXoazbPUo2xGuA/opF5Ww8bRbzKynExyxIa vFMdHh9Y1aPIP2UB3xNf5jgupHlxl3R0dOg/lHiIxzL6uY8TLMOYFZxtb/PX8BRHYrXf YUullce2m7lozYXnSeomUmSqZZIOqv6zD77GwTbSdJoJyWYjeTGQV22Gwdyciwtlqvts RN/uv5KHi+3QbIiMWa724Rw3iMkhL2jiWdW4lzbgK2rWP0x/H7IbWIRbpHr9jiqQgNzc ge8Q== X-Gm-Message-State: AOAM531+WTo128rfNlLPAJnjmnYIgY2deSwRWmVuJZc8nE+GPHTLeTpu P+QwV9iRw8+xZB3bH4n5/WmMFJcVrL8= X-Google-Smtp-Source: ABdhPJymtHJZ9FL3tB4YAXTGKpv9T1oUcaT0tU+GhkmXPYQxYzddNki9YPSsxdGtHJGH5ss2SYmORg== X-Received: by 2002:a7b:c24a:: with SMTP id b10mr28699978wmj.157.1620503951116; Sat, 08 May 2021 12:59:11 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id i14sm14658521wmb.33.2021.05.08.12.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 May 2021 12:59:10 -0700 (PDT) Message-Id: <73b03a1e8e05fd4e1952c8f4b0bb7b8519a77862.1620503945.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sat, 08 May 2021 19:59:01 +0000 Subject: [PATCH v3 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 , 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 b7c9898fac5b..74d395838708 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -768,4 +768,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 Sat May 8 19:59: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: 12246227 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 61C9FC433B4 for ; Sat, 8 May 2021 19:59:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3DBF96128C for ; Sat, 8 May 2021 19:59:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229656AbhEHUAW (ORCPT ); Sat, 8 May 2021 16:00:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229679AbhEHUAP (ORCPT ); Sat, 8 May 2021 16:00:15 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFD48C06175F for ; Sat, 8 May 2021 12:59:12 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id p14-20020a05600c358eb029015c01f207d7so939864wmq.5 for ; Sat, 08 May 2021 12:59: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=Agm8GSFLhpXRd8oGL0AcvidOXI9WVRhHPELomlUmqO8=; b=kNuKkgwFx5AONZj3zZUWf/+mGF2QAD827BZJzK6uztgkT4BFdogTeOWQoXakZOZnnG jFyRaWNadMhVSwIAAZfbhHcjrlDD6bqDKU8oqtV0+FDtzeuiu0A6skmEBLGBv8U+km4y RKnpaH+FcrJTuZKd78sSw+2H+p1uNZwY1eEDhOxzxrV0m66Jm3TUIIcVHABUQvziT6/O fVtW/oydzXXHUNJW0UuENX3whmsxL1D/kRQcmpUTDTLqfLjmNHVvD7PT3oUto7LQzbUk 6SfrJwy+sZzw/Q8KBtiUT8u9I1Y/oRFIQKRfxsB8wI/upM2jP4M1xn/bX1f8o4Vzf+/Z qSpA== 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=Agm8GSFLhpXRd8oGL0AcvidOXI9WVRhHPELomlUmqO8=; b=omXnfgWiCvf249w5FZQlUD+aa1DvJmmRZvJ/OAPceDYugqCVA5QlGFbiamtHRG2Zxz KuGb3c6tlpLygnhCmxaliJKx9Ha1tM4DlBlnuF3G0oShHpIEALRv4UuFP5QvU45CDo6w wpCL7UGGh214knSMCso0q4iB9WaTeg9j/yv++3SbvcuyXTD5VHEi87hJi9cLawhGwaD3 h/ntXhGGRj5m2gVWn6+kUIO+FZEwLtuLd2DuPr8ASxpxGqBt84oM57WkXmsYJ+rJP6fJ Cw50sdfZWbOCsUyyyBrfi3AUxRWHP1yAQBXeQwRwXj2wyFejJj5bKeY+sCITTf2AN/EP ecGw== X-Gm-Message-State: AOAM532G2lioiZzVzrBcP+favEsTJQwZ7itLLQ6OZ5sd+czNjlTmmHxF Mgzz6noLExWQTb3eWmZUiU9Wm4A2sn4= X-Google-Smtp-Source: ABdhPJxDNnikwsc78FaHkydx6AnqkQjS8K1G8ddOANATnTe3M+8vU4/u8VplRFi05o04fxR8QjGXwA== X-Received: by 2002:a1c:bc05:: with SMTP id m5mr26301268wmf.173.1620503951765; Sat, 08 May 2021 12:59:11 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n22sm17632948wmo.12.2021.05.08.12.59.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 May 2021 12:59:11 -0700 (PDT) Message-Id: <66ffc7f02d08f3f07cb3cb2605b113a630f1e127.1620503945.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sat, 08 May 2021 19:59:02 +0000 Subject: [PATCH v3 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 , 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. Sadly, though, it can get very confusing since ignore rules can have exclusions, as in the last of the following .gitignore rules: .gitignore *~ *.log !settings.log In the last entry above, (pathspec->items[3].magic & PATHSPEC_EXCLUDE) will be true due the the '!' negating the rule. Someone might refer to this as "excluded". That means the file 'settings.log' will not match, and thus not be ignored. So we won't return path_excluded for it. So it's an exclude rule that prevents the file from being an exclude. The non-excluded rules are the ones that result in files being excludes. Great fun, eh? 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 dfb174227b36..3f2cfef2c2bb 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 74d395838708..a1d695ee9fe9 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 Sat May 8 19:59: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: 12246229 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 6910AC43461 for ; Sat, 8 May 2021 19:59:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4DD41613D9 for ; Sat, 8 May 2021 19:59:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229728AbhEHUAX (ORCPT ); Sat, 8 May 2021 16:00:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229619AbhEHUAP (ORCPT ); Sat, 8 May 2021 16:00:15 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70EE1C061574 for ; Sat, 8 May 2021 12:59:13 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id d11so12553969wrw.8 for ; Sat, 08 May 2021 12:59: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=9Ij47Mjwsrw/MbJBXGq1dM35BMyHwa2i9Tp1xlUXtHo=; b=Kd3QJcZ9f8Zcr110nOCScqBMtUc2dPaQuJHoMsiDBXJAlOnRWMOOHkwfBeQ86J0+ry Yh16+MNdnHtiZvOrvb2QGK1y0U95wryIip3O5CzQITRsK0yUVh3Qe3KudKxwdqSPDDNF wTsCP6prX4mIRlXBlyRiMuINvvuMSpKOvtGBSFqN+PLuNSp1WZRHDAjDliIQbarTXgE+ jTIkUlM5GxG6pbup9tN+I9+B16uM71qzGTwvqmjEgsuU8OQXyGvH34Bhu74tfng4TfxD i5BA7+Oh2Mh2tDOHRyMUVwvQ7rH6FYT5YvWWDLRrcXfyGPrcdHc7j9/muD7yVGx3wWJl j/PQ== 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=9Ij47Mjwsrw/MbJBXGq1dM35BMyHwa2i9Tp1xlUXtHo=; b=aRaaflDrHxY/rSpMuzOIDujXYKEgRhM5u5q/Uz+kfk+k8hz3cyu9XiCVGLI8bFYkmU uQtK/JHvGaT4X0WScVo1B8YugLjYRS2MiZfODoDBRYkVz4NU3FC1Dde0sdTIsvsIyLVX bqCc+3Jq4vJQ5wdPvTa8BRzvaVhjo1/zDVykAhyZIZwjYGzRwV1rVIa9N2LxjbXvMDz3 aAdJaOszeOfFin9SlpJsU6A7RHZoNc178cqD8sMu9fAMrkKR/gzdUsCzYltPUmxp1ClY j7hUBfNQdVf7inwxv5yLYRMKw5rkQT/ayhBLEsYfELrYIwXs0P5z2PlM6bzzzBotuH/u k3ag== X-Gm-Message-State: AOAM531+7fdW2rVX+w81Kdawz3dH4Q+tLJa0aMu/PwsuH2A9fb5epFko SqMfldXPn9aPDeSFKgLT9gX7Xjeh26M= X-Google-Smtp-Source: ABdhPJzEhgUcMsZuVLN3Bb+zRhU54XxoymfdXkRIzCYJbgKXcpQ4xFvxJORSZvFp/pjXvhBrBV7E2Q== X-Received: by 2002:adf:f251:: with SMTP id b17mr20729836wrp.410.1620503952294; Sat, 08 May 2021 12:59:12 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v13sm15659739wrt.65.2021.05.08.12.59.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 May 2021 12:59:12 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Sat, 08 May 2021 19:59:03 +0000 Subject: [PATCH v3 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 , 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 3f2cfef2c2bb..f5d9732d9e68 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 a1d695ee9fe9..751764c0f1ae 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -768,7 +768,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 Sat May 8 19:59:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12246231 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 5DBCAC433ED for ; Sat, 8 May 2021 19:59:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A7866128C for ; Sat, 8 May 2021 19:59:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229729AbhEHUAX (ORCPT ); Sat, 8 May 2021 16:00:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbhEHUAR (ORCPT ); Sat, 8 May 2021 16:00:17 -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 24987C06175F for ; Sat, 8 May 2021 12:59:14 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id z6so12562317wrm.4 for ; Sat, 08 May 2021 12:59: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=nagqnB6eYBu5uVDk1TnIam/B3bRjk8hGD85T5qbXJ/Q=; b=sMVD6an6Q7SSsUUiK/+8SUfTZ10XV693kFWs5DM2fMk0utKMeBiOFWcynATeQ1hwOi Lg/Jq/FesYGdKpmva4Gq6hPNywQ2cmZKrErI40mryy+QoSfmImBB8CddV3JwA4ulfonq /ZcRBrVXgT70IqFymPsM6lA7h853/H2EO2bCUgttQ6dPX4tMJhweafaXjJkv4HiNEtZQ WaWd1Nnghdnkc0AXnr8Chvs8a0u12PS9U2UbGQvV4rviRTITB+gqILaQv06bTg2hqPXT Krmzlw2kX3BaRA1DGyxAp69CAhHdF+q4Pcm+YisYNcJ/kS4K/QuUsm+g41uG3F+Rqb53 Bq/g== 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=nagqnB6eYBu5uVDk1TnIam/B3bRjk8hGD85T5qbXJ/Q=; b=qtLlLkPxN87ewpGc2XCKOMAVod6U5yTSYigovIjT8zmKHha6JEdqad+xkqcpRld7Nj PdnypQtC79DQ9SrLFk14UTZTN6UWvngGNjFXNlZK78FkMHh8SC0nis+xhZtc0cYb9mrm 0xzxEEoQStbWqN54PtBUMBAHFS5Zxn+DzKeAxKs0bXpj2BXrCT7qzD7mg+35xLjCzRIW pt8IagUpXGAG8j2oykzypxJSNXQzASnR4IaDCFlnyeh82R21rvsWmT1sUmRcJY37CrOL Ki1ksAkh+GesMTDUDqwAdtoq1+pAkyKMYx1BX+xTukRX5M91CG0xsEq3StqoXN4oToFf aPKQ== X-Gm-Message-State: AOAM530HD16YJ36V8Fy+zjhY0+6iyaxPsOh1Ao3ds0i0iaUx3XAHVZdw Uwt151EBqxLsqnUVi94aAHyZQke8LjQ= X-Google-Smtp-Source: ABdhPJxPP60vKdsbjlHC4dQD91P7+jSR6tuwejzwGhvaKa/TUXwwysGqSBb15bXRuXprzqojYUi6Vw== X-Received: by 2002:adf:f74d:: with SMTP id z13mr20768505wrp.147.1620503952936; Sat, 08 May 2021 12:59:12 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c62sm704613wme.5.2021.05.08.12.59.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 May 2021 12:59:12 -0700 (PDT) Message-Id: <57135c35777416a91c0ae6bac7f0a57293815ced.1620503946.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sat, 08 May 2021 19:59:04 +0000 Subject: [PATCH v3 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 , 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 f5d9732d9e68..896a9a62b2c7 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. */