summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2012-07-17 10:53:19 +0200
committernulltoken <emeric.fermas@gmail.com>2012-07-25 07:53:27 +0200
commit7c458e3aee7b39bfec368456d494972fe9ae244b (patch)
tree03c3115e072c1c08e54a16abb4808b55b4e32b7e
parent1cb157184b6547b613a008455ba386425bb38a23 (diff)
downloadlibgit2-7c458e3aee7b39bfec368456d494972fe9ae244b.tar.gz
reflog: add GIT_OID_HEX_ZERO constant
-rw-r--r--src/reflog.c2
-rw-r--r--src/reflog.h2
-rw-r--r--tests-clar/refs/reflog/reflog.c2
3 files changed, 4 insertions, 2 deletions
diff --git a/src/reflog.c b/src/reflog.c
index 004ba936d..0e0758381 100644
--- a/src/reflog.c
+++ b/src/reflog.c
@@ -258,7 +258,7 @@ int git_reflog_write(git_reference *ref, const git_oid *oid_old,
if (oid_old)
git_oid_tostr(old, sizeof(old), oid_old);
else
- p_snprintf(old, sizeof(old), "%0*d", GIT_OID_HEXSZ, 0);
+ memmove(old, GIT_OID_HEX_ZERO, sizeof(old));
error = reflog_write(log_path.ptr, old, new, committer, msg);
diff --git a/src/reflog.h b/src/reflog.h
index 33cf0776c..fe2891909 100644
--- a/src/reflog.h
+++ b/src/reflog.h
@@ -17,6 +17,8 @@
#define GIT_REFLOG_SIZE_MIN (2*GIT_OID_HEXSZ+2+17)
+#define GIT_OID_HEX_ZERO "0000000000000000000000000000000000000000"
+
struct git_reflog_entry {
git_oid oid_old;
git_oid oid_cur;
diff --git a/tests-clar/refs/reflog/reflog.c b/tests-clar/refs/reflog/reflog.c
index 45da8c338..fb69dd2f1 100644
--- a/tests-clar/refs/reflog/reflog.c
+++ b/tests-clar/refs/reflog/reflog.c
@@ -73,7 +73,7 @@ void test_refs_reflog_reflog__write_then_read(void)
entry = (git_reflog_entry *)git_vector_get(&reflog->entries, 0);
assert_signature(committer, entry->committer);
git_oid_tostr(oid_str, GIT_OID_HEXSZ+1, &entry->oid_old);
- cl_assert_equal_s("0000000000000000000000000000000000000000", oid_str);
+ cl_assert_equal_s(GIT_OID_HEX_ZERO, oid_str);
git_oid_tostr(oid_str, GIT_OID_HEXSZ+1, &entry->oid_cur);
cl_assert_equal_s(current_master_tip, oid_str);
cl_assert(entry->msg == NULL);