]> git.ipfire.org Git - thirdparty/git.git/commit
dir: fix off by one errors for ignored and untracked entries
authorPatrick Steinhardt <ps@pks.im>
Thu, 26 Sep 2024 11:46:24 +0000 (13:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Sep 2024 15:25:35 +0000 (08:25 -0700)
commit04ff8008f3a27274e53c69209362a5bbe3dc4457
tree2c8f0c1f72d9653c5d42f8a5dc6dc3eba7805487
parent5bf922a4e914f15d899d38218ad0591933025ed4
dir: fix off by one errors for ignored and untracked entries

In `treat_directory()` we perform some logic to handle ignored and
untracked entries. When populating a directory with entries we first
save the current number of ignored/untracked entries and then populate
new entries at the end of our arrays that keep track of those entries.
When we figure out that all entries have been ignored/are untracked we
then remove this tail of entries from those vectors again. But there is
an off by one error in both paths that causes us to not free the first
ignored and untracked entries, respectively.

Fix these off-by-one errors to plug the resulting leak. While at it,
massage the code a bit to match our modern code style.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
dir.c
t/t3011-common-prefixes-and-directory-traversal.sh
t/t7061-wtstatus-ignore.sh
t/t7521-ignored-mode.sh