| 1 | package commandsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/ |
| 2 | |
| 3 | import ( |
| 4 | "crypto/sha256scip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha256`/" |
| 5 | "encoding/hexscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/" |
| 6 | "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/" |
| 7 | "ioscip-go gomod github.com/golang/go/src go1.25.0 io/" |
| 8 | "osscip-go gomod github.com/golang/go/src go1.25.0 os/" |
| 9 | "path/filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/" |
| 10 | "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/" |
| 11 | |
| 12 | "github.com/git-lfs/git-lfs/v3/errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/" |
| 13 | "github.com/git-lfs/git-lfs/v3/filepathfilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/" |
| 14 | "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`/" |
| 15 | "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`/" |
| 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/trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/" |
| 18 | "github.com/rubyist/tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/" |
| 19 | "github.com/spf13/cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/" |
| 20 | ) |
| 21 | |
| 22 | var ( |
| 23 | fsckDryRunscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/fsckDryRun. bool |
| 24 | fsckObjectsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/fsckObjects. bool |
| 25 | fsckPointersscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/fsckPointers. bool |
| 26 | ) |
| 27 | |
| 28 | type corruptPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer# struct { |
| 29 | blobOidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#blobOid. string |
| 30 | treeOidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#treeOid. string |
| 31 | lfsOidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#lfsOid. string |
| 32 | pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#path. string |
| 33 | messagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#message. string |
| 34 | kindscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#kind. string |
| 35 | } |
| 36 | |
| 37 | func (p corruptPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#) Stringscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#String().() string { |
| 38 | 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: %s", p.kindscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#kind., p.messagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#message.) |
| 39 | } |
| 40 | |
| 41 | // TODO(zeroshirts): 'git fsck' reports status (percentage, current#/total) as |
| 42 | // it checks... we should do the same, as we are rehashing potentially gigs and |
| 43 | // gigs of content. |
| 44 | // |
| 45 | // NOTE(zeroshirts): Ideally git would have hooks for fsck such that we could |
| 46 | // chain a lfs-fsck, but I don't think it does. |
| 47 | func fsckCommandscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/fsckCommand().(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) { |
| 48 | installHooksscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/installHooks().(false) |
| 49 | setupRepositoryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/setupRepository().() |
| 50 | |
| 51 | useIndex := false |
| 52 | exclude := "" |
| 53 | include := "HEAD" |
| 54 | |
| 55 | switch len(args) { |
| 56 | case 0: |
| 57 | useIndex = true |
| 58 | ref, err := gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.CurrentRefscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/CurrentRef().() |
| 59 | if err != nil { |
| 60 | ExitWithErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/ExitWithError().(err) |
| 61 | } |
| 62 | include = ref.Shascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/Ref#Sha. |
| 63 | case 1: |
| 64 | pieces := stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.SplitNscip-go gomod github.com/golang/go/src go1.25.0 strings/SplitN().(args[0], "..", 2) |
| 65 | refs, err := gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.ResolveRefsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ResolveRefs().(pieces) |
| 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 | if len(refs) == 2 { |
| 70 | exclude = refs[0].Shascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/Ref#Sha. |
| 71 | include = refs[1].Shascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/Ref#Sha. |
| 72 | } else { |
| 73 | include = refs[0].Shascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/Ref#Sha. |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | if !fsckPointersscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/fsckPointers. && !fsckObjectsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/fsckObjects. { |
| 78 | fsckPointersscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/fsckPointers. = true |
| 79 | fsckObjectsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/fsckObjects. = true |
| 80 | } |
| 81 | |
| 82 | ok := true |
| 83 | var corruptOids []string |
| 84 | var corruptPointers []corruptPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer# |
| 85 | if fsckObjectsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/fsckObjects. { |
| 86 | corruptOids = doFsckObjectsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/doFsckObjects().(include, exclude, useIndex) |
| 87 | ok = ok && len(corruptOids) == 0 |
| 88 | } |
| 89 | if fsckPointersscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/fsckPointers. { |
| 90 | corruptPointers = doFsckPointersscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/doFsckPointers().(include, exclude) |
| 91 | ok = ok && len(corruptPointers) == 0 |
| 92 | } |
| 93 | |
| 94 | if ok { |
| 95 | Printscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/Print().(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().("Git LFS fsck OK")) |
| 96 | return |
| 97 | } |
| 98 | |
| 99 | if fsckDryRunscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/fsckDryRun. || len(corruptOids) == 0 { |
| 100 | ExitWithCodescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/ExitWithCode().(1) |
| 101 | } |
| 102 | |
| 103 | badDir := 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().(cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/cfg..LFSStorageDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#LFSStorageDir().(), "bad") |
| 104 | Printscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/Print().("objects: repair: %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().("moving corrupt objects to %s", badDir)) |
| 105 | |
| 106 | if err := toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.MkdirAllscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/MkdirAll().(badDir, cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/cfg.); err != nil { |
| 107 | ExitWithErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/ExitWithError().(err) |
| 108 | } |
| 109 | |
| 110 | for _, oid := range corruptOids { |
| 111 | badFile := 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().(badDir, oid) |
| 112 | srcFile := cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/cfg..Filesystemscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#Filesystem().().ObjectPathnamescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/fs`/Filesystem#ObjectPathname().(oid) |
| 113 | if srcFile == osscip-go gomod github.com/golang/go/src go1.25.0 os/.DevNullscip-go gomod github.com/golang/go/src go1.25.0 os/DevNull. { |
| 114 | continue |
| 115 | } |
| 116 | if err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.Renamescip-go gomod github.com/golang/go/src go1.25.0 os/Rename().(srcFile, badFile); err != nil { |
| 117 | if osscip-go gomod github.com/golang/go/src go1.25.0 os/.IsNotExistscip-go gomod github.com/golang/go/src go1.25.0 os/IsNotExist().(err) { |
| 118 | continue |
| 119 | } |
| 120 | ExitWithErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/ExitWithError().(err) |
| 121 | } |
| 122 | } |
| 123 | ExitWithCodescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/ExitWithCode().(1) |
| 124 | } |
| 125 | |
| 126 | // doFsckObjects checks that the objects in the given ref are correct and exist. |
| 127 | func doFsckObjectsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/doFsckObjects().(include, exclude string, useIndex bool) []string { |
| 128 | var corruptOids []string |
| 129 | gitscanner := lfsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/.NewGitScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/NewGitScanner().(cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/cfg., func(p *lfsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/.WrappedPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/WrappedPointer#, err error) { |
| 130 | if err == nil { |
| 131 | var pointerOk bool |
| 132 | pointerOk, err = fsckPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/fsckPointer().(p.Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/WrappedPointer#Name., p.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#Oid., p.Sizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#Size.) |
| 133 | if !pointerOk { |
| 134 | corruptOids = append(corruptOids, p.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#Oid.) |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | if err != nil { |
| 139 | Panicscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/Panic().(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().("Error checking Git LFS files")) |
| 140 | } |
| 141 | }) |
| 142 | |
| 143 | // If 'lfs.fetchexclude' is set and 'git lfs fsck' is run after the |
| 144 | // initial fetch (i.e., has elected to fetch a subset of Git LFS |
| 145 | // objects), the "missing" ones will fail the fsck. |
| 146 | // |
| 147 | // Attach a filepathfilter to avoid _only_ the excluded paths. |
| 148 | gitscanner.Filterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitScanner#Filter. = filepathfilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/New().(nil, cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/cfg..FetchExcludePathsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#FetchExcludePaths().(), filepathfilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/.GitIgnorescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/GitIgnore., cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/cfg..Gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#Git.) |
| 149 | |
| 150 | if exclude == "" { |
| 151 | if err := gitscanner.ScanRefscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitScanner#ScanRef().(include, nil); err != nil { |
| 152 | ExitWithErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/ExitWithError().(err) |
| 153 | } |
| 154 | } else { |
| 155 | if err := gitscanner.ScanRefRangescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitScanner#ScanRefRange().(include, exclude, nil); err != nil { |
| 156 | ExitWithErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/ExitWithError().(err) |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | if useIndex { |
| 161 | if err := gitscanner.ScanIndexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitScanner#ScanIndex().("HEAD", "", nil); err != nil { |
| 162 | ExitWithErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/ExitWithError().(err) |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | return corruptOids |
| 167 | } |
| 168 | |
| 169 | // doFsckPointers checks that the pointers in the given ref are correct and canonical. |
| 170 | func doFsckPointersscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/doFsckPointers().(include, exclude string) []corruptPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer# { |
| 171 | var corruptPointers []corruptPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer# |
| 172 | gitscanner := lfsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/.NewGitScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/NewGitScanner().(cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/cfg., func(p *lfsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/.WrappedPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/WrappedPointer#, err error) { |
| 173 | if p != nil { |
| 174 | tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/.Printfscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/Printf().("Examining %v (%v)", p.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#Oid., p.Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/WrappedPointer#Name.) |
| 175 | if !p.Canonicalscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#Canonical. { |
| 176 | cp := corruptPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#{ |
| 177 | blobOidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#blobOid.: p.Sha1scip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/WrappedPointer#Sha1., |
| 178 | lfsOidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#lfsOid.: p.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#Oid., |
| 179 | messagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#message.: 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().("Pointer for %s (blob %s) was not canonical", p.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#Oid., p.Sha1scip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/WrappedPointer#Sha1.), |
| 180 | kindscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#kind.: "nonCanonicalPointer", |
| 181 | } |
| 182 | Printscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/Print().("pointer: %s", cp.Stringscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#String().()) |
| 183 | corruptPointers = append(corruptPointers, cp) |
| 184 | } |
| 185 | } else if errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.IsPointerScanErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/IsPointerScanError().(err) { |
| 186 | psErr, ok := err.(errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.PointerScanErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/PointerScanError#) |
| 187 | if ok { |
| 188 | cp := corruptPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#{ |
| 189 | treeOidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#treeOid.: psErr.OIDscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/PointerScanError#OID().(), |
| 190 | pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#path.: psErr.Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/PointerScanError#Path().(), |
| 191 | messagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#message.: 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().("%q (treeish %s) should have been a pointer but was not", psErr.Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/PointerScanError#Path().(), psErr.OIDscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/PointerScanError#OID().()), |
| 192 | kindscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#kind.: "unexpectedGitObject", |
| 193 | } |
| 194 | Printscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/Print().("pointer: %s", cp.Stringscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/corruptPointer#String().()) |
| 195 | corruptPointers = append(corruptPointers, cp) |
| 196 | } |
| 197 | } else { |
| 198 | Panicscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/Panic().(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().("Error checking Git LFS files")) |
| 199 | } |
| 200 | }) |
| 201 | |
| 202 | if exclude == "" { |
| 203 | if err := gitscanner.ScanRefByTreescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitScanner#ScanRefByTree().(include, nil); err != nil { |
| 204 | ExitWithErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/ExitWithError().(err) |
| 205 | } |
| 206 | } else { |
| 207 | if err := gitscanner.ScanRefRangeByTreescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitScanner#ScanRefRangeByTree().(include, exclude, nil); err != nil { |
| 208 | ExitWithErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/ExitWithError().(err) |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | return corruptPointers |
| 213 | } |
| 214 | |
| 215 | func fsckPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/fsckPointer().(name, oid string, size int64) (bool, error) { |
| 216 | path := cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/cfg..Filesystemscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#Filesystem().().ObjectPathnamescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/fs`/Filesystem#ObjectPathname().(oid) |
| 217 | |
| 218 | tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/.Printfscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/Printf().("Examining %v (%v)", name, path) |
| 219 | |
| 220 | f, err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.Openscip-go gomod github.com/golang/go/src go1.25.0 os/Open().(path) |
| 221 | if pErr, pOk := err.(*osscip-go gomod github.com/golang/go/src go1.25.0 os/.PathErrorscip-go gomod github.com/golang/go/src go1.25.0 os/PathError#); pOk { |
| 222 | // This is an empty file. No problem here. |
| 223 | if size == 0 { |
| 224 | return true, nil |
| 225 | } |
| 226 | Printscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/Print().("objects: openError: %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().("%s (%s) could not be checked: %s", name, oid, pErr.Errscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/PathError#Err.)) |
| 227 | return false, nil |
| 228 | } |
| 229 | |
| 230 | if err != nil { |
| 231 | return false, err |
| 232 | } |
| 233 | |
| 234 | oidHash := sha256scip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha256`/.Newscip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha256`/New().() |
| 235 | _, err = ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Copyscip-go gomod github.com/golang/go/src go1.25.0 io/Copy().(oidHash, f) |
| 236 | f.Closescip-go gomod github.com/golang/go/src go1.25.0 os/File#Close().() |
| 237 | if err != nil { |
| 238 | return false, err |
| 239 | } |
| 240 | |
| 241 | recalculatedOid := 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().(oidHash.Sumscip-go gomod github.com/golang/go/src go1.25.0 hash/Hash#Sum().(nil)) |
| 242 | if recalculatedOid == oid { |
| 243 | return true, nil |
| 244 | } |
| 245 | |
| 246 | Printscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/Print().(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().("objects: corruptObject: %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().("%s (%s) is corrupt", name, oid))) |
| 247 | return false, nil |
| 248 | } |
| 249 | |
| 250 | func initscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/init().() { |
| 251 | RegisterCommandscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/RegisterCommand().("fsck", fsckCommandscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/fsckCommand()., func(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#) { |
| 252 | cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().BoolVarPscip-go gomod github.com/spf13/pflag v1.0.9 `github.com/spf13/pflag`/FlagSet#BoolVarP().(&fsckDryRunscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/fsckDryRun., "dry-run", "d", false, "List corrupt objects without deleting them.") |
| 253 | cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().BoolVarPscip-go gomod github.com/spf13/pflag v1.0.9 `github.com/spf13/pflag`/FlagSet#BoolVarP().(&fsckObjectsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/fsckObjects., "objects", "", false, "Fsck objects.") |
| 254 | cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().BoolVarPscip-go gomod github.com/spf13/pflag v1.0.9 `github.com/spf13/pflag`/FlagSet#BoolVarP().(&fsckPointersscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/commands`/fsckPointers., "pointers", "", false, "Fsck pointers.") |
| 255 | }) |
| 256 | } |