MCPcopy
hub / github.com/git-lfs/git-lfs / pointerCommand

Function pointerCommand

commands/command_pointer.go:27–152  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

25)
26
27func pointerCommand(cmd *cobra.Command, args []string) {
28 comparing := false
29 something := false
30 buildOid := ""
31 compareOid := ""
32
33 if pointerCheck {
34 var r io.ReadCloser
35 var err error
36
37 if pointerStrict && pointerNoStrict {
38 ExitWithError(errors.New(tr.Tr.Get("Cannot combine --strict with --no-strict")))
39 }
40
41 if len(pointerCompare) > 0 {
42 ExitWithError(errors.New(tr.Tr.Get("Cannot combine --check with --compare")))
43 }
44
45 if len(pointerFile) > 0 {
46 if pointerStdin {
47 ExitWithError(errors.New(tr.Tr.Get("With --check, --file cannot be combined with --stdin")))
48 }
49 r, err = os.Open(pointerFile)
50 if err != nil {
51 ExitWithError(err)
52 }
53 } else if pointerStdin {
54 r = io.NopCloser(os.Stdin)
55 } else {
56 ExitWithError(errors.New(tr.Tr.Get("Must specify either --file or --stdin with --compare")))
57 }
58
59 p, err := lfs.DecodePointer(r)
60 if err != nil {
61 os.Exit(1)
62 }
63 if pointerStrict && !p.Canonical {
64 os.Exit(2)
65 }
66 r.Close()
67 return
68 }
69
70 if len(pointerCompare) > 0 || pointerStdin {
71 comparing = true
72 }
73
74 if len(pointerFile) > 0 {
75 something = true
76 buildFile, err := os.Open(pointerFile)
77 if err != nil {
78 Error(err.Error())
79 os.Exit(1)
80 }
81
82 oidHash := sha256.New()
83 size, err := io.Copy(oidHash, buildFile)
84 buildFile.Close()

Callers

nothing calls this directly

Calls 11

DecodePointerFunction · 0.92
NewPointerFunction · 0.92
EncodePointerFunction · 0.92
HashObjectFunction · 0.92
ExitWithErrorFunction · 0.85
ErrorFunction · 0.85
pointerReaderFunction · 0.85
GetMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected