reflog: add GIT_OID_HEX_ZERO constant

This commit is contained in:
nulltoken 2012-07-17 10:53:19 +02:00
parent 1cb157184b
commit 7c458e3aee
3 changed files with 4 additions and 2 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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);