1
0
mirror of https://github.com/danog/gift.git synced 2024-11-26 20:04:47 +01:00

Merge remote-tracking branch 'BastienLQ/master'

* BastienLQ/master:
  set 'utf8' encoding as default

Conflicts:
	src/git.coffee

Closes #55
This commit is contained in:
Luke Plaster 2015-04-14 23:11:52 +02:00
commit a253157cea
4 changed files with 11 additions and 6 deletions

View File

@ -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
#

View File

@ -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.

View File

@ -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.

View File

@ -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.