Debian Codegraph @

commands/command_migrate_info.go

raw symbols SCIP
1 package commandsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/
2
3 import (
4 "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/"
5 "ioscip-go gomod github.com/golang/go/src go1.25.0 io/"
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 "sortscip-go gomod github.com/golang/go/src go1.25.0 sort/"
9 "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/"
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/git/gitattrscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/"
13 "github.com/git-lfs/git-lfs/v3/git/githistoryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/"
14 "github.com/git-lfs/git-lfs/v3/lfsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/"
15 "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`/"
16 "github.com/git-lfs/git-lfs/v3/toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/"
17 "github.com/git-lfs/git-lfs/v3/tools/humanizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools/humanize`/"
18 "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`/"
19 "github.com/git-lfs/gitobj/v2scip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/"
20 "github.com/spf13/cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/"
21 )
22
23 type migrateInfoPointersTypescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersType# int
24
25 const (
26 migrateInfoPointersFollowscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersFollow. = migrateInfoPointersTypescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersType#(iota)
27 migrateInfoPointersNoFollowscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersNoFollow. = migrateInfoPointersTypescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersType#(iota)
28 migrateInfoPointersIgnorescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersIgnore. = migrateInfoPointersTypescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersType#(iota)
29 )
30
31 var (
32 // migrateInfoTopN is a flag given to the git-lfs-migrate(1) subcommand
33 // 'info' which specifies how many info entries to show by default.
34 migrateInfoTopNscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoTopN. int
35
36 // migrateInfoAboveFmt is a flag given to the git-lfs-migrate(1)
37 // subcommand 'info' specifying a human-readable string threshold of
38 // filesize before entries are counted.
39 migrateInfoAboveFmtscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoAboveFmt. string
40 // migrateInfoAbove is the number of bytes parsed from the above
41 // migrateInfoAboveFmt flag.
42 migrateInfoAbovescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoAbove. uint64
43
44 // migrateInfoUnitFmt is a flag given to the git-lfs-migrate(1)
45 // subcommand 'info' specifying a human-readable string of units with
46 // which to display the number of bytes.
47 migrateInfoUnitFmtscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoUnitFmt. string
48 // migrateInfoUnit is the number of bytes in the unit given as
49 // migrateInfoUnitFmt.
50 migrateInfoUnitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoUnit. uint64
51
52 // migrateInfoPointers is an option given to the git-lfs-migrate(1)
53 // subcommand 'info' specifying how to treat Git LFS pointers.
54 migrateInfoPointersscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointers. string
55 // migrateInfoPointersMode is the Git LFS pointer treatment mode
56 // parsed from migrateInfoPointers.
57 migrateInfoPointersModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersMode. migrateInfoPointersTypescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersType#
58 )
59
60 func migrateInfoCommandscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoCommand().(cmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#, args []string) {
61 l := tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/.NewLoggerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/NewLogger().(osscip-go gomod github.com/golang/go/src go1.25.0 os/.Stderrscip-go gomod github.com/golang/go/src go1.25.0 os/Stderr.,
62 tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/.ForceProgressscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/ForceProgress().(cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/cfg..ForceProgressscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#ForceProgress().()),
63 )
64
65 db, err := getObjectDatabasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/getObjectDatabase().()
66 if err != nil {
67 ExitWithErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/ExitWithError().(err)
68 }
69 defer db.Closescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/ObjectDatabase#Close().()
70
71 rewriter := getHistoryRewriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/getHistoryRewriter().(cmd, db, l)
72
73 exts := make(map[string]*MigrateInfoEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#)
74
75 above, err := humanizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools/humanize`/.ParseBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools/humanize`/ParseBytes().(migrateInfoAboveFmtscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoAboveFmt.)
76 if err != nil {
77 ExitWithErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/ExitWithError().(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().("cannot parse --above=<n>")))
78 }
79
80 if u := cmd.Flagscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flag().("unit"); u.Changedscip-go gomod github.com/spf13/pflag v1.0.9 `github.com/spf13/pflag`/Flag#Changed. {
81 unit, err := humanizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools/humanize`/.ParseByteUnitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools/humanize`/ParseByteUnit().(u.Valuescip-go gomod github.com/spf13/pflag v1.0.9 `github.com/spf13/pflag`/Flag#Value..Stringscip-go gomod github.com/spf13/pflag v1.0.9 `github.com/spf13/pflag`/Value#String().())
82 if err != nil {
83 ExitWithErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/ExitWithError().(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().("cannot parse --unit=<unit>")))
84 }
85
86 migrateInfoUnitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoUnit. = unit
87 }
88
89 pointers := cmd.Flagscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flag().("pointers")
90 if pointers.Changedscip-go gomod github.com/spf13/pflag v1.0.9 `github.com/spf13/pflag`/Flag#Changed. {
91 switch pointers.Valuescip-go gomod github.com/spf13/pflag v1.0.9 `github.com/spf13/pflag`/Flag#Value..Stringscip-go gomod github.com/spf13/pflag v1.0.9 `github.com/spf13/pflag`/Value#String().() {
92 case "follow":
93 migrateInfoPointersModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersMode. = migrateInfoPointersFollowscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersFollow.
94 case "no-follow":
95 migrateInfoPointersModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersMode. = migrateInfoPointersNoFollowscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersNoFollow.
96 case "ignore":
97 migrateInfoPointersModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersMode. = migrateInfoPointersIgnorescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersIgnore.
98 default:
99 ExitWithErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/ExitWithError().(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().("Unsupported --pointers option value")))
100 }
101 }
102
103 if migrateFixupscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateFixup. {
104 include, exclude := getIncludeExcludeArgsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/getIncludeExcludeArgs().(cmd)
105 if include != nil || exclude != nil {
106 ExitWithErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/ExitWithError().(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().("Cannot use --fixup with --include, --exclude")))
107 }
108 if pointers.Changedscip-go gomod github.com/spf13/pflag v1.0.9 `github.com/spf13/pflag`/Flag#Changed. && migrateInfoPointersModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersMode. != migrateInfoPointersIgnorescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersIgnore. {
109 ExitWithErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/ExitWithError().(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().("Cannot use --fixup with --pointers=%s", pointers.Valuescip-go gomod github.com/spf13/pflag v1.0.9 `github.com/spf13/pflag`/Flag#Value..Stringscip-go gomod github.com/spf13/pflag v1.0.9 `github.com/spf13/pflag`/Value#String().())))
110 }
111 migrateInfoPointersModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersMode. = migrateInfoPointersIgnorescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersIgnore.
112 }
113
114 migrateInfoAbovescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoAbove. = above
115 pointersInfoEntry := &MigrateInfoEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#{Qualifierscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#Qualifier.: "LFS Objects", Separatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#Separate.: true}
116 var fixups *gitattrscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/.Treescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/Tree#
117
118 migratescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrate().(args, rewriter, l, &githistoryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/.RewriteOptionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#{
119 BlobFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#BlobFn.: 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) {
120 var entry *MigrateInfoEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#
121 var size int64
122 var p *lfsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/.Pointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#
123 var err error
124
125 if migrateFixupscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateFixup. {
126 if filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Basescip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Base().(path) == ".gitattributes" {
127 return b, nil
128 }
129
130 var ok bool
131 attrs := fixups.Appliedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/Tree#Applied().(path)
132 for _, attr := range attrs {
133 if attr.Kscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/Attr#K. == "filter" {
134 ok = attr.Vscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/Attr#V. == "lfs"
135 }
136 }
137 if !ok {
138 return b, nil
139 }
140 }
141
142 if migrateInfoPointersModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersMode. != migrateInfoPointersNoFollowscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersNoFollow. {
143 p, err = lfsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/.DecodePointerFromBlobscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/DecodePointerFromBlob().(b)
144 }
145 if p != nil && err == nil {
146 if migrateInfoPointersModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersMode. == migrateInfoPointersIgnorescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoPointersIgnore. {
147 return b, nil
148 }
149 entry = pointersInfoEntry
150 size = p.Sizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#Size.
151 } else {
152 entry = findEntryByExtensionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/findEntryByExtension().(exts, path)
153 size = b.Sizescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Blob#Size.
154 }
155
156 entry.Totalscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#Total.++
157
158 if size > int64(migrateInfoAbovescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoAbove.) {
159 entry.TotalAbovescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#TotalAbove.++
160 entry.BytesAbovescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#BytesAbove. += size
161 }
162
163 return b, nil
164 },
165
166 TreePreCallbackFnscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/githistory`/RewriteOptions#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 {
167 if migrateFixupscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateFixup. {
168 if path == "/" {
169 var err error
170
171 fixups, err = gitattrscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/New().(db, t)
172 if err != nil {
173 return err
174 }
175 if err = fixups.FindSpecialAttributesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/Tree#FindSpecialAttributes().(cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/cfg..GitEnvscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#GitEnv().(), cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/cfg..OSEnvscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#OSEnv().(), cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/cfg..LocalGitDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#LocalGitDir().()); err != nil {
176 return err
177 }
178 }
179 return nil
180 }
181
182 for _, e := range t.Entriesscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/Tree#Entries. {
183 if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.25.0 strings/ToLower().(e.Namescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Name.) == ".gitattributes" && e.Typescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#Type().() == 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. {
184 if e.IsLinkscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/TreeEntry#IsLink().() {
185 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().("expected '.gitattributes' to be a file, got a symbolic link"))
186 } else {
187 break
188 }
189 }
190 }
191
192 return nil
193 },
194 })
195 l.Closescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Logger#Close().()
196
197 entries := EntriesBySizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/EntriesBySize#(MapToEntriesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MapToEntries().(exts))
198 entries = removeEmptyEntriesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/removeEmptyEntries().(entries)
199 sortscip-go gomod github.com/golang/go/src go1.25.0 sort/.Sortscip-go gomod github.com/golang/go/src go1.25.0 sort/Sort().(sortscip-go gomod github.com/golang/go/src go1.25.0 sort/.Reversescip-go gomod github.com/golang/go/src go1.25.0 sort/Reverse().(entries))
200
201 migrateInfoTopNscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoTopN. = toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.ClampIntscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ClampInt().(migrateInfoTopNscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoTopN., 0, len(entries))
202
203 entries = entries[:migrateInfoTopNscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoTopN.]
204 if pointersInfoEntry.Totalscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#Total. > 0 {
205 entries = append(entries, pointersInfoEntry)
206 }
207
208 entries.Printscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/EntriesBySize#Print().(osscip-go gomod github.com/golang/go/src go1.25.0 os/.Stdoutscip-go gomod github.com/golang/go/src go1.25.0 os/Stdout.)
209 }
210
211 // MigrateInfoEntry represents a tuple of filetype to bytes and entry count
212 // above and below a threshold.
213 type MigrateInfoEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry# struct {
214 // Qualifier is the filepath's extension.
215 Qualifierscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#Qualifier. string
216 // Separate indicates if the entry should be printed separately.
217 Separatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#Separate. bool
218
219 // BytesAbove is total size of all files above a given threshold.
220 BytesAbovescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#BytesAbove. int64
221 // TotalAbove is the count of all files above a given size threshold.
222 TotalAbovescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#TotalAbove. int64
223 // Total is the count of all files.
224 Totalscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#Total. int64
225 }
226
227 // findEntryByExtension finds or creates an entry from the given map that
228 // corresponds with the given path's file extension (or the path's file name
229 // if there is no file extension).
230 func findEntryByExtensionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/findEntryByExtension().(exts map[string]*MigrateInfoEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#, path string) *MigrateInfoEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry# {
231 ext := 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", filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Extscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Ext().(path))
232
233 // If extension exists, group all items under extension,
234 // else just use the file name.
235 var groupName string
236 if len(ext) > 1 {
237 groupName = ext
238 } else {
239 groupName = filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Basescip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Base().(path)
240 }
241
242 entry := exts[groupName]
243 if entry == nil {
244 entry = &MigrateInfoEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#{Qualifierscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#Qualifier.: groupName}
245 exts[groupName] = entry
246 }
247
248 return entry
249 }
250
251 // MapToEntries creates a set of `*MigrateInfoEntry`'s for a given map of
252 // filepath extensions to file size in bytes.
253 func MapToEntriesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MapToEntries().(exts map[string]*MigrateInfoEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#) []*MigrateInfoEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry# {
254 entries := make([]*MigrateInfoEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#, 0, len(exts))
255 for _, entry := range exts {
256 entries = append(entries, entry)
257 }
258
259 return entries
260 }
261
262 // removeEmptyEntries removes `*MigrateInfoEntry`'s for which no matching file
263 // is above the given threshold "--above".
264 func removeEmptyEntriesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/removeEmptyEntries().(entries []*MigrateInfoEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#) []*MigrateInfoEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry# {
265 nz := make([]*MigrateInfoEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#, 0, len(entries))
266 for _, e := range entries {
267 if e.TotalAbovescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#TotalAbove. > 0 {
268 nz = append(nz, e)
269 }
270 }
271
272 return nz
273 }
274
275 // EntriesBySize is an implementation of sort.Interface that sorts a set of
276 // `*MigrateInfoEntry`'s
277 type EntriesBySizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/EntriesBySize# []*MigrateInfoEntryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#
278
279 // Len returns the total length of the set of `*MigrateInfoEntry`'s.
280 func (e EntriesBySizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/EntriesBySize#) Lenscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/EntriesBySize#Len().() int { return len(e) }
281
282 // Less returns the whether or not the MigrateInfoEntry given at `i` takes up
283 // less total size than the MigrateInfoEntry given at `j`.
284 func (e EntriesBySizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/EntriesBySize#) Lessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/EntriesBySize#Less().(i, j int) bool {
285 if e[i].BytesAbovescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#BytesAbove. == e[j].BytesAbovescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#BytesAbove. {
286 return e[i].Qualifierscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#Qualifier. > e[j].Qualifierscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#Qualifier.
287 } else {
288 return e[i].BytesAbovescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#BytesAbove. < e[j].BytesAbovescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#BytesAbove.
289 }
290 }
291
292 // Swap swaps the entries given at i, j.
293 func (e EntriesBySizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/EntriesBySize#) Swapscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/EntriesBySize#Swap().(i, j int) { e[i], e[j] = e[j], e[i] }
294
295 // Print formats the `*MigrateInfoEntry`'s in the set and prints them to the
296 // given io.Writer, "to", returning "n" the number of bytes written, and any
297 // error, if one occurred.
298 func (e EntriesBySizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/EntriesBySize#) Printscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/EntriesBySize#Print().(to ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Writerscip-go gomod github.com/golang/go/src go1.25.0 io/Writer#) (int, error) {
299 if len(e) == 0 {
300 return 0, nil
301 }
302
303 extensions := make([]string, 0, len(e))
304 separateFlags := make([]bool, 0, len(e))
305 sizes := make([]string, 0, len(e))
306 stats := make([]string, 0, len(e))
307 percentages := make([]string, 0, len(e))
308
309 for _, entry := range e {
310 bytesAbove := uint64(entry.BytesAbovescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#BytesAbove.)
311 above := entry.TotalAbovescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#TotalAbove.
312 total := entry.Totalscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#Total.
313 percentAbove := 100 * (float64(above) / float64(total))
314
315 var size string
316 if migrateInfoUnitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoUnit. > 0 {
317 size = humanizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools/humanize`/.FormatBytesUnitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools/humanize`/FormatBytesUnit().(bytesAbove, migrateInfoUnitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/migrateInfoUnit.)
318 } else {
319 size = humanizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools/humanize`/.FormatBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools/humanize`/FormatBytes().(bytesAbove)
320 }
321
322 // TRANSLATORS: The strings here are intended to have the same
323 // display width including spaces, so please insert trailing
324 // spaces as necessary for your language.
325 stat := 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..GetNscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#GetN().(
326 "%d/%d file ",
327 "%d/%d files",
328 int(total),
329 above,
330 total,
331 )
332
333 percentage := 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().("%.0f%%", percentAbove)
334
335 extensions = append(extensions, entry.Qualifierscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#Qualifier.)
336 separateFlags = append(separateFlags, entry.Separatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/MigrateInfoEntry#Separate.)
337 sizes = append(sizes, size)
338 stats = append(stats, stat)
339 percentages = append(percentages, percentage)
340 }
341
342 extensions = toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.Ljustscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/Ljust().(extensions)
343 sizes = toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.Ljustscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/Ljust().(sizes)
344 stats = toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.Rjustscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/Rjust().(stats)
345 percentages = toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.Rjustscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/Rjust().(percentages)
346
347 output := make([]string, 0, len(e))
348 for i := 0; i < len(e); i++ {
349 extension := extensions[i]
350 size := sizes[i]
351 stat := stats[i]
352 percentage := percentages[i]
353
354 line := 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{extension, size, stat, percentage}, "\t")
355
356 if i > 0 && separateFlags[i] {
357 output = append(output, "")
358 }
359 output = append(output, line)
360 }
361
362 return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.25.0 fmt/Fprintln().(to, 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().(output, "\n"))
363 }