From fdc83998c8c40ffdaa05592ae9f2329a430b3e91 Mon Sep 17 00:00:00 2001 From: eytan Date: Thu, 25 Dec 2014 13:45:11 -0500 Subject: [PATCH] enable specify git binary location along with other options in the constructor Conflicts: src/git.coffee cc #49 cc sentientwaffle/gift#32 --- src/git.coffee | 5 +++-- src/index.coffee | 4 ++-- src/repo.coffee | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/git.coffee b/src/git.coffee index eded6ac..907a444 100644 --- a/src/git.coffee +++ b/src/git.coffee @@ -1,7 +1,8 @@ fs = require 'fs' {exec, spawn} = require 'child_process' -module.exports = Git = (git_dir, dot_git) -> +module.exports = Git = (git_dir, dot_git, git_options) -> + git_options ||= {} dot_git ||= "#{git_dir}/.git" git = (command, options, args, callback) -> @@ -12,7 +13,7 @@ module.exports = Git = (git_dir, dot_git) -> options = options.join " " args ?= [] args = args.join " " if args instanceof Array - bash = "#{Git.bin} #{command} #{options} #{args}" + bash = "#{git_options.bin || Git.bin} #{command} #{options} #{args}" exec bash, {cwd: git_dir, encoding:'binary'}, callback return bash diff --git a/src/index.coffee b/src/index.coffee index 2a61bdf..2991a72 100644 --- a/src/index.coffee +++ b/src/index.coffee @@ -4,8 +4,8 @@ Repo = require './repo' # Public: Create a Repo from the given path. # # Returns Repo. -module.exports = Git = (path, bare=false) -> - return new Repo path, bare +module.exports = Git = (path, bare=false, git_options={}) -> + return new Repo path, bare, git_options # Public: Initialize a git repository. diff --git a/src/repo.coffee b/src/repo.coffee index aa992fb..f8edce8 100644 --- a/src/repo.coffee +++ b/src/repo.coffee @@ -11,12 +11,12 @@ Status = require './status' {Ref, Head} = require './ref' module.exports = class Repo - constructor: (@path, @bare) -> + constructor: (@path, @bare, @git_options) -> if @bare @dot_git = @path else @dot_git = "#{@path}/.git" - @git = cmd @path, @dot_git + @git = cmd @path, @dot_git, @git_options # Public: Get the commit identity for this repository.