@@ -70,9 +70,8 @@ type Repository struct {
70
70
func smartJoin (path , relPath string ) string {
71
71
if filepath .IsAbs (relPath ) {
72
72
return relPath
73
- } else {
74
- return filepath .Join (path , relPath )
75
73
}
74
+ return filepath .Join (path , relPath )
76
75
}
77
76
78
77
func NewRepository (path string ) (* Repository , error ) {
@@ -81,18 +80,14 @@ func NewRepository(path string) (*Repository, error) {
81
80
if err != nil {
82
81
switch err := err .(type ) {
83
82
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 ,
89
86
)
90
87
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 ,
96
91
)
97
92
default :
98
93
return nil , err
@@ -104,10 +99,8 @@ func NewRepository(path string) (*Repository, error) {
104
99
cmd .Dir = gitDir
105
100
out , err = cmd .Output ()
106
101
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 ,
111
104
)
112
105
}
113
106
shallow := smartJoin (gitDir , string (bytes .TrimSpace (out )))
@@ -376,7 +369,7 @@ func parseBatchHeader(spec string, header string) (OID, ObjectType, counts.Count
376
369
if spec == "" {
377
370
spec = words [0 ]
378
371
}
379
- return OID {}, "missing" , 0 , errors . New ( fmt .Sprintf ("missing object %s" , spec ) )
372
+ return OID {}, "missing" , 0 , fmt .Errorf ("missing object %s" , spec )
380
373
}
381
374
382
375
oid , err := NewOID (words [0 ])
0 commit comments