From 7c9136984829174f50cdf314683e272bff71ecca Mon Sep 17 00:00:00 2001 From: Ben Lewis Date: Sat, 15 Nov 2025 01:25:15 +1000 Subject: [PATCH 1/2] Add support for git worktrees by checking for .git files as well as .git directories (worktrees have a .git file). --- ReGitLint/Cleanup.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ReGitLint/Cleanup.cs b/ReGitLint/Cleanup.cs index 13f6258..0ab13fb 100644 --- a/ReGitLint/Cleanup.cs +++ b/ReGitLint/Cleanup.cs @@ -411,11 +411,12 @@ private static string GetGitDirectory() var directoryInfo = new DirectoryInfo(Environment.CurrentDirectory); while (directoryInfo != null) { - if ( - directoryInfo - .GetDirectories(".git", SearchOption.TopDirectoryOnly) - .Any() - ) + var hasGitDir = directoryInfo + .GetDirectories(".git", SearchOption.TopDirectoryOnly).Any(); + var hasGitFile = directoryInfo + .GetFiles(".git", SearchOption.TopDirectoryOnly).Any(); + + if (hasGitDir || hasGitFile) { return directoryInfo.FullName; } From 78f4b704b5e9ae38129e187028a03cb3b2f7096e Mon Sep 17 00:00:00 2001 From: Ben Lewis Date: Tue, 18 Nov 2025 08:41:52 +1000 Subject: [PATCH 2/2] Format code in `GetGitDirectory` --- ReGitLint/Cleanup.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ReGitLint/Cleanup.cs b/ReGitLint/Cleanup.cs index 0ab13fb..5850158 100644 --- a/ReGitLint/Cleanup.cs +++ b/ReGitLint/Cleanup.cs @@ -412,9 +412,12 @@ private static string GetGitDirectory() while (directoryInfo != null) { var hasGitDir = directoryInfo - .GetDirectories(".git", SearchOption.TopDirectoryOnly).Any(); + .GetDirectories(".git", SearchOption.TopDirectoryOnly) + .Any(); + var hasGitFile = directoryInfo - .GetFiles(".git", SearchOption.TopDirectoryOnly).Any(); + .GetFiles(".git", SearchOption.TopDirectoryOnly) + .Any(); if (hasGitDir || hasGitFile) {