<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/dir.c, branch v2.29.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.29.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.29.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2020-09-30T19:53:48Z</updated>
<entry>
<title>dir.c: drop unused "untracked" from treat_path_fast()</title>
<updated>2020-09-30T19:53:48Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2020-09-30T12:35:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=842385b8a4fa56678f13cda599ee96463004e7bf'/>
<id>urn:sha1:842385b8a4fa56678f13cda599ee96463004e7bf</id>
<content type='text'>
We don't use the untracked_cache_dir parameter that is passed in, but
instead look at the untracked_cache_dir inside the cached_dir struct we
are passed. It's been this way since the introduction of
treat_path_fast() in 91a2288b5f (untracked cache: record/validate dir
mtime and reuse cached output, 2015-03-08).

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/leakfix'</title>
<updated>2020-08-27T21:04:49Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-08-27T21:04:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0d9a8e33f9fd07efa10072576df01a9cae5d89e6'/>
<id>urn:sha1:0d9a8e33f9fd07efa10072576df01a9cae5d89e6</id>
<content type='text'>
Code clean-up.

* jk/leakfix:
  submodule--helper: fix leak of core.worktree value
  config: fix leak in git_config_get_expiry_in_days()
  config: drop git_config_get_string_const()
  config: fix leaks from git_config_get_string_const()
  checkout: fix leak of non-existent branch names
  submodule--helper: use strbuf_release() to free strbufs
  clear_pattern_list(): clear embedded hashmaps
</content>
</entry>
<entry>
<title>Merge branch 'en/dir-clear'</title>
<updated>2020-08-24T21:54:34Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-08-24T21:54:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ad00f44f5479441da59bd55261ae717fcb357938'/>
<id>urn:sha1:ad00f44f5479441da59bd55261ae717fcb357938</id>
<content type='text'>
Leakfix with code clean-up.

* en/dir-clear:
  dir: fix problematic API to avoid memory leaks
  dir: make clear_directory() free all relevant memory
</content>
</entry>
<entry>
<title>Merge branch 'en/dir-nonbare-embedded'</title>
<updated>2020-08-24T21:54:29Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-08-24T21:54:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=11f433f79c790bcb5feae71b0320161d7ab7dea7'/>
<id>urn:sha1:11f433f79c790bcb5feae71b0320161d7ab7dea7</id>
<content type='text'>
"ls-files -o" mishandled the top-level directory of another git
working tree that hangs in the current git working tree.

* en/dir-nonbare-embedded:
  dir: avoid prematurely marking nonbare repositories as matches
  t3000: fix some test description typos
</content>
</entry>
<entry>
<title>dir: fix problematic API to avoid memory leaks</title>
<updated>2020-08-19T00:17:31Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2020-08-18T22:58:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=eceba5321410bbcc9e0b11e6aa479832f574eca8'/>
<id>urn:sha1:eceba5321410bbcc9e0b11e6aa479832f574eca8</id>
<content type='text'>
The dir structure seemed to have a number of leaks and problems around
it.  First I noticed that parent_hashmap and recursive_hashmap were
being leaked (though Peff noticed and submitted fixes before me).  Then
I noticed in the previous commit that clear_directory() was only taking
responsibility for a subset of fields within dir_struct, despite the
fact that entries[] and ignored[] we allocated internally to dir.c.
That, of course, resulted in many callers either leaking or haphazardly
trying to free these arrays and their contents.

Digging further, I found that despite the pretty clear documentation
near the top of dir.h that folks were supposed to call clear_directory()
when the user no longer needed the dir_struct, there were four callers
that didn't bother doing that at all.  However, two of them clearly
thought about leaks since they had an UNLEAK(dir) directive, which to me
suggests that the method to free the data was too unclear.  I suspect
the non-obviousness of the API and its holes led folks to avoid it,
which then snowballed into further problems with the entries[],
ignored[], parent_hashmap, and recursive_hashmap problems.

Rename clear_directory() to dir_clear() to be more in line with other
data structures in git, and introduce a dir_init() to handle the
suggested memsetting of dir_struct to all zeroes.  I hope that a name
like "dir_clear()" is more clear, and that the presence of dir_init()
will provide a hint to those looking at the code that they need to look
for either a dir_clear() or a dir_free() and lead them to find
dir_clear().

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: make clear_directory() free all relevant memory</title>
<updated>2020-08-19T00:17:29Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2020-08-18T22:58:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=dad4f23ce59339bb32ad9e1cc1682c696f7a724f'/>
<id>urn:sha1:dad4f23ce59339bb32ad9e1cc1682c696f7a724f</id>
<content type='text'>
The calling convention for the dir API is supposed to end with a call to
clear_directory() to free up no longer needed memory.  However,
clear_directory() didn't free dir-&gt;entries or dir-&gt;ignored.  I believe
this was an oversight, but a number of callers noticed memory leaks and
started free'ing these.  Unfortunately, they did so somewhat haphazardly
(sometimes freeing the entries in the arrays, and sometimes only
free'ing the arrays themselves).  This suggests the callers weren't
trying to make sure any possible memory used might be free'd, but just
the memory they noticed their usecase definitely had allocated.

Fix this mess by moving all the duplicated free'ing logic into
clear_directory().  End by resetting dir to a pristine state so it could
be reused if desired.

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>clear_pattern_list(): clear embedded hashmaps</title>
<updated>2020-08-14T17:48:12Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2020-08-14T11:10:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8dc3156373f4e02c1b1f657350ffae8ee94cbf44'/>
<id>urn:sha1:8dc3156373f4e02c1b1f657350ffae8ee94cbf44</id>
<content type='text'>
Commit 96cc8ab531 (sparse-checkout: use hashmaps for cone patterns,
2019-11-21) added some auxiliary hashmaps to the pattern_list struct,
but they're leaked when clear_pattern_list() is called.

Signed-off-by: Jeff King &lt;peff@peff.net&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>dir: avoid prematurely marking nonbare repositories as matches</title>
<updated>2020-08-12T19:26:47Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2020-08-12T07:12:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ab282aa548b807c022d521e83d843e4585b89dbb'/>
<id>urn:sha1:ab282aa548b807c022d521e83d843e4585b89dbb</id>
<content type='text'>
Nonbare repositories are special directories.  Unlike normal directories
that we might recurse into to list the files they contain, nonbare
repositories must themselves match and then we always report only on the
nonbare repository directory itself and not on any of its contents.

Separately, when traversing directories to try to find untracked or
excluded files, we often think in terms of paths either matching the
specified pathspec, or not matching them.  However, there is a special
value that do_match_pathspec() uses named
MATCHED_RECURSIVELY_LEADING_PATHSPEC which means "this directory does
not match any pathspec BUT it is possible a file or directory underneath
it does."  That special value prevents us from prematurely thinking that
some directory and everything under it is irrelevant, but also allows us
to differentiate from "this is a match".

The combination of these two special cases was previously uncovered.
Add a test to the testsuite to cover it, and make sure that we return a
nonbare repository as a non-match if the best match it got was
MATCHED_RECURSIVELY_LEADING_PATHSPEC.

Reported-by: christian w &lt;usebees@gmail.com&gt;
Simplified-testcase-and-bisection-by: Kyle Meyer &lt;kyle@kyleam.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 'en/fill-directory-exponential' into master</title>
<updated>2020-07-30T20:20:36Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-07-30T20:20:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=82fafc77bac9b3294b3e67bc021eeb511137c0f7'/>
<id>urn:sha1:82fafc77bac9b3294b3e67bc021eeb511137c0f7</id>
<content type='text'>
Fix to a regression introduced during 2.27 cycle.

* en/fill-directory-exponential:
  dir: check pathspecs before returning `path_excluded`
</content>
</entry>
<entry>
<title>dir: check pathspecs before returning `path_excluded`</title>
<updated>2020-07-20T20:25:07Z</updated>
<author>
<name>Martin Ågren</name>
<email>martin.agren@gmail.com</email>
</author>
<published>2020-07-20T18:45:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=cada7308ade0b9a018f9c54ea3f226e2e9c39ee5'/>
<id>urn:sha1:cada7308ade0b9a018f9c54ea3f226e2e9c39ee5</id>
<content type='text'>
In 95c11ecc73 ("Fix error-prone fill_directory() API; make it only
return matches", 2020-04-01), we taught `fill_directory()`, or more
specifically `treat_path()`, to check against any pathspecs so that we
could simplify the callers.

But in doing so, we added a slightly-too-early return for the "excluded"
case. We end up not checking the pathspecs, meaning we return
`path_excluded` when maybe we should return `path_none`. As a result,
`git status --ignored -- pathspec` might show paths that don't actually
match "pathspec".

Move the "excluded" check down to after we've checked any pathspecs.

Reported-by: Andreas Schwab &lt;schwab@linux-m68k.org&gt;
Reviewed-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Martin Ågren &lt;martin.agren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
