MCPcopy Create free account
hub / github.com/go-git/go-git / PlainInitWithOptions

Function PlainInitWithOptions

repository.go:251–292  ·  view source on GitHub ↗
(path string, opts *PlainInitOptions)

Source from the content-addressed store, hash-verified

249}
250
251func PlainInitWithOptions(path string, opts *PlainInitOptions) (*Repository, error) {
252 if opts == nil {
253 opts = &PlainInitOptions{}
254 }
255
256 var wt, dot billy.Filesystem
257
258 if opts.Bare {
259 dot = osfs.New(path)
260 } else {
261 wt = osfs.New(path)
262 dot, _ = wt.Chroot(GitDirName)
263 }
264
265 s := filesystem.NewStorage(dot, cache.NewObjectLRUDefault())
266
267 r, err := InitWithOptions(s, wt, opts.InitOptions)
268 if err != nil {
269 return nil, err
270 }
271
272 cfg, err := r.Config()
273 if err != nil {
274 return nil, err
275 }
276
277 if opts.ObjectFormat != "" {
278 if opts.ObjectFormat == formatcfg.SHA256 && hash.CryptoType != crypto.SHA256 {
279 return nil, ErrSHA256NotSupported
280 }
281
282 cfg.Core.RepositoryFormatVersion = formatcfg.Version_1
283 cfg.Extensions.ObjectFormat = opts.ObjectFormat
284 }
285
286 err = r.Storer.SetConfig(cfg)
287 if err != nil {
288 return nil, err
289 }
290
291 return r, err
292}
293
294// PlainOpen opens a git repository from the given path. It detects if the
295// repository is bare or a normal one. If the path doesn't contain a valid

Callers 2

PlainInitFunction · 0.85

Calls 6

NewStorageFunction · 0.92
NewObjectLRUDefaultFunction · 0.92
InitWithOptionsFunction · 0.85
ChrootMethod · 0.80
ConfigMethod · 0.65
SetConfigMethod · 0.65

Tested by 1