func (c *Config) builtinGitClone(username, url string, workingTreeRawPath chezmoi.AbsPath) error {
	if c.init.ssh {
		return errors.New("builtin git does not support cloning repos over ssh, please install git")
	}

	isBare := false
	var referenceName plumbing.ReferenceName
	if c.init.branch != "" {
		referenceName = plumbing.NewBranchReferenceName(c.init.branch)
	}
	cloneOptions := git.CloneOptions{
		URL:               url,
		Depth:             c.init.depth,
		ReferenceName:     referenceName,
		RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
	}

	for {
		_, err := git.PlainClone(workingTreeRawPath.String(), isBare, &cloneOptions)
		c.logger.Err(err).
			Stringer("path", workingTreeRawPath).
			Bool("isBare", isBare).
			Object("o", loggableGitCloneOptions(cloneOptions)).
			Msg("PlainClone")
		if !errors.Is(err, transport.ErrAuthenticationRequired) {
			return err
		}

		if _, err := fmt.Fprintf(c.stdout, "chezmoi: %s: %v\n", url, err); err != nil {
			return err
		}
		var basicAuth http.BasicAuth
		if basicAuth.Username, err = c.readLine(fmt.Sprintf("Username [default %q]? ", username)); err != nil {
			return err
		}
		if basicAuth.Username == "" {
			basicAuth.Username = username
		}
		if basicAuth.Password, err = c.readPassword("Password? "); err != nil {
			return err
		}
		cloneOptions.Auth = &basicAuth
	}
}
// builtinGitClone clones a repo using the builtin git command.
builtinGitClone clones a repo using the builtin git command.
// builtinGitClone clones a repo using the builtin git command .
func (c *Config) builtinGitClone(username, url string, workingTreeRawPath chezmoi.AbsPath) error {
	if c.init.ssh {
		return errors.New("builtin git does not support cloning repos over ssh, please install git")
	}
	isBare := false
	var referenceName plumbing.ReferenceName
	if c.init.branch != "" {
		referenceName = plumbing.NewBranchReferenceName(c.init.branch)
	}
	cloneOptions := git.CloneOptions{
		URL:               url,
		Depth:             c.init.depth,
		ReferenceName:     referenceName,
		RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
	}
	for {
		_, err := git.PlainClone(workingTreeRawPath.String(), isBare, &cloneOptions)
		c.logger.Err(err).
			Stringer("path", workingTreeRawPath).
			Bool("isBare", isBare).
			Object("o", loggableGitCloneOptions(cloneOptions)).
			Msg("PlainClone")
		if !errors.Is(err, transport.ErrAuthenticationRequired) {
			return err
		}
		if _, err := fmt.Fprintf(c.stdout, "chezmoi: %s: %v\n", url, err); err != nil {
			return err
		}
		var basicAuth http.BasicAuth
		if basicAuth.Username, err = c.readLine(fmt.Sprintf("Username [default %q]? ", username)); err != nil {
			return err
		}
		if basicAuth.Username == "" {
			basicAuth.Username = username
		}
		if basicAuth.Password, err = c.readPassword("Password? "); err != nil {
			return err
		}
		cloneOptions.Auth = &basicAuth
	}
}
func ( c * Config ) builtinGitClone ( username , url string , workingTreeRawPath chezmoi . AbsPath ) error { if c . init . ssh { return errors . New ( " " ) } isBare := false var referenceName plumbing . ReferenceName if c . init . branch != " " { referenceName = plumbing . NewBranchReferenceName ( c . init . branch ) } cloneOptions := git . CloneOptions { URL : url , Depth : c . init . depth , ReferenceName : referenceName , RecurseSubmodules : git . DefaultSubmoduleRecursionDepth , } for { _ , err := git . PlainClone ( workingTreeRawPath . String ( ) , isBare , & cloneOptions ) c . logger . Err ( err ) . Stringer ( " " , workingTreeRawPath ) . Bool ( " " , isBare ) . Object ( " " , loggableGitCloneOptions ( cloneOptions ) ) . Msg ( " " ) if ! errors . Is ( err , transport . ErrAuthenticationRequired ) { return err } if _ , err := fmt . Fprintf ( c . stdout , " \n " , url , err ) ; err != nil { return err } var basicAuth http . BasicAuth if basicAuth . Username , err = c . readLine ( fmt . Sprintf ( " " , username ) ) ; err != nil { return err } if basicAuth . Username == " " { basicAuth . Username = username } if basicAuth . Password , err = c . readPassword ( " " ) ; err != nil { return err } cloneOptions . Auth = & basicAuth } }
builtinGitClone clones a repo using the builtin git command.
builtinGitClone clones a repo using the builtin git command .