Skip to content

Commit

Permalink
Merge remote-tracking branch 'BastienLQ/master'
Browse files Browse the repository at this point in the history
* BastienLQ/master:
  set 'utf8' encoding as default

Conflicts:
	src/git.coffee

Closes #55
  • Loading branch information
notatestuser committed Apr 14, 2015
2 parents 3e0c426 + 08690db commit a253157
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/blob.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
14 changes: 8 additions & 6 deletions src/git.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,37 @@ 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 ?= {}
options = options_to_argv 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
#
# This is used for large files that you'd need to stream.
#
# 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.
Expand Down
1 change: 1 addition & 0 deletions src/repo.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/tree.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit a253157

Please sign in to comment.