diff options
author | Russell Belfer <arrbee@arrbee.com> | 2012-02-21 14:46:24 -0800 |
---|---|---|
committer | Russell Belfer <arrbee@arrbee.com> | 2012-02-21 14:46:24 -0800 |
commit | b6c93aef4276051f9c4536ecbed48f4cd093bd1b (patch) | |
tree | a15962c672890c0c8cc021dafa7d29487f81c75a /src/buffer.c | |
parent | 9c94a356cc61daa85e17c6342db9b3d62f788802 (diff) | |
download | libgit2-b6c93aef4276051f9c4536ecbed48f4cd093bd1b.tar.gz |
Uniform iterators for trees, index, and workdir
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.
Diffstat (limited to 'src/buffer.c')
-rw-r--r-- | src/buffer.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/buffer.c b/src/buffer.c index 7a186ebd8..183da7c5f 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -213,6 +213,12 @@ void git_buf_truncate(git_buf *buf, ssize_t len) } } +void git_buf_rtruncate_at_char(git_buf *buf, char separator) +{ + int idx = git_buf_rfind_next(buf, separator); + git_buf_truncate(buf, idx < 0 ? 0 : idx); +} + void git_buf_swap(git_buf *buf_a, git_buf *buf_b) { git_buf t = *buf_a; @@ -327,7 +333,7 @@ int git_buf_join( const char *str_b) { int error = GIT_SUCCESS; - size_t strlen_a = strlen(str_a); + size_t strlen_a = str_a ? strlen(str_a) : 0; size_t strlen_b = strlen(str_b); int need_sep = 0; ssize_t offset_a = -1; |