diff options
| author | Russell Belfer <arrbee@arrbee.com> | 2012-01-16 15:34:35 -0800 |
|---|---|---|
| committer | Russell Belfer <arrbee@arrbee.com> | 2012-01-16 15:34:35 -0800 |
| commit | 6e03b12f5715cb3f5cb5c8be6512e041cdf44a05 (patch) | |
| tree | 8da5a75da0e2013f34bac773fe201b2a989605f5 /src/buffer.c | |
| parent | d9e5430e5a7bd5d2de7c4fee2f1afbd52ec5aa2f (diff) | |
| parent | cfbc880d8a407bcd2074dda4221d337daf72195c (diff) | |
| download | libgit2-6e03b12f5715cb3f5cb5c8be6512e041cdf44a05.tar.gz | |
Merge pull request #531 from arrbee/gitignore
Initial implementation of gitignore support
git_status_foreach() and git_status_file() will now be
gitignore aware.
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/buffer.c b/src/buffer.c index def3496ce..c57e4aa1b 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -111,8 +111,10 @@ int git_buf_set(git_buf *buf, const char *data, size_t len) if (len == 0 || data == NULL) { git_buf_clear(buf); } else { - ENSURE_SIZE(buf, len + 1); - memmove(buf->ptr, data, len); + if (data != buf->ptr) { + ENSURE_SIZE(buf, len + 1); + memmove(buf->ptr, data, len); + } buf->size = len; buf->ptr[buf->size] = '\0'; } @@ -179,7 +181,7 @@ void git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf) { size_t copylen; - assert(data && datasize); + assert(data && datasize && buf); data[0] = '\0'; @@ -205,7 +207,7 @@ void git_buf_consume(git_buf *buf, const char *end) void git_buf_truncate(git_buf *buf, ssize_t len) { - if (len < buf->size) { + if (len >= 0 && len < buf->size) { buf->size = len; buf->ptr[buf->size] = '\0'; } |
