(cmd *cobra.Command, args []string)
| 24 | ) |
| 25 | |
| 26 | func checkoutCommand(cmd *cobra.Command, args []string) { |
| 27 | setupRepository() |
| 28 | |
| 29 | // TODO: After suitable advance public notice, replace this block |
| 30 | // and the preceding call to setupRepository() with a single call to |
| 31 | // setupWorkingCopy(), which will perform the same check for a bare |
| 32 | // repository but will exit non-zero, as other commands already do. |
| 33 | if cfg.LocalWorkingDir() == "" { |
| 34 | Print(tr.Tr.Get("This operation must be run in a work tree.")) |
| 35 | os.Exit(0) |
| 36 | } |
| 37 | |
| 38 | stage, err := whichCheckout() |
| 39 | if err != nil { |
| 40 | Exit(tr.Tr.Get("Error parsing args: %v", err)) |
| 41 | } |
| 42 | |
| 43 | rootedPaths := rootedPaths(args) |
| 44 | |
| 45 | if checkoutTo != "" && stage != git.IndexStageDefault { |
| 46 | if len(args) != 1 { |
| 47 | Exit(tr.Tr.Get("--to requires exactly one Git LFS object file path")) |
| 48 | } |
| 49 | checkoutConflict(rootedPaths[0], stage) |
| 50 | return |
| 51 | } else if checkoutTo != "" || stage != git.IndexStageDefault { |
| 52 | Exit(tr.Tr.Get("--to and exactly one of --theirs, --ours, and --base must be used together")) |
| 53 | } |
| 54 | |
| 55 | ref, err := git.CurrentRef() |
| 56 | if err != nil { |
| 57 | Panic(err, tr.Tr.Get("Could not checkout")) |
| 58 | } |
| 59 | |
| 60 | // will chdir to root of working tree, if one exists |
| 61 | singleCheckout := newSingleCheckout(cfg.Git, "") |
| 62 | if singleCheckout.Skip() { |
| 63 | fmt.Println(tr.Tr.Get("Cannot checkout LFS objects, Git LFS is not installed.")) |
| 64 | return |
| 65 | } |
| 66 | |
| 67 | var totalBytes int64 |
| 68 | var pointers []*lfs.WrappedPointer |
| 69 | logger := tasklog.NewLogger(os.Stdout, |
| 70 | tasklog.ForceProgress(cfg.ForceProgress()), |
| 71 | ) |
| 72 | meter := tq.NewMeter(cfg) |
| 73 | meter.Direction = tq.Checkout |
| 74 | meter.Logger = meter.LoggerFromEnv(cfg.Os) |
| 75 | logger.Enqueue(meter) |
| 76 | chgitscanner := lfs.NewGitScanner(cfg, func(p *lfs.WrappedPointer, err error) { |
| 77 | if err != nil { |
| 78 | LoggedError(err, tr.Tr.Get("Scanner error: %s", err)) |
| 79 | return |
| 80 | } |
| 81 | |
| 82 | totalBytes += p.Size |
| 83 | meter.Add(p.Size) |
nothing calls this directly
no test coverage detected