Debian Codegraph @

git/rev_list_scanner.go

raw symbols SCIP
1 package gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/
2
3 import (
4 "bufioscip-go gomod github.com/golang/go/src go1.25.0 bufio/"
5 "encoding/hexscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/"
6 "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/"
7 "ioscip-go gomod github.com/golang/go/src go1.25.0 io/"
8 "regexpscip-go gomod github.com/golang/go/src go1.25.0 regexp/"
9 "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/"
10 "syncscip-go gomod github.com/golang/go/src go1.25.0 sync/"
11
12 "github.com/git-lfs/git-lfs/v3/errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/"
13 "github.com/git-lfs/git-lfs/v3/trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/"
14 "github.com/rubyist/tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/"
15 )
16
17 // ScanningMode is a constant type that allows for variation in the range of
18 // commits to scan when given to the `*git.RevListScanner` type.
19 type ScanningModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanningMode# int
20
21 const (
22 // ScanRefsMode will scan between two refspecs.
23 ScanRefsModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsMode. ScanningModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanningMode# = iota
24 // ScanAllMode will scan all history.
25 ScanAllModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanAllMode.
26 // ScanRangeToRemoteMode will scan the difference between any included
27 // SHA1s and a remote tracking ref.
28 ScanRangeToRemoteModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRangeToRemoteMode.
29 )
30
31 // RevListOrder is a constant type that allows for variation in the ordering of
32 // revisions given by the *RevListScanner below.
33 type RevListOrderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListOrder# int
34
35 const (
36 // DefaultRevListOrder is the zero-value for this type and yields the
37 // results as given by git-rev-list(1) without any `--<t>-order`
38 // argument given. By default: reverse chronological order.
39 DefaultRevListOrderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/DefaultRevListOrder. RevListOrderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListOrder# = iota
40 // DateRevListOrder gives the revisions such that no parents are shown
41 // before children, and otherwise in commit timestamp order.
42 DateRevListOrderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/DateRevListOrder.
43 // AuthorDateRevListOrder gives the revisions such that no parents are
44 // shown before children, and otherwise in author date timestamp order.
45 AuthorDateRevListOrderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/AuthorDateRevListOrder.
46 // TopoRevListOrder gives the revisions such that they appear in
47 // topological order.
48 TopoRevListOrderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/TopoRevListOrder.
49 )
50
51 // Flag returns the command-line flag to be passed to git-rev-list(1) in order
52 // to order the output according to the given RevListOrder. It returns both the
53 // flag ("--date-order", "--topo-order", etc) and a bool, whether or not to
54 // append the flag (for instance, DefaultRevListOrder requires no flag).
55 //
56 // Given a type other than those defined above, Flag() will panic().
57 func (o RevListOrderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListOrder#) Flagscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListOrder#Flag().() (string, bool) {
58 switch o {
59 case DefaultRevListOrderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/DefaultRevListOrder.:
60 return "", false
61 case DateRevListOrderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/DateRevListOrder.:
62 return "--date-order", true
63 case AuthorDateRevListOrderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/AuthorDateRevListOrder.:
64 return "--author-date-order", true
65 case TopoRevListOrderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/TopoRevListOrder.:
66 return "--topo-order", true
67 default:
68 panic(fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("git/rev_list_scanner: %s", trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("unknown RevListOrder %d", o)))
69 }
70 }
71
72 // ScanRefsOptions is an "options" type that is used to configure a scan
73 // operation on the `*git.RevListScanner` instance when given to the function
74 // `NewRevListScanner()`.
75 type ScanRefsOptionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions# struct {
76 // Mode is the scan mode to apply, see above.
77 Modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Mode. ScanningModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanningMode#
78 // Remote is the current remote to scan against, if using
79 // ScanRangeToRemoteMode.
80 Remotescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Remote. string
81 // SkipDeletedBlobs specifies whether or not to traverse into commit
82 // ancestry (revealing potentially deleted (unreferenced) blobs, trees,
83 // or commits.
84 SkipDeletedBlobsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#SkipDeletedBlobs. bool
85 // Order specifies the order in which revisions are yielded from the
86 // output of `git-rev-list(1)`. For more information, see the above
87 // documentation on the RevListOrder type.
88 Orderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Order. RevListOrderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListOrder#
89 // CommitsOnly specifies whether or not the *RevListScanner should
90 // return only commits, or all objects in range by performing a
91 // traversal of the graph. By default, false: show all objects.
92 CommitsOnlyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#CommitsOnly. bool
93 // WorkingDir specifies the working directory in which to run
94 // git-rev-list(1). If this is an empty string, (has len(WorkingDir) ==
95 // 0), it is equivalent to running in os.Getwd().
96 WorkingDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#WorkingDir. string
97 // Reverse specifies whether or not to give the revisions in reverse
98 // order.
99 Reversescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Reverse. bool
100
101 // SkippedRefs provides a list of refs to ignore.
102 SkippedRefsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#SkippedRefs. []string
103 // Mutex guards names.
104 Mutexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Mutex. *syncscip-go gomod github.com/golang/go/src go1.25.0 sync/.Mutexscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#
105 // Names maps Git object IDs (encoded as hex using
106 // hex.EncodeString()) to their names, i.e., a directory name
107 // (fully-qualified) for trees, or a pathspec for blob tree entries.
108 Namesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Names. map[string]string
109 }
110
111 // GetName returns the name associated with a given blob/tree sha and "true" if
112 // it exists, or ("", false) if it doesn't.
113 //
114 // GetName is guarded by a use of o.Mutex, and is goroutine safe.
115 func (o *ScanRefsOptionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#) GetNamescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#GetName().(sha string) (string, bool) {
116 o.Mutexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Mutex..Lockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Lock().()
117 defer o.Mutexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Mutex..Unlockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Unlock().()
118
119 name, ok := o.Namesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Names.[sha]
120 return name, ok
121 }
122
123 // SetName sets the name associated with a given blob/tree sha.
124 //
125 // SetName is guarded by a use of o.Mutex, and is therefore goroutine safe.
126 func (o *ScanRefsOptionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#) SetNamescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#SetName().(sha, name string) {
127 o.Mutexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Mutex..Lockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Lock().()
128 defer o.Mutexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Mutex..Unlockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Unlock().()
129
130 o.Namesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Names.[sha] = name
131 }
132
133 // RevListScanner is a Scanner type that parses through results of the `git
134 // rev-list` command.
135 type RevListScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner# struct {
136 // s is a buffered scanner feeding from the output (stdout) of
137 // git-rev-list(1) invocation.
138 sscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#s. *bufioscip-go gomod github.com/golang/go/src go1.25.0 bufio/.Scannerscip-go gomod github.com/golang/go/src go1.25.0 bufio/Scanner#
139 // closeFn is an optional type returning an error yielded by closing any
140 // resources held by an open (running) instance of the *RevListScanner
141 // type.
142 closeFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#closeFn. func() error
143
144 // name is the name of the most recently read object.
145 namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#name. string
146 // oid is the oid of the most recently read object.
147 oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#oid. []byte
148 // err is the most recently encountered error.
149 errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#err. error
150 }
151
152 var (
153 // ambiguousRegex is a regular expression matching the output of stderr
154 // when ambiguous refnames are encountered.
155 ambiguousRegexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ambiguousRegex. = regexpscip-go gomod github.com/golang/go/src go1.25.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.25.0 regexp/MustCompile().(`warning: refname (.*) is ambiguous`)
156 )
157
158 // NewRevListScanner instantiates a new RevListScanner instance scanning all
159 // revisions reachable by refs contained in "include" and not reachable by any
160 // refs included in "excluded", using the *ScanRefsOptions "opt" configuration.
161 //
162 // It returns a new *RevListScanner instance, or an error if one was
163 // encountered. Upon returning, the `git-rev-list(1)` instance is already
164 // running, and Scan() may be called immediately.
165 func NewRevListScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/NewRevListScanner().(include, excluded []string, opt *ScanRefsOptionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#) (*RevListScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#, error) {
166 stdin, args, err := revListArgsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/revListArgs().(include, excluded, opt)
167 if err != nil {
168 return nil, err
169 }
170
171 cmd, err := gitNoLFSscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/gitNoLFS().(args...)
172 if err != nil {
173 return nil, err
174 }
175 if len(opt.WorkingDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#WorkingDir.) > 0 {
176 cmd.Dirscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/Cmd#Dir. = opt.WorkingDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#WorkingDir.
177 }
178
179 cmd.Stdinscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/Cmd#Stdin. = stdin
180 stdout, err := cmd.StdoutPipescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/Cmd#StdoutPipe().()
181 if err != nil {
182 return nil, err
183 }
184 stderr, err := cmd.StderrPipescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/Cmd#StderrPipe().()
185 if err != nil {
186 return nil, err
187 }
188
189 tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/.Printfscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/Printf().("run_command: git %s", stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.25.0 strings/Join().(args, " "))
190 if err := cmd.Startscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/Cmd#Start().(); err != nil {
191 return nil, err
192 }
193
194 return &RevListScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#{
195 sscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#s.: bufioscip-go gomod github.com/golang/go/src go1.25.0 bufio/.NewScannerscip-go gomod github.com/golang/go/src go1.25.0 bufio/NewScanner().(stdout),
196 closeFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#closeFn.: func() error {
197 msg, _ := ioscip-go gomod github.com/golang/go/src go1.25.0 io/.ReadAllscip-go gomod github.com/golang/go/src go1.25.0 io/ReadAll().(stderr)
198
199 // First check if there was a non-zero exit code given
200 // when Wait()-ing on the command execution.
201 if err := cmd.Waitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/Cmd#Wait().(); err != nil {
202 return errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/New().(trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("Error in `git %s`: %v %s",
203 stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.25.0 strings/Join().(args, " "), err, msg))
204 }
205
206 // If the command exited cleanly, but found an ambiguous
207 // refname, promote that to an error and return it.
208 //
209 // `git-rev-list(1)` does not treat ambiguous refnames
210 // as fatal (non-zero exit status), but we do.
211 if am := ambiguousRegexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ambiguousRegex..FindSubmatchscip-go gomod github.com/golang/go/src go1.25.0 regexp/Regexp#FindSubmatch().(msg); len(am) > 1 {
212 return errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/New().(trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("ref %q is ambiguous", am[1]))
213 }
214 return nil
215 },
216 }, nil
217 }
218
219 // revListArgs returns the arguments for a given included and excluded set of
220 // SHA1s, and ScanRefsOptions instance.
221 //
222 // In order, it returns the contents of stdin as an io.Reader, the args passed
223 // to git as a []string, and any error encountered in generating those if one
224 // occurred.
225 func revListArgsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/revListArgs().(include, exclude []string, opt *ScanRefsOptionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#) (ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Readerscip-go gomod github.com/golang/go/src go1.25.0 io/Reader#, []string, error) {
226 var stdin ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Readerscip-go gomod github.com/golang/go/src go1.25.0 io/Reader#
227 args := []string{"rev-list"}
228 if !opt.CommitsOnlyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#CommitsOnly. {
229 args = append(args, "--objects")
230 }
231
232 if opt.Reversescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Reverse. {
233 args = append(args, "--reverse")
234 }
235
236 if orderFlag, ok := opt.Orderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Order..Flagscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListOrder#Flag().(); ok {
237 args = append(args, orderFlag)
238 }
239
240 switch opt.Modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Mode. {
241 case ScanRefsModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsMode.:
242 if opt.SkipDeletedBlobsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#SkipDeletedBlobs. {
243 args = append(args, "--no-walk")
244 } else {
245 args = append(args, "--do-walk")
246 }
247
248 stdin = stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.NewReaderscip-go gomod github.com/golang/go/src go1.25.0 strings/NewReader().(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.25.0 strings/Join().(
249 includeExcludeShasscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/includeExcludeShas().(include, exclude), "\n"))
250 case ScanAllModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanAllMode.:
251 args = append(args, "--all")
252 case ScanRangeToRemoteModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRangeToRemoteMode.:
253 args = append(args, "--ignore-missing")
254 if len(opt.SkippedRefsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#SkippedRefs.) == 0 {
255 args = append(args, "--not", "--remotes="+opt.Remotescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Remote.)
256 stdin = stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.NewReaderscip-go gomod github.com/golang/go/src go1.25.0 strings/NewReader().(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.25.0 strings/Join().(
257 includeExcludeShasscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/includeExcludeShas().(include, exclude), "\n"))
258 } else {
259 stdin = stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.NewReaderscip-go gomod github.com/golang/go/src go1.25.0 strings/NewReader().(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.25.0 strings/Join().(
260 append(includeExcludeShasscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/includeExcludeShas().(include, exclude), opt.SkippedRefsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#SkippedRefs....), "\n"),
261 )
262 }
263 default:
264 return nil, nil, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/New().(trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("unknown scan type: %d", opt.Modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Mode.))
265 }
266 return stdin, append(args, "--stdin", "--"), nil
267 }
268
269 func includeExcludeShasscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/includeExcludeShas().(include, exclude []string) []string {
270 include = nonZeroShasscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/nonZeroShas().(include)
271 exclude = nonZeroShasscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/nonZeroShas().(exclude)
272
273 args := make([]string, 0, len(include)+len(exclude))
274
275 for _, i := range include {
276 args = append(args, i)
277 }
278
279 for _, x := range exclude {
280 args = append(args, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("^%s", x))
281 }
282
283 return args
284 }
285
286 func nonZeroShasscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/nonZeroShas().(all []string) []string {
287 nz := make([]string, 0, len(all))
288
289 for _, sha := range all {
290 if len(sha) > 0 && !IsZeroObjectIDscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/IsZeroObjectID().(sha) {
291 nz = append(nz, sha)
292 }
293 }
294 return nz
295 }
296
297 var startsWithObjectIDscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/startsWithObjectID. = regexpscip-go gomod github.com/golang/go/src go1.25.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.25.0 regexp/MustCompile().(fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().(`\A%s`, ObjectIDRegexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ObjectIDRegex.))
298
299 // Name is an optional field that gives the name of the object (if the object is
300 // a tree, blob).
301 //
302 // It can be called before or after Scan(), but will return "" if called
303 // before.
304 func (s *RevListScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#) Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#Name().() string { return s.namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#name. }
305
306 // OID is the hex-decoded bytes of the object's ID.
307 //
308 // It can be called before or after Scan(), but will return "" if called
309 // before.
310 func (s *RevListScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#) OIDscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#OID().() []byte { return s.oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#oid. }
311
312 // Err returns the last encountered error (or nil) after a call to Scan().
313 //
314 // It SHOULD be called, checked and handled after a call to Scan().
315 func (s *RevListScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#) Errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#Err().() error { return s.errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#err. }
316
317 // Scan scans the next entry given by git-rev-list(1), and returns true/false
318 // indicating if there are more results to scan.
319 func (s *RevListScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#) Scanscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#Scan().() bool {
320 var err error
321 s.oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#oid., s.namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#name., err = s.scanscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#scan().()
322
323 if err != nil {
324 if err != ioscip-go gomod github.com/golang/go/src go1.25.0 io/.EOFscip-go gomod github.com/golang/go/src go1.25.0 io/EOF. {
325 s.errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#err. = err
326 }
327 return false
328 }
329 return len(s.oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#oid.) > 0
330 }
331
332 // Close closes the RevListScanner by freeing any resources held by the
333 // instance while running, and returns any error encountered while doing so.
334 func (s *RevListScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#) Closescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#Close().() error {
335 if s.closeFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#closeFn. == nil {
336 return nil
337 }
338 return s.closeFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#closeFn.()
339 }
340
341 // scan provides the internal implementation of scanning a line of text from the
342 // output of `git-rev-list(1)`.
343 func (s *RevListScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#) scanscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#scan().() ([]byte, string, error) {
344 if !s.sscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#s..Scanscip-go gomod github.com/golang/go/src go1.25.0 bufio/Scanner#Scan().() {
345 return nil, "", s.sscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#s..Errscip-go gomod github.com/golang/go/src go1.25.0 bufio/Scanner#Err().()
346 }
347
348 line := stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.25.0 strings/TrimSpace().(s.sscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#s..Textscip-go gomod github.com/golang/go/src go1.25.0 bufio/Scanner#Text().())
349 if len(line) < ObjectIDLengthsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ObjectIDLengths.[0] {
350 return nil, "", nil
351 }
352
353 oidhex := startsWithObjectIDscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/startsWithObjectID..FindStringscip-go gomod github.com/golang/go/src go1.25.0 regexp/Regexp#FindString().(line)
354 if len(oidhex) == 0 {
355 return nil, "", errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/New().(trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("missing OID in line (got %q)", line))
356 }
357 oid, err := hexscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/.DecodeStringscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/DecodeString().(oidhex)
358 if err != nil {
359 return nil, "", err
360 }
361
362 var name string
363 if len(line) > len(oidhex) {
364 name = line[len(oidhex)+1:]
365 }
366
367 return oid, name, nil
368 }