summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorVicent Martí <tanoku@gmail.com>2012-04-13 20:06:49 -0700
committerVicent Martí <tanoku@gmail.com>2012-04-13 20:06:49 -0700
commite77e53edb37b7dd603da7758b243ef8e91d9e394 (patch)
tree4c31553a2c971adf579d2c5c287749ce45949c8c /src/util.c
parentd1f331564da9d6110b80b538a501da0c66e59142 (diff)
parent14a513e05866721f5ceba18cf425568d2f6af143 (diff)
downloadlibgit2-e77e53edb37b7dd603da7758b243ef8e91d9e394.tar.gz
Merge pull request #627 from arrbee/diff-with-pathspec
Diff with pathspec
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index d0ad47490..81ad10609 100644
--- a/src/util.c
+++ b/src/util.c
@@ -31,6 +31,35 @@ void git_strarray_free(git_strarray *array)
git__free(array->strings);
}
+int git_strarray_copy(git_strarray *tgt, const git_strarray *src)
+{
+ size_t i;
+
+ assert(tgt && src);
+
+ memset(tgt, 0, sizeof(*tgt));
+
+ if (!src->count)
+ return 0;
+
+ tgt->strings = git__calloc(src->count, sizeof(char *));
+ GITERR_CHECK_ALLOC(tgt->strings);
+
+ for (i = 0; i < src->count; ++i) {
+ tgt->strings[tgt->count] = git__strdup(src->strings[i]);
+
+ if (!tgt->strings[tgt->count]) {
+ git_strarray_free(tgt);
+ memset(tgt, 0, sizeof(*tgt));
+ return -1;
+ }
+
+ tgt->count++;
+ }
+
+ return 0;
+}
+
int git__fnmatch(const char *pattern, const char *name, int flags)
{
int ret;