git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: shejialuo <shejialuo@gmail.com>
To: git@vger.kernel.org
Cc: Patrick Steinhardt <ps@pks.im>,
	Karthik Nayak <karthik.188@gmail.com>,
	Eric Sunshine <sunshine@sunshineco.com>,
	Kristoffer Haugsbakk <code@khaugsbakk.name>,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v2 0/1] [BUG] refs: verify does not work if there are v2.43.0 or older worktrees w/o wt. refs
Date: Mon, 2 Jun 2025 21:26:28 +0800	[thread overview]
Message-ID: <aD2mhOlwl1LSYnpe@ArchLinux> (raw)
In-Reply-To: <aDp55upE6AhYunz7@ArchLinux>

Hi All:

This version updates the following things:

1. Update the commit message to incorporate the commit message that
introduces the BUG to better explain.
2. Update the shell script to avoid hardcode gitdir path.
3. Change "rm -rf" to be "rmdir", which would be safer because we should
delete an empty directory, which has a better semantics.

Thanks,
Jialuo

shejialuo (1):
  fsck: ignore missing "refs" directory for linked worktrees

 refs/files-backend.c     |  3 +++
 t/t0602-reffiles-fsck.sh | 17 +++++++++++++++++
 2 files changed, 20 insertions(+)

Range-diff against v1:
1:  bfde11adb6 ! 1:  d949a8a646 fsck: ignore missing "refs" directory for linked worktrees
    @@ Metadata
      ## Commit message ##
         fsck: ignore missing "refs" directory for linked worktrees
     
    -    It is reported that "git refs verify" would fail when encountering
    -    worktrees created on Git v2.43.0 or older versions. These versions
    -    don't automatically create the "refs" directory, causing the error:
    +    "git refs verify" doesn't work if there are worktrees created on Git
    +    v2.43.0 or older versions. These versions don't automatically create the
    +    "refs" directory, causing the error:
     
             error: cannot open directory .git/worktrees/<worktree name>/refs:
             No such file or directory
     
         Since 8f4c00de95 (builtin/worktree: create refdb via ref backend,
         2024-01-08), we automatically create the "refs" directory for new
    -    worktrees. However, the fsck code incorrectly assumes all linked
    -    worktrees have this directory, thus introducing compatibility issue.
    +    worktrees. And in 7c78d819e6 (ref: support multiple worktrees check for
    +    refs, 2024-11-20), we assume that all linked worktrees have this
    +    directory and would wrongly report an error to the user, thus
    +    introducing compatibility issue.
     
         Check for ENOENT errno before reporting directory access errors for
         linked worktrees to maintain backward compatibility.
    @@ t/t0602-reffiles-fsck.sh: test_expect_success 'ref name check should be adapted
     +	(
     +		cd repo &&
     +		test_commit initial &&
    -+
     +		git worktree add --detach ./worktree &&
    ++
    ++		cd worktree &&
    ++		worktree_refdir="$(git rev-parse --git-dir)/refs" &&
     +		# Simulate old directory layout
    -+		rm -rf ./git/worktrees/worktree/refs &&
    ++		rmdir "$worktree_refdir" &&
     +		git refs verify 2>err &&
     +		test_must_be_empty err
     +	)
-- 
2.49.0


  parent reply	other threads:[~2025-06-02 13:26 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-30 19:00 [BUG] refs: verify does not work if there are v2.43.0 or older worktrees w/o wt. refs kristofferhaugsbakk
2025-05-30 22:23 ` Eric Sunshine
2025-05-31  1:03   ` shejialuo
2025-05-31  9:52   ` Kristoffer Haugsbakk
2025-05-31  3:39 ` [PATCH] fsck: ignore missing "refs" directory for linked worktrees shejialuo
2025-05-31 12:17   ` Kristoffer Haugsbakk
2025-06-02  1:33     ` Junio C Hamano
2025-06-02 11:30     ` shejialuo
2025-06-02  9:53   ` Phillip Wood
2025-06-02 10:24     ` Patrick Steinhardt
2025-06-02 13:50       ` phillip.wood123
2025-06-02 19:49       ` Junio C Hamano
2025-06-02 12:16     ` shejialuo
2025-06-02 12:41   ` shejialuo
2025-06-02 13:26   ` shejialuo [this message]
2025-06-02 13:29     ` [PATCH v2 1/1] " shejialuo
2025-06-02 13:59       ` Kristoffer Haugsbakk
2025-06-02 14:11         ` shejialuo
2025-06-02 14:40     ` [PATCH v3 0/1] [BUG] refs: verify does not work if there are v2.43.0 or older worktrees w/o wt. refs shejialuo
2025-06-02 14:41       ` [PATCH v3 1/1] fsck: ignore missing "refs" directory for linked worktrees shejialuo
2025-06-02 15:01       ` [PATCH v3 0/1] [BUG] refs: verify does not work if there are v2.43.0 or older worktrees w/o wt. refs Kristoffer Haugsbakk

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=aD2mhOlwl1LSYnpe@ArchLinux \
    --to=shejialuo@gmail.com \
    --cc=code@khaugsbakk.name \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=karthik.188@gmail.com \
    --cc=ps@pks.im \
    --cc=sunshine@sunshineco.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).