From 6e6a529b573398f0a8828551cf04dafb4f084c9a Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Thu, 29 Jun 2023 14:13:33 -0400 Subject: fsck: avoid misleading variable name When reporting a problem, `git fsck` emits a message such as: missing blob 1234abcd (:file) However, this can be ambiguous when the problem is detected in the index of a worktree other than the one in which `git fsck` was invoked. To address this shortcoming, 592ec63b38 (fsck: mention file path for index errors, 2023-02-24) enhanced the output to mention the path of the index when the problem is detected in some other worktree: missing blob 1234abcd (.git/worktrees/wt/index:file) Unfortunately, the variable in fsck_index() which controls whether the index path should be shown is misleadingly named "is_main_index" which can be misunderstood as referring to the main worktree (i.e. the one housing the .git/ repository) rather than to the current worktree (i.e. the one in which `git fsck` was invoked). Avoid such potential confusion by choosing a name more reflective of its actual purpose. Signed-off-by: Eric Sunshine Acked-by: Jeff King Signed-off-by: Junio C Hamano --- builtin/fsck.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin') diff --git a/builtin/fsck.c b/builtin/fsck.c index 64614b43b2..8813d9b5bb 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -798,7 +798,7 @@ static int fsck_resolve_undo(struct index_state *istate, } static void fsck_index(struct index_state *istate, const char *index_path, - int is_main_index) + int is_current_worktree) { unsigned int i; @@ -820,7 +820,7 @@ static void fsck_index(struct index_state *istate, const char *index_path, obj->flags |= USED; fsck_put_object_name(&fsck_walk_options, &obj->oid, "%s:%s", - is_main_index ? "" : index_path, + is_current_worktree ? "" : index_path, istate->cache[i]->name); mark_object_reachable(obj); } -- cgit v1.3