Re: [PATCH 1/5] t7300: add testcase showing unnecessary traversal into ignored directory
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- May 8, 2021, 00:10 UTC
- Message-ID
- <CAPig+cQw5xBK00rtMVw4b6e_21vgp33yYDfdRape202dpWQjbA@mail.gmail.com>
- In-Reply-To
- <CABPp-BEyUX8j-_rhNTyR5ZiqeLUWbBS-9q5+gEUWOEHpchambQ@mail.gmail.com>
On Fri, May 7, 2021 at 8:04 PM Elijah Newren <newren@gmail.com> wrote:
Show 21 quoted lines
> I think I figured it out. I now have the test simplified down to just: > > test_expect_success 'avoid traversing into ignored directories' ' > test_when_finished rm -f output error trace.* && > test_create_repo 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 > ) > '
I believe that you can close the subshell immediately after `git clean`, which would allow you to drop all the "../" prefixes on pathnames.
Show 9 quoted lines
> This relies on a few extra changes to the code: (1) switching the > existing trace calls in dir.c over to using trace2 variants, and (2) > adding two new counters (visited_directories and visited_paths) that > are output using the trace2 framework. I'm a little unsure if I > should check the paths-visited counter (will some platform have > additional files in every directory besides '.' and '..'? Or not have > one of those?), but it is good to have it check that the code in this > case visits no directories other than the toplevel one (i.e. that > directories-visited is 1).
I can't find the reference, but I recall a reply by jrneider (to some proposed patch) that not all platforms are guaranteed to have "." and ".." entries (but I'm not sure we need to worry about that presently).