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

Re: [PATCH 5/9] refs: avoid duplicate running of the reference-transaction hook

From
Jiang Xin <worldhello.net@gmail.com>
Date
Aug 5, 2022, 01:41 UTC
Message-ID
<CANYiYbFw71bX827akAG87RSKOozPk313Hoe573O9dQ65_U6sLQ@mail.gmail.com>
In-Reply-To
<CAJDSCnOFSnhOU06UHF6T9RT31Gq56BhJn5fQ4_ys2ERrN1stSw@mail.gmail.com>

On Tue, Aug 2, 2022 at 8:18 PM Michael Heemskerk <mheemskerk@atlassian.com> wrote:

Show 21 quoted lines
>
> On Fri, Jul 29, 2022 at 12:20 PM Jiang Xin <worldhello.net@gmail.com> wrote:
> >
> > From: Jiang Xin <zhiyou.jx@alibaba-inc.com>
> >
> > If there are references to be deleted in a transaction, we should remove
> > each reference from both loose references and the "packed-refs" file.
> > The "reference-transaction" hook will run twice, once for the primary
> > ref-store (loose references), and another for the second ref-store (i.e.
> > packed ref-store).
> >
> > To avoid duplicate running of the "reference-trancaction" hook, we pass
> > a special "hook-flags" parameter to initialize the second ref-store.
> > The "REF_TRANSACTION_RUN_PREPARED_HOOK" bit is preserved for the
> > transaction of the second ref-store because we may still want to call
> > command "reference-trancaction prepared" for some pre-checks, such as
> > terminate unwanted transaction for the "packed-refs" file.
>
> Can you elaborate on the rationale for continuing to invoke the "prepared"
> reference-transaction hook for the "packed-refs" file? Did you have a specific
> type of check in mind?

Use "reference-transaction prepared" hook command, we can implement write lock for repositories. We can create a lock file (e.g. "site.lock") inside a repository or in a parent directory to disable write operations for one repository, a group of repositories or all repositories. The magic is in the "reference-transaction prepared" hook command. As a transaction may be triggered twice, one for packed-refs, and one for loose-refs, we should make sure the "reference-transaction prepared" command must run for both transactions on different ref-stores.

BTW, I'm on vacation for the next few days and I will pick up this topic next week.

-- Jiang Xin

Previous: Michael HeemskerkNext: Jiang Xin
Message 10 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.