github.com/driusan/dgit@v0.0.0-20221118233547-f39f0c15edbb/cmd/fetchpack.go (about)

     1  package cmd
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/driusan/dgit/git"
     7  )
     8  
     9  func FetchPack(c *git.Client, args []string) error {
    10  	flags := newFlagSet("fetch-pack")
    11  	opts := git.FetchPackOptions{}
    12  	flags.BoolVar(&opts.All, "all", false, "Fetch all remote refs")
    13  	flags.BoolVar(&opts.Quiet, "quiet", false, "Do not print indexing status")
    14  	flags.BoolVar(&opts.Quiet, "q", false, "Alias of --quiet")
    15  	flags.BoolVar(&opts.Keep, "keep", false, "Not implemented")
    16  	flags.BoolVar(&opts.Keep, "k", false, "Not implemented")
    17  	flags.BoolVar(&opts.Thin, "thin", false, "Fetches a thin pack (Not implemented)")
    18  	flags.BoolVar(&opts.IncludeTag, "include-tag", false, "Send annotated tags along with other objects")
    19  	flags.BoolVar(&opts.NoProgress, "no-progress", false, "Do not show progress information")
    20  	flags.StringVar(&opts.UploadPack, "upload-pack", "", "Execute upload-pack instead of git-upload-pack")
    21  	flags.StringVar(&opts.UploadPack, "exec", "", "Execute upload-pack instead of git-upload-pack")
    22  	depth := flags.Int("depth", 2147483647, "Not implemented")
    23  	_ = flags.String("shallow-since", "", "Not implemented")
    24  	_ = flags.String("shallow-exclude", "", "Not implemented")
    25  	flags.BoolVar(&opts.DeepenRelative, "deepen-relative", false, "Not implemented")
    26  	flags.BoolVar(&opts.CheckSelfContainedAndConnected, "check-self-contained-and-connected", false, "Not implemented")
    27  	flags.BoolVar(&opts.Verbose, "verbose", false, "Be more verbose")
    28  	flags.BoolVar(&opts.Verbose, "v", false, "Alias of verbose")
    29  	flags.Parse(args)
    30  	args = flags.Args()
    31  	opts.Depth = int32(*depth)
    32  	if len(args) < 1 {
    33  		flags.Usage()
    34  		return fmt.Errorf("Invalid flag usage")
    35  	}
    36  	rmt := git.Remote(args[0])
    37  	var wants []git.Refname
    38  	for _, name := range args[1:] {
    39  		wants = append(wants, git.Refname(name))
    40  	}
    41  	_, err := git.FetchPack(c, opts, rmt, wants)
    42  	return err
    43  }