diff --git a/src/blob.coffee b/src/blob.coffee index 103143e..8447c11 100644 --- a/src/blob.coffee +++ b/src/blob.coffee @@ -16,6 +16,7 @@ module.exports = class Blob @repo.git "cat-file", {p: true}, @id , (err, stdout, stderr) -> return callback err, stdout + , 'binary' # Public: Get the blob contents as a stream # diff --git a/src/git.coffee b/src/git.coffee index a8b545d..ccd2fda 100644 --- a/src/git.coffee +++ b/src/git.coffee @@ -5,7 +5,7 @@ module.exports = Git = (git_dir, dot_git, git_options) -> git_options ||= {} dot_git ||= "#{git_dir}/.git" - git = (command, options, args, callback) -> + git = (command, options, args, callback, encoding) -> [callback, args] = [args, callback] if !callback [callback, options] = [options, callback] if !callback options ?= {} @@ -13,14 +13,15 @@ module.exports = Git = (git_dir, dot_git, git_options) -> options = options.join " " args ?= [] args = args.join " " if args instanceof Array + encoding ?= 'utf8' bash = "#{git_options.bin || Git.bin} #{command} #{options} #{args}" - exec bash, {cwd: git_dir, encoding:'binary', maxBuffer: 5000 * 1024}, callback + exec bash, {cwd: git_dir, encoding: encoding, maxBuffer: 5000 * 1024}, callback return bash # Public: Passthrough for raw git commands # - git.cmd = (command, options, args, callback) -> - git command, options, args, callback + git.cmd = (command, options, args, callback, encoding) -> + git command, options, args, encoding, callback # Public: stream results of git command # @@ -28,12 +29,13 @@ module.exports = Git = (git_dir, dot_git, git_options) -> # # returns [outstream, errstream] # - git.streamCmd = (command, options, args) -> + git.streamCmd = (command, options, args, encoding) -> options ?= {} options = options_to_argv options args ?= [] allargs = [command].concat(options).concat(args) - process = spawn Git.bin, allargs, {cwd: git_dir, encoding: 'binary'} + encoding ?= 'utf8' + process = spawn Git.bin, allargs, {cwd: git_dir, encoding: encoding} return [process.stdout, process.stderr] # Public: Get a list of the remote names. diff --git a/src/repo.coffee b/src/repo.coffee index f8edce8..3c0e2be 100644 --- a/src/repo.coffee +++ b/src/repo.coffee @@ -160,6 +160,7 @@ module.exports = class Repo return callback err, Diff.parse_raw(this, stdout) else return callback err, Diff.parse(this, stdout) + , 'binary' # Public: Get the repository's remotes. diff --git a/src/tree.coffee b/src/tree.coffee index 3d67221..e99c2c5 100644 --- a/src/tree.coffee +++ b/src/tree.coffee @@ -27,6 +27,7 @@ module.exports = class Tree for line in stdout.split("\n") @_contents.push @content_from_string(line) if line return callback null, @_contents + , 'binary' # Public: Get the child blobs.