Debian Codegraph @

git/githistory/rewriter.go

raw symbols SCIP
1 package githistoryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/
2
3 import (
4 "encoding/hexscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/"
5 "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/"
6 "osscip-go gomod github.com/golang/go/src go1.25.0 os/"
7 "path/filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/"
8 "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/"
9 "syncscip-go gomod github.com/golang/go/src go1.25.0 sync/"
10
11 "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`/"
12 "github.com/git-lfs/git-lfs/v3/filepathfilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/"
13 "github.com/git-lfs/git-lfs/v3/gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/"
14 "github.com/git-lfs/git-lfs/v3/tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/"
15 "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`/"
16 "github.com/git-lfs/gitobj/v2scip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/"
17 )
18
19 // Rewriter allows rewriting topologically equivalent Git histories
20 // between two revisions.
21 type Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter# struct {
22 // mu guards entries and commits (see below)
23 muscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#mu. *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#
24 // entries is a mapping of old tree entries to new (rewritten) ones.
25 // Since TreeEntry contains a []byte (and is therefore not a key-able
26 // type), a unique TreeEntry -> string function is used for map keys.
27 entriesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#entries. map[string]*gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.TreeEntryscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#
28 // commits is a mapping of old commit SHAs to new ones, where the ASCII
29 // hex encoding of the SHA1 values are used as map keys.
30 commitsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#commits. map[string][]byte
31 // filter is an optional value used to specify which tree entries
32 // (blobs, subtrees) are modifiable given a BlobFn. If non-nil, this
33 // filter will cull out any unmodifiable subtrees and blobs.
34 filterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#filter. *filepathfilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/.Filterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/Filter#
35 // db is the *ObjectDatabase from which blobs, commits, and trees are
36 // loaded.
37 dbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#db. *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.ObjectDatabasescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/ObjectDatabase#
38 // logger is the *tasklog.Logger to which updates are written.
39 loggerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#logger. *tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/.Loggerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Logger#
40 }
41
42 // RewriteOptions is an options type given to the Rewrite() function.
43 type RewriteOptionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions# struct {
44 // Include is the list of refs of which commits reachable by that ref
45 // will be included.
46 Includescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#Include. []string
47 // Exclude is the list of refs of which commits reachable by that ref
48 // will be excluded.
49 Excludescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#Exclude. []string
50
51 // UpdateRefs specifies whether the Rewriter should move refs from the
52 // original graph onto the migrated one. If true, the refs will be
53 // moved, and a reflog entry will be created.
54 UpdateRefsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#UpdateRefs. bool
55
56 // Verbose mode prints migrated objects.
57 Verbosescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#Verbose. bool
58
59 // ObjectMapFilePath is the path to the map of old sha1 to new sha1
60 // commits
61 ObjectMapFilePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#ObjectMapFilePath. string
62
63 // BlobFn specifies a function to rewrite blobs.
64 //
65 // It is called once per unique, unchanged path. That is to say, if
66 // /a/foo and /a/bar contain identical contents, the BlobFn will be
67 // called twice: once for /a/foo and once for /a/bar, but no more on
68 // each blob for subsequent revisions, so long as each entry remains
69 // unchanged.
70 BlobFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#BlobFn. BlobRewriteFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/BlobRewriteFn#
71 // TreePreCallbackFn specifies a function to be called before opening a
72 // tree for rewriting. It will be called on all trees throughout history
73 // in topological ordering through the tree, starting at the root.
74 TreePreCallbackFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#TreePreCallbackFn. TreePreCallbackFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/TreePreCallbackFn#
75 // TreeCallbackFn specifies a function to rewrite trees after they have
76 // been reassembled by calling the above BlobFn on all existing tree
77 // entries.
78 TreeCallbackFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#TreeCallbackFn. TreeCallbackFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/TreeCallbackFn#
79 }
80
81 // blobFn returns a usable BlobRewriteFn, either the one that was given in the
82 // *RewriteOptions, or a noopBlobFn.
83 func (r *RewriteOptionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#) blobFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#blobFn().() BlobRewriteFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/BlobRewriteFn# {
84 if r.BlobFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#BlobFn. == nil {
85 return noopBlobFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/noopBlobFn.
86 }
87 return r.BlobFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#BlobFn.
88 }
89
90 // treePreFn returns a usable TreePreCallbackFn, either the one that was given
91 // in the *RewriteOptions, or a noopTreePreFn.
92 func (r *RewriteOptionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#) treePreFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#treePreFn().() TreePreCallbackFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/TreePreCallbackFn# {
93 if r.TreePreCallbackFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#TreePreCallbackFn. == nil {
94 return noopTreePreFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/noopTreePreFn.
95 }
96 return r.TreePreCallbackFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#TreePreCallbackFn.
97 }
98
99 // treeFn returns a usable TreeRewriteFn, either the one that was given in the
100 // *RewriteOptions, or a noopTreeFn.
101 func (r *RewriteOptionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#) treeFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#treeFn().() TreeCallbackFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/TreeCallbackFn# {
102 if r.TreeCallbackFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#TreeCallbackFn. == nil {
103 return noopTreeFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/noopTreeFn.
104 }
105 return r.TreeCallbackFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#TreeCallbackFn.
106 }
107
108 // BlobRewriteFn is a mapping function that takes a given blob and returns a
109 // new, modified blob. If it returns an error, the new blob will not be written
110 // and instead the error will be returned from the Rewrite() function.
111 //
112 // Invocations of an instance of BlobRewriteFn are not expected to store the
113 // returned blobs in the *git/gitobj.ObjectDatabase.
114 //
115 // The path argument is given to be an absolute path to the tree entry being
116 // rewritten, where the repository root is the root of the path given. For
117 // instance, a file "b.txt" in directory "dir" would be given as "/dir/b.txt",
118 // where as a file "a.txt" in the root would be given as "/a.txt".
119 //
120 // As above, the path separators are OS specific, and equivalent to the result
121 // of filepath.Join(...) or os.PathSeparator.
122 type BlobRewriteFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/BlobRewriteFn# func(path string, b *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.Blobscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Blob#) (*gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.Blobscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Blob#, error)
123
124 // TreePreCallbackFn specifies a function to call upon opening a new tree for
125 // rewriting.
126 //
127 // Unlike its sibling TreeCallbackFn, TreePreCallbackFn may not modify the given
128 // tree.
129 //
130 // TreePreCallbackFn can be nil, and will therefore exhibit behavior equivalent
131 // to only calling the BlobFn on existing tree entries.
132 //
133 // If the TreePreCallbackFn returns an error, it will be returned from the
134 // Rewrite() invocation.
135 type TreePreCallbackFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/TreePreCallbackFn# func(path string, t *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.Treescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Tree#) error
136
137 // TreeCallbackFn specifies a function to call before writing a re-written tree
138 // to the object database. The TreeCallbackFn can return a modified tree to be
139 // written to the object database instead of one generated from calling BlobFn
140 // on all of the tree entries.
141 //
142 // TreeCallbackFn can be nil, and will therefore exhibit behavior equivalent to
143 // only calling the BlobFn on existing tree entries.
144 //
145 // If the TreeCallbackFn returns an error, it will be returned from the
146 // Rewrite() invocation.
147 type TreeCallbackFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/TreeCallbackFn# func(path string, t *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.Treescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Tree#) (*gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.Treescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Tree#, error)
148
149 type rewriterOptionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/rewriterOption# func(*Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#)
150
151 var (
152 // WithFilter is an optional argument given to the NewRewriter
153 // constructor function to limit invocations of the BlobRewriteFn to
154 // only pathspecs that match the given *filepathfilter.Filter.
155 WithFilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/WithFilter. = func(filterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/WithFilter:filter. *filepathfilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/.Filterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/Filter#) rewriterOptionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/rewriterOption# {
156 return func(rscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/WithFilter:r. *Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#) {
157 rscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/WithFilter:r..filterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#filter. = filterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/WithFilter:filter.
158 }
159 }
160
161 // WithLogger logs updates caused by the *git/githistory.Rewriter to the
162 // be given to the provided logger, "l".
163 WithLoggerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/WithLogger. = func(lscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/WithLogger:l. *tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/.Loggerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Logger#) rewriterOptionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/rewriterOption# {
164 return func(rscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/WithLogger:r. *Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#) {
165 rscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/WithLogger:r..loggerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#logger. = lscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/WithLogger:l.
166 }
167 }
168
169 // noopBlobFn is a no-op implementation of the BlobRewriteFn. It returns
170 // the blob that it was given, and returns no error.
171 noopBlobFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/noopBlobFn. = func(pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/noopBlobFn:path. string, bscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/noopBlobFn:b. *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.Blobscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Blob#) (*gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.Blobscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Blob#, error) { return bscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/noopBlobFn:b., nil }
172 // noopTreePreFn is a no-op implementation of the TreePreRewriteFn. It
173 // returns the tree that it was given, and returns no error.
174 noopTreePreFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/noopTreePreFn. = func(pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/noopTreePreFn:path. string, tscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/noopTreePreFn:t. *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.Treescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Tree#) error { return nil }
175 // noopTreeFn is a no-op implementation of the TreeRewriteFn. It returns
176 // the tree that it was given, and returns no error.
177 noopTreeFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/noopTreeFn. = func(pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/noopTreeFn:path. string, tscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/noopTreeFn:t. *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.Treescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Tree#) (*gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.Treescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Tree#, error) { return tscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/noopTreeFn:t., nil }
178 )
179
180 // NewRewriter constructs a *Rewriter from the given *ObjectDatabase instance.
181 func NewRewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/NewRewriter().(db *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.ObjectDatabasescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/ObjectDatabase#, opts ...rewriterOptionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/rewriterOption#) *Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter# {
182 rewriter := &Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#{
183 muscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#mu.: new(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#),
184 entriesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#entries.: make(map[string]*gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.TreeEntryscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#),
185 commitsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#commits.: make(map[string][]byte),
186
187 dbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#db.: db,
188 }
189
190 for _, opt := range opts {
191 opt(rewriter)
192 }
193 return rewriter
194 }
195
196 // Rewrite rewrites the range of commits given by
197 // *RewriteOptions.{Include,Exclude} using the BlobRewriteFn to rewrite
198 // the individual blobs.
199 func (r *Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#) Rewritescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#Rewrite().(opt *RewriteOptionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#) ([]byte, error) {
200 // First, obtain a list of commits to rewrite.
201 commits, err := r.commitsToMigratescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#commitsToMigrate().(opt)
202 if err != nil {
203 return nil, err
204 }
205
206 var perc *tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/.PercentageTaskscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#
207 if opt.UpdateRefsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#UpdateRefs. {
208 perc = r.loggerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#logger..Percentagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Logger#Percentage().(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().("Rewriting commits"), uint64(len(commits)))
209 } else {
210 perc = r.loggerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#logger..Percentagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Logger#Percentage().(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().("Examining commits"), uint64(len(commits)))
211 }
212 defer perc.Completescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Complete().()
213
214 var vPerc *tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/.PercentageTaskscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#
215 if opt.Verbosescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#Verbose. {
216 vPerc = perc
217 }
218
219 var objectMapFile *osscip-go gomod github.com/golang/go/src go1.25.0 os/.Filescip-go gomod github.com/golang/go/src go1.25.0 os/File#
220 if len(opt.ObjectMapFilePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#ObjectMapFilePath.) > 0 {
221 objectMapFile, err = osscip-go gomod github.com/golang/go/src go1.25.0 os/.OpenFilescip-go gomod github.com/golang/go/src go1.25.0 os/OpenFile().(opt.ObjectMapFilePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#ObjectMapFilePath., osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_RDWRscip-go gomod github.com/golang/go/src go1.25.0 os/O_RDWR.|osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_CREATEscip-go gomod github.com/golang/go/src go1.25.0 os/O_CREATE.|osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_EXCLscip-go gomod github.com/golang/go/src go1.25.0 os/O_EXCL., 0666)
222 if err != nil {
223 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().("could not create object map file: %v", err))
224 }
225 defer objectMapFile.Closescip-go gomod github.com/golang/go/src go1.25.0 os/File#Close().()
226 }
227
228 // Keep track of the last commit that we rewrote. Callers often want
229 // this so that they can perform a git-update-ref(1).
230 var tip []byte
231 for _, oid := range commits {
232 // Load the original commit to access the data necessary in
233 // order to rewrite it.
234 original, err := r.dbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#db..Commitscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/ObjectDatabase#Commit().(oid)
235 if err != nil {
236 return nil, err
237 }
238
239 // Rewrite the tree given at that commit.
240 rewrittenTree, err := r.rewriteTreescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#rewriteTree().(oid, original.TreeIDscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Commit#TreeID., "", opt.blobFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#blobFn().(), opt.treePreFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#treePreFn().(), opt.treeFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#treeFn().(), vPerc)
241 if err != nil {
242 return nil, err
243 }
244
245 // Create a new list of parents from the original commit to
246 // point at the rewritten parents in order to create a
247 // topologically equivalent DAG.
248 //
249 // This operation is safe since we are visiting the commits in
250 // reverse topological order and therefore have seen all parents
251 // before children (in other words, r.uncacheCommit(...) will
252 // always return a value, if the prospective parent is a part of
253 // the migration).
254 rewrittenParents := make([][]byte, 0, len(original.ParentIDsscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Commit#ParentIDs.))
255 for _, originalParent := range original.ParentIDsscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Commit#ParentIDs. {
256 rewrittenParent, ok := r.uncacheCommitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#uncacheCommit().(originalParent)
257 if !ok {
258 // If we haven't seen the parent before, this
259 // means that we're doing a partial migration
260 // and the parent that we're looking for isn't
261 // included.
262 //
263 // Use the original parent to properly link
264 // history across the migration boundary.
265 rewrittenParent = originalParent
266 }
267
268 rewrittenParents = append(rewrittenParents, rewrittenParent)
269 }
270
271 // Construct a new commit using the original header information,
272 // but the rewritten set of parents as well as root tree.
273 rewrittenCommit := &gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.Commitscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Commit#{
274 Authorscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Commit#Author.: original.Authorscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Commit#Author.,
275 Committerscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Commit#Committer.: original.Committerscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Commit#Committer.,
276 ExtraHeadersscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Commit#ExtraHeaders.: original.ExtraHeadersscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Commit#ExtraHeaders.,
277 Messagescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Commit#Message.: original.Messagescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Commit#Message.,
278
279 ParentIDsscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Commit#ParentIDs.: rewrittenParents,
280 TreeIDscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Commit#TreeID.: rewrittenTree,
281 }
282
283 var newSha []byte
284
285 if original.Equalscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Commit#Equal().(rewrittenCommit) {
286 newSha = make([]byte, len(oid))
287 copy(newSha, oid)
288 } else {
289 newSha, err = r.dbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#db..WriteCommitscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/ObjectDatabase#WriteCommit().(rewrittenCommit)
290 if err != nil {
291 return nil, err
292 }
293 if objectMapFile != nil {
294 if _, err := fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Fprintf().(objectMapFile, "%x,%x\n", oid, newSha); err != nil {
295 return nil, err
296 }
297 }
298 }
299
300 // Cache that commit so that we can reassign children of this
301 // commit.
302 r.cacheCommitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#cacheCommit().(oid, newSha)
303
304 // Increment the percentage displayed in the terminal.
305 perc.Countscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Count().(1)
306
307 // Move the tip forward.
308 tip = newSha
309 }
310
311 if opt.UpdateRefsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#UpdateRefs. {
312 refs, err := r.refsToMigratescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#refsToMigrate().()
313 if err != nil {
314 return nil, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Wrapscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/Wrap().(err, 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().("could not find refs to update"))
315 }
316
317 root, _ := r.gitDirectoryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#gitDirectory().()
318
319 updater := &refUpdaterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/refUpdater#{
320 cacheFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/refUpdater#cacheFn.: r.uncacheCommitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#uncacheCommit().,
321 loggerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/refUpdater#logger.: r.loggerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#logger.,
322 refsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/refUpdater#refs.: refs,
323 rootscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/refUpdater#root.: root,
324 dbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/refUpdater#db.: r.dbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#db.,
325 }
326
327 if err := updater.updateRefsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/refUpdater#updateRefs().(); err != nil {
328 return nil, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Wrapscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/Wrap().(err, 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().("could not update refs"))
329 }
330 }
331
332 return tip, err
333 }
334
335 // rewriteTree is a recursive function which rewrites a tree given by the ID
336 // "sha" and path "path". It uses the given BlobRewriteFn to rewrite all blobs
337 // within the tree, either calling that function or recurring down into subtrees
338 // by re-assigning the SHA.
339 //
340 // Once it is done assembling the entries in a given subtree, it then calls the
341 // TreeCallbackFn, "tfn" to perform a final traversal of the subtree before
342 // saving it to the object database.
343 //
344 // It returns the new SHA of the rewritten tree, or an error if the tree was
345 // unable to be rewritten.
346 func (r *Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#) rewriteTreescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#rewriteTree().(commitOID []byte, treeOID []byte, path string,
347 fn BlobRewriteFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/BlobRewriteFn#, tpfn TreePreCallbackFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/TreePreCallbackFn#, tfn TreeCallbackFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/TreeCallbackFn#,
348 perc *tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/.PercentageTaskscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#) ([]byte, error) {
349
350 tree, err := r.dbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#db..Treescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/ObjectDatabase#Tree().(treeOID)
351 if err != nil {
352 return nil, err
353 }
354
355 if err := tpfn("/"+path, tree); err != nil {
356 return nil, err
357 }
358
359 entries := make([]*gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.TreeEntryscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#, 0, len(tree.Entriesscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Tree#Entries.))
360 for _, entry := range tree.Entriesscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Tree#Entries. {
361 var fullpath string
362 if len(path) > 0 {
363 fullpath = 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().([]string{path, entry.Namescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Name.}, "/")
364 } else {
365 fullpath = entry.Namescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Name.
366 }
367
368 if !r.allowsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#allows().(entry.Typescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Type().(), fullpath) {
369 entries = append(entries, copyEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/copyEntry().(entry))
370 continue
371 }
372
373 // If this is a symlink, skip it
374 if entry.Filemodescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Filemode. == 0120000 {
375 entries = append(entries, copyEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/copyEntry().(entry))
376 continue
377 }
378
379 if cached := r.uncacheEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#uncacheEntry().(fullpath, entry); cached != nil {
380 entries = append(entries, copyEntryModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/copyEntryMode().(cached,
381 entry.Filemodescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Filemode.))
382 continue
383 }
384
385 var oid []byte
386
387 switch entry.Typescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Type().() {
388 case gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.BlobObjectTypescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/BlobObjectType.:
389 oid, err = r.rewriteBlobscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#rewriteBlob().(commitOID, entry.Oidscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Oid., fullpath, fn, perc)
390 case gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.TreeObjectTypescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeObjectType.:
391 oid, err = r.rewriteTreescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#rewriteTree().(commitOID, entry.Oidscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Oid., fullpath, fn, tpfn, tfn, perc)
392 default:
393 oid = entry.Oidscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Oid.
394
395 }
396 if err != nil {
397 return nil, err
398 }
399
400 entries = append(entries, r.cacheEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#cacheEntry().(fullpath, entry, &gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.TreeEntryscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#{
401 Filemodescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Filemode.: entry.Filemodescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Filemode.,
402 Namescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Name.: entry.Namescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Name.,
403 Oidscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Oid.: oid,
404 }))
405 }
406
407 rewritten, err := tfn("/"+path, &gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.Treescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Tree#{Entriesscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Tree#Entries.: entries})
408 if err != nil {
409 return nil, err
410 }
411
412 if tree.Equalscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Tree#Equal().(rewritten) {
413 return treeOID, nil
414 }
415 return r.dbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#db..WriteTreescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/ObjectDatabase#WriteTree().(rewritten)
416 }
417
418 func copyEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/copyEntry().(e *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.TreeEntryscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#) *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.TreeEntryscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry# {
419 if e == nil {
420 return nil
421 }
422
423 oid := make([]byte, len(e.Oidscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Oid.))
424 copy(oid, e.Oidscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Oid.)
425
426 return &gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.TreeEntryscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#{
427 Filemodescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Filemode.: e.Filemodescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Filemode.,
428 Namescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Name.: e.Namescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Name.,
429 Oidscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Oid.: oid,
430 }
431 }
432
433 func copyEntryModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/copyEntryMode().(e *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.TreeEntryscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#, mode int32) *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.TreeEntryscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry# {
434 copied := copyEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/copyEntry().(e)
435 copied.Filemodescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Filemode. = mode
436
437 return copied
438 }
439
440 // gitDirectory returns a path to the .git directory on success.
441 func (r *Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#) gitDirectoryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#gitDirectory().() (string, bool) {
442 root, ok := r.dbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#db..Rootscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/ObjectDatabase#Root().()
443 if ok {
444 root = filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().(root, "..")
445 }
446 return root, ok
447 }
448
449 func (r *Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#) allowsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#allows().(typ gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.ObjectTypescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/ObjectType#, abs string) bool {
450 switch typ {
451 case gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.BlobObjectTypescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/BlobObjectType.:
452 return r.Filterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#Filter().().Allowsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/Filter#Allows().(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.TrimPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/TrimPrefix().(abs, "/"))
453 case gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.CommitObjectTypescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/CommitObjectType., gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.TreeObjectTypescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeObjectType.:
454 return true
455 default:
456 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/githistory: %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 entry type: %s", typ)))
457 }
458 }
459
460 // rewriteBlob calls the given BlobRewriteFn "fn" on a blob given in the object
461 // database by the SHA1 "from" []byte. It writes and returns the new blob SHA,
462 // or an error if either the BlobRewriteFn returned one, or if the object could
463 // not be loaded/saved.
464 func (r *Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#) rewriteBlobscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#rewriteBlob().(commitOID, from []byte, path string, fn BlobRewriteFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/BlobRewriteFn#, perc *tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/.PercentageTaskscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#) ([]byte, error) {
465 blob, err := r.dbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#db..Blobscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/ObjectDatabase#Blob().(from)
466 if err != nil {
467 return nil, err
468 }
469
470 b, err := fn(path, blob)
471 if err != nil {
472 return nil, err
473 }
474
475 if !blob.Equalscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Blob#Equal().(b) {
476 sha, err := r.dbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#db..WriteBlobscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/ObjectDatabase#WriteBlob().(b)
477 if err != nil {
478 return nil, err
479 }
480
481 // Close the source blob, so long as it is not equal to the
482 // rewritten blob. If the two are equal, as in the check above
483 // this comment, calling r.db.WriteBlob(b) will have already
484 // closed both "b" and "blob" since they are the same.
485 //
486 // Closing an *os.File twice causes an `os.ErrInvalid` to be
487 // returned.
488 if err = blob.Closescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Blob#Close().(); err != nil {
489 return nil, err
490 }
491
492 if perc != nil {
493 perc.Entryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Entry().(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().(" commit %s: %s", hexscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/.EncodeToStringscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/EncodeToString().(commitOID), path))
494 }
495
496 return sha, nil
497 }
498
499 // Close the source blob, since it is identical to the rewritten blob,
500 // but neither were written.
501 if err := blob.Closescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Blob#Close().(); err != nil {
502 return nil, err
503 }
504 return from, nil
505 }
506
507 // commitsToMigrate returns an in-memory copy of a list of commits according to
508 // the output of git-rev-list(1) (given the *RewriteOptions), where each
509 // outputted commit is 20 bytes of raw SHA1.
510 //
511 // If any error was encountered, it will be returned.
512 func (r *Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#) commitsToMigratescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#commitsToMigrate().(opt *RewriteOptionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#) ([][]byte, error) {
513 waiter := r.loggerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#logger..Waiterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Logger#Waiter().(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().("Sorting commits"))
514 defer waiter.Completescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/WaitingTask#Complete().()
515
516 scanner, err := gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.NewRevListScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/NewRevListScanner().(
517 opt.Includescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#Include., opt.Excludescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#Exclude., r.scannerOptsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#scannerOpts().())
518 if err != nil {
519 return nil, err
520 }
521
522 var commits [][]byte
523 for scanner.Scanscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#Scan().() {
524 commits = append(commits, scanner.OIDscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#OID().())
525 }
526
527 if err = scanner.Errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#Err().(); err != nil {
528 return nil, err
529 }
530 if err = scanner.Closescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RevListScanner#Close().(); err != nil {
531 return nil, err
532 }
533 return commits, nil
534 }
535
536 // refsToMigrate returns a list of references to migrate, or an error if loading
537 // those references failed.
538 func (r *Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#) refsToMigratescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#refsToMigrate().() ([]*gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.Refscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/Ref#, error) {
539 var refs []*gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.Refscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/Ref#
540 var err error
541
542 if root, ok := r.gitDirectoryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#gitDirectory().(); ok {
543 refs, err = gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.AllRefsInscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/AllRefsIn().(root)
544 } else {
545 refs, err = gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.AllRefsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/AllRefs().()
546 }
547
548 if err != nil {
549 return nil, err
550 }
551
552 var local []*gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.Refscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/Ref#
553 for _, ref := range refs {
554 if ref.Typescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/Ref#Type. == gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.RefTypeRemoteBranchscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/RefTypeRemoteBranch. {
555 continue
556 }
557
558 local = append(local, ref)
559 }
560
561 return local, nil
562 }
563
564 // scannerOpts returns a *git.ScanRefsOptions instance to be given to the
565 // *git.RevListScanner.
566 //
567 // If the database this *Rewriter is operating in a given root (not in memory)
568 // it re-assigns the working directory to be there.
569 func (r *Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#) scannerOptsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#scannerOpts().() *gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.ScanRefsOptionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions# {
570 opts := &gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.ScanRefsOptionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#{
571 Modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Mode.: gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.ScanRefsModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsMode.,
572 Orderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Order.: gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.TopoRevListOrderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/TopoRevListOrder.,
573 Reversescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Reverse.: true,
574 CommitsOnlyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#CommitsOnly.: true,
575
576 SkippedRefsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#SkippedRefs.: make([]string, 0),
577 Mutexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Mutex.: new(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#),
578 Namesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#Names.: make(map[string]string),
579 }
580
581 if root, ok := r.gitDirectoryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#gitDirectory().(); ok {
582 opts.WorkingDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ScanRefsOptions#WorkingDir. = root
583 }
584 return opts
585 }
586
587 // Filter returns the filter used by this *Rewriter to filter subtrees, blobs
588 // (see above).
589 func (r *Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#) Filterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#Filter().() *filepathfilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/.Filterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/Filter# {
590 return r.filterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#filter.
591 }
592
593 // cacheEntry caches then given "from" entry so that it is always rewritten as
594 // a *TreeEntry equivalent to "to".
595 func (r *Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#) cacheEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#cacheEntry().(path string, from, to *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.TreeEntryscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#) *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.TreeEntryscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry# {
596 r.muscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#mu..Lockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Lock().()
597 defer r.muscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#mu..Unlockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Unlock().()
598
599 r.entriesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#entries.[r.entryKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#entryKey().(path, from)] = to
600
601 return to
602 }
603
604 // uncacheEntry returns a *TreeEntry that is cached from the given *TreeEntry
605 // "from". That is to say, it returns the *TreeEntry that "from" should be
606 // rewritten to, or nil if none could be found.
607 func (r *Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#) uncacheEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#uncacheEntry().(path string, from *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.TreeEntryscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#) *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.TreeEntryscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry# {
608 r.muscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#mu..Lockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Lock().()
609 defer r.muscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#mu..Unlockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Unlock().()
610
611 return r.entriesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#entries.[r.entryKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#entryKey().(path, from)]
612 }
613
614 // entryKey returns a unique key for a given *TreeEntry "e".
615 func (r *Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#) entryKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#entryKey().(path string, e *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.TreeEntryscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#) string {
616 return 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", path, e.Oidscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Oid.)
617 }
618
619 // cacheEntry caches then given "from" commit so that it is always rewritten as
620 // a *git/gitobj.Commit equivalent to "to".
621 func (r *Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#) cacheCommitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#cacheCommit().(from, to []byte) {
622 r.muscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#mu..Lockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Lock().()
623 defer r.muscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#mu..Unlockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Unlock().()
624
625 r.commitsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#commits.[hexscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/.EncodeToStringscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/EncodeToString().(from)] = to
626 }
627
628 // uncacheCommit returns a *git/gitobj.Commit that is cached from the given
629 // *git/gitobj.Commit "from". That is to say, it returns the *git/gitobj.Commit that
630 // "from" should be rewritten to and true, or nil and false if none could be
631 // found.
632 func (r *Rewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#) uncacheCommitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#uncacheCommit().(from []byte) ([]byte, bool) {
633 r.muscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#mu..Lockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Lock().()
634 defer r.muscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#mu..Unlockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Unlock().()
635
636 c, ok := r.commitsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/Rewriter#commits.[hexscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/.EncodeToStringscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/EncodeToString().(from)]
637 return c, ok
638 }