On Thu, Mar 26, 2020 at 6:02 AM Derrick Stolee <stolee@xxxxxxxxx> wrote: > > On 3/25/2020 3:31 PM, Elijah Newren via GitGitGadget wrote: > > From: Elijah Newren <newren@xxxxxxxxx> > > > > The untracked cache is caching wrong information, resulting in commands > > like `git status --porcelain` producing erroneous answers. The tests in > > t7063 actually have a wide enough test to catch a relevant case, in > > particular surrounding the directory 'dthree/', but it appears the > > answers were not checked quite closely enough and the tests were coded > > with the wrong expectation. Once the wrong info got into the cache in > > an early test, since later tests built on it, many others have a wrong > > expectation as well. This affects just over a third of the tests in > > t7063. > > Wow. Good find. or maybe not... > > The error can be seen starting at t7063.12 (the first one switched from > > expect_success to expect_failure in this patch). That test runs in a > > directory with the following files present: > > done/one > > dthree/three > > dtwo/two > > four > > .gitignore > > one > > three > > two > > > > Of those files, the following files are tracked: > > done/one > > one > > two > > > > and the contents of .gitignore are: > > four > > > > and the contents of .git/info/exclude are: > > three > > > > And there is no core.excludesfile. Therefore, the following should be > > untracked: > > .gitignore > > dthree/ > > dtwo/ > > Indeed, these three paths are reported if you run > > git ls-files -o --directory --exclude-standard > > within this directory. However, 'git status --porcelain' was reporting > > for this test: > > A done/one > > A one > > A two > > ?? .gitignore > > ?? dtwo/ > > which was clearly wrong -- dthree/ should also be listed as untracked. > > This appears to have been broken since the test was introduced with > > commit a3ddcefd97 ("t7063: tests for untracked cache", 2015-03-08). > > Correct the test to expect the right output, marking the test as failed > > for now. Make the same change throughout the remainder of the testsuite > > to reflect that dthree/ remains an untracked directory throughout and > > should be recognized as such. > > I wonder if we could simultaneously verify these "expected" results match > using another command without the untracked cache? It's good that we have > the expected outputs explicitly, but perhaps double-checking the command > with `-c core.untrackedCache=false` would help us know these are the correct > expected outputs? This was an *awesome* idea, even if the implementation doesn't quite work. It turns out that -c core.untrackedCache=false does not instruct status to ignore the untracked cache, it instructs status to delete it. Since we had subsequent tests that depended on the untrackedCache created in previous tests, this would break a number of tests. But I can introduce a helper to workaround that: # Ignore_Untracked_Cache, abbreviated to 3 letters because then people can # compare commands side-by-side, e.g. # iuc status --porcelain >expect && # git status --porcelain >actual && # test_cmp expect actual iuc() { git ls-files -s >../current-index-entries git ls-files -t | grep ^S | sed -e s/^S.// >../current-sparse-entries GIT_INDEX_FILE=.git/tmp_index export GIT_INDEX_FILE git update-index --index-info <../current-index-entries git update-index --skip-worktree $(cat ../current-sparse-entries) git -c core.untrackedCache=false "$@" ret=$? rm ../current-index-entries rm $GIT_INDEX_FILE unset GIT_INDEX_FILE return $ret } Doing that helped me discover that the test didn't have a wrong expectation; I did. When a directory that is not tracked is filled entirely with files that are ignored, then status --porcelain treats the directory itself as ignored...and thus doesn't display it. (`git status --porcelain --ignored` will show it). I had seen that somewhere, but hadn't fully understood the check_only and stop_at_first_file pieces related to it. Anyway, with this helpful hint: * I can say that there was not a bug in the untracked cache (at least not any that I'm aware of) * I can update my first patch to do more thorough checking instead of changing the expectation * I found the bug in my final patch that had been evading me * I added a huge comment explaining check_only and stop_at_first_file, how they're used, and what they mean for the future reader * I also no longer need to partially disable the untracked cache in my changes. New patches incoming...