MCPcopy
hub / github.com/go-git/go-git / PlainInitWithOptions

Function PlainInitWithOptions

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

Source from the content-addressed store, hash-verified

256}
257
258func PlainInitWithOptions(path string, opts *PlainInitOptions) (*Repository, error) {
259 if opts == nil {
260 opts = &PlainInitOptions{}
261 }
262
263 var wt, dot billy.Filesystem
264
265 if opts.Bare {
266 dot = osfs.New(path)
267 } else {
268 wt = osfs.New(path)
269 dot, _ = wt.Chroot(GitDirName)
270 }
271
272 s := filesystem.NewStorage(dot, cache.NewObjectLRUDefault())
273
274 r, err := InitWithOptions(s, wt, opts.InitOptions)
275 if err != nil {
276 return nil, err
277 }
278
279 cfg, err := r.Config()
280 if err != nil {
281 return nil, err
282 }
283
284 if opts.ObjectFormat != "" {
285 if opts.ObjectFormat == formatcfg.SHA256 && hash.CryptoType != crypto.SHA256 {
286 return nil, ErrSHA256NotSupported
287 }
288
289 cfg.Core.RepositoryFormatVersion = formatcfg.Version_1
290 cfg.Extensions.ObjectFormat = opts.ObjectFormat
291 }
292
293 err = r.Storer.SetConfig(cfg)
294 if err != nil {
295 return nil, err
296 }
297
298 return r, err
299}
300
301// PlainOpen opens a git repository from the given path. It detects if the
302// 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
ConfigMethod · 0.65
SetConfigMethod · 0.65
ChrootMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…