diff options
author | Russell Belfer <rb@github.com> | 2013-01-30 23:10:39 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-01-30 23:10:39 +0400 |
commit | f1e2735c74d03105592a282e2c32f45033db0e8d (patch) | |
tree | 6bb4ac08b1b90022c61339db67fd5949dc6fced8 /src/buffer.h | |
parent | d2041216578de4e6fbb466d439fac5de7f35caf3 (diff) |
Add helper for diff line stats
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.
Diffstat (limited to 'src/buffer.h')
-rw-r--r-- | src/buffer.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/buffer.h b/src/buffer.h index 4efd240b5..6e73895b4 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -134,6 +134,13 @@ GIT_INLINE(ssize_t) git_buf_rfind(git_buf *buf, char ch) return idx; } +GIT_INLINE(ssize_t) git_buf_find(git_buf *buf, char ch) +{ + size_t idx = 0; + while (idx < buf->size && buf->ptr[idx] != ch) idx++; + return (idx == buf->size) ? -1 : (ssize_t)idx; +} + /* Remove whitespace from the end of the buffer */ void git_buf_rtrim(git_buf *buf); |