diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2021-09-13 11:40:38 -0400 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2021-09-14 09:18:22 -0400 |
commit | aa993f76ca556b06194e7da0f56afcf30cb5ee5e (patch) | |
tree | beff88cfb70c9a6558d5f4b88b433fcd5a1cb736 /src/buffer.c | |
parent | 646bae34c9962d308ea82c5d03f5862d20fcca02 (diff) | |
download | libgit2-aa993f76ca556b06194e7da0f56afcf30cb5ee5e.tar.gz |
buf: introduce `git_buf_truncate_at`
Diffstat (limited to 'src/buffer.c')
-rw-r--r-- | src/buffer.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/buffer.c b/src/buffer.c index ab2a6139a..a57df1284 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -600,6 +600,13 @@ void git_buf_shorten(git_buf *buf, size_t amount) git_buf_clear(buf); } +void git_buf_truncate_at_char(git_buf *buf, char separator) +{ + ssize_t idx = git_buf_find(buf, separator); + if (idx >= 0) + git_buf_truncate(buf, (size_t)idx); +} + void git_buf_rtruncate_at_char(git_buf *buf, char separator) { ssize_t idx = git_buf_rfind_next(buf, separator); |