|
f0e693b1
|
2021-09-07T17:53:49
|
|
str: introduce `git_str` for internal, `git_buf` is external
libgit2 has two distinct requirements that were previously solved by
`git_buf`. We require:
1. A general purpose string class that provides a number of utility APIs
for manipulating data (eg, concatenating, truncating, etc).
2. A structure that we can use to return strings to callers that they
can take ownership of.
By using a single class (`git_buf`) for both of these purposes, we have
confused the API to the point that refactorings are difficult and
reasoning about correctness is also difficult.
Move the utility class `git_buf` to be called `git_str`: this represents
its general purpose, as an internal string buffer class. The name also
is an homage to Junio Hamano ("gitstr").
The public API remains `git_buf`, and has a much smaller footprint. It
is generally only used as an "out" param with strict requirements that
follow the documentation. (Exceptions exist for some legacy APIs to
avoid breaking callers unnecessarily.)
Utility functions exist to convert a user-specified `git_buf` to a
`git_str` so that we can call internal functions, then converting it
back again.
|
|
d103f008
|
2019-05-21T13:44:47
|
|
pool: use `size_t` for sizes
|
|
c4a64b1b
|
2019-05-21T13:27:39
|
|
tree-cache: safely cast to uint32_t
|
|
f673e232
|
2018-12-27T13:47:34
|
|
git_error: use new names in internal APIs and usage
Move to the `git_error` name in the internal API for error-related
functions.
|
|
21652ee9
|
2018-10-18T11:43:30
|
|
tree-cache: avoid out-of-bound reads when parsing trees
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.
|
|
0c7f49dd
|
2017-06-30T13:39:01
|
|
Make sure to always include "common.h" first
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.
|
|
909d5494
|
2016-12-29T12:25:15
|
|
giterr_set: consistent error messages
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
|
|
bb0757d5
|
2014-10-22T21:09:31
|
|
tree-cache: correct the entry_count calculation
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.
|
|
cf1013a8
|
2014-10-12T17:21:17
|
|
There is no "z" size specifier on MSVC
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>
|
|
795d8e93
|
2014-09-29T08:03:22
|
|
index: make sure to write cached subtrees if parent is invalidated
If e.g. the root tree is invalidated, we still want to write out
its children, since those may still have valid cache entries.
|
|
c2f8b215
|
2014-09-28T07:00:49
|
|
index: write out the tree cache extension
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.
|
|
46bb0067
|
2014-07-11T11:52:38
|
|
tree-cache: remove the parent pointer
This wasn't used. We invalidate based on the full path, so we always go
down the tree, never up.
|
|
6843cebe
|
2014-07-10T14:10:39
|
|
index: fill the tree cache when reading from a tree
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.
|
|
19c88310
|
2014-07-10T13:48:13
|
|
tree-cache: move to use a pool allocator
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.
|
|
d091a9db
|
2014-07-10T12:21:28
|
|
tree-cache: extract the allocation
|
|
1fa17b5c
|
2014-03-14T22:01:30
|
|
Minor tree cache speedups
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.
|
|
a5d73188
|
2013-11-19T13:16:09
|
|
tree-cache: Fix error message typo
|
|
3d523345
|
2013-11-19T13:15:47
|
|
tree-cache: Don't segfault upon corruption
|
|
82e6a42c
|
2013-11-19T13:13:51
|
|
tree-cache: Zero out the allocated tree children array
|
|
7b69289f
|
2013-11-19T12:54:57
|
|
tree-cache: Free the tree upon the detection of a corrupted child
|
|
359fc2d2
|
2013-01-08T17:07:25
|
|
update copyrights
|
|
08f3d6ca
|
2012-12-12T19:23:05
|
|
tree cache: loosen negative entry count check
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.
|
|
3f035860
|
2012-06-07T22:43:03
|
|
misc: Fix warnings from PVS Studio trial
|
|
3fbcac89
|
2012-05-02T19:56:38
|
|
Remove old and unused error codes
|
|
2218fd57
|
2012-04-20T02:23:14
|
|
tree-cache: don't error out on a childless invalidated entry
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.
|
|
05862156
|
2012-04-20T02:23:14
|
|
tree-cache: don't error out on a childless invalidated entry
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.
|
|
5e0de328
|
2012-02-13T17:10:24
|
|
Update Copyright header
Signed-off-by: schu <schu-github@schulog.org>
|
|
3286c408
|
2011-10-28T14:51:13
|
|
global: Properly use `git__` memory wrappers
Ensure that all memory related functions (malloc, calloc, strdup, free,
etc) are using their respective `git__` wrappers.
|
|
acd31b4a
|
2011-07-26T12:44:06
|
|
tree cache: correctly handle invalidated trees
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>
|
|
3ba69ba8
|
2011-08-02T15:27:42
|
|
Add git_tree_cache_get
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
|
|
69bffab9
|
2011-07-26T14:58:32
|
|
Add git_tree_cache_invalidate_path
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>
|
|
b183ffe7
|
2011-07-26T12:26:12
|
|
Make tree cache name a flex-array
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
|
|
b4171320
|
2011-07-26T11:34:54
|
|
Move the tree cache functions to their own file
Rename git_index_tree to git_tree_cache.
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
|