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

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

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Aug 23, 2021, 11:36 UTC
Message-ID
<cover-v5-00.13-00000000000-20210823T113115Z-avarab@gmail.com>
In-Reply-To
<cover-00.11-0000000000-20210726T234237Z-avarab@gmail.com>

A re-roll of https://lore.kernel.org/git/cover-00.11-0000000000-20210726T234237Z-avarab@gmail.com

This incorporates Jeff King's https://lore.kernel.org/git/YQyGe9qOPRA0nf5v@coredump.intra.peff.net; so this replaces ab/refs-files-cleanup and jk/refs-files-cleanup-cleanup.

There's also a trivial commit message grammar fix here that Junio already squashed into his version of v4. The rest of the changes are all due to the rebase on Jeff's commit to get rid of the "flags" parameter.

But most importantly there's a new "refs API: remove OID argument to reflog_expire()" patch here, to change the function signature of reflog_expire() to not pass the OID. Leaving it in place caused a segfault in the reftable topic, now it just won't compile in combination with this. I'm submitting update(s) to those other topics on top to make these all work nicely together.

Jeff King (1):
  refs: drop unused "flags" parameter to lock_ref_oid_basic()
Ævar Arnfjörð Bjarmason (12):
  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 API: remove OID argument to reflog_expire()
  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                |  13 +++--
 refs.h                |   9 ++-
 refs/debug.c          |   8 +--
 refs/files-backend.c  | 132 +++++++++++-------------------------------
 refs/packed-backend.c |   7 ++-
 refs/refs-internal.h  |   2 +-
 8 files changed, 64 insertions(+), 123 deletions(-)
Range-diff against v4:
 1:  92fc3af0727 =  1:  61cf49b9582 refs/packet: add missing BUG() invocations to reflog callbacks
 2:  67cd2331fb4 !  2:  a20548c1a4d refs/files: remove unused REF_DELETING in lock_ref_oid_basic()
    @@ Metadata
      ## Commit message ##
         refs/files: remove unused REF_DELETING in lock_ref_oid_basic()
     
    -    The lock_ref_oid_basic() function has gradually been by most callers
    -    no longer performing a low-level "acquire lock, update and release",
    -    and instead using the ref transaction API. So there are only 4
    -    remaining callers of lock_ref_oid_basic().
    +    The lock_ref_oid_basic() function has gradually been replaced by
    +    most callers no longer performing a low-level "acquire lock,
    +    update and release", and instead using the ref transaction API.
    +    So there are only 4 remaining callers of lock_ref_oid_basic().
     
         None of those callers pass REF_DELETING anymore, the last caller went
         away in 92b1551b1d (refs: resolve symbolic refs first,
 -:  ----------- >  3:  d3216a6b1d8 refs: drop unused "flags" parameter to lock_ref_oid_basic()
 3:  7d76514b559 !  4:  3e538eb3008 refs/files: remove unused "extras/skip" in lock_ref_oid_basic()
    @@ refs/files-backend.c: static int create_reflock(const char *path, void *cb)
      					   const struct object_id *old_oid,
     -					   const struct string_list *extras,
     -					   const struct string_list *skip,
    - 					   unsigned int flags, int *type,
    - 					   struct strbuf *err)
    + 					   int *type, struct strbuf *err)
      {
    + 	struct strbuf ref_file = STRBUF_INIT;
     @@ refs/files-backend.c: static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs,
      			last_errno = errno;
      			if (!refs_verify_refname_available(
    @@ refs/files-backend.c: static int files_copy_or_rename_ref(struct ref_store *ref_
      
      	logmoved = log;
      
    +-
     -	lock = lock_ref_oid_basic(refs, newrefname, NULL, NULL, NULL,
    --				  REF_NO_DEREF, NULL, &err);
    -+	lock = lock_ref_oid_basic(refs, newrefname, NULL, REF_NO_DEREF, NULL,
    -+				  &err);
    +-				  NULL, &err);
    ++	lock = lock_ref_oid_basic(refs, newrefname, NULL, NULL, &err);
      	if (!lock) {
      		if (copy)
      			error("unable to copy '%s' to '%s': %s", oldrefname, newrefname, err.buf);
    @@ refs/files-backend.c: static int files_copy_or_rename_ref(struct ref_store *ref_
      
       rollback:
     -	lock = lock_ref_oid_basic(refs, oldrefname, NULL, NULL, NULL,
    -+	lock = lock_ref_oid_basic(refs, oldrefname, NULL,
    - 				  REF_NO_DEREF, NULL, &err);
    +-				  NULL, &err);
    ++	lock = lock_ref_oid_basic(refs, oldrefname, NULL, NULL, &err);
      	if (!lock) {
      		error("unable to lock %s for rollback: %s", oldrefname, err.buf);
    + 		strbuf_release(&err);
     @@ refs/files-backend.c: static int files_create_symref(struct ref_store *ref_store,
    + 	struct ref_lock *lock;
      	int ret;
      
    - 	lock = lock_ref_oid_basic(refs, refname, NULL,
    --				  NULL, NULL, REF_NO_DEREF, NULL,
    -+				  REF_NO_DEREF, NULL,
    - 				  &err);
    +-	lock = lock_ref_oid_basic(refs, refname, NULL,
    +-				  NULL, NULL, NULL,
    +-				  &err);
    ++	lock = lock_ref_oid_basic(refs, refname, NULL, NULL, &err);
      	if (!lock) {
      		error("%s", err.buf);
    + 		strbuf_release(&err);
     @@ 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:
      	 */
    - 	lock = lock_ref_oid_basic(refs, refname, oid,
    --				  NULL, NULL, REF_NO_DEREF,
    -+				  REF_NO_DEREF,
    - 				  &type, &err);
    +-	lock = lock_ref_oid_basic(refs, refname, oid,
    +-				  NULL, NULL, &type, &err);
    ++	lock = lock_ref_oid_basic(refs, refname, oid, &type, &err);
      	if (!lock) {
      		error("cannot lock ref '%s': %s", refname, err.buf);
    + 		strbuf_release(&err);
 4:  852f86e666f =  5:  b7335e79f8b refs/files: remove unused "skip" in lock_raw_ref() too
 5:  685b48328af =  6:  24449766060 refs/debug: re-indent argument list for "prepare"
 6:  b75e7673d70 =  7:  3b7daf03e5a refs: make repo_dwim_log() accept a NULL oid
 7:  7fe6c9bd921 =  8:  51abe459e70 refs/files: add a comment about refs_reflog_exists() call
 8:  c9c2da35997 !  9:  aba12606cea reflog expire: don't lock reflogs using previously seen OID
    @@ 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:
      	 */
    --	lock = lock_ref_oid_basic(refs, refname, oid,
    -+	lock = lock_ref_oid_basic(refs, refname, NULL,
    - 				  REF_NO_DEREF,
    - 				  &type, &err);
    +-	lock = lock_ref_oid_basic(refs, refname, oid, &type, &err);
    ++	lock = lock_ref_oid_basic(refs, refname, NULL, &type, &err);
      	if (!lock) {
    -@@ refs/files-backend.c: static int files_reflog_expire(struct ref_store *ref_store,
    + 		error("cannot lock ref '%s': %s", refname, err.buf);
      		strbuf_release(&err);
      		return -1;
      	}
 -:  ----------- > 10:  5afa8f1be29 refs API: remove OID argument to reflog_expire()
 9:  b61c734cf5c ! 11:  7712e29abe6 refs/files: remove unused "oid" in lock_ref_oid_basic()
    @@ refs/files-backend.c: static struct ref_iterator *files_ref_iterator_begin(
      {
      	/*
     @@ refs/files-backend.c: static int create_reflock(const char *path, void *cb)
    +  * On failure errno is set to something meaningful.
       */
      static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs,
    - 					   const char *refname,
    +-					   const char *refname,
     -					   const struct object_id *old_oid,
    - 					   unsigned int flags, int *type,
    - 					   struct strbuf *err)
    +-					   int *type, struct strbuf *err)
    ++					   const char *refname, int *type,
    ++					   struct strbuf *err)
      {
      	struct strbuf ref_file = STRBUF_INIT;
      	struct ref_lock *lock;
    @@ refs/files-backend.c: static int files_copy_or_rename_ref(struct ref_store *ref_
      
      	logmoved = log;
      
    --	lock = lock_ref_oid_basic(refs, newrefname, NULL, REF_NO_DEREF, NULL,
    --				  &err);
    -+	lock = lock_ref_oid_basic(refs, newrefname, REF_NO_DEREF, NULL, &err);
    +-	lock = lock_ref_oid_basic(refs, newrefname, NULL, NULL, &err);
    ++	lock = lock_ref_oid_basic(refs, newrefname, NULL, &err);
      	if (!lock) {
      		if (copy)
      			error("unable to copy '%s' to '%s': %s", oldrefname, newrefname, err.buf);
    @@ refs/files-backend.c: static int files_copy_or_rename_ref(struct ref_store *ref_
      	goto out;
      
       rollback:
    --	lock = lock_ref_oid_basic(refs, oldrefname, NULL,
    --				  REF_NO_DEREF, NULL, &err);
    -+	lock = lock_ref_oid_basic(refs, oldrefname, REF_NO_DEREF, NULL, &err);
    +-	lock = lock_ref_oid_basic(refs, oldrefname, NULL, NULL, &err);
    ++	lock = lock_ref_oid_basic(refs, oldrefname, NULL, &err);
      	if (!lock) {
      		error("unable to lock %s for rollback: %s", oldrefname, err.buf);
      		strbuf_release(&err);
    @@ refs/files-backend.c: static int files_create_symref(struct ref_store *ref_store
      	struct ref_lock *lock;
      	int ret;
      
    --	lock = lock_ref_oid_basic(refs, refname, NULL,
    --				  REF_NO_DEREF, NULL,
    --				  &err);
    -+	lock = lock_ref_oid_basic(refs, refname, REF_NO_DEREF, NULL, &err);
    +-	lock = lock_ref_oid_basic(refs, refname, NULL, NULL, &err);
    ++	lock = lock_ref_oid_basic(refs, refname, NULL, &err);
      	if (!lock) {
      		error("%s", err.buf);
      		strbuf_release(&err);
    @@ 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:
      	 */
    --	lock = lock_ref_oid_basic(refs, refname, NULL,
    --				  REF_NO_DEREF,
    --				  &type, &err);
    -+	lock = lock_ref_oid_basic(refs, refname, REF_NO_DEREF, &type, &err);
    +-	lock = lock_ref_oid_basic(refs, refname, NULL, &type, &err);
    ++	lock = lock_ref_oid_basic(refs, refname, &type, &err);
      	if (!lock) {
      		error("cannot lock ref '%s': %s", refname, err.buf);
      		strbuf_release(&err);
10:  009abc99688 = 12:  f746939a27a refs/files: remove unused "errno == EISDIR" code
11:  acb131cc1c5 = 13:  2e30ee04edb refs/files: remove unused "errno != ENOTDIR" condition
-- 
2.33.0.662.g438caf9576d
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 71 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.