From a46ec45746f965f2895098e058979225d92d66e5 Mon Sep 17 00:00:00 2001 From: schu Date: Wed, 10 Aug 2011 16:19:42 +0200 Subject: refs: split internal and external references Currently libgit2 shares pointers to its internal reference cache with the user. This leads to several problems like invalidation of reference pointers when reordering the cache or manipulation of the cache from user side. Give each user its own git_reference instead of leaking the internal representation (struct reference). Add the following new API functions: * git_reference_free * git_reference_is_packed Signed-off-by: schu --- src/commit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/commit.c') diff --git a/src/commit.c b/src/commit.c index b9eb3650f..1010fdc56 100644 --- a/src/commit.c +++ b/src/commit.c @@ -137,12 +137,13 @@ int git_commit_create( if (error == GIT_SUCCESS && update_ref != NULL) { git_reference *head; + git_reference *target; error = git_reference_lookup(&head, repo, update_ref); if (error < GIT_SUCCESS) return git__rethrow(error, "Failed to create commit"); - error = git_reference_resolve(&head, head); + error = git_reference_resolve(&target, head); if (error < GIT_SUCCESS) { if (error != GIT_ENOTFOUND) return git__rethrow(error, "Failed to create commit"); @@ -156,7 +157,7 @@ int git_commit_create( return git_reference_create_oid(&head, repo, git_reference_target(head), oid, 1); } - error = git_reference_set_oid(head, oid); + error = git_reference_set_oid(target, oid); } if (error < GIT_SUCCESS) -- cgit v1.2.1