summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
authorRussell Belfer <arrbee@arrbee.com>2012-01-09 15:37:19 -0800
committerRussell Belfer <arrbee@arrbee.com>2012-01-11 14:39:51 -0800
commitdf743c7d3a04553ffc04ae7cbc64fb300e7f61d2 (patch)
tree7f0dfa714ddb292448cbeaa69f2b5d90a3274d85 /src/buffer.c
parent7e443f696068cd8c84a759e532c2845348e5a6ad (diff)
downloadlibgit2-df743c7d3a04553ffc04ae7cbc64fb300e7f61d2.tar.gz
Initial implementation of gitignore support
Adds support for .gitignore files to git_status_foreach() and git_status_file(). This includes refactoring the gitattributes code to share logic where possible. The GIT_STATUS_IGNORED flag will now be passed in for files that are ignored (provided they are not already in the index or the head of repo).
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/buffer.c b/src/buffer.c
index def3496ce..b6854258b 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';
}
@@ -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';
}