summaryrefslogtreecommitdiff
path: root/refs
diff options
context:
space:
mode:
Diffstat (limited to 'refs')
-rw-r--r--refs/files-backend.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 55c76879f4..a4c7858787 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -3853,22 +3853,12 @@ cleanup:
static int files_fsck_refs_name(struct ref_store *ref_store UNUSED,
struct fsck_options *o,
const char *refname,
- const char *path,
+ const char *path UNUSED,
int mode UNUSED)
{
struct strbuf sb = STRBUF_INIT;
- const char *filename;
int ret = 0;
- filename = basename((char *) path);
-
- /*
- * Ignore the files ending with ".lock" as they may be lock files
- * However, do not allow bare ".lock" files.
- */
- if (filename[0] != '.' && ends_with(filename, ".lock"))
- goto cleanup;
-
if (is_root_ref(refname))
goto cleanup;
@@ -3928,6 +3918,7 @@ static int files_fsck_refs_dir(struct ref_store *ref_store,
struct strbuf refname = STRBUF_INIT;
struct strbuf sb = STRBUF_INIT;
struct dir_iterator *iter;
+ const char *filename;
int iter_status;
int ret = 0;
@@ -3951,6 +3942,15 @@ static int files_fsck_refs_dir(struct ref_store *ref_store,
strbuf_addf(&refname, "worktrees/%s/", wt->id);
strbuf_addf(&refname, "refs/%s", iter->relative_path);
+ filename = basename((char *) iter->path.buf);
+
+ /*
+ * Ignore the files ending with ".lock" as they may be lock files.
+ * However, do not skip invalid refnames with '.lock' suffix.
+ */
+ if (filename[0] != '.' && ends_with(filename, ".lock"))
+ continue;
+
if (files_fsck_ref(ref_store, o, refname.buf,
iter->path.buf, iter->st.st_mode) < 0)
ret = -1;