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

[PATCH v4 00/11] fix "git reflog expire" race & get rid of EISDIR in refs API

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jul 26, 2021, 23:44 UTC
Message-ID
<cover-00.11-0000000000-20210726T234237Z-avarab@gmail.com>
In-Reply-To
<cover-00.12-00000000000-20210720T102051Z-avarab@gmail.com>

This version hopefully addresses the weirdness of passing the lock->old_oid as the "oid". We still do so, but the "refs API: pass the "lock OID" to reflog "prepare"" and its change from s/const// is gone, instead the relevant (and much smaller) part of that is squashed into the "reflog expire: don't lock reflogs using previously seen OID" change.

Ævar Arnfjörð Bjarmason (11):
  refs/packet: add missing BUG() invocations to reflog callbacks
  refs/files: remove unused REF_DELETING in lock_ref_oid_basic()
  refs/files: remove unused "extras/skip" in lock_ref_oid_basic()
  refs/files: remove unused "skip" in lock_raw_ref() too
  refs/debug: re-indent argument list for "prepare"
  refs: make repo_dwim_log() accept a NULL oid
  refs/files: add a comment about refs_reflog_exists() call
  reflog expire: don't lock reflogs using previously seen OID
  refs/files: remove unused "oid" in lock_ref_oid_basic()
  refs/files: remove unused "errno == EISDIR" code
  refs/files: remove unused "errno != ENOTDIR" condition
 builtin/reflog.c      |  13 ++---
 reflog-walk.c         |   3 +-
 refs.c                |   5 +-
 refs.h                |   2 +-
 refs/debug.c          |   4 +-
 refs/files-backend.c  | 130 ++++++++++++------------------------------
 refs/packed-backend.c |   5 ++
 7 files changed, 53 insertions(+), 109 deletions(-)
