Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arg substitution for shell special chars #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/git.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ module.exports = Git = (git_dir, dot_git, git_options) ->
options = options_to_argv options
options = options.join " "
args ?= []
args = args.join " " if args instanceof Array
if args instanceof Array
shell_args = for arg in args
arg.replace(/(["\s'$`\\])/g,'\\$1')
args = shell_args.join " "
encoding ?= 'utf8'
bash = "#{git_options.bin || Git.bin} #{command} #{options} #{args}"
exec bash, {
Expand Down
4 changes: 2 additions & 2 deletions src/repo.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ module.exports = class Repo
#
identify: (actor, callback) ->
# git config user.email "[email protected]"
@git "config", {}, ["user.email", "\"#{actor.email}\""], (err) =>
@git "config", {}, ["user.email", "#{actor.email}"], (err) =>
return callback err if err
# git config user.name "Your Name"
@git "config", {}, ["user.name", "\"#{actor.name}\""], (err) =>
@git "config", {}, ["user.name", "#{actor.name}"], (err) =>
return callback err if err
return callback null

Expand Down
2 changes: 1 addition & 1 deletion test/repo.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe "Repo", ->

describe "#add", ->
repo = null
git_dir = __dirname + "/fixtures/junk_add"
git_dir = __dirname + "/fixtures/junk _$add"
status = null
file = null

Expand Down