Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2013-07-14 12:35:27 +0400
committerJunio C Hamano <gitster@pobox.com>2013-07-15 21:56:06 +0400
commite4d92cdcd9450af7ae4c40de2b7c5c27a1faa138 (patch)
tree109ff87d743706a097a180954113e2036c79af03 /pathspec.c
parentf01d9820e768e7eb9eab4ad9a55a62317e0b23ad (diff)
pathspec: add copy_pathspec
Because free_pathspec wants to free "items" pointer in the pathspec structure, a simple structure assignment is not enough if you want to copy an existing pathspec into another. Freeing the original will damage the copy unless a deep copy is made. Note that the strings in pathspec->items->match and the array pathspec->raw[] are still shared between the original and the copy. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pathspec.c')
-rw-r--r--pathspec.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/pathspec.c b/pathspec.c
index 403095ba8c..8fe56cd8e9 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -249,3 +249,11 @@ const char **get_pathspec(const char *prefix, const char **pathspec)
return NULL;
return pathspec;
}
+
+void copy_pathspec(struct pathspec *dst, const struct pathspec *src)
+{
+ *dst = *src;
+ dst->items = xmalloc(sizeof(struct pathspec_item) * dst->nr);
+ memcpy(dst->items, src->items,
+ sizeof(struct pathspec_item) * dst->nr);
+}