MCPcopy Create free account
hub / github.com/git/git / reftable_log_record_copy_from

Function reftable_log_record_copy_from

reftable/record.c:696–746  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

694}
695
696static int reftable_log_record_copy_from(void *rec, const void *src_rec,
697 uint32_t hash_size)
698{
699 struct reftable_log_record *dst = rec;
700 const struct reftable_log_record *src =
701 (const struct reftable_log_record *)src_rec;
702 int ret;
703
704 reftable_log_record_release(dst);
705 *dst = *src;
706
707 if (dst->refname) {
708 dst->refname = reftable_strdup(dst->refname);
709 if (!dst->refname) {
710 ret = REFTABLE_OUT_OF_MEMORY_ERROR;
711 goto out;
712 }
713 }
714
715 switch (dst->value_type) {
716 case REFTABLE_LOG_DELETION:
717 break;
718 case REFTABLE_LOG_UPDATE:
719 if (dst->value.update.email)
720 dst->value.update.email =
721 reftable_strdup(dst->value.update.email);
722 if (dst->value.update.name)
723 dst->value.update.name =
724 reftable_strdup(dst->value.update.name);
725 if (dst->value.update.message)
726 dst->value.update.message =
727 reftable_strdup(dst->value.update.message);
728
729 if (!dst->value.update.email ||
730 !dst->value.update.name ||
731 !dst->value.update.message) {
732 ret = REFTABLE_OUT_OF_MEMORY_ERROR;
733 goto out;
734 }
735
736 memcpy(dst->value.update.new_hash,
737 src->value.update.new_hash, hash_size);
738 memcpy(dst->value.update.old_hash,
739 src->value.update.old_hash, hash_size);
740 break;
741 }
742
743 ret = 0;
744out:
745 return ret;
746}
747
748static void reftable_log_record_release_void(void *rec)
749{

Callers

nothing calls this directly

Calls 2

reftable_strdupFunction · 0.85

Tested by

no test coverage detected