From db106d01f093b3e61170e3738d6651a2866cb76e Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 30 Oct 2012 09:40:50 -0700 Subject: Move rename detection into new file This improves the naming for the rename related functionality moving it to be called `git_diff_find_similar()` and renaming all the associated constants, etc. to make more sense. I also moved the new code (plus the existing `git_diff_merge`) into a new file `diff_tform.c` where I can put new functions related to manipulating git diff lists. This also updates the implementation significantly from the last revision fixing some ordering issues (where break-rewrite needs to be handled prior to copy and rename detection) and improving config option handling. --- src/vector.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/vector.c') diff --git a/src/vector.c b/src/vector.c index c6a644cc3..e56b97849 100644 --- a/src/vector.c +++ b/src/vector.c @@ -241,3 +241,33 @@ void git_vector_swap(git_vector *a, git_vector *b) memcpy(a, b, sizeof(t)); memcpy(b, &t, sizeof(t)); } + +int git_vector_resize_to(git_vector *v, size_t new_length) +{ + if (new_length <= v->length) + return 0; + + while (new_length >= v->_alloc_size) + if (resize_vector(v) < 0) + return -1; + + memset(&v->contents[v->length], 0, + sizeof(void *) * (new_length - v->length)); + + v->length = new_length; + + return 0; +} + +int git_vector_set(void **old, git_vector *v, size_t position, void *value) +{ + if (git_vector_resize_to(v, position + 1) < 0) + return -1; + + if (old != NULL) + *old = v->contents[position]; + + v->contents[position] = value; + + return 0; +} -- cgit v1.2.1