Thread (238 messages) 238 messages, 6 authors, 2024-10-06

Re: [GSoC][PATCH v14 11/11] fsck: add ref name check for files backend

From: Patrick Steinhardt <hidden>
Date: 2024-08-05 12:58:46

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

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help