<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/dir.c, branch v2.34.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.34.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.34.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2021-11-23T22:48:11Z</updated>
<entry>
<title>Merge branch 'ds/add-rm-with-sparse-index' into maint</title>
<updated>2021-11-23T22:48:11Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-11-23T22:48:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=eef0a8e7c1ea6987fe2a6acaf21f612d66974aff'/>
<id>urn:sha1:eef0a8e7c1ea6987fe2a6acaf21f612d66974aff</id>
<content type='text'>
Regression fix for 2.34

* ds/add-rm-with-sparse-index:
  dir: revert "dir: select directories correctly"
</content>
</entry>
<entry>
<title>dir: revert "dir: select directories correctly"</title>
<updated>2021-11-22T22:53:23Z</updated>
<author>
<name>Derrick Stolee</name>
<email>dstolee@microsoft.com</email>
</author>
<published>2021-11-19T14:13:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=33c5d6c8456ecb1e89450483586f5f3f115ffa93'/>
<id>urn:sha1:33c5d6c8456ecb1e89450483586f5f3f115ffa93</id>
<content type='text'>
This reverts commit f6526728f950cacfd5b5e42bcc65f2c47f3da654.

The change in f652672 (dir: select directories correctly, 2021-09-24)
caused a regression in directory-based matches with non-cone-mode
patterns, especially for .gitignore patterns. A test is included to
prevent this regression in the future.

The commit ed495847 (dir: fix pattern matching on dirs, 2021-09-24) was
reverted in 5ceb663 (dir: fix directory-matching bug, 2021-11-02) for
similar reasons. Neither commit changed tests, and tests added later in
the series continue to pass when these commits are reverted.

Reported-by: Danial Alihosseini &lt;danial.alihosseini@gmail.com&gt;
Signed-off-by: Derrick Stolee &lt;dstolee@microsoft.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ds/add-rm-with-sparse-index'</title>
<updated>2021-11-03T20:32:28Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-11-03T20:32:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=36f0a2e20f3eeeaef8c356a4c9d27c3a5a5e13d0'/>
<id>urn:sha1:36f0a2e20f3eeeaef8c356a4c9d27c3a5a5e13d0</id>
<content type='text'>
Regression fix.

* ds/add-rm-with-sparse-index:
  dir: fix directory-matching bug
</content>
</entry>
<entry>
<title>dir: fix directory-matching bug</title>
<updated>2021-11-03T17:10:36Z</updated>
<author>
<name>Derrick Stolee</name>
<email>dstolee@microsoft.com</email>
</author>
<published>2021-11-02T14:40:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5ceb663e926bd22248d1d72d70fa701c558587ea'/>
<id>urn:sha1:5ceb663e926bd22248d1d72d70fa701c558587ea</id>
<content type='text'>
This reverts the change from ed49584 (dir: fix pattern matching on dirs,
2021-09-24), which claimed to fix a directory-matching problem without a
test case. It turns out to _create_ a bug, but it is a bit subtle.

The bug would have been revealed by the first of two tests being added to
t0008-ignores.sh. The first uses a pattern "/git/" inside the a/.gitignores
file, which matches against 'a/git/foo' but not 'a/git-foo/bar'. This test
would fail before the revert.

The second test shows what happens if the test instead uses a pattern "git/"
and this test passes both before and after the revert.

The difference in these two cases are due to how
last_matching_pattern_from_list() checks patterns both if they have the
PATTERN_FLAG_MUSTBEDIR and PATTERN_FLAG_NODIR flags. In the case of "git/",
the PATTERN_FLAG_NODIR is also provided, making the change in behavior in
match_pathname() not affect the end result of
last_matching_pattern_from_list().

Reported-by: Glen Choo &lt;chooglen@google.com&gt;
Signed-off-by: Derrick Stolee &lt;dstolee@microsoft.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'mt/fix-add-rm-with-sparse-index'</title>
<updated>2021-10-29T22:43:16Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-10-29T22:43:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=68fb83b58ed4ef8705974bc1cc47fb6bb7ca5bdd'/>
<id>urn:sha1:68fb83b58ed4ef8705974bc1cc47fb6bb7ca5bdd</id>
<content type='text'>
Fix-up to a topic already merged to 'master'.

* mt/fix-add-rm-with-sparse-index:
  add, rm, mv: fix bug that prevents the update of non-sparse dirs
</content>
</entry>
<entry>
<title>add, rm, mv: fix bug that prevents the update of non-sparse dirs</title>
<updated>2021-10-28T15:46:07Z</updated>
<author>
<name>Matheus Tavares</name>
<email>matheus.bernardino@usp.br</email>
</author>
<published>2021-10-28T14:21:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=20141e322c8c27054c105fca5c812043c2bc7440'/>
<id>urn:sha1:20141e322c8c27054c105fca5c812043c2bc7440</id>
<content type='text'>
These three commands recently learned to avoid updating paths outside
the sparse checkout even if they are missing the SKIP_WORKTREE bit. This
is done using path_in_sparse_checkout(), which checks whether a given
path matches the current list of sparsity rules, similar to what
clear_ce_flags() does when we run "git sparse checkout init" or "git
sparse-checkout reapply". However, clear_ce_flags() uses a recursive
approach, applying the match results from parent directories on paths
that get the UNDECIDED result, whereas path_in_sparse_checkout() only
attempts to match the full path and immediately considers UNDECIDED as
NOT_MATCHED. This makes the function miss matches with leading
directories. For example, if the user has the sparsity patterns "!/a"
and "b/", add, rm, and mv will fail to update the path "a/b/c" and end
up displaying a warning about it being outside the sparse checkout even
though it isn't. This problem only occurs in full pattern mode as the
pattern matching functions never return UNDECIDED for cone mode.