Range-diff against v3:
 1:  737d2d8c3d =  1:  92fc3af072 refs/packet: add missing BUG() invocations to reflog callbacks
 2:  dfb9e34076 =  2:  67cd2331fb refs/files: remove unused REF_DELETING in lock_ref_oid_basic()
 3:  0f2262fec6 =  3:  7d76514b55 refs/files: remove unused "extras/skip" in lock_ref_oid_basic()
 4:  7fb7ff9749 =  4:  852f86e666 refs/files: remove unused "skip" in lock_raw_ref() too
 5:  4e526c34aa =  5:  685b48328a refs/debug: re-indent argument list for "prepare"
 6:  295594fe8a <  -:  ---------- refs API: pass the "lock OID" to reflog "prepare"
 7:  e45ec439db =  6:  b75e7673d7 refs: make repo_dwim_log() accept a NULL oid
 8:  8ae8e5ac02 =  7:  7fe6c9bd92 refs/files: add a comment about refs_reflog_exists() call
 9:  1050743e27 !  8:  c9c2da3599 reflog expire: don't lock reflogs using previously seen OID
    @@ Commit message
         [3].
     
         I'm leaving behind now-unused code the refs API etc. that takes the
    -    now-NULL "oid" argument, and other code that can be simplified now
    +    now-NULL "unused_oid" argument, and other code that can be simplified now
         that we never have on OID in that context, that'll be cleaned up in
         subsequent commits, but for now let's narrowly focus on fixing the
         "git gc" issue. As the modified assert() shows we always pass a NULL
    @@ builtin/reflog.c: static int cmd_reflog_delete(int argc, const char **argv, cons
      					should_expire_reflog_ent,
      					reflog_expiry_cleanup,
     
    + ## refs.h ##
    +@@ refs.h: enum expire_reflog_flags {
    +  * expiration policy that is desired.
    +  *
    +  * reflog_expiry_prepare_fn -- Called once after the reference is
    +- *     locked.
    ++ *     locked. Called with the OID of the locked reference.
    +  *
    +  * reflog_expiry_should_prune_fn -- Called once for each entry in the
    +  *     existing reflog. It should return true iff that entry should be
    +
      ## refs/files-backend.c ##
    +@@ refs/files-backend.c: static int expire_reflog_ent(struct object_id *ooid, struct object_id *noid,
    + }
    + 
    + static int files_reflog_expire(struct ref_store *ref_store,
    +-			       const char *refname, const struct object_id *oid,
    ++			       const char *refname, const struct object_id *unused_oid,
    + 			       unsigned int flags,
    + 			       reflog_expiry_prepare_fn prepare_fn,
    + 			       reflog_expiry_should_prune_fn should_prune_fn,
    +@@ refs/files-backend.c: static int files_reflog_expire(struct ref_store *ref_store,
    + 	int status = 0;
    + 	int type;
    + 	struct strbuf err = STRBUF_INIT;
    ++	const struct object_id *oid;
    + 
    + 	memset(&cb, 0, sizeof(cb));
    + 	cb.flags = flags;
     @@ refs/files-backend.c: static int files_reflog_expire(struct ref_store *ref_store,
      	 * reference itself, plus we might need to update the
      	 * reference if --updateref was specified:
    @@ refs/files-backend.c: static int files_reflog_expire(struct ref_store *ref_store
      				  REF_NO_DEREF,
      				  &type, &err);
      	if (!lock) {
    +@@ refs/files-backend.c: static int files_reflog_expire(struct ref_store *ref_store,
    + 		strbuf_release(&err);
    + 		return -1;
    + 	}
    ++	oid = &lock->old_oid;
    + 
    + 	/*
    + 	 * When refs are deleted, their reflog is deleted before the
     @@ refs/files-backend.c: static int files_reflog_expire(struct ref_store *ref_store,
      		}
      	}
      
    --	assert(oideq(&lock->old_oid, oid));
    -+	assert(!oid);
    - 	(*prepare_fn)(refname, &lock->old_oid, cb.policy_cb);
    ++	assert(!unused_oid);
    + 	(*prepare_fn)(refname, oid, cb.policy_cb);
      	refs_for_each_reflog_ent(ref_store, refname, expire_reflog_ent, &cb);
      	(*cleanup_fn)(cb.policy_cb);
10:  753c20f89b =  9:  b61c734cf5 refs/files: remove unused "oid" in lock_ref_oid_basic()
11:  8a71bbef97 = 10:  009abc9968 refs/files: remove unused "errno == EISDIR" code
12:  452253d597 = 11:  acb131cc1c refs/files: remove unused "errno != ENOTDIR" condition
-- 
2.32.0.956.g6b0c84ceda8
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 57 of 88 in “refs file backend: remove dead "errno == EISDIR" code”
  1. refs file backend: remove dead "errno == EISDIR" codeÆvar Arnfjörð Bjarmason, Jul 14, 2021
  2. Jeff KingJul 14, 2021
  3. Ævar Arnfjörð BjarmasonJul 14, 2021
  4. Jeff KingJul 14, 2021
  5. Ævar Arnfjörð BjarmasonJul 15, 2021
  6. Jeff KingJul 15, 2021
  7. Junio C HamanoJul 17, 2021
  8. Jeff KingJul 17, 2021
  9. Junio C HamanoJul 19, 2021
  10. Junio C HamanoJul 19, 2021
  11. Ævar Arnfjörð BjarmasonJul 17, 2021
  12. 00/11 fix "git reflog expire" race & get rid of EISDIR in refs APIÆvar Arnfjörð Bjarmason, Jul 16, 2021
  13. 01/11 refs/packet: add missing BUG() invocations to reflog callbacksÆvar Arnfjörð Bjarmason, Jul 16, 2021
  14. 02/11 refs/files: remove unused REF_DELETING in lock_ref_oid_basic()Ævar Arnfjörð Bjarmason, Jul 16, 2021
  15. Jeff KingJul 17, 2021
  16. Junio C HamanoJul 19, 2021
  17. Jeff KingJul 20, 2021
  18. 03/11 refs/files: remove unused "extras/skip" in lock_ref_oid_basic()Ævar Arnfjörð Bjarmason, Jul 16, 2021
  19. 04/11 refs/files: remove unused "skip" in lock_raw_ref() tooÆvar Arnfjörð Bjarmason, Jul 16, 2021
  20. 05/11 refs/debug: re-indent argument list for "prepare"Ævar Arnfjörð Bjarmason, Jul 16, 2021
  21. 06/11 refs API: pass the "lock OID" to reflog "prepare"Ævar Arnfjörð Bjarmason, Jul 16, 2021
  22. Jeff KingJul 17, 2021
  23. Junio C HamanoJul 19, 2021
  24. Ævar Arnfjörð BjarmasonJul 19, 2021
  25. 07/11 refs: make repo_dwim_log() accept a NULL oidÆvar Arnfjörð Bjarmason, Jul 16, 2021
  26. 08/11 refs/files: add a comment about refs_reflog_exists() callÆvar Arnfjörð Bjarmason, Jul 16, 2021
  27. Jeff KingJul 17, 2021
  28. Junio C HamanoJul 19, 2021
  29. Jeff KingJul 20, 2021
  30. 09/11 reflog expire: don't lock reflogs using previously seen OIDÆvar Arnfjörð Bjarmason, Jul 16, 2021
  31. Jeff KingJul 17, 2021
  32. Han-Wen NienhuysAug 17, 2021
  33. Junio C HamanoAug 18, 2021
  34. Carlo Marcelo Arenas BelónAug 19, 2021
  35. Junio C HamanoAug 20, 2021
  36. 10/11 refs/files: remove unused "oid" in lock_ref_oid_basic()Ævar Arnfjörð Bjarmason, Jul 16, 2021
  37. Jeff KingJul 17, 2021
  38. 11/11 refs/files: remove unused "errno == EISDIR" codeÆvar Arnfjörð Bjarmason, Jul 16, 2021
  39. Jeff KingJul 17, 2021
  40. Jeff KingJul 17, 2021
  41. 00/12 fix "git reflog expire" race & get rid of EISDIR in refs APIÆvar Arnfjörð Bjarmason, Jul 20, 2021
  42. 10/12 refs/files: remove unused "oid" in lock_ref_oid_basic()Ævar Arnfjörð Bjarmason, Jul 20, 2021
  43. 05/12 refs/debug: re-indent argument list for "prepare"Ævar Arnfjörð Bjarmason, Jul 20, 2021
  44. 08/12 refs/files: add a comment about refs_reflog_exists() callÆvar Arnfjörð Bjarmason, Jul 20, 2021
  45. 07/12 refs: make repo_dwim_log() accept a NULL oidÆvar Arnfjörð Bjarmason, Jul 20, 2021
  46. 02/12 refs/files: remove unused REF_DELETING in lock_ref_oid_basic()Ævar Arnfjörð Bjarmason, Jul 20, 2021
  47. Junio C HamanoAug 2, 2021
  48. 01/12 refs/packet: add missing BUG() invocations to reflog callbacksÆvar Arnfjörð Bjarmason, Jul 20, 2021
  49. 11/12 refs/files: remove unused "errno == EISDIR" codeÆvar Arnfjörð Bjarmason, Jul 20, 2021
  50. 09/12 reflog expire: don't lock reflogs using previously seen OIDÆvar Arnfjörð Bjarmason, Jul 20, 2021
  51. 03/12 refs/files: remove unused "extras/skip" in lock_ref_oid_basic()Ævar Arnfjörð Bjarmason, Jul 20, 2021
  52. 06/12 refs API: pass the "lock OID" to reflog "prepare"Ævar Arnfjörð Bjarmason, Jul 20, 2021
  53. Junio C HamanoJul 21, 2021
  54. Junio C HamanoJul 21, 2021
  55. 12/12 refs/files: remove unused "errno != ENOTDIR" conditionÆvar Arnfjörð Bjarmason, Jul 20, 2021
  56. 04/12 refs/files: remove unused "skip" in lock_raw_ref() tooÆvar Arnfjörð Bjarmason, Jul 20, 2021
  57. 00/11 fix "git reflog expire" race & get rid of EISDIR in refs APIÆvar Arnfjörð Bjarmason, Jul 26, 2021
  58. 02/11 refs/files: remove unused REF_DELETING in lock_ref_oid_basic()Ævar Arnfjörð Bjarmason, Jul 26, 2021
  59. 01/11 refs/packet: add missing BUG() invocations to reflog callbacksÆvar Arnfjörð Bjarmason, Jul 26, 2021
  60. 03/11 refs/files: remove unused "extras/skip" in lock_ref_oid_basic()Ævar Arnfjörð Bjarmason, Jul 26, 2021
  61. 05/11 refs/debug: re-indent argument list for "prepare"Ævar Arnfjörð Bjarmason, Jul 26, 2021
  62. 04/11 refs/files: remove unused "skip" in lock_raw_ref() tooÆvar Arnfjörð Bjarmason, Jul 26, 2021
  63. 07/11 refs/files: add a comment about refs_reflog_exists() callÆvar Arnfjörð Bjarmason, Jul 26, 2021
  64. 09/11 refs/files: remove unused "oid" in lock_ref_oid_basic()Ævar Arnfjörð Bjarmason, Jul 26, 2021
  65. 08/11 reflog expire: don't lock reflogs using previously seen OIDÆvar Arnfjörð Bjarmason, Jul 26, 2021
  66. Junio C HamanoAug 2, 2021
  67. Ævar Arnfjörð BjarmasonAug 4, 2021
  68. 10/11 refs/files: remove unused "errno == EISDIR" codeÆvar Arnfjörð Bjarmason, Jul 26, 2021
  69. 11/11 refs/files: remove unused "errno != ENOTDIR" conditionÆvar Arnfjörð Bjarmason, Jul 26, 2021
  70. 06/11 refs: make repo_dwim_log() accept a NULL oidÆvar Arnfjörð Bjarmason, Jul 26, 2021
  71. 00/13 fix "git reflog expire" race & get rid of EISDIR in refs APIÆvar Arnfjörð Bjarmason, Aug 23, 2021
  72. 01/13 refs/packet: add missing BUG() invocations to reflog callbacksÆvar Arnfjörð Bjarmason, Aug 23, 2021
  73. 02/13 refs/files: remove unused REF_DELETING in lock_ref_oid_basic()Ævar Arnfjörð Bjarmason, Aug 23, 2021
  74. 03/13 refs: drop unused "flags" parameter to lock_ref_oid_basic()Ævar Arnfjörð Bjarmason, Aug 23, 2021
  75. 04/13 refs/files: remove unused "extras/skip" in lock_ref_oid_basic()Ævar Arnfjörð Bjarmason, Aug 23, 2021
  76. 05/13 refs/files: remove unused "skip" in lock_raw_ref() tooÆvar Arnfjörð Bjarmason, Aug 23, 2021
  77. 06/13 refs/debug: re-indent argument list for "prepare"Ævar Arnfjörð Bjarmason, Aug 23, 2021
  78. 07/13 refs: make repo_dwim_log() accept a NULL oidÆvar Arnfjörð Bjarmason, Aug 23, 2021
  79. 08/13 refs/files: add a comment about refs_reflog_exists() callÆvar Arnfjörð Bjarmason, Aug 23, 2021
  80. 09/13 reflog expire: don't lock reflogs using previously seen OIDÆvar Arnfjörð Bjarmason, Aug 23, 2021
  81. 10/13 refs API: remove OID argument to reflog_expire()Ævar Arnfjörð Bjarmason, Aug 23, 2021
  82. 11/13 refs/files: remove unused "oid" in lock_ref_oid_basic()Ævar Arnfjörð Bjarmason, Aug 23, 2021
  83. 12/13 refs/files: remove unused "errno == EISDIR" codeÆvar Arnfjörð Bjarmason, Aug 23, 2021
  84. 13/13 refs/files: remove unused "errno != ENOTDIR" conditionÆvar Arnfjörð Bjarmason, Aug 23, 2021
  85. Ævar Arnfjörð BjarmasonJul 23, 2021
  86. Junio C HamanoJul 23, 2021
  87. Ævar Arnfjörð BjarmasonJul 26, 2021
  88. Junio C HamanoJul 26, 2021

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.