From: Jiang Xin <worldhello.net@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
Patrick Steinhardt <ps@pks.im>, Git List <git@vger.kernel.org>
Cc: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Subject: Re: [PATCH 6/9] refs: add reflog_info to hold more fields for reflog entry
Date: Mon, 1 Aug 2022 19:32:44 +0800 [thread overview]
Message-ID: <CANYiYbG28jAZ8Kk17h0gkmmU300b1n917oPtBM_WeFX3QN=VXQ@mail.gmail.com> (raw)
In-Reply-To: <20220729101245.6469-7-worldhello.net@gmail.com>
On Fri, Jul 29, 2022 at 6:12 PM Jiang Xin <worldhello.net@gmail.com> wrote:
>
> From: Jiang Xin <zhiyou.jx@alibaba-inc.com>
>
> 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@alibaba-inc.com>
> ---
> 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;
> }
next prev parent reply other threads:[~2022-08-01 11:33 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-29 10:12 [PATCH 0/9] Fix issues of reference-transaction hook for various git commands Jiang Xin
2022-07-29 10:12 ` [PATCH 1/9] t1416: more testcases for reference-transaction hook Jiang Xin
2022-07-30 6:44 ` Eric Sunshine
2022-07-31 3:25 ` Jiang Xin
2022-07-29 10:12 ` [PATCH 2/9] refs: update missing old-oid in transaction from lockfile Jiang Xin
2022-07-29 10:12 ` [PATCH 3/9] refs: add new field in transaction for running transaction hook Jiang Xin
2022-07-29 10:12 ` [PATCH 4/9] refs: do not run transaction hook for git-pack-refs Jiang Xin
2022-07-29 10:12 ` [PATCH 5/9] refs: avoid duplicate running of the reference-transaction hook Jiang Xin
2022-08-02 12:18 ` Michael Heemskerk
2022-08-05 1:41 ` Jiang Xin
2022-08-19 3:21 ` [PATCH v2 0/9] Fix issues of refx-txn hook for various git commands Jiang Xin
2022-08-19 3:21 ` [PATCH v2 1/9] t1416: more testcases for reference-transaction hook Jiang Xin
2022-08-19 3:21 ` [PATCH v2 2/9] refs: update missing old-oid in transaction from lockfile Jiang Xin
2022-08-19 3:21 ` [PATCH v2 3/9] refs: add new field in transaction for running transaction hook Jiang Xin
2022-08-19 3:21 ` [PATCH v2 4/9] refs: do not run transaction hook for git-pack-refs Jiang Xin
2022-08-19 3:21 ` [PATCH v2 5/9] refs: avoid duplicate running of the reference-transaction hook Jiang Xin
2022-08-19 3:21 ` [PATCH v2 6/9] refs: add reflog_info to hold more fields for reflog entry Jiang Xin
2022-08-19 3:21 ` [PATCH v2 7/9] refs: get error message via refs_update_ref_extended() Jiang Xin
2022-08-19 3:21 ` [PATCH v2 8/9] refs: reimplement files_copy_or_rename_ref() to run refs-txn hook Jiang Xin
2022-08-19 3:21 ` [PATCH v2 9/9] refs: reimplement refs_delete_refs() and run hook once Jiang Xin
2022-07-29 10:12 ` [PATCH 6/9] refs: add reflog_info to hold more fields for reflog entry Jiang Xin
2022-08-01 11:32 ` Jiang Xin [this message]
2022-07-29 10:12 ` [PATCH 7/9] refs: get error message via refs_update_ref_extended() Jiang Xin
2022-07-29 10:12 ` [PATCH 8/9] refs: reimplement files_copy_or_rename_ref() to run hook Jiang Xin
2022-07-29 10:12 ` [PATCH 9/9] refs: reimplement refs_delete_refs() and run hook once Jiang Xin
2022-08-02 12:42 ` Michael Heemskerk
2022-08-09 11:05 ` Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CANYiYbG28jAZ8Kk17h0gkmmU300b1n917oPtBM_WeFX3QN=VXQ@mail.gmail.com' \
--to=worldhello.net@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ps@pks.im \
--cc=zhiyou.jx@alibaba-inc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).