aboutsummaryrefslogtreecommitdiffstats
path: root/refs/refs-internal.h
diff options
context:
space:
mode:
authorshejialuo <shejialuo@gmail.com>2024-11-20 19:51:32 +0800
committerJunio C Hamano <gitster@pobox.com>2024-11-21 08:21:32 +0900
commit7c78d819e6a14434ae3fa8a2127bb3969376cac1 (patch)
tree3be46325629313034c211e57f35235051de30c0e /refs/refs-internal.h
parentref: initialize ref name outside of check functions (diff)
downloadgit-7c78d819e6a14434ae3fa8a2127bb3969376cac1.tar.gz
git-7c78d819e6a14434ae3fa8a2127bb3969376cac1.zip
ref: support multiple worktrees check for refs
We have already set up the infrastructure to check the consistency for refs, but we do not support multiple worktrees. However, "git-fsck(1)" will check the refs of worktrees. As we decide to get feature parity with "git-fsck(1)", we need to set up support for multiple worktrees. Because each worktree has its own specific refs, instead of just showing the users "refs/worktree/foo", we need to display the full name such as "worktrees/<id>/refs/worktree/foo". So we should know the id of the worktree to get the full name. Add a new parameter "struct worktree *" for "refs-internal.h::fsck_fn". Then change the related functions to follow this new interface. The "packed-refs" only exists in the main worktree, so we should only check "packed-refs" in the main worktree. Use "is_main_worktree" method to skip checking "packed-refs" in "packed_fsck" function. Then, enhance the "files-backend.c::files_fsck_refs_dir" function to add "worktree/<id>/" prefix when we are not in the main worktree. Last, add a new test to check the refname when there are multiple worktrees to exercise the code. Mentored-by: Patrick Steinhardt <ps@pks.im> Mentored-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: shejialuo <shejialuo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs/refs-internal.h')
-rw-r--r--refs/refs-internal.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index 2313c830d8..037d7991cd 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -653,7 +653,8 @@ typedef int read_symbolic_ref_fn(struct ref_store *ref_store, const char *refnam
struct strbuf *referent);
typedef int fsck_fn(struct ref_store *ref_store,
- struct fsck_options *o);
+ struct fsck_options *o,
+ struct worktree *wt);
struct ref_storage_be {
const char *name;