Re: [PATCH 6/9] refs: add reflog_info to hold more fields for reflog entry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 29, 2022 at 6:12 PM Jiang Xin <worldhello.net@xxxxxxxxx> wrote:
>
> From: Jiang Xin <zhiyou.jx@xxxxxxxxxxxxxxx>
>
> The parameter "msg" of the functions "ref_transaction_add_update()" and
> "refs_update_ref()" is used as a comment for creating a new reflog
> entry. For some cases, like copying or renaming a branch, we may need
> more custom fields for the new reflog entry, such as old-oid which is
> different from the oid we get from the lock file. Therefore, we create
> a new structure "reflog_info" to hold more custom fields for the new
> reflog entry, and add two additional extended version functions.
>
> We will use this extension in a later commit to reimplement
> "files_copy_or_rename_ref()" using "refs_update_ref_extended()" to
> create new reference in a transaction and add proper reflog entry.
>
> Signed-off-by: Jiang Xin <zhiyou.jx@xxxxxxxxxxxxxxx>
> ---
>  refs.c               | 54 +++++++++++++++++++++++++++++++++++++++-----
>  refs.h               | 20 ++++++++++++++++
>  refs/debug.c         |  2 +-
>  refs/files-backend.c | 14 ++++++++----
>  refs/refs-internal.h | 17 ++++++++++++--
>  5 files changed, 94 insertions(+), 13 deletions(-)
>
> diff --git a/refs.c b/refs.c
> index 48b69460e2..e53f011e6b 100644
> --- a/refs.c
> +++ b/refs.c

> @@ -1074,7 +1078,12 @@ struct ref_update *ref_transaction_add_update(
>                 oidcpy(&update->new_oid, new_oid);
>         if (flags & REF_HAVE_OLD)
>                 oidcpy(&update->old_oid, old_oid);
> -       update->msg = normalize_reflog_message(msg);
> +       if (reflog_info) {
> +               update->reflog_info = xmalloc(sizeof(*reflog_info));

Should be:
        update->reflog_info = xcalloc(1, sizeof(*reflog_info));

Will fix in v2.

> +               update->reflog_info->msg = normalize_reflog_message(reflog_info->msg);
> +               if (reflog_info->old_oid)
> +                       update->reflog_info->old_oid = oiddup(reflog_info->old_oid);
> +       }
>         return update;
>  }



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux