diff options
author | Vicent Martà <tanoku@gmail.com> | 2012-05-05 14:22:06 -0700 |
---|---|---|
committer | Vicent Martà <tanoku@gmail.com> | 2012-05-05 14:22:06 -0700 |
commit | 4ef14af93517b3842bc0dfa24147cf10dd029582 (patch) | |
tree | 88f90fa8c9d903f072a2b1c647c51a9899e520c7 /src/diff.c | |
parent | f95e8cc07c85034f737872455fce2895186be19d (diff) | |
parent | 282283acc65bab9de231a2b3dc489eb171d5f1cf (diff) | |
download | libgit2-development-merge.tar.gz |
Merge pull request #664 from arrbee/attrs-from-indexdevelopment-merge
Support git attrs from index (and bare repo)
Diffstat (limited to 'src/diff.c')
-rw-r--r-- | src/diff.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/diff.c b/src/diff.c index b845f9e8c..524cc9f59 100644 --- a/src/diff.c +++ b/src/diff.c @@ -506,7 +506,7 @@ static int diff_from_iterators( git_diff_list **diff_ptr) { const git_index_entry *oitem, *nitem; - char *ignore_prefix = NULL; + git_buf ignore_prefix = GIT_BUF_INIT; git_diff_list *diff = git_diff_list_alloc(repo, opts); if (!diff) goto fail; @@ -536,8 +536,8 @@ static int diff_from_iterators( git_delta_t delta_type = GIT_DELTA_ADDED; /* contained in ignored parent directory, so this can be skipped. */ - if (ignore_prefix != NULL && - git__prefixcmp(nitem->path, ignore_prefix) == 0) + if (git_buf_len(&ignore_prefix) && + git__prefixcmp(nitem->path, git_buf_cstr(&ignore_prefix)) == 0) { if (git_iterator_advance(new_iter, &nitem) < 0) goto fail; @@ -555,7 +555,7 @@ static int diff_from_iterators( (oitem && git__prefixcmp(oitem->path, nitem->path) == 0)) { if (is_ignored) - ignore_prefix = nitem->path; + git_buf_sets(&ignore_prefix, nitem->path); if (git_iterator_advance_into_directory(new_iter, &nitem) < 0) goto fail; @@ -589,12 +589,16 @@ static int diff_from_iterators( git_iterator_free(old_iter); git_iterator_free(new_iter); + git_buf_free(&ignore_prefix); + *diff_ptr = diff; return 0; fail: git_iterator_free(old_iter); git_iterator_free(new_iter); + git_buf_free(&ignore_prefix); + git_diff_list_free(diff); *diff_ptr = NULL; return -1; |