| 1 | package standalonescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/ |
| 2 | |
| 3 | import ( |
| 4 | "bufioscip-go gomod github.com/golang/go/src go1.25.0 bufio/" |
| 5 | "encoding/jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/" |
| 6 | "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/" |
| 7 | "net/urlscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/" |
| 8 | "osscip-go gomod github.com/golang/go/src go1.25.0 os/" |
| 9 | "os/execscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/" |
| 10 | "path/filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/" |
| 11 | "regexpscip-go gomod github.com/golang/go/src go1.25.0 regexp/" |
| 12 | "runtimescip-go gomod github.com/golang/go/src go1.25.0 runtime/" |
| 13 | "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/" |
| 14 | |
| 15 | "github.com/git-lfs/git-lfs/v3/configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/" |
| 16 | "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`/" |
| 17 | "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`/" |
| 18 | "github.com/git-lfs/git-lfs/v3/lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/" |
| 19 | "github.com/git-lfs/git-lfs/v3/subprocessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/" |
| 20 | "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`/" |
| 21 | "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`/" |
| 22 | "github.com/rubyist/tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/" |
| 23 | ) |
| 24 | |
| 25 | // inputMessage represents a message from Git LFS to the standalone transfer |
| 26 | // agent. Not all fields will be filled in on all requests. |
| 27 | type inputMessagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage# struct { |
| 28 | Eventscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage#Event. string `json:"event"` |
| 29 | Operationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage#Operation. string `json:"operation"` |
| 30 | Remotescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage#Remote. string `json:"remote"` |
| 31 | Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage#Oid. string `json:"oid"` |
| 32 | Sizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage#Size. int64 `json:"size"` |
| 33 | Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage#Path. string `json:"path"` |
| 34 | } |
| 35 | |
| 36 | // errorMessage represents an optional error message that may occur in a |
| 37 | // completion response. |
| 38 | type errorMessagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/errorMessage# struct { |
| 39 | Messagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/errorMessage#Message. string `json:"message"` |
| 40 | } |
| 41 | |
| 42 | // outputErrorMessage represents an error message that may occur during startup. |
| 43 | type outputErrorMessagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/outputErrorMessage# struct { |
| 44 | Errorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/outputErrorMessage#Error. errorMessagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/errorMessage# `json:"error"` |
| 45 | } |
| 46 | |
| 47 | // completeMessage represents a completion response. |
| 48 | type completeMessagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/completeMessage# struct { |
| 49 | Eventscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/completeMessage#Event. string `json:"event"` |
| 50 | Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/completeMessage#Oid. string `json:"oid"` |
| 51 | Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/completeMessage#Path. string `json:"path,omitempty"` |
| 52 | Errorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/completeMessage#Error. *errorMessagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/errorMessage# `json:"error,omitempty"` |
| 53 | } |
| 54 | |
| 55 | type fileHandlerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler# struct { |
| 56 | remotePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#remotePath. string |
| 57 | remoteConfigscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#remoteConfig. *configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Configurationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration# |
| 58 | outputscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#output. *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# |
| 59 | configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#config. *configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Configurationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration# |
| 60 | tempdirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#tempdir. string |
| 61 | } |
| 62 | |
| 63 | // fileUrlFromRemote looks up the URL depending on the remote. The remote can be |
| 64 | // a literal URL or the name of a remote. |
| 65 | // |
| 66 | // In this situation, we only accept file URLs. |
| 67 | func fileUrlFromRemotescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileUrlFromRemote().(cfg *configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Configurationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#, name string, direction string) (*urlscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#, error) { |
| 68 | if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(name, "file://") { |
| 69 | if url, err := urlscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/.Parsescip-go gomod github.com/golang/go/src go1.25.0 `net/url`/Parse().(name); err == nil { |
| 70 | return url, nil |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | apiClient := lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/.NewClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewClient().(cfg) |
| 75 | defer apiClient.Closescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Close().() |
| 76 | |
| 77 | for _, remote := range cfg.Remotesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#Remotes().() { |
| 78 | if remote != name { |
| 79 | continue |
| 80 | } |
| 81 | remoteEndpoint := apiClient.Endpointsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Endpoints..Endpointscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/EndpointFinder#Endpoint.(direction, remote) |
| 82 | if !stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(remoteEndpoint.Urlscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#Url., "file://") { |
| 83 | return nil, nil |
| 84 | } |
| 85 | return urlscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/.Parsescip-go gomod github.com/golang/go/src go1.25.0 `net/url`/Parse().(remoteEndpoint.Urlscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#Url.) |
| 86 | } |
| 87 | return nil, nil |
| 88 | } |
| 89 | |
| 90 | // gitDirAtPath finds the .git directory corresponding to the given path, which |
| 91 | // may be the .git directory itself, the working tree, or the root of a bare |
| 92 | // repository. |
| 93 | // |
| 94 | // We filter out the GIT_DIR environment variable to ensure we get the expected |
| 95 | // result, and we change directories to ensure that we can make use of |
| 96 | // filepath.Abs. Using --absolute-git-dir instead of --git-dir is not an option |
| 97 | // because we support Git versions that don't have --absolute-git-dir. |
| 98 | func gitDirAtPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/gitDirAtPath().(path string) (string, error) { |
| 99 | // Filter out all the GIT_* environment variables. |
| 100 | env := osscip-go gomod github.com/golang/go/src go1.25.0 os/.Environscip-go gomod github.com/golang/go/src go1.25.0 os/Environ().() |
| 101 | n := 0 |
| 102 | for _, val := range env { |
| 103 | if !stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(val, "GIT_") { |
| 104 | env[n] = val |
| 105 | n++ |
| 106 | } |
| 107 | } |
| 108 | env = env[:n] |
| 109 | |
| 110 | // Trim any trailing .git path segment. |
| 111 | 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) == ".git" { |
| 112 | path = filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Dirscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Dir().(path) |
| 113 | } |
| 114 | |
| 115 | curdir, err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.Getwdscip-go gomod github.com/golang/go/src go1.25.0 os/Getwd().() |
| 116 | if err != nil { |
| 117 | return "", err |
| 118 | } |
| 119 | |
| 120 | err = osscip-go gomod github.com/golang/go/src go1.25.0 os/.Chdirscip-go gomod github.com/golang/go/src go1.25.0 os/Chdir().(path) |
| 121 | if err != nil { |
| 122 | return "", err |
| 123 | } |
| 124 | |
| 125 | cmd, err := subprocessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/.ExecCommandscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/ExecCommand().("git", "rev-parse", "--git-dir") |
| 126 | if err != nil { |
| 127 | return "", 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().("failed to find `git rev-parse --git-dir`")) |
| 128 | } |
| 129 | cmd.Cmdscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/Cmd#Cmd..Envscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/Cmd#Env. = env |
| 130 | out, err := cmd.Outputscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/Cmd#Output().() |
| 131 | if err != nil { |
| 132 | if err, ok := err.(*execscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/.ExitErrorscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/ExitError#); ok && len(err.Stderrscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/ExitError#Stderr.) > 0 { |
| 133 | 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().("failed to call `git rev-parse --git-dir`: %s", string(err.Stderrscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/ExitError#Stderr.))) |
| 134 | } |
| 135 | return "", 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().("failed to call `git rev-parse --git-dir`")) |
| 136 | } |
| 137 | |
| 138 | gitdir, err := toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.TranslateCygwinPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TranslateCygwinPath().(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.TrimRightscip-go gomod github.com/golang/go/src go1.25.0 strings/TrimRight().(string(out), "\n")) |
| 139 | if err != nil { |
| 140 | return "", 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().("unable to translate path")) |
| 141 | } |
| 142 | |
| 143 | gitdir, err = filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Absscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Abs().(gitdir) |
| 144 | if err != nil { |
| 145 | return "", 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().("unable to canonicalize path")) |
| 146 | } |
| 147 | |
| 148 | err = osscip-go gomod github.com/golang/go/src go1.25.0 os/.Chdirscip-go gomod github.com/golang/go/src go1.25.0 os/Chdir().(curdir) |
| 149 | if err != nil { |
| 150 | return "", err |
| 151 | } |
| 152 | return toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.CanonicalizeSystemPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CanonicalizeSystemPath().(gitdir) |
| 153 | } |
| 154 | |
| 155 | func fixUrlPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fixUrlPath().(path string) string { |
| 156 | if runtimescip-go gomod github.com/golang/go/src go1.25.0 runtime/.GOOSscip-go gomod github.com/golang/go/src go1.25.0 runtime/GOOS. != "windows" { |
| 157 | return path |
| 158 | } |
| 159 | |
| 160 | // When parsing a file URL, Go produces a path starting with a slash. If |
| 161 | // it looks like there's a Windows drive letter at the beginning, strip |
| 162 | // off the beginning slash. If this is a Unix-style path from a |
| 163 | // Cygwin-like environment, we'll canonicalize it later. |
| 164 | re := regexpscip-go gomod github.com/golang/go/src go1.25.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.25.0 regexp/MustCompile().("/[A-Za-z]:/") |
| 165 | if re.MatchStringscip-go gomod github.com/golang/go/src go1.25.0 regexp/Regexp#MatchString().(path) { |
| 166 | return path[1:] |
| 167 | } |
| 168 | return path |
| 169 | } |
| 170 | |
| 171 | // newHandler creates a new handler for the protocol. |
| 172 | func newHandlerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/newHandler().(cfg *configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Configurationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#, output *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#, msg *inputMessagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage#) (*fileHandlerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#, error) { |
| 173 | url, err := fileUrlFromRemotescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileUrlFromRemote().(cfg, msg.Remotescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage#Remote., msg.Operationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage#Operation.) |
| 174 | if err != nil { |
| 175 | return nil, err |
| 176 | } |
| 177 | if url == nil { |
| 178 | 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().("no valid file:// URLs found")) |
| 179 | } |
| 180 | |
| 181 | path, err := toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.TranslateCygwinPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TranslateCygwinPath().(fixUrlPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fixUrlPath().(url.Pathscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#Path.)) |
| 182 | if err != nil { |
| 183 | return nil, err |
| 184 | } |
| 185 | |
| 186 | gitdir, err := gitDirAtPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/gitDirAtPath().(path) |
| 187 | if err != nil { |
| 188 | return nil, err |
| 189 | } |
| 190 | |
| 191 | tempdir, err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.MkdirTempscip-go gomod github.com/golang/go/src go1.25.0 os/MkdirTemp().(cfg.TempDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#TempDir().(), "lfs-standalone-file-*") |
| 192 | if err != nil { |
| 193 | return nil, err |
| 194 | } |
| 195 | |
| 196 | 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().("using %q as remote git directory", gitdir) |
| 197 | |
| 198 | return &fileHandlerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#{ |
| 199 | remotePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#remotePath.: path, |
| 200 | remoteConfigscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#remoteConfig.: configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.NewInscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/NewIn().(gitdir, gitdir), |
| 201 | outputscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#output.: output, |
| 202 | configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#config.: cfg, |
| 203 | tempdirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#tempdir.: tempdir, |
| 204 | }, nil |
| 205 | } |
| 206 | |
| 207 | // dispatch dispatches the event depending on the message type. |
| 208 | func (h *fileHandlerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#) dispatchscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#dispatch().(msg *inputMessagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage#) (bool, error) { |
| 209 | switch msg.Eventscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage#Event. { |
| 210 | case "init": |
| 211 | 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().(h.outputscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#output., "{}") |
| 212 | case "upload": |
| 213 | h.respondscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#respond().(h.uploadscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#upload().(msg.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage#Oid., msg.Sizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage#Size., msg.Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage#Path.)) |
| 214 | case "download": |
| 215 | h.respondscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#respond().(h.downloadscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#download().(msg.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage#Oid., msg.Sizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage#Size.)) |
| 216 | case "terminate": |
| 217 | return false, nil |
| 218 | default: |
| 219 | return false, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/New().(trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("unknown event %q", msg.Eventscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage#Event.)) |
| 220 | } |
| 221 | return true, nil |
| 222 | } |
| 223 | |
| 224 | // respond sends a response to an upload or download command, using the return |
| 225 | // values from those functions. |
| 226 | func (h *fileHandlerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#) respondscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#respond().(oid string, path string, err error) { |
| 227 | response := &completeMessagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/completeMessage#{ |
| 228 | Eventscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/completeMessage#Event.: "complete", |
| 229 | Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/completeMessage#Oid.: oid, |
| 230 | Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/completeMessage#Path.: path, |
| 231 | } |
| 232 | if err != nil { |
| 233 | response.Errorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/completeMessage#Error. = &errorMessagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/errorMessage#{Messagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/errorMessage#Message.: err.Error()} |
| 234 | } |
| 235 | jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/.NewEncoderscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/NewEncoder().(h.outputscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#output.).Encodescip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/Encoder#Encode().(response) |
| 236 | } |
| 237 | |
| 238 | // upload performs the upload action for the given OID, size, and path. It |
| 239 | // returns arguments suitable for the respond method. |
| 240 | func (h *fileHandlerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#) uploadscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#upload().(oid string, size int64, path string) (string, string, error) { |
| 241 | if h.remoteConfigscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#remoteConfig..LFSObjectExistsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#LFSObjectExists().(oid, size) { |
| 242 | // Already there, nothing to do. |
| 243 | return oid, "", nil |
| 244 | } |
| 245 | dest, err := h.remoteConfigscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#remoteConfig..Filesystemscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#Filesystem().().ObjectPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/fs`/Filesystem#ObjectPath().(oid) |
| 246 | if err != nil { |
| 247 | return oid, "", err |
| 248 | } |
| 249 | return oid, "", lfsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/.LinkOrCopyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/LinkOrCopy().(h.remoteConfigscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#remoteConfig., path, dest) |
| 250 | } |
| 251 | |
| 252 | // download performs the download action for the given OID and size. It returns |
| 253 | // arguments suitable for the respond method. |
| 254 | func (h *fileHandlerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#) downloadscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#download().(oid string, size int64) (string, string, error) { |
| 255 | if !h.remoteConfigscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#remoteConfig..LFSObjectExistsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#LFSObjectExists().(oid, size) { |
| 256 | 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().("missing object in %q (%s)", h.remotePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#remotePath., oid) |
| 257 | return oid, "", 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().("remote missing object %s", oid)) |
| 258 | } |
| 259 | |
| 260 | src, err := h.remoteConfigscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#remoteConfig..Filesystemscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#Filesystem().().ObjectPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/fs`/Filesystem#ObjectPath().(oid) |
| 261 | if err != nil { |
| 262 | return oid, "", err |
| 263 | } |
| 264 | |
| 265 | tmp, err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.CreateTempscip-go gomod github.com/golang/go/src go1.25.0 os/CreateTemp().(h.tempdirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#tempdir., "download") |
| 266 | if err != nil { |
| 267 | return oid, "", err |
| 268 | } |
| 269 | tmp.Closescip-go gomod github.com/golang/go/src go1.25.0 os/File#Close().() |
| 270 | osscip-go gomod github.com/golang/go/src go1.25.0 os/.Removescip-go gomod github.com/golang/go/src go1.25.0 os/Remove().(tmp.Namescip-go gomod github.com/golang/go/src go1.25.0 os/File#Name().()) |
| 271 | path := tmp.Namescip-go gomod github.com/golang/go/src go1.25.0 os/File#Name().() |
| 272 | return oid, path, lfsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/.LinkOrCopyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/LinkOrCopy().(h.configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#config., src, path) |
| 273 | } |
| 274 | |
| 275 | // ProcessStandaloneData is the primary endpoint for processing data with a |
| 276 | // standalone transfer agent. It reads input from the specified input file and |
| 277 | // produces output to the specified output file. |
| 278 | func ProcessStandaloneDatascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/ProcessStandaloneData().(cfg *configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Configurationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#, input *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#, output *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#) error { |
| 279 | var handler *fileHandlerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler# |
| 280 | |
| 281 | var eventErr error |
| 282 | scanner := bufioscip-go gomod github.com/golang/go/src go1.25.0 bufio/.NewScannerscip-go gomod github.com/golang/go/src go1.25.0 bufio/NewScanner().(input) |
| 283 | for scanner.Scanscip-go gomod github.com/golang/go/src go1.25.0 bufio/Scanner#Scan().() { |
| 284 | var msg inputMessagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/inputMessage# |
| 285 | if err := jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/.NewDecoderscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/NewDecoder().(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.NewReaderscip-go gomod github.com/golang/go/src go1.25.0 strings/NewReader().(scanner.Textscip-go gomod github.com/golang/go/src go1.25.0 bufio/Scanner#Text().())).Decodescip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/Decoder#Decode().(&msg); err != nil { |
| 286 | return 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().("error decoding JSON")) |
| 287 | } |
| 288 | if handler == nil { |
| 289 | var err error |
| 290 | handler, err = newHandlerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/newHandler().(cfg, output, &msg) |
| 291 | if err != nil { |
| 292 | err := 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().("error creating handler")) |
| 293 | errMsg := outputErrorMessagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/outputErrorMessage#{ |
| 294 | Errorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/outputErrorMessage#Error.: errorMessagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/errorMessage#{ |
| 295 | Messagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/errorMessage#Message.: err.Error(), |
| 296 | }, |
| 297 | } |
| 298 | jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/.NewEncoderscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/NewEncoder().(output).Encodescip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/Encoder#Encode().(errMsg) |
| 299 | return err |
| 300 | } |
| 301 | } |
| 302 | if cont, err := handler.dispatchscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#dispatch().(&msg); !cont || err != nil { |
| 303 | eventErr = err |
| 304 | break |
| 305 | } |
| 306 | } |
| 307 | if handler != nil { |
| 308 | osscip-go gomod github.com/golang/go/src go1.25.0 os/.RemoveAllscip-go gomod github.com/golang/go/src go1.25.0 os/RemoveAll().(handler.tempdirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp/standalone`/fileHandler#tempdir.) |
| 309 | } |
| 310 | err := scanner.Errscip-go gomod github.com/golang/go/src go1.25.0 bufio/Scanner#Err().() |
| 311 | if err != nil { |
| 312 | err = 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().("error reading input")) |
| 313 | } |
| 314 | return errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Joinscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/Join().(eventErr, err) |
| 315 | } |