@@ -15,7 +15,7 @@ import (
1515type RemoteHandler interface {
1616 List (remote * Remote , forPush bool ) ([]string , error )
1717 Fetch (remote * Remote , refsToFetch []RefToFetch ) error
18- Push (remote * Remote , refsToPush []RefToPush ) (* []string , error )
18+ Push (remote * Remote , refsToPush []RefToPush ) ([]string , error )
1919
2020 Initialize (remote * Remote ) error
2121}
@@ -30,10 +30,8 @@ type Remote struct {
3030
3131 Handler RemoteHandler
3232
33- todo []func () (string , error )
34- pushList []func () (* []string , error )
35- fetchList []func () error
36- Force bool
33+ todo []func () (string , error )
34+ Force bool
3735}
3836
3937type RefToPush struct {
@@ -89,23 +87,12 @@ func (r *Remote) Printf(format string, a ...interface{}) (n int, err error) {
8987 return fmt .Fprintf (r .writer , format , a ... )
9088}
9189
92- func (r * Remote ) push (refsToPush []RefToPush ) {
93- r .pushList = append (r .pushList , func () (* []string , error ) {
94- locals , err := r .Handler .Push (r , refsToPush )
95- if err != nil {
96- return nil , err
97- }
98-
99- return locals , nil
100-
101- //return fmt.Sprintf("ok %s\n", done), nil, nil
102- })
90+ func (r * Remote ) push (refsToPush []RefToPush ) ([]string , error ) {
91+ return r .Handler .Push (r , refsToPush )
10392}
10493
105- func (r * Remote ) fetch (refsToFetch []RefToFetch ) {
106- r .fetchList = append (r .fetchList , func () error {
107- return r .Handler .Fetch (r , refsToFetch )
108- })
94+ func (r * Remote ) fetch (refsToFetch []RefToFetch ) error {
95+ return r .Handler .Fetch (r , refsToFetch )
10996}
11097
11198func (r * Remote ) ProcessCommands () error {
@@ -161,16 +148,12 @@ loop:
161148 fallthrough
162149 case command == "\n " :
163150 if strings .HasPrefix (prevCommand , "push " ) {
164- r .push (refsToPush )
165- var locals * []string
166- for _ , task := range r .pushList {
167- locals , err = task ()
168- if err != nil {
169- return err
170- }
151+ locals , err := r .push (refsToPush )
152+ if err != nil {
153+ return err
171154 }
172155 if locals != nil {
173- for _ , local := range * locals {
156+ for _ , local := range locals {
174157 r .Printf ("ok %s\n " , local )
175158 }
176159 r .Printf ("\n " )
@@ -181,12 +164,9 @@ loop:
181164 }
182165
183166 if strings .HasPrefix (prevCommand , "fetch " ) {
184- r .fetch (refsToFetch )
185- for _ , task := range r .fetchList {
186- err = task ()
187- if err != nil {
188- return err
189- }
167+ err = r .fetch (refsToFetch )
168+ if err != nil {
169+ return err
190170 }
191171
192172 r .Printf ("\n " )
0 commit comments