To fix this, replicate the recursive behavior of clear_ce_flags() in
path_in_sparse_checkout(), falling back to the parent directory match
when a path gets the UNDECIDED result. (If this turns out to be too
expensive in some cases, we may want to later add some form of caching
to accelerate multiple queries within the same directory. This is not
implemented in this patch, though.) Also add two tests for each affected
command (add, rm, and mv) to check that they behave correctly with the
recursive pattern matching. The first test would previously fail without
this patch while the second already succeeded. It is added mostly to
make sure that we are not breaking the existing pattern matching for
directories that are really sparse, and also as a protection against any
future regressions.

Two other existing tests had to be changed as well: one test in t3602
checks that "git rm -r &lt;dir&gt;" won't remove sparse entries, but it didn't
allow the non-sparse entries inside &lt;dir&gt; to be removed. The other one,
in t7002, tested that "git mv" would correctly display a warning message
for sparse paths, but it accidentally expected the message to include
two non-sparse paths as well.

Signed-off-by: Matheus Tavares &lt;matheus.bernardino@usp.br&gt;
Acked-by: Derrick Stolee &lt;dstolee@microsoft.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ds/add-rm-with-sparse-index'</title>
<updated>2021-10-13T22:15:56Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-10-13T22:15:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2d498a7c894444fba5cfb0007e6b757afcde63c6'/>
<id>urn:sha1:2d498a7c894444fba5cfb0007e6b757afcde63c6</id>
<content type='text'>
"git add", "git mv", and "git rm" have been adjusted to avoid
updating paths outside of the sparse-checkout definition unless
the user specifies a "--sparse" option.

* ds/add-rm-with-sparse-index:
  advice: update message to suggest '--sparse'
  mv: refuse to move sparse paths
  rm: skip sparse paths with missing SKIP_WORKTREE
  rm: add --sparse option
  add: update --renormalize to skip sparse paths
  add: update --chmod to skip sparse paths
  add: implement the --sparse option
  add: skip tracked paths outside sparse-checkout cone
  add: fail when adding an untracked sparse file
  dir: fix pattern matching on dirs
  dir: select directories correctly
  t1092: behavior for adding sparse files
  t3705: test that 'sparse_entry' is unstaged
</content>
</entry>
<entry>
<title>dir: fix pattern matching on dirs</title>
<updated>2021-09-28T17:31:02Z</updated>
<author>
<name>Derrick Stolee</name>
<email>dstolee@microsoft.com</email>
</author>
<published>2021-09-24T15:39:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ed4958477b28a1dd28597e40094e9a202a870379'/>
<id>urn:sha1:ed4958477b28a1dd28597e40094e9a202a870379</id>
<content type='text'>
Within match_pathname(), one successful matching category happens when
the pattern is equal to its non-wildcard prefix. At this point, we have
checked that the input 'pathname' matches the pattern up to the prefix
length, and then we subtraced that length from both 'patternlen' and
'namelen'.

In the case of a directory match, this prefix match should be
sufficient. However, the success condition only cared about _exact_
equality here. Instead, we should allow any path that agrees on this
prefix in the case of PATTERN_FLAG_MUSTBEDIR.

This case was not tested before because of the way unpack_trees() would
match a parent directory before visiting the contained paths. This
approach is changing, so we must change this comparison.

Signed-off-by: Derrick Stolee &lt;dstolee@microsoft.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>dir: select directories correctly</title>
<updated>2021-09-28T17:31:02Z</updated>
<author>
<name>Derrick Stolee</name>
<email>dstolee@microsoft.com</email>
</author>
<published>2021-09-24T15:39:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f6526728f950cacfd5b5e42bcc65f2c47f3da654'/>
<id>urn:sha1:f6526728f950cacfd5b5e42bcc65f2c47f3da654</id>
<content type='text'>
When matching a path against a list of patterns, the ones that require a
directory match previously did not work when a filename is specified.
This was fine when all pattern-matching was done within methods such as
unpack_trees() that check a directory before recursing into the
contained files. However, other commands will start matching individual
files against pattern lists without that recursive approach.

The last_matching_pattern_from_list() logic performs some checks on the
filetype of a path within the index when the PATTERN_FLAG_MUSTBEDIR flag
is set. This works great when setting SKIP_WORKTREE bits within
unpack_trees(), but doesn't work well when passing an arbitrary path
such as a file within a matching directory.

We extract the logic around determining the file type, but attempt to
avoid checking the filesystem if the parent directory already matches
the sparse-checkout patterns. The new path_matches_dir_pattern() method
includes a 'path_parent' parameter that is used to store the parent
directory of 'pathname' between multiple pattern matching tests. This is
loaded lazily, only on the first pattern it finds that has the
PATTERN_FLAG_MUSTBEDIR flag.

If we find that a path has a parent directory, we start by checking to
see if that parent directory matches the pattern. If so, then we do not
need to query the index for the type (which can be expensive). If we
find that the parent does not match, then we still must check the type
from the index for the given pathname.

Note that this does not affect cone mode pattern matching, but instead
the more general -- and slower -- full pattern set. Thus, this does not
affect the sparse index.

Helped-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Derrick Stolee &lt;dstolee@microsoft.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jt/submodule-name-to-gitdir'</title>
<updated>2021-09-23T20:44:49Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-09-23T20:44:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f7511fdfbd6dc249aca551d56fcb3011d85ddd08'/>
<id>urn:sha1:f7511fdfbd6dc249aca551d56fcb3011d85ddd08</id>
<content type='text'>
Code refactoring.

* jt/submodule-name-to-gitdir:
  submodule: extract path to submodule gitdir func
</content>
</entry>
</feed>
