This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_10x by this push:
     new 5919636e5aa build: support running in a git worktree (RAT, git-status) 
(#5165)
5919636e5aa is described below

commit 5919636e5aa56fc5257403221a178d1b9f4a6c88
Author: David Smiley <[email protected]>
AuthorDate: Tue Oct 20 08:32:18 2026 +0100

    build: support running in a git worktree (RAT, git-status) (#5165)
    
    Co-authored-by: Claude Sonnet 5.5 <[email protected]>
    (cherry picked from commit 681f8b208ffb1dbb76089dd0f88806e1c7c9cd3b)
---
 gradle/validation/git-status.gradle  | 14 +++++---------
 gradle/validation/rat-sources.gradle |  4 +++-
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/gradle/validation/git-status.gradle 
b/gradle/validation/git-status.gradle
index 17fa3527511..3dc28394019 100644
--- a/gradle/validation/git-status.gradle
+++ b/gradle/validation/git-status.gradle
@@ -41,6 +41,7 @@ configure(rootProject) {
     doFirst {
       try {
         def repository = new FileRepositoryBuilder()
+            .findGitDir(rootProject.projectDir)
             .setWorkTree(rootProject.projectDir)
             .setMustExist(true)
             .build()
@@ -65,6 +66,7 @@ configure(rootProject) {
       def status
       try {
         def repository = new FileRepositoryBuilder()
+            .findGitDir(rootProject.projectDir)
             .setWorkTree(rootProject.projectDir)
             .setMustExist(true)
             .build()
@@ -73,15 +75,9 @@ configure(rootProject) {
         status = null
       }
       if (status == null) {
-        if (file("${rootProject.projectDir}/.git").exists()) {
-          // Ignore git worktree branches until jgit supports them.
-          logger
-              .warn("WARNING: git worktrees are not supported by jgit (won't 
check dirty files): ${rootProject.projectDir}")
-        } else {
-          // Ignore the check. This isn't a git checkout.
-          logger
-              .warn("WARNING: Directory is not a valid git checkout (won't 
check dirty files): ${rootProject.projectDir}")
-        }
+        // Ignore the check. This isn't a git checkout.
+        logger
+            .warn("WARNING: Directory is not a valid git checkout (won't check 
dirty files): ${rootProject.projectDir}")
       } else {
         // git ignores any folders which are empty (this includes folders with 
recursively empty sub-folders).
         def untrackedNonEmptyFolders = status.untrackedFolders.findAll {path ->
diff --git a/gradle/validation/rat-sources.gradle 
b/gradle/validation/rat-sources.gradle
index 6b256f40044..181c6bd7eb9 100644
--- a/gradle/validation/rat-sources.gradle
+++ b/gradle/validation/rat-sources.gradle
@@ -51,14 +51,16 @@ Set<String> loadGitTrackedFiles() {
   rootProject.ext.ratGitIndexLoaded = true
   rootProject.ext.ratGitTrackedFiles = null
 
+  // .git is a file (not a directory) in a git worktree
   def dotGit = new File(rootProject.projectDir, ".git")
-  if (!dotGit.isDirectory()) {
+  if (!dotGit.exists()) {
     return null // not a git repository
   }
 
   def repository = null
   try {
     repository = new FileRepositoryBuilder()
+        .findGitDir(rootProject.projectDir)
         .setWorkTree(rootProject.projectDir)
         .setMustExist(true)
         .build()

Reply via email to