summaryrefslogtreecommitdiff
path: root/src/tree-cache.c
Commit message (Collapse)AuthorAgeFilesLines
* pool: use `size_t` for sizesEdward Thomson2019-06-241-19/+6
|
* tree-cache: safely cast to uint32_tEdward Thomson2019-06-241-6/+26
|
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-5/+5
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* tree-cache: avoid out-of-bound reads when parsing treesPatrick Steinhardt2018-10-181-2/+2
| | | | | | | | | | We use the `git__strtol32` function to parse the child and entry count of treecaches from the index, which do not accept a buffer length. As the buffer that is being passed in is untrusted data and may thus be malformed and may not contain a terminating `NUL` byte, we can overrun the buffer and thus perform an out-of-bounds read. Fix the issue by uzing `git__strntol32` instead.
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
* giterr_set: consistent error messagesEdward Thomson2016-12-291-2/+2
| | | | | | | | Error messages should be sentence fragments, and therefore: 1. Should not begin with a capital letter, 2. Should not conclude with punctuation, and 3. Should not end a sentence and begin a new one
* tree-cache: correct the entry_count calculationCarlos Martín Nieto2014-10-221-31/+4
| | | | | | | | | | | | | The entry_count field is the amount of index entries covered by a particular cache entry, that is how many files are there (recursively) under a particular directory. The current code that attemps to do this is severely defincient and is trying to count the amount of children, which always comes up to zero. We don't even need to recount, since we have the information during the cache creation. We can take that number and keep it, as we only ever invalidate or replace.
* There is no "z" size specifier on MSVCSven Strickroth2014-10-131-1/+1
| | | | | | See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx and https://stackoverflow.com/questions/6655410/why-doesnt-zd-printf-format-work-in-vs2010 Signed-off-by: Sven Strickroth <email@cs-ware.de>
* index: make sure to write cached subtrees if parent is invalidatedCarlos Martín Nieto2014-10-101-4/+2
| | | | | If e.g. the root tree is invalidated, we still want to write out its children, since those may still have valid cache entries.
* index: write out the tree cache extensionCarlos Martín Nieto2014-10-101-4/+56
| | | | | | | | | | Keeping the cache around after read-tree is only one part of the optimisation opportunities. In order to share the cache between program instances, we need to write the TREE extension to the index. Do so, taking the opportunity to rename 'entries' to 'entry_count' to match the name given in the format description. The included test is rather trivial, but works as a sanity check.
* tree-cache: remove the parent pointerCarlos Martín Nieto2014-10-101-8/+7
| | | | | This wasn't used. We invalidate based on the full path, so we always go down the tree, never up.
* index: fill the tree cache when reading from a treeCarlos Martín Nieto2014-10-101-0/+71
| | | | | | When reading from a tree, we know what every tree is going to look like, so we can fill in the tree cache completely, making use of the index for modification of trees a lot quicker.
* tree-cache: move to use a pool allocatorCarlos Martín Nieto2014-10-101-26/+10
| | | | | | This simplifies freeing the entries quite a bit; though there aren't that many failure paths right now, introducing filling the cache from a tree will introduce more. This makes sure not to leak memory on errors.
* tree-cache: extract the allocationCarlos Martín Nieto2014-10-101-12/+22
|
* Minor tree cache speedupsRussell Belfer2014-04-171-17/+10
| | | | | | | | While I was looking at the conflict cleanup code, I looked over at the tree cache code, since we clear the tree cache for each entry that gets removed and there is some redundancy there. I made some small tweaks to avoid extra calls to strchr and strlen in a few circumstances.
* tree-cache: Fix error message typonulltoken2013-11-191-2/+2
|
* tree-cache: Don't segfault upon corruptionnulltoken2013-11-191-3/+6
|
* tree-cache: Zero out the allocated tree children arraynulltoken2013-11-191-0/+2
|
* tree-cache: Free the tree upon the detection of a corrupted childnulltoken2013-11-191-1/+1
|
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* tree cache: loosen negative entry count checkNguyễn Thái Ngọc Duy2012-12-121-1/+1
| | | | | | | | | | | While C Git has been writing entry count -1 (ie. never other negative numbers) as invalid since day 1, it accepts all negative entry counts as invalid. JGit follows the same rule. libgit2 should also follow, or the index that works with C Git or JGit may someday be rejected by libgit2. Other reimplementations like dulwich and grit have not bothered with parsing or writing tree cache.
* misc: Fix warnings from PVS Studio trialVicent Martí2012-06-071-1/+1
|
* Remove old and unused error codesVicent Martí2012-05-021-47/+30
|
* tree-cache: don't error out on a childless invalidated entryCarlos Martín Nieto2012-04-231-1/+1
| | | | | | | | | The code used to assume that there had to be data after the newline in a tree cache extension entry. This isn't true for a childless invalidated entry if it's the last one, as there won't be any children nor a hash to take up space. Adapt the off-by-one comparison to also work in this case. Fixes #633.
* Update Copyright headerschu2012-02-131-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* global: Properly use `git__` memory wrappersVicent Marti2011-10-281-2/+2
| | | | | Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
* Add git_tree_cache_getCarlos Martín Nieto2011-09-271-1/+24
| | | | Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* Add git_tree_cache_invalidate_pathCarlos Martín Nieto2011-09-271-1/+47
| | | | | | | Whenever a file is updated in the index, each tree leading towards it needs to be invalidated. Provide the supporting function. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* tree cache: correctly handle invalidated treesCarlos Martín Nieto2011-09-271-17/+10
| | | | | | | | | | | | The fix introduced in a02fc2cd1 (2011-05-24; index: correctly parse invalidated TREE extensions) threw out the rest of the data in the extension if it found an invalidated entry. This was the result of incorrect reading of the documentation. Insted, keep reading the extension, as there may be cached data we can use. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* Make tree cache name a flex-arrayCarlos Martín Nieto2011-09-271-14/+12
| | | | Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* Move the tree cache functions to their own fileCarlos Martín Nieto2011-09-271-0/+141
Rename git_index_tree to git_tree_cache. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>