Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: cleanup root resolution code
  • Loading branch information
daniel-mohedano committed Feb 6, 2026
commit 526780e135a87dcead96a0dfe8948f68d3cadce5
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ public class ShellGitClient implements GitClient {
this.latestCommitsSince = latestCommitsSince;
this.latestCommitsLimit = latestCommitsLimit;

String gitRepoRoot = findGitRepositoryRoot(new File(repoRoot).getAbsoluteFile());
this.repoRoot = gitRepoRoot;
this.safeDirectoryOption = "safe.directory=" + gitRepoRoot;
commandExecutor = new ShellCommandExecutor(new File(gitRepoRoot), timeoutMillis);
LOGGER.debug("Git safe directory configured to {}", gitRepoRoot);
this.repoRoot = findGitRepositoryRoot(new File(repoRoot));
this.safeDirectoryOption = "safe.directory=" + this.repoRoot;
commandExecutor = new ShellCommandExecutor(new File(this.repoRoot), timeoutMillis);
}

/**
Expand All @@ -91,13 +89,17 @@ public class ShellGitClient implements GitClient {
*/
static String findGitRepositoryRoot(File startDir) {
File current = startDir.getAbsoluteFile();
LOGGER.debug("Finding git repository root for {}", current.getPath());
while (current != null) {
File gitDir = new File(current, ".git");
if (gitDir.exists()) {
return current.getPath();
String repoRootFound = current.getPath();
LOGGER.debug("Git repository root found as {}", repoRootFound);
return repoRootFound;
}
current = current.getParentFile();
}
LOGGER.debug("No .git found for repository root, defaulting to original starting directory");
return startDir.getAbsolutePath();
}

Expand Down
Loading