summaryrefslogtreecommitdiff
path: root/unpack-trees.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2013-06-02 17:46:53 +0200
committerJunio C Hamano <gitster@pobox.com>2013-06-02 15:31:13 -0700
commita33bd4d34def15d12372aeb8c59a7465416f9f66 (patch)
tree5b20ead91c71719b6a60aa1e2875fd11dd8af7ca /unpack-trees.c
parent21a6b9fa4212277d925b789795e83ac96c2aaa01 (diff)
downloadgit-a33bd4d34def15d12372aeb8c59a7465416f9f66.tar.gz
unpack-trees: factor out dup_entry
While we're add it, mark the struct cache_entry pointer of add_entry const because we only read from it and this allows callers to pass in const pointers. Signed-off-by: René Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'unpack-trees.c')
-rw-r--r--unpack-trees.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index ede4299b83..e8b4cc1986 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -116,14 +116,20 @@ static void do_add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
}
-static void add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
- unsigned int set, unsigned int clear)
+static struct cache_entry *dup_entry(const struct cache_entry *ce)
{
unsigned int size = ce_size(ce);
struct cache_entry *new = xmalloc(size);
memcpy(new, ce, size);
- do_add_entry(o, new, set, clear);
+ return new;
+}
+
+static void add_entry(struct unpack_trees_options *o,
+ const struct cache_entry *ce,
+ unsigned int set, unsigned int clear)
+{
+ do_add_entry(o, dup_entry(ce), set, clear);
}
/*