@@ -70,9 +70,8 @@ type Repository struct {
7070func smartJoin (path , relPath string ) string {
7171 if filepath .IsAbs (relPath ) {
7272 return relPath
73- } else {
74- return filepath .Join (path , relPath )
7573 }
74+ return filepath .Join (path , relPath )
7675}
7776
7877func NewRepository (path string ) (* Repository , error ) {
@@ -81,18 +80,14 @@ func NewRepository(path string) (*Repository, error) {
8180 if err != nil {
8281 switch err := err .(type ) {
8382 case * exec.Error :
84- return nil , errors .New (
85- fmt .Sprintf (
86- "could not run git (is it in your PATH?): %s" ,
87- err .Err ,
88- ),
83+ return nil , fmt .Errorf (
84+ "could not run git (is it in your PATH?): %s" ,
85+ err .Err ,
8986 )
9087 case * exec.ExitError :
91- return nil , errors .New (
92- fmt .Sprintf (
93- "git rev-parse failed: %s" ,
94- err .Stderr ,
95- ),
88+ return nil , fmt .Errorf (
89+ "git rev-parse failed: %s" ,
90+ err .Stderr ,
9691 )
9792 default :
9893 return nil , err
@@ -104,10 +99,8 @@ func NewRepository(path string) (*Repository, error) {
10499 cmd .Dir = gitDir
105100 out , err = cmd .Output ()
106101 if err != nil {
107- return nil , errors .New (
108- fmt .Sprintf (
109- "could not run 'git rev-parse --git-path shallow': %s" , err ,
110- ),
102+ return nil , fmt .Errorf (
103+ "could not run 'git rev-parse --git-path shallow': %s" , err ,
111104 )
112105 }
113106 shallow := smartJoin (gitDir , string (bytes .TrimSpace (out )))
@@ -376,7 +369,7 @@ func parseBatchHeader(spec string, header string) (OID, ObjectType, counts.Count
376369 if spec == "" {
377370 spec = words [0 ]
378371 }
379- return OID {}, "missing" , 0 , errors . New ( fmt .Sprintf ("missing object %s" , spec ) )
372+ return OID {}, "missing" , 0 , fmt .Errorf ("missing object %s" , spec )
380373 }
381374
382375 oid , err := NewOID (words [0 ])
0 commit comments