summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-11-06 02:52:43 +0100
committerVicent Marti <tanoku@gmail.com>2011-11-06 03:15:38 +0100
commit62dd6d1637e40f9fa16005ef447d4fc6f8fb25e8 (patch)
tree8bc75b2e2c09f7af9f1f600fc25117b09c9d2f00
parentd4a0b124d00c70933d7c6ac9065c401cc2d70b2e (diff)
downloadlibgit2-new-references.tar.gz
reflog: Do not free references before timenew-references
-rw-r--r--src/reflog.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/reflog.c b/src/reflog.c
index 81e171acf..e0fa7a060 100644
--- a/src/reflog.c
+++ b/src/reflog.c
@@ -215,27 +215,37 @@ int git_reflog_write(git_reference *ref, const git_oid *oid_old,
const git_oid *oid;
if ((error = git_reference_resolve(&r, ref)) < GIT_SUCCESS)
- return git__rethrow(error, "Failed to write reflog. Cannot resolve reference `%s`", ref->name);
+ return git__rethrow(error,
+ "Failed to write reflog. Cannot resolve reference `%s`", ref->name);
oid = git_reference_oid(r);
if (oid == NULL) {
git_reference_free(r);
- return git__throw(GIT_ERROR, "Failed to write reflog. Cannot resolve reference `%s`", r->name);
+ return git__throw(GIT_ERROR,
+ "Failed to write reflog. Cannot resolve reference `%s`", r->name);
}
- git_reference_free(r);
-
git_oid_to_string(new, GIT_OID_HEXSZ+1, oid);
- git_path_join_n(log_path, 3, ref->owner->path_repository, GIT_REFLOG_DIR, ref->name);
+ git_path_join_n(log_path, 3,
+ ref->owner->path_repository, GIT_REFLOG_DIR, ref->name);
+
+ git_reference_free(r);
if (git_futils_exists(log_path)) {
- if ((error = git_futils_mkpath2file(log_path, GIT_REFLOG_DIR_MODE)) < GIT_SUCCESS)
- return git__rethrow(error, "Failed to write reflog. Cannot create reflog directory");
+ error = git_futils_mkpath2file(log_path, GIT_REFLOG_DIR_MODE);
+ if (error < GIT_SUCCESS)
+ return git__rethrow(error,
+ "Failed to write reflog. Cannot create reflog directory");
+
} else if (git_futils_isfile(log_path)) {
- return git__throw(GIT_ERROR, "Failed to write reflog. `%s` is directory", log_path);
- } else if (oid_old == NULL)
- return git__throw(GIT_ERROR, "Failed to write reflog. Old OID cannot be NULL for existing reference");
+ return git__throw(GIT_ERROR,
+ "Failed to write reflog. `%s` is directory", log_path);
+
+ } else if (oid_old == NULL) {
+ return git__throw(GIT_ERROR,
+ "Failed to write reflog. Old OID cannot be NULL for existing reference");
+ }
if (oid_old)
git_oid_to_string(old, GIT_OID_HEXSZ+1, oid_old);