git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jiang Xin <worldhello.net@gmail.com>
Date
Aug 1, 2022, 11:32 UTC
Message-ID
<CANYiYbG28jAZ8Kk17h0gkmmU300b1n917oPtBM_WeFX3QN=VXQ@mail.gmail.com>
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:
Show 28 quoted lines
>
> 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
Show 7 quoted lines
> @@ -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.
Show 6 quoted lines
> +               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;
>  }
Previous: Jiang XinNext: Jiang Xin
Message 22 of 27 in “Fix issues of reference-transaction hook for various git commands”
  1. 0/9 Fix issues of reference-transaction hook for various git commandsJiang Xin, Jul 29, 2022
  2. 2/9 refs: update missing old-oid in transaction from lockfileJiang Xin, Jul 29, 2022
  3. 3/9 refs: add new field in transaction for running transaction hookJiang Xin, Jul 29, 2022
  4. 1/9 t1416: more testcases for reference-transaction hookJiang Xin, Jul 29, 2022
  5. Eric SunshineJul 30, 2022
  6. Jiang XinJul 31, 2022
  7. 4/9 refs: do not run transaction hook for git-pack-refsJiang Xin, Jul 29, 2022
  8. 5/9 refs: avoid duplicate running of the reference-transaction hookJiang Xin, Jul 29, 2022
  9. Michael HeemskerkAug 2, 2022
  10. Jiang XinAug 5, 2022
  11. 0/9 Fix issues of refx-txn hook for various git commandsJiang Xin, Aug 19, 2022
  12. 2/9 refs: update missing old-oid in transaction from lockfileJiang Xin, Aug 19, 2022
  13. 3/9 refs: add new field in transaction for running transaction hookJiang Xin, Aug 19, 2022
  14. 1/9 t1416: more testcases for reference-transaction hookJiang Xin, Aug 19, 2022
  15. 4/9 refs: do not run transaction hook for git-pack-refsJiang Xin, Aug 19, 2022
  16. 5/9 refs: avoid duplicate running of the reference-transaction hookJiang Xin, Aug 19, 2022
  17. 6/9 refs: add reflog_info to hold more fields for reflog entryJiang Xin, Aug 19, 2022
  18. 9/9 refs: reimplement refs_delete_refs() and run hook onceJiang Xin, Aug 19, 2022
  19. 7/9 refs: get error message via refs_update_ref_extended()Jiang Xin, Aug 19, 2022
  20. 8/9 refs: reimplement files_copy_or_rename_ref() to run refs-txn hookJiang Xin, Aug 19, 2022
  21. 6/9 refs: add reflog_info to hold more fields for reflog entryJiang Xin, Jul 29, 2022
  22. Jiang XinAug 1, 2022
  23. 7/9 refs: get error message via refs_update_ref_extended()Jiang Xin, Jul 29, 2022
  24. 8/9 refs: reimplement files_copy_or_rename_ref() to run hookJiang Xin, Jul 29, 2022
  25. 9/9 refs: reimplement refs_delete_refs() and run hook onceJiang Xin, Jul 29, 2022
  26. Michael HeemskerkAug 2, 2022
  27. Patrick SteinhardtAug 9, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.