diff options
author | guillep2k <github.com@mailfilter.com.ar> | 2019-08-02 03:57:53 -0300 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-08-02 07:57:53 +0100 |
commit | 06392479b44f4af913a9067fba6d4947ed323235 (patch) | |
tree | e43bd8c2887e459c945d196cfe62595660700324 /models | |
parent | 0fabdf03b245cb9d0040179824281506521d8ede (diff) | |
download | gitea-06392479b44f4af913a9067fba6d4947ed323235.tar.gz gitea-06392479b44f4af913a9067fba6d4947ed323235.zip |
Skip non-regular files (e.g. submodules) on repo indexing (#7711)
Diffstat (limited to 'models')
-rw-r--r-- | models/repo_indexer.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/models/repo_indexer.go b/models/repo_indexer.go index 140ec66c03..83383807a7 100644 --- a/models/repo_indexer.go +++ b/models/repo_indexer.go @@ -231,20 +231,28 @@ func addDelete(filename string, repo *Repository, batch rupture.FlushingBatch) e return indexerUpdate.AddToFlushingBatch(batch) } +func isIndexable(entry *git.TreeEntry) bool { + return entry.IsRegular() +} + // parseGitLsTreeOutput parses the output of a `git ls-tree -r --full-name` command func parseGitLsTreeOutput(stdout []byte) ([]fileUpdate, error) { entries, err := git.ParseTreeEntries(stdout) if err != nil { return nil, err } + var idxCount = 0 updates := make([]fileUpdate, len(entries)) - for i, entry := range entries { - updates[i] = fileUpdate{ - Filename: entry.Name(), - BlobSha: entry.ID.String(), + for _, entry := range entries { + if isIndexable(entry) { + updates[idxCount] = fileUpdate{ + Filename: entry.Name(), + BlobSha: entry.ID.String(), + } + idxCount++ } } - return updates, nil + return updates[:idxCount], nil } // genesisChanges get changes to add repo to the indexer for the first time |