From e0d0bf52237210938f3b078a477530bc394df9b4 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Wed, 31 May 2017 10:56:19 -0700 Subject: [PATCH 1/3] Use git ls-files for loading paths when available. --- lib/load-paths-handler.coffee | 37 ++++++++++++++++++++++------------- package.json | 1 + 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/lib/load-paths-handler.coffee b/lib/load-paths-handler.coffee index 3a67eeb9..327e74d7 100644 --- a/lib/load-paths-handler.coffee +++ b/lib/load-paths-handler.coffee @@ -4,33 +4,42 @@ path = require 'path' _ = require 'underscore-plus' {GitRepository} = require 'atom' {Minimatch} = require 'minimatch' +{GitProcess} = require 'dugite' PathsChunkSize = 100 emittedPaths = new Set class PathLoader - constructor: (@rootPath, ignoreVcsIgnores, @traverseSymlinkDirectories, @ignoredNames) -> + constructor: (@rootPath, @ignoreVcsIgnores, @traverseSymlinkDirectories, @ignoredNames) -> @paths = [] @realPathCache = {} - @repo = null - if ignoreVcsIgnores - repo = GitRepository.open(@rootPath, refreshOnWindowFocus: false) - @repo = repo if repo?.relativize(path.join(@rootPath, 'test')) is 'test' load: (done) -> - @loadPath @rootPath, true, => - @flushPaths() - @repo?.destroy() - done() + repo = GitRepository.open(@rootPath, refreshOnWindowFocus: false) + if repo?.relativize(path.join(@rootPath, 'test')) is 'test' + args = ['ls-files', '-c', '-o', '-z'] + if @ignoreVcsIgnores + args.push('--exclude-standard') + for ignoredName in @ignoredNames + args.push("-x") + args.push(ignoredName.pattern) + GitProcess.exec(args, @rootPath, {maxBuffer: 30 * 1024 * 1024}).then (result) -> + paths = result.stdout.split('\0') + while (paths.length) + emit('load-paths:paths-found', paths.splice(0, PathsChunkSize * 100)) + repo?.destroy() + done() + else + @loadPath @rootPath, true, => + @flushPaths() + repo?.destroy() + done() isIgnored: (loadedPath) -> relativePath = path.relative(@rootPath, loadedPath) - if @repo?.isPathIgnored(relativePath) - true - else - for ignoredName in @ignoredNames - return true if ignoredName.match(relativePath) + for ignoredName in @ignoredNames + return true if ignoredName.match(relativePath) pathLoaded: (loadedPath, done) -> unless @isIgnored(loadedPath) or emittedPaths.has(loadedPath) diff --git a/package.json b/package.json index aaf1c1bf..92b113e1 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "dependencies": { "async": "0.2.6", "atom-select-list": "^0.1.0", + "dugite": "^1.30.0", "fs-plus": "^3.0.0", "fuzzaldrin": "^2.0", "fuzzaldrin-plus": "^0.4.1", From a40a8e27eaacd65a177f7087467fb222dcce9b5c Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Fri, 16 Jun 2017 10:06:31 -0700 Subject: [PATCH 2/3] Use dugite's GitProcess.spawn for streaming output in ls-files. --- lib/load-paths-handler.coffee | 11 +++++++---- package.json | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/load-paths-handler.coffee b/lib/load-paths-handler.coffee index 327e74d7..3868c83f 100644 --- a/lib/load-paths-handler.coffee +++ b/lib/load-paths-handler.coffee @@ -24,10 +24,13 @@ class PathLoader for ignoredName in @ignoredNames args.push("-x") args.push(ignoredName.pattern) - GitProcess.exec(args, @rootPath, {maxBuffer: 30 * 1024 * 1024}).then (result) -> - paths = result.stdout.split('\0') - while (paths.length) - emit('load-paths:paths-found', paths.splice(0, PathsChunkSize * 100)) + output = "" + proc = GitProcess.spawn(args, @rootPath) + proc.stdout.on 'data', (chunk) -> + files = (output + chunk).split("\0") + output = files.pop() + emit('load-paths:paths-found', files) + proc.on "close", (code) -> repo?.destroy() done() else diff --git a/package.json b/package.json index 92b113e1..ebf09fd9 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "dependencies": { "async": "0.2.6", "atom-select-list": "^0.1.0", - "dugite": "^1.30.0", + "dugite": "^1.35.0", "fs-plus": "^3.0.0", "fuzzaldrin": "^2.0", "fuzzaldrin-plus": "^0.4.1", From cc8f90b3ed0fb11b62a3b57df80199ecc2e13627 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Wed, 21 Jun 2017 07:55:21 -0700 Subject: [PATCH 3/3] Use long names for command arguments and change double to single quotes. --- lib/load-paths-handler.coffee | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/load-paths-handler.coffee b/lib/load-paths-handler.coffee index 3868c83f..731790fa 100644 --- a/lib/load-paths-handler.coffee +++ b/lib/load-paths-handler.coffee @@ -18,19 +18,19 @@ class PathLoader load: (done) -> repo = GitRepository.open(@rootPath, refreshOnWindowFocus: false) if repo?.relativize(path.join(@rootPath, 'test')) is 'test' - args = ['ls-files', '-c', '-o', '-z'] + args = ['ls-files', '--cached', '--others', '-z'] if @ignoreVcsIgnores args.push('--exclude-standard') for ignoredName in @ignoredNames - args.push("-x") + args.push('--exclude') args.push(ignoredName.pattern) - output = "" + output = '' proc = GitProcess.spawn(args, @rootPath) proc.stdout.on 'data', (chunk) -> - files = (output + chunk).split("\0") + files = (output + chunk).split('\0') output = files.pop() emit('load-paths:paths-found', files) - proc.on "close", (code) -> + proc.on 'close', (code) -> repo?.destroy() done() else