You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: git_ref.go
    path of file: ./repos/moby/vendor/github.com/moby/buildkit/util/gitutil
    
    the code of the file until where you have to start completion: package gitutil

import (
	"net/url"
	"strings"

	"github.com/containerd/containerd/errdefs"
	"github.com/pkg/errors"
)

// GitRef represents a git ref.
//
// Examples:
//   - "https://github.com/foo/bar.git#baz/qux:quux/quuz" is parsed into:
//     {Remote: "https://github.com/foo/bar.git", ShortName: "bar", Commit:"baz/qux", SubDir: "quux/quuz"}.
type GitRef struct {
	// Remote is the remote repository path.
	Remote string

	// ShortName is the directory name of the repo.
	// e.g., "bar" for "https://github.com/foo/bar.git"
	ShortName string

	// Commit is a co
    
func ParseGitRef(ref string) (*GitRef, error) {
	res := &GitRef{}

	var (
		remote *GitURL
		err    error
	)

	if strings.HasPrefix(ref, "github.com/") {
		res.IndistinguishableFromLocal = true // Deprecated
		remote = fromURL(&url.URL{
			Scheme: "https",
			Host:   "github.com",
			Path:   strings.TrimPrefix(ref, "github.com/"),
		})
	} else {
		remote, err = ParseURL(ref)
		if errors.Is(err, ErrUnknownProtocol) {
			remote, err = ParseURL("https://" + ref)
		}
		if err != nil {
			return nil, err
		}

		switch remote.Scheme {
		case HTTPProtocol, GitProtocol:
			res.UnencryptedTCP = true // Discouraged, but not deprecated
		}

		switch remote.Scheme {
		// An HTTP(S) URL is considered to be a valid git ref only when it has the ".git[...]" suffix.
		case HTTPProtocol, HTTPSProtocol:
			if !strings.HasSuffix(remote.Path, ".git") {
				return nil, errdefs.ErrInvalidArgument
			}
		}
	}

	res.Remote = remote.Remote
	if res.IndistinguishableFromLocal {
		_, res.Remote, _ = strings.Cut(res.Remote, "://")
	}
	if remote.Fragment != nil {
		res.Commit, res.SubDir = remote.Fragment.Ref, remote.Fragment.Subdir
	}

	repoSplitBySlash := strings.Split(res.Remote, "/")
	res.ShortName = strings.TrimSuffix(repoSplitBySlash[len(repoSplitBySlash)-1], ".git")

	return res, nil
}