<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/dir.c, branch gitk-resize-error</title>
<subtitle>Fork of git SCM with my patches.</subtitle>
<id>http://git.kilabit.info/git/atom?h=gitk-resize-error</id>
<link rel='self' href='http://git.kilabit.info/git/atom?h=gitk-resize-error'/>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/'/>
<updated>2022-01-10T19:52:49Z</updated>
<entry>
<title>Merge branch 'ds/sparse-checkout-malformed-pattern-fix'</title>
<updated>2022-01-10T19:52:49Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-01-10T19:52:49Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=09481fec21f339d980fca369be3936964003d38b'/>
<id>urn:sha1:09481fec21f339d980fca369be3936964003d38b</id>
<content type='text'>
Certain sparse-checkout patterns that are valid in non-cone mode
led to segfault in cone mode, which has been corrected.

* ds/sparse-checkout-malformed-pattern-fix:
  sparse-checkout: refuse to add to bad patterns
  sparse-checkout: fix OOM error with mixed patterns
  sparse-checkout: fix segfault on malformed patterns
</content>
</entry>
<entry>
<title>Merge branch 'en/keep-cwd'</title>
<updated>2022-01-05T22:01:28Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-01-05T22:01:28Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=da81d473fcfa67dfbcf0504d2b5225885e51e532'/>
<id>urn:sha1:da81d473fcfa67dfbcf0504d2b5225885e51e532</id>
<content type='text'>
Many git commands that deal with working tree files try to remove a
directory that becomes empty (i.e. "git switch" from a branch that
has the directory to another branch that does not would attempt
remove all files in the directory and the directory itself).  This
drops users into an unfamiliar situation if the command was run in
a subdirectory that becomes subject to removal due to the command.
The commands have been taught to keep an empty directory if it is
the directory they were started in to avoid surprising users.

* en/keep-cwd:
  t2501: simplify the tests since we can now assume desired behavior
  dir: new flag to remove_dir_recurse() to spare the original_cwd
  dir: avoid incidentally removing the original_cwd in remove_path()
  stash: do not attempt to remove startup_info-&gt;original_cwd
  rebase: do not attempt to remove startup_info-&gt;original_cwd
  clean: do not attempt to remove startup_info-&gt;original_cwd
  symlinks: do not include startup_info-&gt;original_cwd in dir removal
  unpack-trees: add special cwd handling
  unpack-trees: refuse to remove startup_info-&gt;original_cwd
  setup: introduce startup_info-&gt;original_cwd
  t2501: add various tests for removing the current working directory
</content>
</entry>
<entry>
<title>sparse-checkout: refuse to add to bad patterns</title>
<updated>2021-12-30T22:39:57Z</updated>
<author>
<name>Derrick Stolee</name>
<email>dstolee@microsoft.com</email>
</author>
<published>2021-12-16T16:13:42Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=a3eca5844526fd6111e7a1e8bdfa9813673a6f23'/>
<id>urn:sha1:a3eca5844526fd6111e7a1e8bdfa9813673a6f23</id>
<content type='text'>
When in cone mode sparse-checkout, it is unclear how 'git
sparse-checkout add &lt;dir1&gt; ...' should behave if the existing
sparse-checkout file does not match the cone mode patterns. Change the
behavior to fail with an error message about the existing patterns.

Also, all cone mode patterns start with a '/' character, so add that
restriction. This is necessary for our example test 'cone mode: warn on
bad pattern', but also requires modifying the example sparse-checkout
file we use to test the warnings related to recognizing cone mode
patterns.

This error checking would cause a failure further down the test script
because of a test that adds non-cone mode patterns without cleaning them
up. Perform that cleanup as part of the test now.

Reviewed-by: Elijah Newren &lt;newren@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>sparse-checkout: fix segfault on malformed patterns</title>
<updated>2021-12-30T22:39:57Z</updated>
<author>
<name>Derrick Stolee</name>
<email>dstolee@microsoft.com</email>
</author>
<published>2021-12-16T16:13:40Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=a481d4378cc503ac5646d44533a05fcac569a93f'/>
<id>urn:sha1:a481d4378cc503ac5646d44533a05fcac569a93f</id>
<content type='text'>
Then core.sparseCheckoutCone is enabled, the sparse-checkout patterns are
used to populate two hashsets that accelerate pattern matching. If the user
modifies the sparse-checkout file outside of the 'sparse-checkout' builtin,
then strange patterns can happen, triggering some error checks.

