Skip to content

Commit

Permalink
Add a public override for the maxBuffer option
Browse files Browse the repository at this point in the history
- add maxBuffer property to index module
- allow passing of maxBuffer to the git object via git_options
- pass the index maxBuffer along with the git_options
  • Loading branch information
Gord Tanner committed Sep 25, 2015
1 parent 544500e commit caddd22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/git.coffee
Expand Up @@ -15,7 +15,11 @@ module.exports = Git = (git_dir, dot_git, git_options) ->
args = args.join " " if args instanceof Array
encoding ?= 'utf8'
bash = "#{git_options.bin || Git.bin} #{command} #{options} #{args}"
exec bash, {cwd: git_dir, encoding: encoding, maxBuffer: 5000 * 1024}, callback
exec bash, {
cwd: git_dir,
encoding: encoding,
maxBuffer: git_options.maxBuffer || 5000 * 1024
}, callback
return bash

# Public: Passthrough for raw git commands
Expand Down
11 changes: 7 additions & 4 deletions src/index.coffee
Expand Up @@ -4,9 +4,12 @@ Repo = require './repo'
# Public: Create a Repo from the given path.
#
# Returns Repo.
module.exports = Git = (path, bare=false, git_options={}) ->
return new Repo path, bare, git_options
module.exports = Git = (path, bare=false, git_options={
maxBuffer: Git.maxBuffer
}) -> return new Repo path, bare, git_options

# Public: maxBuffer size for git commands
Git.maxBuffer = 5000 * 1024

# Public: Initialize a git repository.
#
Expand All @@ -23,7 +26,7 @@ Git.init = (path, bare, callback) ->
exec bash, {cwd: path}
, (err, stdout, stderr) ->
return callback err if err
return callback err, (new Repo path, bare)
return callback err, (new Repo path, bare, { maxBuffer: Git.maxBuffer })

# Public: Clone a git repository.
#
Expand All @@ -35,4 +38,4 @@ Git.clone = (repository, path, callback) ->
bash = "git clone #{repository} #{path}"
exec bash, (err, stdout, stderr) ->
return callback err if err
return callback err, (new Repo path)
return callback err, (new Repo path, false, { maxBuffer: Git.maxBuffer })

0 comments on commit caddd22

Please sign in to comment.