From: Han Young <hanyang.tony@bytedance.com>
To: git@vger.kernel.org
Cc: Han Young <hanyang.tony@bytedance.com>
Subject: [PATCH 1/2] read-cache: report lock error when refreshing index
Date: Wed, 21 May 2025 16:35:20 +0800 [thread overview]
Message-ID: <20250521083521.6552-2-hanyang.tony@bytedance.com> (raw)
In-Reply-To: <20250521083521.6552-1-hanyang.tony@bytedance.com>
In the repo_refresh_and_write_index of read-cache.c, we return -1 to
indicate that writing the index to disk failed.
However, callers do not use this information. Commands such as stash print
"could not write index"
and then exit, which does not help to discover the exact problem.
We can let repo_hold_locked_index print the error message if the locking
failed.
Signed-off-by: Han Young <hanyang.tony@bytedance.com>
---
read-cache.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/read-cache.c b/read-cache.c
index 73f83a7e7a..874f87d040 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1485,7 +1485,7 @@ int repo_refresh_and_write_index(struct repository *repo,
struct lock_file lock_file = LOCK_INIT;
int fd, ret = 0;
- fd = repo_hold_locked_index(repo, &lock_file, 0);
+ fd = repo_hold_locked_index(repo, &lock_file, gentle ? 0 : LOCK_REPORT_ON_ERROR);
if (!gentle && fd < 0)
return -1;
if (refresh_index(repo->index, refresh_flags, pathspec, seen, header_msg))
--
2.48.1
next prev parent reply other threads:[~2025-05-21 8:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-21 8:35 [PATCH 0/2] report lock error in write_index Han Young
2025-05-21 8:35 ` Han Young [this message]
2025-05-21 8:35 ` [PATCH 2/2] read-cache: unify write index error message Han Young
2025-05-21 9:18 ` [PATCH 0/2] report lock error in write_index Han Young
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=20250521083521.6552-2-hanyang.tony@bytedance.com \
--to=hanyang.tony@bytedance.com \
--cc=git@vger.kernel.org \
/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).