summaryrefslogtreecommitdiff
path: root/src/buffer.h
Commit message (Collapse)AuthorAgeFilesLines
* buf: introduce `git_buf_truncate_at`Edward Thomson2021-09-141-0/+1
|
* buf: deprecate public git_buf writing functionsethomson/buf_is_readonlyEdward Thomson2021-08-291-0/+59
| | | | | | | | | | A `git_buf` is now a read-only structure as far as callers are concerned. This is a mechanism that we can return data to callers using memory that is owned by the library and can be cleaned up by callers (using `git_buf_dispose`). A `git_buf` can no longer be allocated by callers or provided to the library.
* buf: bom enum is in the buf namespaceEdward Thomson2021-05-111-9/+9
| | | | | Instead of a `git_bom_t` that a `git_buf` function returns, let's keep it `git_buf_bom_t`.
* buf: remove internal `git_buf_text` namespaceEdward Thomson2021-05-111-0/+92
| | | | | The `git_buf_text` namespace is unnecessary and strange. Remove it, just keep the functions prefixed with `git_buf`.
* buffer: git_buf_copy_cstr should return a valueEdward Thomson2020-11-251-1/+1
| | | | | | `git_buf_copy_cstr` is called with user-input, and wants to sanity-check that input. Allow it to return a value if the input was malformed in a way that we cannot cope.
* buffer: git_buf_sanitize should return a valueEdward Thomson2020-11-251-1/+1
| | | | | | `git_buf_sanitize` is called with user-input, and wants to sanity-check that input. Allow it to return a value if the input was malformed in a way that we cannot cope.
* buf: add consume_bytesEdward Thomson2020-01-241-0/+1
| | | | | Allow users to consume a buffer by the number of bytes, not just to an ending pointer.
* Fix last references to deprecated git_buf_freeSven Strickroth2018-06-181-1/+1
| | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* Introduce `git_buf_decode_percent`Edward Thomson2018-03-191-0/+3
| | | | | Introduce a function to take a percent-encoded string (URI encoded, described by RFC 1738) and decode it into a `git_buf`.
* buffer: return errors for `git_buf_init` and `git_buf_attach`Patrick Steinhardt2017-06-081-2/+2
| | | | | | | | | | Both the `git_buf_init` and `git_buf_attach` functions may call `git_buf_grow` in case they were given an allocation length as parameter. As such, it is possible for these functions to fail when we run out of memory. While it won't probably be used anytime soon, it does indeed make sense to also record this fact by returning an error code from both functions. As they belong to the internal API only, this change does not break our interface.
* buffer: clarify how `git_buf_sanitize` handles non-NULL inputPatrick Steinhardt2017-02-131-1/+2
| | | | | | | | | | | When `git_buf_sanitize` gets called, it converts a buffer with NULL content to be correctly initialized. This is done by pointing it to `git_buf__initbuf`. While the method's documentation states this clearly, it may also lead to the conclusion that it will do the same to buffers which do _not_ have NULL contents. Clarify behavior when passing a buffer with non-NULL contents, where `git_buf_sanitize` will ensure that the contents are `\0`-terminated.
* git_buf_quote: quote ugly charactersEdward Thomson2016-05-261-1/+2
|
* git_buf: decode base85 inputsEdward Thomson2016-05-261-0/+2
|
* Patch parsing from patch filesEdward Thomson2016-05-261-0/+5
|
* buffer: don't allow growing borrowed buffersCarlos Martín Nieto2015-06-241-1/+1
| | | | | | | | | | When we don't own a buffer (asize=0) we currently allow the usage of grow to copy the memory into a buffer we do own. This muddles the meaning of grow, and lets us be a bit cavalier with ownership semantics. Don't allow this any more. Usage of grow should be restricted to buffers which we know own their own memory. If unsure, we must not attempt to modify it.
* buffer: introduce git_buf_attach_notownedEdward Thomson2015-02-191-0/+6
| | | | | | Provide a convenience function that creates a buffer that can be provided to callers but will not be freed via `git_buf_free`, so the buffer creator maintains the allocation lifecycle of the buffer's contents.
* git_buf_grow_by: increase buf asize incrementallyEdward Thomson2015-02-121-0/+12
| | | | | Introduce `git_buf_grow_by` to incrementally increase the size of a `git_buf`, performing an overflow calculation on the growth.
* Introduce git_buf_decode_base64Edward Thomson2014-08-151-2/+4
| | | | Decode base64-encoded text into a git_buf
* patch: emit binary patches (optionally)Edward Thomson2014-04-221-0/+3
|
* Introduce git_buf_putcnJacques Germishuys2014-04-101-0/+1
| | | | Allows for inserting the same character n amount of times
* Add efficient git_buf join3 APIRussell Belfer2014-04-011-0/+4
| | | | | | | There are a few places where we need to join three strings to assemble a path. This adds a simple join3 function to avoid the comparatively expensive join_n (which calls strlen on each string twice).
* Remove now-duplicated stdarg.h includeEdward Thomson2014-02-241-2/+0
|
* Handle git_buf's from users more liberallyEdward Thomson2014-01-081-0/+9
|
* Clean up warningsEdward Thomson2013-12-091-1/+2
|
* Merge git_buf and git_bufferRussell Belfer2013-09-171-48/+17
| | | | | | | | | | | This makes the git_buf struct that was used internally into an externally available structure and eliminates the git_buffer. As part of that, some of the special cases that arose with the externally used git_buffer were blended into the git_buf, such as being careful about git_buf objects that may have a NULL ptr and allowing for bufs with a valid ptr and size but zero asize as a way of referring to externally owned data.
* Extend public filter api with filter listsRussell Belfer2013-09-171-0/+5
| | | | | | | | | | | This moves the git_filter_list into the public API so that users can create, apply, and dispose of filter lists. This allows more granular application of filters to user data outside of libgit2 internals. This also converts all the internal usage of filters to the public APIs along with a few small tweaks to make it easier to use the public git_buffer stuff alongside the internal git_buf.
* Create public filter object and use itRussell Belfer2013-09-171-0/+22
| | | | | | | This creates include/sys/filter.h with a basic definition of a git_filter and then converts the internal code to use it. There are related internal objects (git_filter_list) that we will want to publish at some point, but this is a first step.
* Add helpful buffer shorten functionRussell Belfer2013-07-011-0/+1
|
* Add const to some buffer functionsRussell Belfer2013-03-061-6/+5
|
* Add helper for diff line statsRussell Belfer2013-01-301-0/+7
| | | | | | | | | | | | This adds a `git_diff_patch_line_stats()` API that gets the total number of adds, deletes, and context lines in a patch. This will make it a little easier to emulate `git diff --stat` and the like. Right now, this relies on generating the `git_diff_patch` object, which is a pretty heavyweight way to get stat information. At some future point, it would probably be nice to be able to get this information without allocating the entire `git_diff_patch`, but that's a much larger project.
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Consolidate text buffer functionsRussell Belfer2012-11-281-36/+20
| | | | | | | | | | | | | There are many scattered functions that look into the contents of buffers to do various text manipulations (such as escaping or unescaping data, calculating text stats, guessing if content is binary, etc). This groups all those functions together into a new file and converts the code to use that. This has two enhancements to existing functionality. The old text stats function is significantly rewritten and the BOM detection code was extended (although largely we can't deal with anything other than a UTF8 BOM).
* buf: introduce git_buf_splice()nulltoken2012-10-251-0/+25
|
* Separated git_strarray from common.h. Added doxy comments.Paul Thompson2012-10-111-0/+1
|
* Add git_buf_put_base64 to buffer APIRussell Belfer2012-10-101-0/+3
|
* Add git_buf_unescape and git__unescape to unescape all characters in a ↵yorah2012-07-241-0/+3
| | | | string (in-place)
* Add a couple of useful git_buf utilitiesRussell Belfer2012-07-101-0/+19
| | | | | | | * `git_buf_rfind` (with tests and tests for `git_buf_rfind_next`) * `git_buf_puts_escaped` and `git_buf_puts_escaped_regex` (with tests) to copy strings into a buffer while injecting an escape sequence (e.g. '\') in front of particular characters.
* Other optimization and warning fixesRussell Belfer2012-05-171-3/+7
| | | | | This fixes a warning left by the earlier optimization and addresses one of the other hotspots identified by GProf.
* Optimize away git_text_gather_stats in diffRussell Belfer2012-05-171-0/+3
| | | | | | | | GProf shows `git_text_gather_stats` as the most expensive call in large diffs. The function calculates a lot of information that is not actually used and does not do so in a optimal order. This introduces a tuned `git_buf_is_binary` function that executes the same algorithm in a fraction of the time.
* Document git_buf_common_prefixRussell Belfer2012-05-151-0/+1
| | | | | This function fills in a git_buf with the common prefix of an array of strings, but let's make that a little more clear.
* Ranged iterators and rewritten git_status_fileRussell Belfer2012-05-151-0/+2
| | | | | | | | | | | | | | | | | | | | | The goal of this work is to rewrite git_status_file to use the same underlying code as git_status_foreach. This is done in 3 phases: 1. Extend iterators to allow ranged iteration with start and end prefixes for the range of file names to be covered. 2. Improve diff so that when there is a pathspec and there is a common non-wildcard prefix of the pathspec, it will use ranged iterators to minimize excess iteration. 3. Rewrite git_status_file to call git_status_foreach_ext with a pathspec that covers just the one file being checked. Since ranged iterators underlie the status & diff implementation, this is actually fairly efficient. The workdir iterator does end up loading the contents of all the directories down to the single file, which should ideally be avoided, but it is pretty good.
* compat: Add `stdarg.h` includeVicent Martí2012-05-051-0/+1
|
* buffer: Add `git_buf_vprintf`Vicent Martí2012-05-031-0/+1
|
* buf: add git_buf_len() accessor to expose the current length of the buffer ↵nulltoken2012-04-291-1/+6
| | | | content
* Convert attr, ignore, mwindow, status to new errorsRussell Belfer2012-03-161-8/+8
| | | | | Also cleaned up some previously converted code that still had little things to polish.
* Continue error conversionRussell Belfer2012-03-141-2/+2
| | | | | | | This converts blob.c, fileops.c, and all of the win32 files. Also, various minor cleanups throughout the code. Plus, in testing the win32 build, I cleaned up a bunch (although not all) of the warnings with the 64-bit build.
* error-handling: RepositoryVicent Martí2012-03-071-8/+3
| | | | | | | | This also includes droping `git_buf_lasterror` because it makes no sense in the new system. Note that in most of the places were it has been dropped, the code needs cleanup. I.e. GIT_ENOMEM is going away, so instead it should return a generic `-1` and obviously not throw anything.
* Add filter tests and fix some bugsRussell Belfer2012-03-021-0/+2
| | | | | This adds some initial unit tests for file filtering and fixes some simple bugs in filter application.
* buffer: Unify `git_fbuffer` and `git_buf`Vicent Martí2012-02-271-3/+6
| | | | | | | | | | | | | | This makes so much sense that I can't believe it hasn't been done before. Kill the old `git_fbuffer` and read files straight into `git_buf` objects. Also: In order to fully support 4GB files in 32-bit systems, the `git_buf` implementation has been changed from using `ssize_t` for storage and storing negative values on allocation failure, to using `size_t` and changing the buffer pointer to a magical pointer on allocation failure. Hopefully this won't break anything.
* Uniform iterators for trees, index, and workdirRussell Belfer2012-02-211-0/+1
| | | | | | | | | | | | | | | This create a new git_iterator type of object that provides a uniform interface for iterating over the index, an arbitrary tree, or the working directory of a repository. As part of this, git ignore support was extended to support push and pop of directory-based ignore files as the working directory is being traversed (so the array of ignores does not have to be recreated at each directory during traveral). There are a number of other small utility functions in buffer, path, vector, and fileops that are included in this patch that made the iterator implementation cleaner.