One of these error checks is possible to hit when some special characters
exist in a line. A warning message is correctly written to stderr, but then
there is additional logic that attempts to remove the line from the hashset
and free the data. This leads to a segfault in the 'git sparse-checkout
list' command because it iterates over the contents of the hashset, which is
now invalid.

The fix here is to stop trying to remove from the hashset. In addition,
we disable cone mode sparse-checkout because of the malformed data. This
results in the pattern-matching working with a possibly-slower
algorithm, but using the patterns as they are in the sparse-checkout
file.

This also changes the behavior of commands such as 'git sparse-checkout
list' because the output patterns will be the contents of the
sparse-checkout file instead of the list of directories. This is an
existing behavior for other types of bad patterns.

Add a test that triggers the segfault without the code change.

Reported-by: John Burnett &lt;johnburnett@johnburnett.com&gt;
Reviewed-by: Elijah Newren &lt;newren@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>dir: new flag to remove_dir_recurse() to spare the original_cwd</title>
<updated>2021-12-09T21:33:13Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2021-12-09T05:08:34Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=580a5d7f75fc7b6c4c369ef429742d9d417acddd'/>
<id>urn:sha1:580a5d7f75fc7b6c4c369ef429742d9d417acddd</id>
<content type='text'>
remove_dir_recurse(), and its non-static wrapper called
remove_dir_recursively(), both take flags for modifying its behavior.
As with the previous commits, we would generally like to protect
the original_cwd, but we want to forced user commands (e.g. 'git rm -rf
...') or other special cases to remove it.  Add a flag for this purpose.
After reading through every caller of remove_dir_recursively() in the
current codebase, there was only one that should be adjusted and that
one only in a very unusual circumstance.  Add a pair of new testcases to
highlight that very specific case involving submodules &amp;&amp; --git-dir &amp;&amp;
--work-tree.

Acked-by: Derrick Stolee &lt;stolee@gmail.com&gt;
Acked-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>dir: avoid incidentally removing the original_cwd in remove_path()</title>
<updated>2021-12-09T21:33:13Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2021-12-09T05:08:33Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=63bbe8beb78ee8af5a7faeee4be747a82d8e2dc7'/>
<id>urn:sha1:63bbe8beb78ee8af5a7faeee4be747a82d8e2dc7</id>
<content type='text'>
Modern git often tries to avoid leaving empty directories around when
removing files.  Originally, it did not bother.  This behavior started
with commit 80e21a9ed809 (merge-recursive::removeFile: remove empty
directories, 2005-11-19), stating the reason simply as:

    When the last file in a directory is removed as the result of a
    merge, try to rmdir the now-empty directory.

This was reimplemented in C and renamed to remove_path() in commit
e1b3a2cad7 ("Build-in merge-recursive", 2008-02-07), but was still
internal to merge-recursive.

This trend towards removing leading empty directories continued with
commit d9b814cc97f1 (Add builtin "git rm" command, 2006-05-19), which
stated the reasoning as:

    The other question is what to do with leading directories. The old
    "git rm" script didn't do anything, which is somewhat inconsistent.
    This one will actually clean up directories that have become empty
    as a result of removing the last file, but maybe we want to have a
    flag to decide the behaviour?

remove_path() in dir.c was added in 4a92d1bfb784 (Add remove_path: a
function to remove as much as possible of a path, 2008-09-27), because
it was noted that we had two separate implementations of the same idea
AND both were buggy.  It described the purpose of the function as

    a function to remove as much as possible of a path

Why remove as much as possible?  Well, at the time we probably would
have said something like:

  * removing leading directories makes things feel tidy
  * removing leading directories doesn't hurt anything so long as they
    had no files in them.

But I don't believe those reasons hold when the empty directory happens
to be the current working directory we inherited from our parent
process.  Leaving the parent process in a deleted directory can cause
user confusion when subsequent processes fail: any git command, for
example, will immediately fail with

    fatal: Unable to read current working directory: No such file or directory

Other commands may similarly get confused.  Modify remove_path() so that
the empty leading directories it also deletes does not include the
current working directory we inherited from our parent process.  I have
looked through every caller of remove_path() in the current codebase to
make sure that all should take this change.

Acked-by: Derrick Stolee &lt;stolee@gmail.com&gt;
Acked-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Elijah Newren &lt;newren@gmail.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-23T02:40:10Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-11-23T02:40:10Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=1bf2673685990e0c9a5040d5289de3e7a5f9c96e'/>
<id>urn:sha1:1bf2673685990e0c9a5040d5289de3e7a5f9c96e</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='http://git.kilabit.info/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='http://git.kilabit.info/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='http://git.kilabit.info/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>
</feed>
