@@ -12,12 +12,15 @@ var Git = function(p)
12
12
13
13
Git . prototype . git = function ( /* command, args, options, callback */ )
14
14
{
15
- var command , gitargs = [ ] , options = { } , callback = null ;
15
+ var gitargs = [ ] , options = { } , callback = null ;
16
16
var args = Array . prototype . slice . call ( arguments ) ;
17
17
18
- command = args . shift ( ) ;
18
+ gitargs . push ( args . shift ( ) ) ;
19
+ while ( typeof args [ 0 ] === "string" )
20
+ gitargs . push ( args . shift ( ) ) ;
19
21
if ( util . isArray ( args [ 0 ] ) )
20
- gitargs = args . shift ( ) ;
22
+ gitargs = gitargs . concat ( args . shift ( ) ) ;
23
+
21
24
if ( typeof args [ 0 ] === "object" )
22
25
options = args . shift ( ) ;
23
26
if ( typeof args [ 0 ] === "function" )
@@ -27,7 +30,6 @@ Git.prototype.git = function(/* command, args, options, callback */)
27
30
options . env = options . env || { } ;
28
31
options . cwd = options . cwd || this . path ;
29
32
30
- gitargs . unshift ( command ) ;
31
33
var child = spawn ( "git" , gitargs , { cwd : options . cwd , env : options . env } ) ;
32
34
33
35
child . stderr . setEncoding ( 'utf8' ) ;
@@ -68,7 +70,7 @@ Git.prototype.git = function(/* command, args, options, callback */)
68
70
Git . prototype . status = function ( callback ) {
69
71
var result = Object . create ( null ) ;
70
72
71
- var child = this . git ( "status" , [ "--porcelain" ] , function ( err ) {
73
+ var child = this . git ( "status" , "--porcelain" , function ( err ) {
72
74
if ( err ) callback ( err , null ) ;
73
75
else callback ( null , result ) ;
74
76
} ) ;
@@ -81,23 +83,23 @@ Git.prototype.status = function(callback) {
81
83
} ;
82
84
83
85
Git . prototype . addAll = function ( callback ) {
84
- this . git ( "add" , [ "--all" , ":/" ] , callback ) ;
86
+ this . git ( "add" , "--all" , ":/" , callback ) ;
85
87
} ;
86
88
87
89
Git . prototype . update_ref = function ( /* ref, value, oldvalue, callback */ ) {
88
- var ref , value , oldvalue , callback ;
90
+ var ref , value , oldvalue = null , callback ;
89
91
var args = Array . prototype . slice . call ( arguments ) ;
90
92
91
93
ref = args . shift ( ) ;
92
94
value = args . shift ( ) ;
93
- if ( typeof args [ 0 ] === "string" )
95
+ if ( typeof args [ 0 ] === "string" || args [ 0 ] === null )
94
96
oldvalue = args . shift ( ) ;
95
97
callback = args . shift ( ) ;
96
98
97
99
if ( oldvalue !== null )
98
- this . git ( "update-ref" , [ ref , value , oldvalue ] , callback ) ;
100
+ this . git ( "update-ref" , ref , value , oldvalue , callback ) ;
99
101
else
100
- this . git ( "update-ref" , [ ref , value ] , callback ) ;
102
+ this . git ( "update-ref" , ref , value , callback ) ;
101
103
} ;
102
104
103
105
@@ -134,10 +136,10 @@ Git.prototype.commit_tree = function(/* tree, message, parents, options, callbac
134
136
135
137
var result = null ;
136
138
137
- var gitargs = [ tree ] ;
139
+ var parentFlags = [ ] ;
138
140
for ( var k in parents ) {
139
- gitargs . push ( "-p" ) ;
140
- gitargs . push ( parents [ k ] ) ;
141
+ parentFlags . push ( "-p" ) ;
142
+ parentFlags . push ( parents [ k ] ) ;
141
143
}
142
144
143
145
var env = { } ;
@@ -150,7 +152,7 @@ Git.prototype.commit_tree = function(/* tree, message, parents, options, callbac
150
152
env . GIT_COMMITTER_EMAIL = options . committer . email ;
151
153
}
152
154
153
- var child = this . git ( "commit-tree" , gitargs , { env : env } , function ( err ) {
155
+ var child = this . git ( "commit-tree" , tree , parentFlags , { env : env } , function ( err ) {
154
156
if ( err ) callback ( err , null ) ;
155
157
else callback ( null , result ) ;
156
158
} ) ;
0 commit comments