On Thu, Aug 01, 2024 at 11:15:24PM +0800, shejialuo wrote:
quoted hunk ↗ jump to hunk
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 5574e78656..1186b6cbb1 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -3419,6 +3419,37 @@ typedef int (*files_fsck_refs_fn)(struct fsck_options *o,
const char *refs_check_dir,
struct dir_iterator *iter);
+static int files_fsck_refs_name(struct fsck_options *o,
+ const char *gitdir UNUSED,
+ const char *refs_check_dir,
+ struct dir_iterator *iter)
+{
+ struct strbuf sb = STRBUF_INIT;
+ size_t len = 0;
+ int ret = 0;
+
+ /*
+ * Ignore the files ending with ".lock" as they may be lock files
+ * However, do not allow bare ".lock" files.
+ */
+ if (strip_suffix(iter->basename, ".lock", &len) && (len != 0))
+ goto clean;
Better:
if (ends_with(iter->basename, ".lock))
goto cleanup;
Patrick