From 3b0030a6436351415da3865edf17bbe33657669b Mon Sep 17 00:00:00 2001 From: Sandro Jäckel Date: Fri, 10 Sep 2021 10:08:25 +0200 Subject: rtree: fix error when running `rtree index` and absorbed .git dirs where indexed The fixes the following error when /home/user/src/vscode-settings/ is a git repo with an absorbed .git dir where .git points to the real repo ``` $ rtree index repository /home/sandro/src/exampleA has been deleted -> delete from index !! expected repository at /home/user/src/exampleB/.git, but is not a directory ``` --- internal/rtree/index.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/rtree/index.go b/internal/rtree/index.go index 64c8c74..b802ef8 100644 --- a/internal/rtree/index.go +++ b/internal/rtree/index.go @@ -132,12 +132,14 @@ func (i *Index) Rebuild() error { fi, err := os.Stat(gitDirPath) switch { case err == nil: - if fi.IsDir() { + // in a normal repo .git is a directory but when the repo is a submodule of another repo + // and the .git dir is absorbed then it is a file which contains the path to the real .git directory + if fi.IsDir() || fi.Mode().IsRegular() { //everything okay with this repo newRepos = append(newRepos, repo) continue } - return fmt.Errorf("expected repository at %s, but is not a directory", gitDirPath) + return fmt.Errorf("expected repository at %s, but is not a directory or file", gitDirPath) case !os.IsNotExist(err): return err } -- cgit v1.3.1