repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
sequence | docstring
stringlengths 6
2.61k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 85
252
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
git-lfs/git-lfs | errors/context.go | GetContext | func GetContext(err error, key string) interface{} {
if e, ok := err.(withContext); ok {
return e.Get(key)
}
return ""
} | go | func GetContext(err error, key string) interface{} {
if e, ok := err.(withContext); ok {
return e.Get(key)
}
return ""
} | [
"func",
"GetContext",
"(",
"err",
"error",
",",
"key",
"string",
")",
"interface",
"{",
"}",
"{",
"if",
"e",
",",
"ok",
":=",
"err",
".",
"(",
"withContext",
")",
";",
"ok",
"{",
"return",
"e",
".",
"Get",
"(",
"key",
")",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] | // ErrorGetContext gets a value from the error's context. If the error has not
// been wrapped, it returns an empty string. | [
"ErrorGetContext",
"gets",
"a",
"value",
"from",
"the",
"error",
"s",
"context",
".",
"If",
"the",
"error",
"has",
"not",
"been",
"wrapped",
"it",
"returns",
"an",
"empty",
"string",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/errors/context.go#L20-L25 | train |
git-lfs/git-lfs | errors/context.go | DelContext | func DelContext(err error, key string) {
if e, ok := err.(withContext); ok {
e.Del(key)
}
} | go | func DelContext(err error, key string) {
if e, ok := err.(withContext); ok {
e.Del(key)
}
} | [
"func",
"DelContext",
"(",
"err",
"error",
",",
"key",
"string",
")",
"{",
"if",
"e",
",",
"ok",
":=",
"err",
".",
"(",
"withContext",
")",
";",
"ok",
"{",
"e",
".",
"Del",
"(",
"key",
")",
"\n",
"}",
"\n",
"}"
] | // ErrorDelContext removes a value from the error's context. If the error has
// not been wrapped, it does nothing. | [
"ErrorDelContext",
"removes",
"a",
"value",
"from",
"the",
"error",
"s",
"context",
".",
"If",
"the",
"error",
"has",
"not",
"been",
"wrapped",
"it",
"does",
"nothing",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/errors/context.go#L29-L33 | train |
git-lfs/git-lfs | errors/context.go | Context | func Context(err error) map[string]interface{} {
if e, ok := err.(withContext); ok {
return e.Context()
}
return nil
} | go | func Context(err error) map[string]interface{} {
if e, ok := err.(withContext); ok {
return e.Context()
}
return nil
} | [
"func",
"Context",
"(",
"err",
"error",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"if",
"e",
",",
"ok",
":=",
"err",
".",
"(",
"withContext",
")",
";",
"ok",
"{",
"return",
"e",
".",
"Context",
"(",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // ErrorContext returns the context map for an error if it is a wrappedError.
// If it is not a wrappedError it will return an empty map. | [
"ErrorContext",
"returns",
"the",
"context",
"map",
"for",
"an",
"error",
"if",
"it",
"is",
"a",
"wrappedError",
".",
"If",
"it",
"is",
"not",
"a",
"wrappedError",
"it",
"will",
"return",
"an",
"empty",
"map",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/errors/context.go#L37-L42 | train |
git-lfs/git-lfs | lfs/hook.go | NewStandardHook | func NewStandardHook(theType, hookDir string, upgradeables []string, cfg *config.Configuration) *Hook {
return &Hook{
Type: theType,
Contents: strings.Replace(hookBaseContent, "{{Command}}", theType, -1),
Dir: hookDir,
upgradeables: upgradeables,
cfg: cfg,
}
} | go | func NewStandardHook(theType, hookDir string, upgradeables []string, cfg *config.Configuration) *Hook {
return &Hook{
Type: theType,
Contents: strings.Replace(hookBaseContent, "{{Command}}", theType, -1),
Dir: hookDir,
upgradeables: upgradeables,
cfg: cfg,
}
} | [
"func",
"NewStandardHook",
"(",
"theType",
",",
"hookDir",
"string",
",",
"upgradeables",
"[",
"]",
"string",
",",
"cfg",
"*",
"config",
".",
"Configuration",
")",
"*",
"Hook",
"{",
"return",
"&",
"Hook",
"{",
"Type",
":",
"theType",
",",
"Contents",
":",
"strings",
".",
"Replace",
"(",
"hookBaseContent",
",",
"\"",
"\"",
",",
"theType",
",",
"-",
"1",
")",
",",
"Dir",
":",
"hookDir",
",",
"upgradeables",
":",
"upgradeables",
",",
"cfg",
":",
"cfg",
",",
"}",
"\n",
"}"
] | // NewStandardHook creates a new hook using the template script calling 'git lfs theType' | [
"NewStandardHook",
"creates",
"a",
"new",
"hook",
"using",
"the",
"template",
"script",
"calling",
"git",
"lfs",
"theType"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/hook.go#L48-L56 | train |
git-lfs/git-lfs | lfs/hook.go | Install | func (h *Hook) Install(force bool) error {
msg := fmt.Sprintf("Install hook: %s, force=%t, path=%s", h.Type, force, h.Path())
if err := tools.MkdirAll(h.Dir, h.cfg); err != nil {
return err
}
if h.Exists() && !force {
tracerx.Printf(msg + ", upgrading...")
return h.Upgrade()
}
tracerx.Printf(msg)
return h.write()
} | go | func (h *Hook) Install(force bool) error {
msg := fmt.Sprintf("Install hook: %s, force=%t, path=%s", h.Type, force, h.Path())
if err := tools.MkdirAll(h.Dir, h.cfg); err != nil {
return err
}
if h.Exists() && !force {
tracerx.Printf(msg + ", upgrading...")
return h.Upgrade()
}
tracerx.Printf(msg)
return h.write()
} | [
"func",
"(",
"h",
"*",
"Hook",
")",
"Install",
"(",
"force",
"bool",
")",
"error",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"h",
".",
"Type",
",",
"force",
",",
"h",
".",
"Path",
"(",
")",
")",
"\n\n",
"if",
"err",
":=",
"tools",
".",
"MkdirAll",
"(",
"h",
".",
"Dir",
",",
"h",
".",
"cfg",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"h",
".",
"Exists",
"(",
")",
"&&",
"!",
"force",
"{",
"tracerx",
".",
"Printf",
"(",
"msg",
"+",
"\"",
"\"",
")",
"\n",
"return",
"h",
".",
"Upgrade",
"(",
")",
"\n",
"}",
"\n\n",
"tracerx",
".",
"Printf",
"(",
"msg",
")",
"\n",
"return",
"h",
".",
"write",
"(",
")",
"\n",
"}"
] | // Install installs this Git hook on disk, or upgrades it if it does exist, and
// is upgradeable. It will create a hooks directory relative to the local Git
// directory. It returns and halts at any errors, and returns nil if the
// operation was a success. | [
"Install",
"installs",
"this",
"Git",
"hook",
"on",
"disk",
"or",
"upgrades",
"it",
"if",
"it",
"does",
"exist",
"and",
"is",
"upgradeable",
".",
"It",
"will",
"create",
"a",
"hooks",
"directory",
"relative",
"to",
"the",
"local",
"Git",
"directory",
".",
"It",
"returns",
"and",
"halts",
"at",
"any",
"errors",
"and",
"returns",
"nil",
"if",
"the",
"operation",
"was",
"a",
"success",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/hook.go#L74-L88 | train |
git-lfs/git-lfs | lfs/hook.go | write | func (h *Hook) write() error {
return ioutil.WriteFile(h.Path(), []byte(h.Contents+"\n"), 0755)
} | go | func (h *Hook) write() error {
return ioutil.WriteFile(h.Path(), []byte(h.Contents+"\n"), 0755)
} | [
"func",
"(",
"h",
"*",
"Hook",
")",
"write",
"(",
")",
"error",
"{",
"return",
"ioutil",
".",
"WriteFile",
"(",
"h",
".",
"Path",
"(",
")",
",",
"[",
"]",
"byte",
"(",
"h",
".",
"Contents",
"+",
"\"",
"\\n",
"\"",
")",
",",
"0755",
")",
"\n",
"}"
] | // write writes the contents of this Hook to disk, appending a newline at the
// end, and sets the mode to octal 0755. It writes to disk unconditionally, and
// returns at any error. | [
"write",
"writes",
"the",
"contents",
"of",
"this",
"Hook",
"to",
"disk",
"appending",
"a",
"newline",
"at",
"the",
"end",
"and",
"sets",
"the",
"mode",
"to",
"octal",
"0755",
".",
"It",
"writes",
"to",
"disk",
"unconditionally",
"and",
"returns",
"at",
"any",
"error",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/hook.go#L93-L95 | train |
git-lfs/git-lfs | lfs/hook.go | Uninstall | func (h *Hook) Uninstall() error {
msg := fmt.Sprintf("Uninstall hook: %s, path=%s", h.Type, h.Path())
match, err := h.matchesCurrent()
if err != nil {
return err
}
if !match {
tracerx.Printf(msg + ", doesn't match...")
return nil
}
tracerx.Printf(msg)
return os.RemoveAll(h.Path())
} | go | func (h *Hook) Uninstall() error {
msg := fmt.Sprintf("Uninstall hook: %s, path=%s", h.Type, h.Path())
match, err := h.matchesCurrent()
if err != nil {
return err
}
if !match {
tracerx.Printf(msg + ", doesn't match...")
return nil
}
tracerx.Printf(msg)
return os.RemoveAll(h.Path())
} | [
"func",
"(",
"h",
"*",
"Hook",
")",
"Uninstall",
"(",
")",
"error",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"h",
".",
"Type",
",",
"h",
".",
"Path",
"(",
")",
")",
"\n\n",
"match",
",",
"err",
":=",
"h",
".",
"matchesCurrent",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"!",
"match",
"{",
"tracerx",
".",
"Printf",
"(",
"msg",
"+",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"tracerx",
".",
"Printf",
"(",
"msg",
")",
"\n",
"return",
"os",
".",
"RemoveAll",
"(",
"h",
".",
"Path",
"(",
")",
")",
"\n",
"}"
] | // Uninstall removes the hook on disk so long as it matches the current version,
// or any of the past versions of this hook. | [
"Uninstall",
"removes",
"the",
"hook",
"on",
"disk",
"so",
"long",
"as",
"it",
"matches",
"the",
"current",
"version",
"or",
"any",
"of",
"the",
"past",
"versions",
"of",
"this",
"hook",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/hook.go#L116-L131 | train |
git-lfs/git-lfs | lfs/hook.go | matchesCurrent | func (h *Hook) matchesCurrent() (bool, error) {
file, err := os.Open(h.Path())
if err != nil {
return false, err
}
by, err := ioutil.ReadAll(io.LimitReader(file, 1024))
file.Close()
if err != nil {
return false, err
}
contents := strings.TrimSpace(tools.Undent(string(by)))
if contents == h.Contents || len(contents) == 0 {
return true, nil
}
for _, u := range h.upgradeables {
if u == contents {
return true, nil
}
}
return false, fmt.Errorf("Hook already exists: %s\n\n%s\n", string(h.Type), tools.Indent(contents))
} | go | func (h *Hook) matchesCurrent() (bool, error) {
file, err := os.Open(h.Path())
if err != nil {
return false, err
}
by, err := ioutil.ReadAll(io.LimitReader(file, 1024))
file.Close()
if err != nil {
return false, err
}
contents := strings.TrimSpace(tools.Undent(string(by)))
if contents == h.Contents || len(contents) == 0 {
return true, nil
}
for _, u := range h.upgradeables {
if u == contents {
return true, nil
}
}
return false, fmt.Errorf("Hook already exists: %s\n\n%s\n", string(h.Type), tools.Indent(contents))
} | [
"func",
"(",
"h",
"*",
"Hook",
")",
"matchesCurrent",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"h",
".",
"Path",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"by",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"io",
".",
"LimitReader",
"(",
"file",
",",
"1024",
")",
")",
"\n",
"file",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"contents",
":=",
"strings",
".",
"TrimSpace",
"(",
"tools",
".",
"Undent",
"(",
"string",
"(",
"by",
")",
")",
")",
"\n",
"if",
"contents",
"==",
"h",
".",
"Contents",
"||",
"len",
"(",
"contents",
")",
"==",
"0",
"{",
"return",
"true",
",",
"nil",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"u",
":=",
"range",
"h",
".",
"upgradeables",
"{",
"if",
"u",
"==",
"contents",
"{",
"return",
"true",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"false",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\n",
"\\n",
"\\n",
"\"",
",",
"string",
"(",
"h",
".",
"Type",
")",
",",
"tools",
".",
"Indent",
"(",
"contents",
")",
")",
"\n",
"}"
] | // matchesCurrent returns whether or not an existing git hook is able to be
// written to or upgraded. A git hook matches those conditions if and only if
// its contents match the current contents, or any past "upgrade-able" contents
// of this hook. | [
"matchesCurrent",
"returns",
"whether",
"or",
"not",
"an",
"existing",
"git",
"hook",
"is",
"able",
"to",
"be",
"written",
"to",
"or",
"upgraded",
".",
"A",
"git",
"hook",
"matches",
"those",
"conditions",
"if",
"and",
"only",
"if",
"its",
"contents",
"match",
"the",
"current",
"contents",
"or",
"any",
"past",
"upgrade",
"-",
"able",
"contents",
"of",
"this",
"hook",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/hook.go#L137-L161 | train |
git-lfs/git-lfs | lfsapi/endpoint_finder.go | Upgrade | func (a *Access) Upgrade(newMode AccessMode) Access {
return Access{url: a.url, mode: newMode}
} | go | func (a *Access) Upgrade(newMode AccessMode) Access {
return Access{url: a.url, mode: newMode}
} | [
"func",
"(",
"a",
"*",
"Access",
")",
"Upgrade",
"(",
"newMode",
"AccessMode",
")",
"Access",
"{",
"return",
"Access",
"{",
"url",
":",
"a",
".",
"url",
",",
"mode",
":",
"newMode",
"}",
"\n",
"}"
] | // Returns a copy of an AccessMode with the mode upgraded to newMode | [
"Returns",
"a",
"copy",
"of",
"an",
"AccessMode",
"with",
"the",
"mode",
"upgraded",
"to",
"newMode"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfsapi/endpoint_finder.go#L35-L37 | train |
git-lfs/git-lfs | lfsapi/endpoint_finder.go | replaceUrlAlias | func (e *endpointGitFinder) replaceUrlAlias(aliases map[string]string, rawurl string) (string, bool) {
var longestalias string
for alias, _ := range aliases {
if !strings.HasPrefix(rawurl, alias) {
continue
}
if longestalias < alias {
longestalias = alias
}
}
if len(longestalias) > 0 {
return aliases[longestalias] + rawurl[len(longestalias):], true
}
return rawurl, false
} | go | func (e *endpointGitFinder) replaceUrlAlias(aliases map[string]string, rawurl string) (string, bool) {
var longestalias string
for alias, _ := range aliases {
if !strings.HasPrefix(rawurl, alias) {
continue
}
if longestalias < alias {
longestalias = alias
}
}
if len(longestalias) > 0 {
return aliases[longestalias] + rawurl[len(longestalias):], true
}
return rawurl, false
} | [
"func",
"(",
"e",
"*",
"endpointGitFinder",
")",
"replaceUrlAlias",
"(",
"aliases",
"map",
"[",
"string",
"]",
"string",
",",
"rawurl",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"var",
"longestalias",
"string",
"\n",
"for",
"alias",
",",
"_",
":=",
"range",
"aliases",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"rawurl",
",",
"alias",
")",
"{",
"continue",
"\n",
"}",
"\n\n",
"if",
"longestalias",
"<",
"alias",
"{",
"longestalias",
"=",
"alias",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"longestalias",
")",
">",
"0",
"{",
"return",
"aliases",
"[",
"longestalias",
"]",
"+",
"rawurl",
"[",
"len",
"(",
"longestalias",
")",
":",
"]",
",",
"true",
"\n",
"}",
"\n\n",
"return",
"rawurl",
",",
"false",
"\n",
"}"
] | // replaceUrlAlias is a helper function for ReplaceUrlAlias. It must only be
// called while the e.aliasMu mutex is held. | [
"replaceUrlAlias",
"is",
"a",
"helper",
"function",
"for",
"ReplaceUrlAlias",
".",
"It",
"must",
"only",
"be",
"called",
"while",
"the",
"e",
".",
"aliasMu",
"mutex",
"is",
"held",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfsapi/endpoint_finder.go#L305-L322 | train |
git-lfs/git-lfs | tools/str_tools.go | Ljust | func Ljust(strs []string) []string {
llen := len(Longest(strs))
dup := make([]string, len(strs), cap(strs))
copy(dup, strs)
for i, str := range strs {
width := MaxInt(0, llen-len(str))
padding := strings.Repeat(" ", width)
dup[i] = str + padding
}
return dup
} | go | func Ljust(strs []string) []string {
llen := len(Longest(strs))
dup := make([]string, len(strs), cap(strs))
copy(dup, strs)
for i, str := range strs {
width := MaxInt(0, llen-len(str))
padding := strings.Repeat(" ", width)
dup[i] = str + padding
}
return dup
} | [
"func",
"Ljust",
"(",
"strs",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"llen",
":=",
"len",
"(",
"Longest",
"(",
"strs",
")",
")",
"\n\n",
"dup",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"strs",
")",
",",
"cap",
"(",
"strs",
")",
")",
"\n",
"copy",
"(",
"dup",
",",
"strs",
")",
"\n\n",
"for",
"i",
",",
"str",
":=",
"range",
"strs",
"{",
"width",
":=",
"MaxInt",
"(",
"0",
",",
"llen",
"-",
"len",
"(",
"str",
")",
")",
"\n",
"padding",
":=",
"strings",
".",
"Repeat",
"(",
"\"",
"\"",
",",
"width",
")",
"\n\n",
"dup",
"[",
"i",
"]",
"=",
"str",
"+",
"padding",
"\n",
"}",
"\n\n",
"return",
"dup",
"\n",
"}"
] | // Ljust returns a copied string slice where each element is left justified to
// match the width of the longest element in the set. | [
"Ljust",
"returns",
"a",
"copied",
"string",
"slice",
"where",
"each",
"element",
"is",
"left",
"justified",
"to",
"match",
"the",
"width",
"of",
"the",
"longest",
"element",
"in",
"the",
"set",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tools/str_tools.go#L51-L65 | train |
git-lfs/git-lfs | tools/str_tools.go | Indent | func Indent(str string) string {
indented := strings.Replace(str, "\n", "\n\t", -1)
if len(indented) > 0 {
indented = "\t" + indented
}
return indented
} | go | func Indent(str string) string {
indented := strings.Replace(str, "\n", "\n\t", -1)
if len(indented) > 0 {
indented = "\t" + indented
}
return indented
} | [
"func",
"Indent",
"(",
"str",
"string",
")",
"string",
"{",
"indented",
":=",
"strings",
".",
"Replace",
"(",
"str",
",",
"\"",
"\\n",
"\"",
",",
"\"",
"\\n",
"\\t",
"\"",
",",
"-",
"1",
")",
"\n",
"if",
"len",
"(",
"indented",
")",
">",
"0",
"{",
"indented",
"=",
"\"",
"\\t",
"\"",
"+",
"indented",
"\n",
"}",
"\n\n",
"return",
"indented",
"\n",
"}"
] | // Indent returns a string which prepends "\t" TAB characters to the beginning
// of each line in the given string "str". | [
"Indent",
"returns",
"a",
"string",
"which",
"prepends",
"\\",
"t",
"TAB",
"characters",
"to",
"the",
"beginning",
"of",
"each",
"line",
"in",
"the",
"given",
"string",
"str",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tools/str_tools.go#L106-L113 | train |
git-lfs/git-lfs | commands/command_checkout.go | rootedPaths | func rootedPaths(args []string) []string {
pathConverter, err := lfs.NewCurrentToRepoPathConverter(cfg)
if err != nil {
Panic(err, "Could not checkout")
}
rootedpaths := make([]string, 0, len(args))
for _, arg := range args {
rootedpaths = append(rootedpaths, pathConverter.Convert(arg))
}
return rootedpaths
} | go | func rootedPaths(args []string) []string {
pathConverter, err := lfs.NewCurrentToRepoPathConverter(cfg)
if err != nil {
Panic(err, "Could not checkout")
}
rootedpaths := make([]string, 0, len(args))
for _, arg := range args {
rootedpaths = append(rootedpaths, pathConverter.Convert(arg))
}
return rootedpaths
} | [
"func",
"rootedPaths",
"(",
"args",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"pathConverter",
",",
"err",
":=",
"lfs",
".",
"NewCurrentToRepoPathConverter",
"(",
"cfg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"Panic",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"rootedpaths",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"args",
")",
")",
"\n",
"for",
"_",
",",
"arg",
":=",
"range",
"args",
"{",
"rootedpaths",
"=",
"append",
"(",
"rootedpaths",
",",
"pathConverter",
".",
"Convert",
"(",
"arg",
")",
")",
"\n",
"}",
"\n",
"return",
"rootedpaths",
"\n",
"}"
] | // Parameters are filters
// firstly convert any pathspecs to the root of the repo, in case this is being
// executed in a sub-folder | [
"Parameters",
"are",
"filters",
"firstly",
"convert",
"any",
"pathspecs",
"to",
"the",
"root",
"of",
"the",
"repo",
"in",
"case",
"this",
"is",
"being",
"executed",
"in",
"a",
"sub",
"-",
"folder"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/commands/command_checkout.go#L150-L161 | train |
git-lfs/git-lfs | commands/command_locks.go | Filters | func (l *locksFlags) Filters() (map[string]string, error) {
filters := make(map[string]string)
if l.Path != "" {
path, err := lockPath(l.Path)
if err != nil {
return nil, err
}
filters["path"] = path
}
if l.Id != "" {
filters["id"] = l.Id
}
return filters, nil
} | go | func (l *locksFlags) Filters() (map[string]string, error) {
filters := make(map[string]string)
if l.Path != "" {
path, err := lockPath(l.Path)
if err != nil {
return nil, err
}
filters["path"] = path
}
if l.Id != "" {
filters["id"] = l.Id
}
return filters, nil
} | [
"func",
"(",
"l",
"*",
"locksFlags",
")",
"Filters",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"filters",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n\n",
"if",
"l",
".",
"Path",
"!=",
"\"",
"\"",
"{",
"path",
",",
"err",
":=",
"lockPath",
"(",
"l",
".",
"Path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"filters",
"[",
"\"",
"\"",
"]",
"=",
"path",
"\n",
"}",
"\n",
"if",
"l",
".",
"Id",
"!=",
"\"",
"\"",
"{",
"filters",
"[",
"\"",
"\"",
"]",
"=",
"l",
".",
"Id",
"\n",
"}",
"\n\n",
"return",
"filters",
",",
"nil",
"\n",
"}"
] | // Filters produces a filter based on locksFlags instance. | [
"Filters",
"produces",
"a",
"filter",
"based",
"on",
"locksFlags",
"instance",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/commands/command_locks.go#L156-L172 | train |
git-lfs/git-lfs | commands/command_filter_process.go | incomingOrCached | func incomingOrCached(r io.Reader, ptr *lfs.Pointer) (io.Reader, error) {
buf := make([]byte, 1024)
n, err := r.Read(buf)
buf = buf[:n]
if n == 0 {
if ptr == nil {
// If we read no data from the given io.Reader "r" _and_
// there was no data to fall back on, return an empty
// io.Reader yielding no data.
return bytes.NewReader(buf), nil
}
// If we read no data from the given io.Reader "r", _and_ there
// is a pointer that we can fall back on, return an io.Reader
// that yields the encoded version of the given pointer.
return strings.NewReader(ptr.Encoded()), nil
}
if err == io.EOF {
return bytes.NewReader(buf), nil
}
return io.MultiReader(bytes.NewReader(buf), r), err
} | go | func incomingOrCached(r io.Reader, ptr *lfs.Pointer) (io.Reader, error) {
buf := make([]byte, 1024)
n, err := r.Read(buf)
buf = buf[:n]
if n == 0 {
if ptr == nil {
// If we read no data from the given io.Reader "r" _and_
// there was no data to fall back on, return an empty
// io.Reader yielding no data.
return bytes.NewReader(buf), nil
}
// If we read no data from the given io.Reader "r", _and_ there
// is a pointer that we can fall back on, return an io.Reader
// that yields the encoded version of the given pointer.
return strings.NewReader(ptr.Encoded()), nil
}
if err == io.EOF {
return bytes.NewReader(buf), nil
}
return io.MultiReader(bytes.NewReader(buf), r), err
} | [
"func",
"incomingOrCached",
"(",
"r",
"io",
".",
"Reader",
",",
"ptr",
"*",
"lfs",
".",
"Pointer",
")",
"(",
"io",
".",
"Reader",
",",
"error",
")",
"{",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"1024",
")",
"\n",
"n",
",",
"err",
":=",
"r",
".",
"Read",
"(",
"buf",
")",
"\n",
"buf",
"=",
"buf",
"[",
":",
"n",
"]",
"\n\n",
"if",
"n",
"==",
"0",
"{",
"if",
"ptr",
"==",
"nil",
"{",
"// If we read no data from the given io.Reader \"r\" _and_",
"// there was no data to fall back on, return an empty",
"// io.Reader yielding no data.",
"return",
"bytes",
".",
"NewReader",
"(",
"buf",
")",
",",
"nil",
"\n",
"}",
"\n",
"// If we read no data from the given io.Reader \"r\", _and_ there",
"// is a pointer that we can fall back on, return an io.Reader",
"// that yields the encoded version of the given pointer.",
"return",
"strings",
".",
"NewReader",
"(",
"ptr",
".",
"Encoded",
"(",
")",
")",
",",
"nil",
"\n",
"}",
"\n\n",
"if",
"err",
"==",
"io",
".",
"EOF",
"{",
"return",
"bytes",
".",
"NewReader",
"(",
"buf",
")",
",",
"nil",
"\n",
"}",
"\n",
"return",
"io",
".",
"MultiReader",
"(",
"bytes",
".",
"NewReader",
"(",
"buf",
")",
",",
"r",
")",
",",
"err",
"\n",
"}"
] | // incomingOrCached returns an io.Reader that is either the contents of the
// given io.Reader "r", or the encoded contents of "ptr". It returns an error if
// there was an error reading from "r".
//
// This is done because when a `command=smudge` with `can-delay=0` is issued,
// the entry's contents are not sent, and must be re-encoded from the stored
// pointer corresponding to the request's filepath. | [
"incomingOrCached",
"returns",
"an",
"io",
".",
"Reader",
"that",
"is",
"either",
"the",
"contents",
"of",
"the",
"given",
"io",
".",
"Reader",
"r",
"or",
"the",
"encoded",
"contents",
"of",
"ptr",
".",
"It",
"returns",
"an",
"error",
"if",
"there",
"was",
"an",
"error",
"reading",
"from",
"r",
".",
"This",
"is",
"done",
"because",
"when",
"a",
"command",
"=",
"smudge",
"with",
"can",
"-",
"delay",
"=",
"0",
"is",
"issued",
"the",
"entry",
"s",
"contents",
"are",
"not",
"sent",
"and",
"must",
"be",
"re",
"-",
"encoded",
"from",
"the",
"stored",
"pointer",
"corresponding",
"to",
"the",
"request",
"s",
"filepath",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/commands/command_filter_process.go#L281-L303 | train |
git-lfs/git-lfs | commands/command_filter_process.go | statusFromErr | func statusFromErr(err error) git.FilterProcessStatus {
if err != nil && err != io.EOF {
return git.StatusError
}
return git.StatusSuccess
} | go | func statusFromErr(err error) git.FilterProcessStatus {
if err != nil && err != io.EOF {
return git.StatusError
}
return git.StatusSuccess
} | [
"func",
"statusFromErr",
"(",
"err",
"error",
")",
"git",
".",
"FilterProcessStatus",
"{",
"if",
"err",
"!=",
"nil",
"&&",
"err",
"!=",
"io",
".",
"EOF",
"{",
"return",
"git",
".",
"StatusError",
"\n",
"}",
"\n",
"return",
"git",
".",
"StatusSuccess",
"\n",
"}"
] | // statusFromErr returns the status code that should be sent over the filter
// protocol based on a given error, "err". | [
"statusFromErr",
"returns",
"the",
"status",
"code",
"that",
"should",
"be",
"sent",
"over",
"the",
"filter",
"protocol",
"based",
"on",
"a",
"given",
"error",
"err",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/commands/command_filter_process.go#L348-L353 | train |
git-lfs/git-lfs | commands/command_filter_process.go | delayedStatusFromErr | func delayedStatusFromErr(err error) git.FilterProcessStatus {
status := statusFromErr(err)
switch status {
case git.StatusSuccess:
return git.StatusDelay
default:
return status
}
} | go | func delayedStatusFromErr(err error) git.FilterProcessStatus {
status := statusFromErr(err)
switch status {
case git.StatusSuccess:
return git.StatusDelay
default:
return status
}
} | [
"func",
"delayedStatusFromErr",
"(",
"err",
"error",
")",
"git",
".",
"FilterProcessStatus",
"{",
"status",
":=",
"statusFromErr",
"(",
"err",
")",
"\n\n",
"switch",
"status",
"{",
"case",
"git",
".",
"StatusSuccess",
":",
"return",
"git",
".",
"StatusDelay",
"\n",
"default",
":",
"return",
"status",
"\n",
"}",
"\n",
"}"
] | // delayedStatusFromErr returns the status code that should be sent over the
// filter protocol based on a given error, "err" when the blob smudge operation
// was delayed. | [
"delayedStatusFromErr",
"returns",
"the",
"status",
"code",
"that",
"should",
"be",
"sent",
"over",
"the",
"filter",
"protocol",
"based",
"on",
"a",
"given",
"error",
"err",
"when",
"the",
"blob",
"smudge",
"operation",
"was",
"delayed",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/commands/command_filter_process.go#L358-L367 | train |
git-lfs/git-lfs | commands/command_pre_push.go | decodeRefs | func decodeRefs(input string) (*git.Ref, *git.Ref) {
refs := strings.Split(strings.TrimSpace(input), " ")
for len(refs) < 4 {
refs = append(refs, "")
}
leftRef := git.ParseRef(refs[0], refs[1])
rightRef := git.ParseRef(refs[2], refs[3])
return leftRef, rightRef
} | go | func decodeRefs(input string) (*git.Ref, *git.Ref) {
refs := strings.Split(strings.TrimSpace(input), " ")
for len(refs) < 4 {
refs = append(refs, "")
}
leftRef := git.ParseRef(refs[0], refs[1])
rightRef := git.ParseRef(refs[2], refs[3])
return leftRef, rightRef
} | [
"func",
"decodeRefs",
"(",
"input",
"string",
")",
"(",
"*",
"git",
".",
"Ref",
",",
"*",
"git",
".",
"Ref",
")",
"{",
"refs",
":=",
"strings",
".",
"Split",
"(",
"strings",
".",
"TrimSpace",
"(",
"input",
")",
",",
"\"",
"\"",
")",
"\n",
"for",
"len",
"(",
"refs",
")",
"<",
"4",
"{",
"refs",
"=",
"append",
"(",
"refs",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"leftRef",
":=",
"git",
".",
"ParseRef",
"(",
"refs",
"[",
"0",
"]",
",",
"refs",
"[",
"1",
"]",
")",
"\n",
"rightRef",
":=",
"git",
".",
"ParseRef",
"(",
"refs",
"[",
"2",
"]",
",",
"refs",
"[",
"3",
"]",
")",
"\n",
"return",
"leftRef",
",",
"rightRef",
"\n",
"}"
] | // decodeRefs pulls the sha1s out of the line read from the pre-push
// hook's stdin. | [
"decodeRefs",
"pulls",
"the",
"sha1s",
"out",
"of",
"the",
"line",
"read",
"from",
"the",
"pre",
"-",
"push",
"hook",
"s",
"stdin",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/commands/command_pre_push.go#L94-L103 | train |
git-lfs/git-lfs | tools/time_tools.go | IsExpiredAtOrIn | func IsExpiredAtOrIn(from time.Time, until time.Duration, at time.Time, in time.Duration) (time.Time, bool) {
expiration := TimeAtOrIn(from, at, in)
if expiration.IsZero() {
return expiration, false
}
return expiration, expiration.Before(time.Now().Add(until))
} | go | func IsExpiredAtOrIn(from time.Time, until time.Duration, at time.Time, in time.Duration) (time.Time, bool) {
expiration := TimeAtOrIn(from, at, in)
if expiration.IsZero() {
return expiration, false
}
return expiration, expiration.Before(time.Now().Add(until))
} | [
"func",
"IsExpiredAtOrIn",
"(",
"from",
"time",
".",
"Time",
",",
"until",
"time",
".",
"Duration",
",",
"at",
"time",
".",
"Time",
",",
"in",
"time",
".",
"Duration",
")",
"(",
"time",
".",
"Time",
",",
"bool",
")",
"{",
"expiration",
":=",
"TimeAtOrIn",
"(",
"from",
",",
"at",
",",
"in",
")",
"\n",
"if",
"expiration",
".",
"IsZero",
"(",
")",
"{",
"return",
"expiration",
",",
"false",
"\n",
"}",
"\n\n",
"return",
"expiration",
",",
"expiration",
".",
"Before",
"(",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"until",
")",
")",
"\n",
"}"
] | // IsExpiredAtOrIn returns whether or not the result of calling TimeAtOrIn is
// "expired" within "until" units of time from now. | [
"IsExpiredAtOrIn",
"returns",
"whether",
"or",
"not",
"the",
"result",
"of",
"calling",
"TimeAtOrIn",
"is",
"expired",
"within",
"until",
"units",
"of",
"time",
"from",
"now",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tools/time_tools.go#L9-L16 | train |
git-lfs/git-lfs | tools/time_tools.go | TimeAtOrIn | func TimeAtOrIn(from, at time.Time, in time.Duration) time.Time {
if in == 0 {
return at
}
return from.Add(in)
} | go | func TimeAtOrIn(from, at time.Time, in time.Duration) time.Time {
if in == 0 {
return at
}
return from.Add(in)
} | [
"func",
"TimeAtOrIn",
"(",
"from",
",",
"at",
"time",
".",
"Time",
",",
"in",
"time",
".",
"Duration",
")",
"time",
".",
"Time",
"{",
"if",
"in",
"==",
"0",
"{",
"return",
"at",
"\n",
"}",
"\n",
"return",
"from",
".",
"Add",
"(",
"in",
")",
"\n",
"}"
] | // TimeAtOrIn returns either "at", or the "in" duration added to the current
// time. TimeAtOrIn prefers to add a duration rather than return the "at"
// parameter. | [
"TimeAtOrIn",
"returns",
"either",
"at",
"or",
"the",
"in",
"duration",
"added",
"to",
"the",
"current",
"time",
".",
"TimeAtOrIn",
"prefers",
"to",
"add",
"a",
"duration",
"rather",
"than",
"return",
"the",
"at",
"parameter",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tools/time_tools.go#L21-L26 | train |
git-lfs/git-lfs | git/githistory/rewriter.go | rewriteTree | func (r *Rewriter) rewriteTree(commitOID []byte, treeOID []byte, path string,
fn BlobRewriteFn, tpfn TreePreCallbackFn, tfn TreeCallbackFn,
perc *tasklog.PercentageTask) ([]byte, error) {
tree, err := r.db.Tree(treeOID)
if err != nil {
return nil, err
}
if err := tpfn("/"+path, tree); err != nil {
return nil, err
}
entries := make([]*gitobj.TreeEntry, 0, len(tree.Entries))
for _, entry := range tree.Entries {
var fullpath string
if len(path) > 0 {
fullpath = strings.Join([]string{path, entry.Name}, "/")
} else {
fullpath = entry.Name
}
if !r.allows(entry.Type(), fullpath) {
entries = append(entries, copyEntry(entry))
continue
}
// If this is a symlink, skip it
if entry.Filemode == 0120000 {
entries = append(entries, copyEntry(entry))
continue
}
if cached := r.uncacheEntry(entry); cached != nil {
entries = append(entries, copyEntry(cached))
continue
}
var oid []byte
switch entry.Type() {
case gitobj.BlobObjectType:
oid, err = r.rewriteBlob(commitOID, entry.Oid, fullpath, fn, perc)
case gitobj.TreeObjectType:
oid, err = r.rewriteTree(commitOID, entry.Oid, fullpath, fn, tpfn, tfn, perc)
default:
oid = entry.Oid
}
if err != nil {
return nil, err
}
entries = append(entries, r.cacheEntry(entry, &gitobj.TreeEntry{
Filemode: entry.Filemode,
Name: entry.Name,
Oid: oid,
}))
}
rewritten, err := tfn("/"+path, &gitobj.Tree{Entries: entries})
if err != nil {
return nil, err
}
if tree.Equal(rewritten) {
return treeOID, nil
}
return r.db.WriteTree(rewritten)
} | go | func (r *Rewriter) rewriteTree(commitOID []byte, treeOID []byte, path string,
fn BlobRewriteFn, tpfn TreePreCallbackFn, tfn TreeCallbackFn,
perc *tasklog.PercentageTask) ([]byte, error) {
tree, err := r.db.Tree(treeOID)
if err != nil {
return nil, err
}
if err := tpfn("/"+path, tree); err != nil {
return nil, err
}
entries := make([]*gitobj.TreeEntry, 0, len(tree.Entries))
for _, entry := range tree.Entries {
var fullpath string
if len(path) > 0 {
fullpath = strings.Join([]string{path, entry.Name}, "/")
} else {
fullpath = entry.Name
}
if !r.allows(entry.Type(), fullpath) {
entries = append(entries, copyEntry(entry))
continue
}
// If this is a symlink, skip it
if entry.Filemode == 0120000 {
entries = append(entries, copyEntry(entry))
continue
}
if cached := r.uncacheEntry(entry); cached != nil {
entries = append(entries, copyEntry(cached))
continue
}
var oid []byte
switch entry.Type() {
case gitobj.BlobObjectType:
oid, err = r.rewriteBlob(commitOID, entry.Oid, fullpath, fn, perc)
case gitobj.TreeObjectType:
oid, err = r.rewriteTree(commitOID, entry.Oid, fullpath, fn, tpfn, tfn, perc)
default:
oid = entry.Oid
}
if err != nil {
return nil, err
}
entries = append(entries, r.cacheEntry(entry, &gitobj.TreeEntry{
Filemode: entry.Filemode,
Name: entry.Name,
Oid: oid,
}))
}
rewritten, err := tfn("/"+path, &gitobj.Tree{Entries: entries})
if err != nil {
return nil, err
}
if tree.Equal(rewritten) {
return treeOID, nil
}
return r.db.WriteTree(rewritten)
} | [
"func",
"(",
"r",
"*",
"Rewriter",
")",
"rewriteTree",
"(",
"commitOID",
"[",
"]",
"byte",
",",
"treeOID",
"[",
"]",
"byte",
",",
"path",
"string",
",",
"fn",
"BlobRewriteFn",
",",
"tpfn",
"TreePreCallbackFn",
",",
"tfn",
"TreeCallbackFn",
",",
"perc",
"*",
"tasklog",
".",
"PercentageTask",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"tree",
",",
"err",
":=",
"r",
".",
"db",
".",
"Tree",
"(",
"treeOID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"tpfn",
"(",
"\"",
"\"",
"+",
"path",
",",
"tree",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"entries",
":=",
"make",
"(",
"[",
"]",
"*",
"gitobj",
".",
"TreeEntry",
",",
"0",
",",
"len",
"(",
"tree",
".",
"Entries",
")",
")",
"\n",
"for",
"_",
",",
"entry",
":=",
"range",
"tree",
".",
"Entries",
"{",
"var",
"fullpath",
"string",
"\n",
"if",
"len",
"(",
"path",
")",
">",
"0",
"{",
"fullpath",
"=",
"strings",
".",
"Join",
"(",
"[",
"]",
"string",
"{",
"path",
",",
"entry",
".",
"Name",
"}",
",",
"\"",
"\"",
")",
"\n",
"}",
"else",
"{",
"fullpath",
"=",
"entry",
".",
"Name",
"\n",
"}",
"\n\n",
"if",
"!",
"r",
".",
"allows",
"(",
"entry",
".",
"Type",
"(",
")",
",",
"fullpath",
")",
"{",
"entries",
"=",
"append",
"(",
"entries",
",",
"copyEntry",
"(",
"entry",
")",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"// If this is a symlink, skip it",
"if",
"entry",
".",
"Filemode",
"==",
"0120000",
"{",
"entries",
"=",
"append",
"(",
"entries",
",",
"copyEntry",
"(",
"entry",
")",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"if",
"cached",
":=",
"r",
".",
"uncacheEntry",
"(",
"entry",
")",
";",
"cached",
"!=",
"nil",
"{",
"entries",
"=",
"append",
"(",
"entries",
",",
"copyEntry",
"(",
"cached",
")",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"var",
"oid",
"[",
"]",
"byte",
"\n\n",
"switch",
"entry",
".",
"Type",
"(",
")",
"{",
"case",
"gitobj",
".",
"BlobObjectType",
":",
"oid",
",",
"err",
"=",
"r",
".",
"rewriteBlob",
"(",
"commitOID",
",",
"entry",
".",
"Oid",
",",
"fullpath",
",",
"fn",
",",
"perc",
")",
"\n",
"case",
"gitobj",
".",
"TreeObjectType",
":",
"oid",
",",
"err",
"=",
"r",
".",
"rewriteTree",
"(",
"commitOID",
",",
"entry",
".",
"Oid",
",",
"fullpath",
",",
"fn",
",",
"tpfn",
",",
"tfn",
",",
"perc",
")",
"\n",
"default",
":",
"oid",
"=",
"entry",
".",
"Oid",
"\n\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"entries",
"=",
"append",
"(",
"entries",
",",
"r",
".",
"cacheEntry",
"(",
"entry",
",",
"&",
"gitobj",
".",
"TreeEntry",
"{",
"Filemode",
":",
"entry",
".",
"Filemode",
",",
"Name",
":",
"entry",
".",
"Name",
",",
"Oid",
":",
"oid",
",",
"}",
")",
")",
"\n",
"}",
"\n\n",
"rewritten",
",",
"err",
":=",
"tfn",
"(",
"\"",
"\"",
"+",
"path",
",",
"&",
"gitobj",
".",
"Tree",
"{",
"Entries",
":",
"entries",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"tree",
".",
"Equal",
"(",
"rewritten",
")",
"{",
"return",
"treeOID",
",",
"nil",
"\n",
"}",
"\n",
"return",
"r",
".",
"db",
".",
"WriteTree",
"(",
"rewritten",
")",
"\n",
"}"
] | // rewriteTree is a recursive function which rewrites a tree given by the ID
// "sha" and path "path". It uses the given BlobRewriteFn to rewrite all blobs
// within the tree, either calling that function or recurring down into subtrees
// by re-assigning the SHA.
//
// Once it is done assembling the entries in a given subtree, it then calls the
// TreeCallbackFn, "tfn" to perform a final traversal of the subtree before
// saving it to the object database.
//
// It returns the new SHA of the rewritten tree, or an error if the tree was
// unable to be rewritten. | [
"rewriteTree",
"is",
"a",
"recursive",
"function",
"which",
"rewrites",
"a",
"tree",
"given",
"by",
"the",
"ID",
"sha",
"and",
"path",
"path",
".",
"It",
"uses",
"the",
"given",
"BlobRewriteFn",
"to",
"rewrite",
"all",
"blobs",
"within",
"the",
"tree",
"either",
"calling",
"that",
"function",
"or",
"recurring",
"down",
"into",
"subtrees",
"by",
"re",
"-",
"assigning",
"the",
"SHA",
".",
"Once",
"it",
"is",
"done",
"assembling",
"the",
"entries",
"in",
"a",
"given",
"subtree",
"it",
"then",
"calls",
"the",
"TreeCallbackFn",
"tfn",
"to",
"perform",
"a",
"final",
"traversal",
"of",
"the",
"subtree",
"before",
"saving",
"it",
"to",
"the",
"object",
"database",
".",
"It",
"returns",
"the",
"new",
"SHA",
"of",
"the",
"rewritten",
"tree",
"or",
"an",
"error",
"if",
"the",
"tree",
"was",
"unable",
"to",
"be",
"rewritten",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/githistory/rewriter.go#L353-L422 | train |
git-lfs/git-lfs | git/githistory/rewriter.go | refsToMigrate | func (r *Rewriter) refsToMigrate() ([]*git.Ref, error) {
var refs []*git.Ref
var err error
if root, ok := r.db.Root(); ok {
refs, err = git.AllRefsIn(root)
} else {
refs, err = git.AllRefs()
}
if err != nil {
return nil, err
}
var local []*git.Ref
for _, ref := range refs {
if ref.Type == git.RefTypeRemoteBranch {
continue
}
local = append(local, ref)
}
return local, nil
} | go | func (r *Rewriter) refsToMigrate() ([]*git.Ref, error) {
var refs []*git.Ref
var err error
if root, ok := r.db.Root(); ok {
refs, err = git.AllRefsIn(root)
} else {
refs, err = git.AllRefs()
}
if err != nil {
return nil, err
}
var local []*git.Ref
for _, ref := range refs {
if ref.Type == git.RefTypeRemoteBranch {
continue
}
local = append(local, ref)
}
return local, nil
} | [
"func",
"(",
"r",
"*",
"Rewriter",
")",
"refsToMigrate",
"(",
")",
"(",
"[",
"]",
"*",
"git",
".",
"Ref",
",",
"error",
")",
"{",
"var",
"refs",
"[",
"]",
"*",
"git",
".",
"Ref",
"\n",
"var",
"err",
"error",
"\n\n",
"if",
"root",
",",
"ok",
":=",
"r",
".",
"db",
".",
"Root",
"(",
")",
";",
"ok",
"{",
"refs",
",",
"err",
"=",
"git",
".",
"AllRefsIn",
"(",
"root",
")",
"\n",
"}",
"else",
"{",
"refs",
",",
"err",
"=",
"git",
".",
"AllRefs",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"local",
"[",
"]",
"*",
"git",
".",
"Ref",
"\n",
"for",
"_",
",",
"ref",
":=",
"range",
"refs",
"{",
"if",
"ref",
".",
"Type",
"==",
"git",
".",
"RefTypeRemoteBranch",
"{",
"continue",
"\n",
"}",
"\n\n",
"local",
"=",
"append",
"(",
"local",
",",
"ref",
")",
"\n",
"}",
"\n\n",
"return",
"local",
",",
"nil",
"\n",
"}"
] | // refsToMigrate returns a list of references to migrate, or an error if loading
// those references failed. | [
"refsToMigrate",
"returns",
"a",
"list",
"of",
"references",
"to",
"migrate",
"or",
"an",
"error",
"if",
"loading",
"those",
"references",
"failed",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/githistory/rewriter.go#L528-L552 | train |
git-lfs/git-lfs | tools/stringset.go | NewStringSetFromSlice | func NewStringSetFromSlice(s []string) StringSet {
a := NewStringSetWithCapacity(len(s))
for _, item := range s {
a.Add(item)
}
return a
} | go | func NewStringSetFromSlice(s []string) StringSet {
a := NewStringSetWithCapacity(len(s))
for _, item := range s {
a.Add(item)
}
return a
} | [
"func",
"NewStringSetFromSlice",
"(",
"s",
"[",
"]",
"string",
")",
"StringSet",
"{",
"a",
":=",
"NewStringSetWithCapacity",
"(",
"len",
"(",
"s",
")",
")",
"\n",
"for",
"_",
",",
"item",
":=",
"range",
"s",
"{",
"a",
".",
"Add",
"(",
"item",
")",
"\n",
"}",
"\n",
"return",
"a",
"\n",
"}"
] | // Creates and returns a reference to a set from an existing slice | [
"Creates",
"and",
"returns",
"a",
"reference",
"to",
"a",
"set",
"from",
"an",
"existing",
"slice"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tools/stringset.go#L26-L32 | train |
git-lfs/git-lfs | tools/stringset.go | IsSubset | func (set StringSet) IsSubset(other StringSet) bool {
for elem := range set {
if !other.Contains(elem) {
return false
}
}
return true
} | go | func (set StringSet) IsSubset(other StringSet) bool {
for elem := range set {
if !other.Contains(elem) {
return false
}
}
return true
} | [
"func",
"(",
"set",
"StringSet",
")",
"IsSubset",
"(",
"other",
"StringSet",
")",
"bool",
"{",
"for",
"elem",
":=",
"range",
"set",
"{",
"if",
"!",
"other",
".",
"Contains",
"(",
"elem",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] | // Determines if every item in the other set is in this set. | [
"Determines",
"if",
"every",
"item",
"in",
"the",
"other",
"set",
"is",
"in",
"this",
"set",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tools/stringset.go#L57-L64 | train |
git-lfs/git-lfs | tasklog/log.go | tty | func tty(writer io.Writer) bool {
if v, ok := writer.(hasFd); ok {
return isatty.IsTerminal(v.Fd()) || isatty.IsCygwinTerminal(v.Fd())
}
return false
} | go | func tty(writer io.Writer) bool {
if v, ok := writer.(hasFd); ok {
return isatty.IsTerminal(v.Fd()) || isatty.IsCygwinTerminal(v.Fd())
}
return false
} | [
"func",
"tty",
"(",
"writer",
"io",
".",
"Writer",
")",
"bool",
"{",
"if",
"v",
",",
"ok",
":=",
"writer",
".",
"(",
"hasFd",
")",
";",
"ok",
"{",
"return",
"isatty",
".",
"IsTerminal",
"(",
"v",
".",
"Fd",
"(",
")",
")",
"||",
"isatty",
".",
"IsCygwinTerminal",
"(",
"v",
".",
"Fd",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // tty returns true if the writer is connected to a tty | [
"tty",
"returns",
"true",
"if",
"the",
"writer",
"is",
"connected",
"to",
"a",
"tty"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tasklog/log.go#L99-L104 | train |
git-lfs/git-lfs | tasklog/log.go | Enqueue | func (l *Logger) Enqueue(ts ...Task) {
if l == nil {
for _, t := range ts {
if t == nil {
// NOTE: Do not allow nil tasks which are unable
// to be completed.
continue
}
go func(t Task) {
for range t.Updates() {
// Discard all updates.
}
}(t)
}
return
}
l.wg.Add(len(ts))
for _, t := range ts {
if t == nil {
// NOTE: See above.
continue
}
l.queue <- t
}
} | go | func (l *Logger) Enqueue(ts ...Task) {
if l == nil {
for _, t := range ts {
if t == nil {
// NOTE: Do not allow nil tasks which are unable
// to be completed.
continue
}
go func(t Task) {
for range t.Updates() {
// Discard all updates.
}
}(t)
}
return
}
l.wg.Add(len(ts))
for _, t := range ts {
if t == nil {
// NOTE: See above.
continue
}
l.queue <- t
}
} | [
"func",
"(",
"l",
"*",
"Logger",
")",
"Enqueue",
"(",
"ts",
"...",
"Task",
")",
"{",
"if",
"l",
"==",
"nil",
"{",
"for",
"_",
",",
"t",
":=",
"range",
"ts",
"{",
"if",
"t",
"==",
"nil",
"{",
"// NOTE: Do not allow nil tasks which are unable",
"// to be completed.",
"continue",
"\n",
"}",
"\n",
"go",
"func",
"(",
"t",
"Task",
")",
"{",
"for",
"range",
"t",
".",
"Updates",
"(",
")",
"{",
"// Discard all updates.",
"}",
"\n",
"}",
"(",
"t",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}",
"\n\n",
"l",
".",
"wg",
".",
"Add",
"(",
"len",
"(",
"ts",
")",
")",
"\n",
"for",
"_",
",",
"t",
":=",
"range",
"ts",
"{",
"if",
"t",
"==",
"nil",
"{",
"// NOTE: See above.",
"continue",
"\n",
"}",
"\n",
"l",
".",
"queue",
"<-",
"t",
"\n",
"}",
"\n",
"}"
] | // Enqueue enqueues the given Tasks "ts". | [
"Enqueue",
"enqueues",
"the",
"given",
"Tasks",
"ts",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tasklog/log.go#L151-L176 | train |
git-lfs/git-lfs | tasklog/log.go | consume | func (l *Logger) consume() {
go func() {
// Process the single next task in sequence until completion,
// then consume the next task.
for task := range l.tasks {
l.logTask(task)
}
}()
defer close(l.tasks)
pending := make([]Task, 0)
for {
// If there is a pending task, "peek" it off of the set of
// pending tasks.
var next Task
if len(pending) > 0 {
next = pending[0]
}
if next == nil {
// If there was no pending task, wait for either a)
// l.queue to close, or b) a new task to be submitted.
task, ok := <-l.queue
if !ok {
// If the queue is closed, no more new tasks may
// be added.
return
}
// Otherwise, add a new task to the set of tasks to
// process immediately, since there is no current
// buffer.
l.tasks <- task
} else {
// If there is a pending task, wait for either a) a
// write to process the task to become non-blocking, or
// b) a new task to enter the queue.
select {
case task, ok := <-l.queue:
if !ok {
// If the queue is closed, no more tasks
// may be added.
return
}
// Otherwise, add the next task to the set of
// pending, active tasks.
pending = append(pending, task)
case l.tasks <- next:
// Or "pop" the peeked task off of the pending
// set.
pending = pending[1:]
}
}
}
} | go | func (l *Logger) consume() {
go func() {
// Process the single next task in sequence until completion,
// then consume the next task.
for task := range l.tasks {
l.logTask(task)
}
}()
defer close(l.tasks)
pending := make([]Task, 0)
for {
// If there is a pending task, "peek" it off of the set of
// pending tasks.
var next Task
if len(pending) > 0 {
next = pending[0]
}
if next == nil {
// If there was no pending task, wait for either a)
// l.queue to close, or b) a new task to be submitted.
task, ok := <-l.queue
if !ok {
// If the queue is closed, no more new tasks may
// be added.
return
}
// Otherwise, add a new task to the set of tasks to
// process immediately, since there is no current
// buffer.
l.tasks <- task
} else {
// If there is a pending task, wait for either a) a
// write to process the task to become non-blocking, or
// b) a new task to enter the queue.
select {
case task, ok := <-l.queue:
if !ok {
// If the queue is closed, no more tasks
// may be added.
return
}
// Otherwise, add the next task to the set of
// pending, active tasks.
pending = append(pending, task)
case l.tasks <- next:
// Or "pop" the peeked task off of the pending
// set.
pending = pending[1:]
}
}
}
} | [
"func",
"(",
"l",
"*",
"Logger",
")",
"consume",
"(",
")",
"{",
"go",
"func",
"(",
")",
"{",
"// Process the single next task in sequence until completion,",
"// then consume the next task.",
"for",
"task",
":=",
"range",
"l",
".",
"tasks",
"{",
"l",
".",
"logTask",
"(",
"task",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"defer",
"close",
"(",
"l",
".",
"tasks",
")",
"\n\n",
"pending",
":=",
"make",
"(",
"[",
"]",
"Task",
",",
"0",
")",
"\n\n",
"for",
"{",
"// If there is a pending task, \"peek\" it off of the set of",
"// pending tasks.",
"var",
"next",
"Task",
"\n",
"if",
"len",
"(",
"pending",
")",
">",
"0",
"{",
"next",
"=",
"pending",
"[",
"0",
"]",
"\n",
"}",
"\n\n",
"if",
"next",
"==",
"nil",
"{",
"// If there was no pending task, wait for either a)",
"// l.queue to close, or b) a new task to be submitted.",
"task",
",",
"ok",
":=",
"<-",
"l",
".",
"queue",
"\n",
"if",
"!",
"ok",
"{",
"// If the queue is closed, no more new tasks may",
"// be added.",
"return",
"\n",
"}",
"\n\n",
"// Otherwise, add a new task to the set of tasks to",
"// process immediately, since there is no current",
"// buffer.",
"l",
".",
"tasks",
"<-",
"task",
"\n",
"}",
"else",
"{",
"// If there is a pending task, wait for either a) a",
"// write to process the task to become non-blocking, or",
"// b) a new task to enter the queue.",
"select",
"{",
"case",
"task",
",",
"ok",
":=",
"<-",
"l",
".",
"queue",
":",
"if",
"!",
"ok",
"{",
"// If the queue is closed, no more tasks",
"// may be added.",
"return",
"\n",
"}",
"\n",
"// Otherwise, add the next task to the set of",
"// pending, active tasks.",
"pending",
"=",
"append",
"(",
"pending",
",",
"task",
")",
"\n",
"case",
"l",
".",
"tasks",
"<-",
"next",
":",
"// Or \"pop\" the peeked task off of the pending",
"// set.",
"pending",
"=",
"pending",
"[",
"1",
":",
"]",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // consume creates a pseudo-infinte buffer between the incoming set of tasks and
// the queue of tasks to work on. | [
"consume",
"creates",
"a",
"pseudo",
"-",
"infinte",
"buffer",
"between",
"the",
"incoming",
"set",
"of",
"tasks",
"and",
"the",
"queue",
"of",
"tasks",
"to",
"work",
"on",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tasklog/log.go#L180-L236 | train |
git-lfs/git-lfs | tasklog/log.go | logLine | func (l *Logger) logLine(str string) (n int, err error) {
padding := strings.Repeat(" ", maxInt(0, l.widthFn()-len(str)))
return l.log(str + padding + "\r")
} | go | func (l *Logger) logLine(str string) (n int, err error) {
padding := strings.Repeat(" ", maxInt(0, l.widthFn()-len(str)))
return l.log(str + padding + "\r")
} | [
"func",
"(",
"l",
"*",
"Logger",
")",
"logLine",
"(",
"str",
"string",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"padding",
":=",
"strings",
".",
"Repeat",
"(",
"\"",
"\"",
",",
"maxInt",
"(",
"0",
",",
"l",
".",
"widthFn",
"(",
")",
"-",
"len",
"(",
"str",
")",
")",
")",
"\n\n",
"return",
"l",
".",
"log",
"(",
"str",
"+",
"padding",
"+",
"\"",
"\\r",
"\"",
")",
"\n",
"}"
] | // logLine writes a complete line and moves the cursor to the beginning of the
// line.
//
// It returns the number of bytes "n" written to the sink and the error "err",
// if one was encountered. | [
"logLine",
"writes",
"a",
"complete",
"line",
"and",
"moves",
"the",
"cursor",
"to",
"the",
"beginning",
"of",
"the",
"line",
".",
"It",
"returns",
"the",
"number",
"of",
"bytes",
"n",
"written",
"to",
"the",
"sink",
"and",
"the",
"error",
"err",
"if",
"one",
"was",
"encountered",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tasklog/log.go#L287-L291 | train |
git-lfs/git-lfs | tasklog/log.go | log | func (l *Logger) log(str string) (n int, err error) {
return fmt.Fprint(l.sink, str)
} | go | func (l *Logger) log(str string) (n int, err error) {
return fmt.Fprint(l.sink, str)
} | [
"func",
"(",
"l",
"*",
"Logger",
")",
"log",
"(",
"str",
"string",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"return",
"fmt",
".",
"Fprint",
"(",
"l",
".",
"sink",
",",
"str",
")",
"\n",
"}"
] | // log writes a string verbatim to the sink.
//
// It returns the number of bytes "n" written to the sink and the error "err",
// if one was encountered. | [
"log",
"writes",
"a",
"string",
"verbatim",
"to",
"the",
"sink",
".",
"It",
"returns",
"the",
"number",
"of",
"bytes",
"n",
"written",
"to",
"the",
"sink",
"and",
"the",
"error",
"err",
"if",
"one",
"was",
"encountered",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tasklog/log.go#L297-L299 | train |
git-lfs/git-lfs | git/git.go | gitConfigNoLFS | func gitConfigNoLFS(args ...string) []string {
// Before git 2.8, setting filters to blank causes lots of warnings, so use cat instead (slightly slower)
// Also pre 2.2 it failed completely. We used to use it anyway in git 2.2-2.7 and
// suppress the messages in stderr, but doing that with standard StderrPipe suppresses
// the git clone output (git thinks it's not a terminal) and makes it look like it's
// not working. You can get around that with https://github.com/kr/pty but that
// causes difficult issues with passing through Stdin for login prompts
// This way is simpler & more practical.
filterOverride := ""
if !IsGitVersionAtLeast("2.8.0") {
filterOverride = "cat"
}
return append([]string{
"-c", fmt.Sprintf("filter.lfs.smudge=%v", filterOverride),
"-c", fmt.Sprintf("filter.lfs.clean=%v", filterOverride),
"-c", "filter.lfs.process=",
"-c", "filter.lfs.required=false",
}, args...)
} | go | func gitConfigNoLFS(args ...string) []string {
// Before git 2.8, setting filters to blank causes lots of warnings, so use cat instead (slightly slower)
// Also pre 2.2 it failed completely. We used to use it anyway in git 2.2-2.7 and
// suppress the messages in stderr, but doing that with standard StderrPipe suppresses
// the git clone output (git thinks it's not a terminal) and makes it look like it's
// not working. You can get around that with https://github.com/kr/pty but that
// causes difficult issues with passing through Stdin for login prompts
// This way is simpler & more practical.
filterOverride := ""
if !IsGitVersionAtLeast("2.8.0") {
filterOverride = "cat"
}
return append([]string{
"-c", fmt.Sprintf("filter.lfs.smudge=%v", filterOverride),
"-c", fmt.Sprintf("filter.lfs.clean=%v", filterOverride),
"-c", "filter.lfs.process=",
"-c", "filter.lfs.required=false",
}, args...)
} | [
"func",
"gitConfigNoLFS",
"(",
"args",
"...",
"string",
")",
"[",
"]",
"string",
"{",
"// Before git 2.8, setting filters to blank causes lots of warnings, so use cat instead (slightly slower)",
"// Also pre 2.2 it failed completely. We used to use it anyway in git 2.2-2.7 and",
"// suppress the messages in stderr, but doing that with standard StderrPipe suppresses",
"// the git clone output (git thinks it's not a terminal) and makes it look like it's",
"// not working. You can get around that with https://github.com/kr/pty but that",
"// causes difficult issues with passing through Stdin for login prompts",
"// This way is simpler & more practical.",
"filterOverride",
":=",
"\"",
"\"",
"\n",
"if",
"!",
"IsGitVersionAtLeast",
"(",
"\"",
"\"",
")",
"{",
"filterOverride",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"append",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"filterOverride",
")",
",",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"filterOverride",
")",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"}",
",",
"args",
"...",
")",
"\n",
"}"
] | // Prepend Git config instructions to disable Git LFS filter | [
"Prepend",
"Git",
"config",
"instructions",
"to",
"disable",
"Git",
"LFS",
"filter"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/git.go#L130-L149 | train |
git-lfs/git-lfs | git/git.go | ValidateRemote | func ValidateRemote(remote string) error {
remotes, err := RemoteList()
if err != nil {
return err
}
for _, r := range remotes {
if r == remote {
return nil
}
}
if err = ValidateRemoteURL(remote); err == nil {
return nil
}
return fmt.Errorf("Invalid remote name: %q", remote)
} | go | func ValidateRemote(remote string) error {
remotes, err := RemoteList()
if err != nil {
return err
}
for _, r := range remotes {
if r == remote {
return nil
}
}
if err = ValidateRemoteURL(remote); err == nil {
return nil
}
return fmt.Errorf("Invalid remote name: %q", remote)
} | [
"func",
"ValidateRemote",
"(",
"remote",
"string",
")",
"error",
"{",
"remotes",
",",
"err",
":=",
"RemoteList",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"for",
"_",
",",
"r",
":=",
"range",
"remotes",
"{",
"if",
"r",
"==",
"remote",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"err",
"=",
"ValidateRemoteURL",
"(",
"remote",
")",
";",
"err",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"remote",
")",
"\n",
"}"
] | // ValidateRemote checks that a named remote is valid for use
// Mainly to check user-supplied remotes & fail more nicely | [
"ValidateRemote",
"checks",
"that",
"a",
"named",
"remote",
"is",
"valid",
"for",
"use",
"Mainly",
"to",
"check",
"user",
"-",
"supplied",
"remotes",
"&",
"fail",
"more",
"nicely"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/git.go#L407-L423 | train |
git-lfs/git-lfs | git/git.go | ValidateRemoteURL | func ValidateRemoteURL(remote string) error {
u, _ := url.Parse(remote)
if u == nil || u.Scheme == "" {
// This is either an invalid remote name (maybe the user made a typo
// when selecting a named remote) or a bare SSH URL like
// "[email protected]:path/to/resource.git". Guess that this is a URL in the latter
// form if the string contains a colon ":", and an invalid remote if it
// does not.
if strings.Contains(remote, ":") {
return nil
} else {
return fmt.Errorf("Invalid remote name: %q", remote)
}
}
switch u.Scheme {
case "ssh", "http", "https", "git":
return nil
default:
return fmt.Errorf("Invalid remote url protocol %q in %q", u.Scheme, remote)
}
} | go | func ValidateRemoteURL(remote string) error {
u, _ := url.Parse(remote)
if u == nil || u.Scheme == "" {
// This is either an invalid remote name (maybe the user made a typo
// when selecting a named remote) or a bare SSH URL like
// "[email protected]:path/to/resource.git". Guess that this is a URL in the latter
// form if the string contains a colon ":", and an invalid remote if it
// does not.
if strings.Contains(remote, ":") {
return nil
} else {
return fmt.Errorf("Invalid remote name: %q", remote)
}
}
switch u.Scheme {
case "ssh", "http", "https", "git":
return nil
default:
return fmt.Errorf("Invalid remote url protocol %q in %q", u.Scheme, remote)
}
} | [
"func",
"ValidateRemoteURL",
"(",
"remote",
"string",
")",
"error",
"{",
"u",
",",
"_",
":=",
"url",
".",
"Parse",
"(",
"remote",
")",
"\n",
"if",
"u",
"==",
"nil",
"||",
"u",
".",
"Scheme",
"==",
"\"",
"\"",
"{",
"// This is either an invalid remote name (maybe the user made a typo",
"// when selecting a named remote) or a bare SSH URL like",
"// \"[email protected]:path/to/resource.git\". Guess that this is a URL in the latter",
"// form if the string contains a colon \":\", and an invalid remote if it",
"// does not.",
"if",
"strings",
".",
"Contains",
"(",
"remote",
",",
"\"",
"\"",
")",
"{",
"return",
"nil",
"\n",
"}",
"else",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"remote",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"switch",
"u",
".",
"Scheme",
"{",
"case",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
":",
"return",
"nil",
"\n",
"default",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"u",
".",
"Scheme",
",",
"remote",
")",
"\n",
"}",
"\n",
"}"
] | // ValidateRemoteURL checks that a string is a valid Git remote URL | [
"ValidateRemoteURL",
"checks",
"that",
"a",
"string",
"is",
"a",
"valid",
"Git",
"remote",
"URL"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/git.go#L426-L447 | train |
git-lfs/git-lfs | git/git.go | ParseRefToTypeAndName | func ParseRefToTypeAndName(fullref string) (t RefType, name string) {
const localPrefix = "refs/heads/"
const remotePrefix = "refs/remotes/"
const localTagPrefix = "refs/tags/"
if fullref == "HEAD" {
name = fullref
t = RefTypeHEAD
} else if strings.HasPrefix(fullref, localPrefix) {
name = fullref[len(localPrefix):]
t = RefTypeLocalBranch
} else if strings.HasPrefix(fullref, remotePrefix) {
name = fullref[len(remotePrefix):]
t = RefTypeRemoteBranch
} else if strings.HasPrefix(fullref, localTagPrefix) {
name = fullref[len(localTagPrefix):]
t = RefTypeLocalTag
} else {
name = fullref
t = RefTypeOther
}
return
} | go | func ParseRefToTypeAndName(fullref string) (t RefType, name string) {
const localPrefix = "refs/heads/"
const remotePrefix = "refs/remotes/"
const localTagPrefix = "refs/tags/"
if fullref == "HEAD" {
name = fullref
t = RefTypeHEAD
} else if strings.HasPrefix(fullref, localPrefix) {
name = fullref[len(localPrefix):]
t = RefTypeLocalBranch
} else if strings.HasPrefix(fullref, remotePrefix) {
name = fullref[len(remotePrefix):]
t = RefTypeRemoteBranch
} else if strings.HasPrefix(fullref, localTagPrefix) {
name = fullref[len(localTagPrefix):]
t = RefTypeLocalTag
} else {
name = fullref
t = RefTypeOther
}
return
} | [
"func",
"ParseRefToTypeAndName",
"(",
"fullref",
"string",
")",
"(",
"t",
"RefType",
",",
"name",
"string",
")",
"{",
"const",
"localPrefix",
"=",
"\"",
"\"",
"\n",
"const",
"remotePrefix",
"=",
"\"",
"\"",
"\n",
"const",
"localTagPrefix",
"=",
"\"",
"\"",
"\n\n",
"if",
"fullref",
"==",
"\"",
"\"",
"{",
"name",
"=",
"fullref",
"\n",
"t",
"=",
"RefTypeHEAD",
"\n",
"}",
"else",
"if",
"strings",
".",
"HasPrefix",
"(",
"fullref",
",",
"localPrefix",
")",
"{",
"name",
"=",
"fullref",
"[",
"len",
"(",
"localPrefix",
")",
":",
"]",
"\n",
"t",
"=",
"RefTypeLocalBranch",
"\n",
"}",
"else",
"if",
"strings",
".",
"HasPrefix",
"(",
"fullref",
",",
"remotePrefix",
")",
"{",
"name",
"=",
"fullref",
"[",
"len",
"(",
"remotePrefix",
")",
":",
"]",
"\n",
"t",
"=",
"RefTypeRemoteBranch",
"\n",
"}",
"else",
"if",
"strings",
".",
"HasPrefix",
"(",
"fullref",
",",
"localTagPrefix",
")",
"{",
"name",
"=",
"fullref",
"[",
"len",
"(",
"localTagPrefix",
")",
":",
"]",
"\n",
"t",
"=",
"RefTypeLocalTag",
"\n",
"}",
"else",
"{",
"name",
"=",
"fullref",
"\n",
"t",
"=",
"RefTypeOther",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // Get the type & name of a git reference | [
"Get",
"the",
"type",
"&",
"name",
"of",
"a",
"git",
"reference"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/git.go#L514-L536 | train |
git-lfs/git-lfs | git/git.go | GetCommitSummary | func GetCommitSummary(commit string) (*CommitSummary, error) {
cmd := gitNoLFS("show", "-s",
`--format=%H|%h|%P|%ai|%ci|%ae|%an|%ce|%cn|%s`, commit)
out, err := cmd.CombinedOutput()
if err != nil {
return nil, fmt.Errorf("Failed to call git show: %v %v", err, string(out))
}
// At most 10 substrings so subject line is not split on anything
fields := strings.SplitN(string(out), "|", 10)
// Cope with the case where subject is blank
if len(fields) >= 9 {
ret := &CommitSummary{}
// Get SHAs from output, not commit input, so we can support symbolic refs
ret.Sha = fields[0]
ret.ShortSha = fields[1]
ret.Parents = strings.Split(fields[2], " ")
// %aD & %cD (RFC2822) matches Go's RFC1123Z format
ret.AuthorDate, _ = ParseGitDate(fields[3])
ret.CommitDate, _ = ParseGitDate(fields[4])
ret.AuthorEmail = fields[5]
ret.AuthorName = fields[6]
ret.CommitterEmail = fields[7]
ret.CommitterName = fields[8]
if len(fields) > 9 {
ret.Subject = strings.TrimRight(fields[9], "\n")
}
return ret, nil
} else {
msg := fmt.Sprintf("Unexpected output from git show: %v", string(out))
return nil, errors.New(msg)
}
} | go | func GetCommitSummary(commit string) (*CommitSummary, error) {
cmd := gitNoLFS("show", "-s",
`--format=%H|%h|%P|%ai|%ci|%ae|%an|%ce|%cn|%s`, commit)
out, err := cmd.CombinedOutput()
if err != nil {
return nil, fmt.Errorf("Failed to call git show: %v %v", err, string(out))
}
// At most 10 substrings so subject line is not split on anything
fields := strings.SplitN(string(out), "|", 10)
// Cope with the case where subject is blank
if len(fields) >= 9 {
ret := &CommitSummary{}
// Get SHAs from output, not commit input, so we can support symbolic refs
ret.Sha = fields[0]
ret.ShortSha = fields[1]
ret.Parents = strings.Split(fields[2], " ")
// %aD & %cD (RFC2822) matches Go's RFC1123Z format
ret.AuthorDate, _ = ParseGitDate(fields[3])
ret.CommitDate, _ = ParseGitDate(fields[4])
ret.AuthorEmail = fields[5]
ret.AuthorName = fields[6]
ret.CommitterEmail = fields[7]
ret.CommitterName = fields[8]
if len(fields) > 9 {
ret.Subject = strings.TrimRight(fields[9], "\n")
}
return ret, nil
} else {
msg := fmt.Sprintf("Unexpected output from git show: %v", string(out))
return nil, errors.New(msg)
}
} | [
"func",
"GetCommitSummary",
"(",
"commit",
"string",
")",
"(",
"*",
"CommitSummary",
",",
"error",
")",
"{",
"cmd",
":=",
"gitNoLFS",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"`--format=%H|%h|%P|%ai|%ci|%ae|%an|%ce|%cn|%s`",
",",
"commit",
")",
"\n\n",
"out",
",",
"err",
":=",
"cmd",
".",
"CombinedOutput",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
",",
"string",
"(",
"out",
")",
")",
"\n",
"}",
"\n\n",
"// At most 10 substrings so subject line is not split on anything",
"fields",
":=",
"strings",
".",
"SplitN",
"(",
"string",
"(",
"out",
")",
",",
"\"",
"\"",
",",
"10",
")",
"\n",
"// Cope with the case where subject is blank",
"if",
"len",
"(",
"fields",
")",
">=",
"9",
"{",
"ret",
":=",
"&",
"CommitSummary",
"{",
"}",
"\n",
"// Get SHAs from output, not commit input, so we can support symbolic refs",
"ret",
".",
"Sha",
"=",
"fields",
"[",
"0",
"]",
"\n",
"ret",
".",
"ShortSha",
"=",
"fields",
"[",
"1",
"]",
"\n",
"ret",
".",
"Parents",
"=",
"strings",
".",
"Split",
"(",
"fields",
"[",
"2",
"]",
",",
"\"",
"\"",
")",
"\n",
"// %aD & %cD (RFC2822) matches Go's RFC1123Z format",
"ret",
".",
"AuthorDate",
",",
"_",
"=",
"ParseGitDate",
"(",
"fields",
"[",
"3",
"]",
")",
"\n",
"ret",
".",
"CommitDate",
",",
"_",
"=",
"ParseGitDate",
"(",
"fields",
"[",
"4",
"]",
")",
"\n",
"ret",
".",
"AuthorEmail",
"=",
"fields",
"[",
"5",
"]",
"\n",
"ret",
".",
"AuthorName",
"=",
"fields",
"[",
"6",
"]",
"\n",
"ret",
".",
"CommitterEmail",
"=",
"fields",
"[",
"7",
"]",
"\n",
"ret",
".",
"CommitterName",
"=",
"fields",
"[",
"8",
"]",
"\n",
"if",
"len",
"(",
"fields",
")",
">",
"9",
"{",
"ret",
".",
"Subject",
"=",
"strings",
".",
"TrimRight",
"(",
"fields",
"[",
"9",
"]",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"}",
"\n",
"return",
"ret",
",",
"nil",
"\n",
"}",
"else",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"string",
"(",
"out",
")",
")",
"\n",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"msg",
")",
"\n",
"}",
"\n",
"}"
] | // Get summary information about a commit | [
"Get",
"summary",
"information",
"about",
"a",
"commit"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/git.go#L557-L590 | train |
git-lfs/git-lfs | git/git.go | parseRefFile | func parseRefFile(filename string) (*Ref, error) {
bytes, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
contents := strings.TrimSpace(string(bytes))
if strings.HasPrefix(contents, "ref:") {
contents = strings.TrimSpace(contents[4:])
}
return ResolveRef(contents)
} | go | func parseRefFile(filename string) (*Ref, error) {
bytes, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
contents := strings.TrimSpace(string(bytes))
if strings.HasPrefix(contents, "ref:") {
contents = strings.TrimSpace(contents[4:])
}
return ResolveRef(contents)
} | [
"func",
"parseRefFile",
"(",
"filename",
"string",
")",
"(",
"*",
"Ref",
",",
"error",
")",
"{",
"bytes",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"contents",
":=",
"strings",
".",
"TrimSpace",
"(",
"string",
"(",
"bytes",
")",
")",
"\n",
"if",
"strings",
".",
"HasPrefix",
"(",
"contents",
",",
"\"",
"\"",
")",
"{",
"contents",
"=",
"strings",
".",
"TrimSpace",
"(",
"contents",
"[",
"4",
":",
"]",
")",
"\n",
"}",
"\n",
"return",
"ResolveRef",
"(",
"contents",
")",
"\n",
"}"
] | // Manually parse a reference file like HEAD and return the Ref it resolves to | [
"Manually",
"parse",
"a",
"reference",
"file",
"like",
"HEAD",
"and",
"return",
"the",
"Ref",
"it",
"resolves",
"to"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/git.go#L728-L738 | train |
git-lfs/git-lfs | git/git.go | IsBare | func IsBare() (bool, error) {
s, err := subprocess.SimpleExec(
"git", "rev-parse", "--is-bare-repository")
if err != nil {
return false, err
}
return strconv.ParseBool(s)
} | go | func IsBare() (bool, error) {
s, err := subprocess.SimpleExec(
"git", "rev-parse", "--is-bare-repository")
if err != nil {
return false, err
}
return strconv.ParseBool(s)
} | [
"func",
"IsBare",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"s",
",",
"err",
":=",
"subprocess",
".",
"SimpleExec",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"strconv",
".",
"ParseBool",
"(",
"s",
")",
"\n",
"}"
] | // IsBare returns whether or not a repository is bare. It requires that the
// current working directory is a repository.
//
// If there was an error determining whether or not the repository is bare, it
// will be returned. | [
"IsBare",
"returns",
"whether",
"or",
"not",
"a",
"repository",
"is",
"bare",
".",
"It",
"requires",
"that",
"the",
"current",
"working",
"directory",
"is",
"a",
"repository",
".",
"If",
"there",
"was",
"an",
"error",
"determining",
"whether",
"or",
"not",
"the",
"repository",
"is",
"bare",
"it",
"will",
"be",
"returned",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/git.go#L745-L754 | train |
git-lfs/git-lfs | git/git.go | CachedRemoteRefs | func CachedRemoteRefs(remoteName string) ([]*Ref, error) {
var ret []*Ref
cmd := gitNoLFS("show-ref")
outp, err := cmd.StdoutPipe()
if err != nil {
return nil, fmt.Errorf("Failed to call git show-ref: %v", err)
}
cmd.Start()
scanner := bufio.NewScanner(outp)
r := regexp.MustCompile(fmt.Sprintf(`([0-9a-fA-F]{40})\s+refs/remotes/%v/(.*)`, remoteName))
for scanner.Scan() {
if match := r.FindStringSubmatch(scanner.Text()); match != nil {
name := strings.TrimSpace(match[2])
// Don't match head
if name == "HEAD" {
continue
}
sha := match[1]
ret = append(ret, &Ref{name, RefTypeRemoteBranch, sha})
}
}
return ret, cmd.Wait()
} | go | func CachedRemoteRefs(remoteName string) ([]*Ref, error) {
var ret []*Ref
cmd := gitNoLFS("show-ref")
outp, err := cmd.StdoutPipe()
if err != nil {
return nil, fmt.Errorf("Failed to call git show-ref: %v", err)
}
cmd.Start()
scanner := bufio.NewScanner(outp)
r := regexp.MustCompile(fmt.Sprintf(`([0-9a-fA-F]{40})\s+refs/remotes/%v/(.*)`, remoteName))
for scanner.Scan() {
if match := r.FindStringSubmatch(scanner.Text()); match != nil {
name := strings.TrimSpace(match[2])
// Don't match head
if name == "HEAD" {
continue
}
sha := match[1]
ret = append(ret, &Ref{name, RefTypeRemoteBranch, sha})
}
}
return ret, cmd.Wait()
} | [
"func",
"CachedRemoteRefs",
"(",
"remoteName",
"string",
")",
"(",
"[",
"]",
"*",
"Ref",
",",
"error",
")",
"{",
"var",
"ret",
"[",
"]",
"*",
"Ref",
"\n",
"cmd",
":=",
"gitNoLFS",
"(",
"\"",
"\"",
")",
"\n\n",
"outp",
",",
"err",
":=",
"cmd",
".",
"StdoutPipe",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"cmd",
".",
"Start",
"(",
")",
"\n",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"outp",
")",
"\n\n",
"r",
":=",
"regexp",
".",
"MustCompile",
"(",
"fmt",
".",
"Sprintf",
"(",
"`([0-9a-fA-F]{40})\\s+refs/remotes/%v/(.*)`",
",",
"remoteName",
")",
")",
"\n",
"for",
"scanner",
".",
"Scan",
"(",
")",
"{",
"if",
"match",
":=",
"r",
".",
"FindStringSubmatch",
"(",
"scanner",
".",
"Text",
"(",
")",
")",
";",
"match",
"!=",
"nil",
"{",
"name",
":=",
"strings",
".",
"TrimSpace",
"(",
"match",
"[",
"2",
"]",
")",
"\n",
"// Don't match head",
"if",
"name",
"==",
"\"",
"\"",
"{",
"continue",
"\n",
"}",
"\n\n",
"sha",
":=",
"match",
"[",
"1",
"]",
"\n",
"ret",
"=",
"append",
"(",
"ret",
",",
"&",
"Ref",
"{",
"name",
",",
"RefTypeRemoteBranch",
",",
"sha",
"}",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"ret",
",",
"cmd",
".",
"Wait",
"(",
")",
"\n",
"}"
] | // CachedRemoteRefs returns the list of branches & tags for a remote which are
// currently cached locally. No remote request is made to verify them. | [
"CachedRemoteRefs",
"returns",
"the",
"list",
"of",
"branches",
"&",
"tags",
"for",
"a",
"remote",
"which",
"are",
"currently",
"cached",
"locally",
".",
"No",
"remote",
"request",
"is",
"made",
"to",
"verify",
"them",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/git.go#L965-L990 | train |
git-lfs/git-lfs | git/git.go | Fetch | func Fetch(remotes ...string) error {
if len(remotes) == 0 {
return nil
}
var args []string
if len(remotes) > 1 {
args = []string{"--multiple", "--"}
}
args = append(args, remotes...)
_, err := gitNoLFSSimple(append([]string{"fetch"}, args...)...)
return err
} | go | func Fetch(remotes ...string) error {
if len(remotes) == 0 {
return nil
}
var args []string
if len(remotes) > 1 {
args = []string{"--multiple", "--"}
}
args = append(args, remotes...)
_, err := gitNoLFSSimple(append([]string{"fetch"}, args...)...)
return err
} | [
"func",
"Fetch",
"(",
"remotes",
"...",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"remotes",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"var",
"args",
"[",
"]",
"string",
"\n",
"if",
"len",
"(",
"remotes",
")",
">",
"1",
"{",
"args",
"=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
"\n",
"}",
"\n",
"args",
"=",
"append",
"(",
"args",
",",
"remotes",
"...",
")",
"\n\n",
"_",
",",
"err",
":=",
"gitNoLFSSimple",
"(",
"append",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
",",
"args",
"...",
")",
"...",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Fetch performs a fetch with no arguments against the given remotes. | [
"Fetch",
"performs",
"a",
"fetch",
"with",
"no",
"arguments",
"against",
"the",
"given",
"remotes",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/git.go#L993-L1006 | train |
git-lfs/git-lfs | git/git.go | AllRefsIn | func AllRefsIn(wd string) ([]*Ref, error) {
cmd := gitNoLFS(
"for-each-ref", "--format=%(objectname)%00%(refname)")
cmd.Dir = wd
outp, err := cmd.StdoutPipe()
if err != nil {
return nil, lfserrors.Wrap(err, "cannot open pipe")
}
cmd.Start()
refs := make([]*Ref, 0)
scanner := bufio.NewScanner(outp)
for scanner.Scan() {
parts := strings.SplitN(scanner.Text(), "\x00", 2)
if len(parts) != 2 {
return nil, lfserrors.Errorf(
"git: invalid for-each-ref line: %q", scanner.Text())
}
sha := parts[0]
typ, name := ParseRefToTypeAndName(parts[1])
refs = append(refs, &Ref{
Name: name,
Type: typ,
Sha: sha,
})
}
if err := scanner.Err(); err != nil {
return nil, err
}
return refs, nil
} | go | func AllRefsIn(wd string) ([]*Ref, error) {
cmd := gitNoLFS(
"for-each-ref", "--format=%(objectname)%00%(refname)")
cmd.Dir = wd
outp, err := cmd.StdoutPipe()
if err != nil {
return nil, lfserrors.Wrap(err, "cannot open pipe")
}
cmd.Start()
refs := make([]*Ref, 0)
scanner := bufio.NewScanner(outp)
for scanner.Scan() {
parts := strings.SplitN(scanner.Text(), "\x00", 2)
if len(parts) != 2 {
return nil, lfserrors.Errorf(
"git: invalid for-each-ref line: %q", scanner.Text())
}
sha := parts[0]
typ, name := ParseRefToTypeAndName(parts[1])
refs = append(refs, &Ref{
Name: name,
Type: typ,
Sha: sha,
})
}
if err := scanner.Err(); err != nil {
return nil, err
}
return refs, nil
} | [
"func",
"AllRefsIn",
"(",
"wd",
"string",
")",
"(",
"[",
"]",
"*",
"Ref",
",",
"error",
")",
"{",
"cmd",
":=",
"gitNoLFS",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"cmd",
".",
"Dir",
"=",
"wd",
"\n\n",
"outp",
",",
"err",
":=",
"cmd",
".",
"StdoutPipe",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"lfserrors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"cmd",
".",
"Start",
"(",
")",
"\n\n",
"refs",
":=",
"make",
"(",
"[",
"]",
"*",
"Ref",
",",
"0",
")",
"\n\n",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"outp",
")",
"\n",
"for",
"scanner",
".",
"Scan",
"(",
")",
"{",
"parts",
":=",
"strings",
".",
"SplitN",
"(",
"scanner",
".",
"Text",
"(",
")",
",",
"\"",
"\\x00",
"\"",
",",
"2",
")",
"\n",
"if",
"len",
"(",
"parts",
")",
"!=",
"2",
"{",
"return",
"nil",
",",
"lfserrors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"scanner",
".",
"Text",
"(",
")",
")",
"\n",
"}",
"\n\n",
"sha",
":=",
"parts",
"[",
"0",
"]",
"\n",
"typ",
",",
"name",
":=",
"ParseRefToTypeAndName",
"(",
"parts",
"[",
"1",
"]",
")",
"\n\n",
"refs",
"=",
"append",
"(",
"refs",
",",
"&",
"Ref",
"{",
"Name",
":",
"name",
",",
"Type",
":",
"typ",
",",
"Sha",
":",
"sha",
",",
"}",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"scanner",
".",
"Err",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"refs",
",",
"nil",
"\n",
"}"
] | // AllRefs returns a slice of all references in a Git repository located in a
// the given working directory "wd", or an error if those references could not
// be loaded. | [
"AllRefs",
"returns",
"a",
"slice",
"of",
"all",
"references",
"in",
"a",
"Git",
"repository",
"located",
"in",
"a",
"the",
"given",
"working",
"directory",
"wd",
"or",
"an",
"error",
"if",
"those",
"references",
"could",
"not",
"be",
"loaded",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/git.go#L1046-L1082 | train |
git-lfs/git-lfs | git/git.go | GetFilesChanged | func GetFilesChanged(from, to string) ([]string, error) {
var files []string
args := []string{
"-c", "core.quotepath=false", // handle special chars in filenames
"diff-tree",
"--no-commit-id",
"--name-only",
"-r",
}
if len(from) > 0 {
args = append(args, from)
}
if len(to) > 0 {
args = append(args, to)
}
args = append(args, "--") // no ambiguous patterns
cmd := gitNoLFS(args...)
outp, err := cmd.StdoutPipe()
if err != nil {
return nil, fmt.Errorf("Failed to call git diff: %v", err)
}
if err := cmd.Start(); err != nil {
return nil, fmt.Errorf("Failed to start git diff: %v", err)
}
scanner := bufio.NewScanner(outp)
for scanner.Scan() {
files = append(files, strings.TrimSpace(scanner.Text()))
}
if err := cmd.Wait(); err != nil {
return nil, fmt.Errorf("Git diff failed: %v", err)
}
return files, err
} | go | func GetFilesChanged(from, to string) ([]string, error) {
var files []string
args := []string{
"-c", "core.quotepath=false", // handle special chars in filenames
"diff-tree",
"--no-commit-id",
"--name-only",
"-r",
}
if len(from) > 0 {
args = append(args, from)
}
if len(to) > 0 {
args = append(args, to)
}
args = append(args, "--") // no ambiguous patterns
cmd := gitNoLFS(args...)
outp, err := cmd.StdoutPipe()
if err != nil {
return nil, fmt.Errorf("Failed to call git diff: %v", err)
}
if err := cmd.Start(); err != nil {
return nil, fmt.Errorf("Failed to start git diff: %v", err)
}
scanner := bufio.NewScanner(outp)
for scanner.Scan() {
files = append(files, strings.TrimSpace(scanner.Text()))
}
if err := cmd.Wait(); err != nil {
return nil, fmt.Errorf("Git diff failed: %v", err)
}
return files, err
} | [
"func",
"GetFilesChanged",
"(",
"from",
",",
"to",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"files",
"[",
"]",
"string",
"\n",
"args",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"// handle special chars in filenames",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"}",
"\n\n",
"if",
"len",
"(",
"from",
")",
">",
"0",
"{",
"args",
"=",
"append",
"(",
"args",
",",
"from",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"to",
")",
">",
"0",
"{",
"args",
"=",
"append",
"(",
"args",
",",
"to",
")",
"\n",
"}",
"\n",
"args",
"=",
"append",
"(",
"args",
",",
"\"",
"\"",
")",
"// no ambiguous patterns",
"\n\n",
"cmd",
":=",
"gitNoLFS",
"(",
"args",
"...",
")",
"\n",
"outp",
",",
"err",
":=",
"cmd",
".",
"StdoutPipe",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"cmd",
".",
"Start",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"outp",
")",
"\n",
"for",
"scanner",
".",
"Scan",
"(",
")",
"{",
"files",
"=",
"append",
"(",
"files",
",",
"strings",
".",
"TrimSpace",
"(",
"scanner",
".",
"Text",
"(",
")",
")",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"cmd",
".",
"Wait",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"files",
",",
"err",
"\n",
"}"
] | // GetFilesChanged returns a list of files which were changed, either between 2
// commits, or at a single commit if you only supply one argument and a blank
// string for the other | [
"GetFilesChanged",
"returns",
"a",
"list",
"of",
"files",
"which",
"were",
"changed",
"either",
"between",
"2",
"commits",
"or",
"at",
"a",
"single",
"commit",
"if",
"you",
"only",
"supply",
"one",
"argument",
"and",
"a",
"blank",
"string",
"for",
"the",
"other"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/git.go#L1134-L1169 | train |
git-lfs/git-lfs | git/git.go | IsFileModified | func IsFileModified(filepath string) (bool, error) {
args := []string{
"-c", "core.quotepath=false", // handle special chars in filenames
"status",
"--porcelain",
"--", // separator in case filename ambiguous
filepath,
}
cmd := git(args...)
outp, err := cmd.StdoutPipe()
if err != nil {
return false, lfserrors.Wrap(err, "Failed to call git status")
}
if err := cmd.Start(); err != nil {
return false, lfserrors.Wrap(err, "Failed to start git status")
}
matched := false
for scanner := bufio.NewScanner(outp); scanner.Scan(); {
line := scanner.Text()
// Porcelain format is "<I><W> <filename>"
// Where <I> = index status, <W> = working copy status
if len(line) > 3 {
// Double-check even though should be only match
if strings.TrimSpace(line[3:]) == filepath {
matched = true
// keep consuming output to exit cleanly
// will typically fall straight through anyway due to 1 line output
}
}
}
if err := cmd.Wait(); err != nil {
return false, lfserrors.Wrap(err, "Git status failed")
}
return matched, nil
} | go | func IsFileModified(filepath string) (bool, error) {
args := []string{
"-c", "core.quotepath=false", // handle special chars in filenames
"status",
"--porcelain",
"--", // separator in case filename ambiguous
filepath,
}
cmd := git(args...)
outp, err := cmd.StdoutPipe()
if err != nil {
return false, lfserrors.Wrap(err, "Failed to call git status")
}
if err := cmd.Start(); err != nil {
return false, lfserrors.Wrap(err, "Failed to start git status")
}
matched := false
for scanner := bufio.NewScanner(outp); scanner.Scan(); {
line := scanner.Text()
// Porcelain format is "<I><W> <filename>"
// Where <I> = index status, <W> = working copy status
if len(line) > 3 {
// Double-check even though should be only match
if strings.TrimSpace(line[3:]) == filepath {
matched = true
// keep consuming output to exit cleanly
// will typically fall straight through anyway due to 1 line output
}
}
}
if err := cmd.Wait(); err != nil {
return false, lfserrors.Wrap(err, "Git status failed")
}
return matched, nil
} | [
"func",
"IsFileModified",
"(",
"filepath",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"args",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"// handle special chars in filenames",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"// separator in case filename ambiguous",
"filepath",
",",
"}",
"\n",
"cmd",
":=",
"git",
"(",
"args",
"...",
")",
"\n",
"outp",
",",
"err",
":=",
"cmd",
".",
"StdoutPipe",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"lfserrors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"cmd",
".",
"Start",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"lfserrors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"matched",
":=",
"false",
"\n",
"for",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"outp",
")",
";",
"scanner",
".",
"Scan",
"(",
")",
";",
"{",
"line",
":=",
"scanner",
".",
"Text",
"(",
")",
"\n",
"// Porcelain format is \"<I><W> <filename>\"",
"// Where <I> = index status, <W> = working copy status",
"if",
"len",
"(",
"line",
")",
">",
"3",
"{",
"// Double-check even though should be only match",
"if",
"strings",
".",
"TrimSpace",
"(",
"line",
"[",
"3",
":",
"]",
")",
"==",
"filepath",
"{",
"matched",
"=",
"true",
"\n",
"// keep consuming output to exit cleanly",
"// will typically fall straight through anyway due to 1 line output",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"err",
":=",
"cmd",
".",
"Wait",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"lfserrors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"matched",
",",
"nil",
"\n",
"}"
] | // IsFileModified returns whether the filepath specified is modified according
// to `git status`. A file is modified if it has uncommitted changes in the
// working copy or the index. This includes being untracked. | [
"IsFileModified",
"returns",
"whether",
"the",
"filepath",
"specified",
"is",
"modified",
"according",
"to",
"git",
"status",
".",
"A",
"file",
"is",
"modified",
"if",
"it",
"has",
"uncommitted",
"changes",
"in",
"the",
"working",
"copy",
"or",
"the",
"index",
".",
"This",
"includes",
"being",
"untracked",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/git.go#L1174-L1210 | train |
git-lfs/git-lfs | git/git.go | IsWorkingCopyDirty | func IsWorkingCopyDirty() (bool, error) {
bare, err := IsBare()
if bare || err != nil {
return false, err
}
out, err := gitSimple("status", "--porcelain")
if err != nil {
return false, err
}
return len(out) != 0, nil
} | go | func IsWorkingCopyDirty() (bool, error) {
bare, err := IsBare()
if bare || err != nil {
return false, err
}
out, err := gitSimple("status", "--porcelain")
if err != nil {
return false, err
}
return len(out) != 0, nil
} | [
"func",
"IsWorkingCopyDirty",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"bare",
",",
"err",
":=",
"IsBare",
"(",
")",
"\n",
"if",
"bare",
"||",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"out",
",",
"err",
":=",
"gitSimple",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"return",
"len",
"(",
"out",
")",
"!=",
"0",
",",
"nil",
"\n",
"}"
] | // IsWorkingCopyDirty returns true if and only if the working copy in which the
// command was executed is dirty as compared to the index.
//
// If the status of the working copy could not be determined, an error will be
// returned instead. | [
"IsWorkingCopyDirty",
"returns",
"true",
"if",
"and",
"only",
"if",
"the",
"working",
"copy",
"in",
"which",
"the",
"command",
"was",
"executed",
"is",
"dirty",
"as",
"compared",
"to",
"the",
"index",
".",
"If",
"the",
"status",
"of",
"the",
"working",
"copy",
"could",
"not",
"be",
"determined",
"an",
"error",
"will",
"be",
"returned",
"instead",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/git.go#L1217-L1228 | train |
git-lfs/git-lfs | tq/manifest.go | GetAdapterNames | func (m *Manifest) GetAdapterNames(dir Direction) []string {
switch dir {
case Upload:
return m.GetUploadAdapterNames()
case Download:
return m.GetDownloadAdapterNames()
}
return nil
} | go | func (m *Manifest) GetAdapterNames(dir Direction) []string {
switch dir {
case Upload:
return m.GetUploadAdapterNames()
case Download:
return m.GetDownloadAdapterNames()
}
return nil
} | [
"func",
"(",
"m",
"*",
"Manifest",
")",
"GetAdapterNames",
"(",
"dir",
"Direction",
")",
"[",
"]",
"string",
"{",
"switch",
"dir",
"{",
"case",
"Upload",
":",
"return",
"m",
".",
"GetUploadAdapterNames",
"(",
")",
"\n",
"case",
"Download",
":",
"return",
"m",
".",
"GetDownloadAdapterNames",
"(",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // GetAdapterNames returns a list of the names of adapters available to be created | [
"GetAdapterNames",
"returns",
"a",
"list",
"of",
"the",
"names",
"of",
"adapters",
"available",
"to",
"be",
"created"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tq/manifest.go#L123-L131 | train |
git-lfs/git-lfs | tq/manifest.go | getAdapterNames | func (m *Manifest) getAdapterNames(adapters map[string]NewAdapterFunc) []string {
if m.basicTransfersOnly {
return []string{BasicAdapterName}
}
m.mu.Lock()
defer m.mu.Unlock()
ret := make([]string, 0, len(adapters))
for n, _ := range adapters {
ret = append(ret, n)
}
return ret
} | go | func (m *Manifest) getAdapterNames(adapters map[string]NewAdapterFunc) []string {
if m.basicTransfersOnly {
return []string{BasicAdapterName}
}
m.mu.Lock()
defer m.mu.Unlock()
ret := make([]string, 0, len(adapters))
for n, _ := range adapters {
ret = append(ret, n)
}
return ret
} | [
"func",
"(",
"m",
"*",
"Manifest",
")",
"getAdapterNames",
"(",
"adapters",
"map",
"[",
"string",
"]",
"NewAdapterFunc",
")",
"[",
"]",
"string",
"{",
"if",
"m",
".",
"basicTransfersOnly",
"{",
"return",
"[",
"]",
"string",
"{",
"BasicAdapterName",
"}",
"\n",
"}",
"\n\n",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"ret",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"adapters",
")",
")",
"\n",
"for",
"n",
",",
"_",
":=",
"range",
"adapters",
"{",
"ret",
"=",
"append",
"(",
"ret",
",",
"n",
")",
"\n",
"}",
"\n",
"return",
"ret",
"\n",
"}"
] | // getAdapterNames returns a list of the names of adapters available to be created | [
"getAdapterNames",
"returns",
"a",
"list",
"of",
"the",
"names",
"of",
"adapters",
"available",
"to",
"be",
"created"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tq/manifest.go#L144-L157 | train |
git-lfs/git-lfs | tq/manifest.go | RegisterNewAdapterFunc | func (m *Manifest) RegisterNewAdapterFunc(name string, dir Direction, f NewAdapterFunc) {
m.mu.Lock()
defer m.mu.Unlock()
switch dir {
case Upload:
m.uploadAdapterFuncs[name] = f
case Download:
m.downloadAdapterFuncs[name] = f
}
} | go | func (m *Manifest) RegisterNewAdapterFunc(name string, dir Direction, f NewAdapterFunc) {
m.mu.Lock()
defer m.mu.Unlock()
switch dir {
case Upload:
m.uploadAdapterFuncs[name] = f
case Download:
m.downloadAdapterFuncs[name] = f
}
} | [
"func",
"(",
"m",
"*",
"Manifest",
")",
"RegisterNewAdapterFunc",
"(",
"name",
"string",
",",
"dir",
"Direction",
",",
"f",
"NewAdapterFunc",
")",
"{",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"switch",
"dir",
"{",
"case",
"Upload",
":",
"m",
".",
"uploadAdapterFuncs",
"[",
"name",
"]",
"=",
"f",
"\n",
"case",
"Download",
":",
"m",
".",
"downloadAdapterFuncs",
"[",
"name",
"]",
"=",
"f",
"\n",
"}",
"\n",
"}"
] | // RegisterNewTransferAdapterFunc registers a new function for creating upload
// or download adapters. If a function with that name & direction is already
// registered, it is overridden | [
"RegisterNewTransferAdapterFunc",
"registers",
"a",
"new",
"function",
"for",
"creating",
"upload",
"or",
"download",
"adapters",
".",
"If",
"a",
"function",
"with",
"that",
"name",
"&",
"direction",
"is",
"already",
"registered",
"it",
"is",
"overridden"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tq/manifest.go#L162-L172 | train |
git-lfs/git-lfs | tq/manifest.go | NewAdapterOrDefault | func (m *Manifest) NewAdapterOrDefault(name string, dir Direction) Adapter {
if len(name) == 0 {
name = BasicAdapterName
}
a := m.NewAdapter(name, dir)
if a == nil {
tracerx.Printf("Defaulting to basic transfer adapter since %q did not exist", name)
a = m.NewAdapter(BasicAdapterName, dir)
}
return a
} | go | func (m *Manifest) NewAdapterOrDefault(name string, dir Direction) Adapter {
if len(name) == 0 {
name = BasicAdapterName
}
a := m.NewAdapter(name, dir)
if a == nil {
tracerx.Printf("Defaulting to basic transfer adapter since %q did not exist", name)
a = m.NewAdapter(BasicAdapterName, dir)
}
return a
} | [
"func",
"(",
"m",
"*",
"Manifest",
")",
"NewAdapterOrDefault",
"(",
"name",
"string",
",",
"dir",
"Direction",
")",
"Adapter",
"{",
"if",
"len",
"(",
"name",
")",
"==",
"0",
"{",
"name",
"=",
"BasicAdapterName",
"\n",
"}",
"\n\n",
"a",
":=",
"m",
".",
"NewAdapter",
"(",
"name",
",",
"dir",
")",
"\n",
"if",
"a",
"==",
"nil",
"{",
"tracerx",
".",
"Printf",
"(",
"\"",
"\"",
",",
"name",
")",
"\n",
"a",
"=",
"m",
".",
"NewAdapter",
"(",
"BasicAdapterName",
",",
"dir",
")",
"\n",
"}",
"\n",
"return",
"a",
"\n",
"}"
] | // Create a new adapter by name and direction; default to BasicAdapterName if doesn't exist | [
"Create",
"a",
"new",
"adapter",
"by",
"name",
"and",
"direction",
";",
"default",
"to",
"BasicAdapterName",
"if",
"doesn",
"t",
"exist"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tq/manifest.go#L175-L186 | train |
git-lfs/git-lfs | tq/manifest.go | NewAdapter | func (m *Manifest) NewAdapter(name string, dir Direction) Adapter {
m.mu.Lock()
defer m.mu.Unlock()
switch dir {
case Upload:
if u, ok := m.uploadAdapterFuncs[name]; ok {
return u(name, dir)
}
case Download:
if d, ok := m.downloadAdapterFuncs[name]; ok {
return d(name, dir)
}
}
return nil
} | go | func (m *Manifest) NewAdapter(name string, dir Direction) Adapter {
m.mu.Lock()
defer m.mu.Unlock()
switch dir {
case Upload:
if u, ok := m.uploadAdapterFuncs[name]; ok {
return u(name, dir)
}
case Download:
if d, ok := m.downloadAdapterFuncs[name]; ok {
return d(name, dir)
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"Manifest",
")",
"NewAdapter",
"(",
"name",
"string",
",",
"dir",
"Direction",
")",
"Adapter",
"{",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"switch",
"dir",
"{",
"case",
"Upload",
":",
"if",
"u",
",",
"ok",
":=",
"m",
".",
"uploadAdapterFuncs",
"[",
"name",
"]",
";",
"ok",
"{",
"return",
"u",
"(",
"name",
",",
"dir",
")",
"\n",
"}",
"\n",
"case",
"Download",
":",
"if",
"d",
",",
"ok",
":=",
"m",
".",
"downloadAdapterFuncs",
"[",
"name",
"]",
";",
"ok",
"{",
"return",
"d",
"(",
"name",
",",
"dir",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Create a new adapter by name and direction, or nil if doesn't exist | [
"Create",
"a",
"new",
"adapter",
"by",
"name",
"and",
"direction",
"or",
"nil",
"if",
"doesn",
"t",
"exist"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tq/manifest.go#L189-L204 | train |
git-lfs/git-lfs | tq/manifest.go | NewDownloadAdapter | func (m *Manifest) NewDownloadAdapter(name string) Adapter {
return m.NewAdapterOrDefault(name, Download)
} | go | func (m *Manifest) NewDownloadAdapter(name string) Adapter {
return m.NewAdapterOrDefault(name, Download)
} | [
"func",
"(",
"m",
"*",
"Manifest",
")",
"NewDownloadAdapter",
"(",
"name",
"string",
")",
"Adapter",
"{",
"return",
"m",
".",
"NewAdapterOrDefault",
"(",
"name",
",",
"Download",
")",
"\n",
"}"
] | // Create a new download adapter by name, or BasicAdapterName if doesn't exist | [
"Create",
"a",
"new",
"download",
"adapter",
"by",
"name",
"or",
"BasicAdapterName",
"if",
"doesn",
"t",
"exist"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tq/manifest.go#L207-L209 | train |
git-lfs/git-lfs | tq/manifest.go | NewUploadAdapter | func (m *Manifest) NewUploadAdapter(name string) Adapter {
return m.NewAdapterOrDefault(name, Upload)
} | go | func (m *Manifest) NewUploadAdapter(name string) Adapter {
return m.NewAdapterOrDefault(name, Upload)
} | [
"func",
"(",
"m",
"*",
"Manifest",
")",
"NewUploadAdapter",
"(",
"name",
"string",
")",
"Adapter",
"{",
"return",
"m",
".",
"NewAdapterOrDefault",
"(",
"name",
",",
"Upload",
")",
"\n",
"}"
] | // Create a new upload adapter by name, or BasicAdapterName if doesn't exist | [
"Create",
"a",
"new",
"upload",
"adapter",
"by",
"name",
"or",
"BasicAdapterName",
"if",
"doesn",
"t",
"exist"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tq/manifest.go#L212-L214 | train |
git-lfs/git-lfs | git/config.go | NewReadOnlyConfig | func NewReadOnlyConfig(workdir, gitdir string) *Configuration {
cfg := NewConfig(workdir, gitdir)
cfg.readOnly = true
return cfg
} | go | func NewReadOnlyConfig(workdir, gitdir string) *Configuration {
cfg := NewConfig(workdir, gitdir)
cfg.readOnly = true
return cfg
} | [
"func",
"NewReadOnlyConfig",
"(",
"workdir",
",",
"gitdir",
"string",
")",
"*",
"Configuration",
"{",
"cfg",
":=",
"NewConfig",
"(",
"workdir",
",",
"gitdir",
")",
"\n",
"cfg",
".",
"readOnly",
"=",
"true",
"\n",
"return",
"cfg",
"\n\n",
"}"
] | // NewReadOnlyConfig creates a new confguration that returns an error if an
// attempt to write to the configuration is made. | [
"NewReadOnlyConfig",
"creates",
"a",
"new",
"confguration",
"that",
"returns",
"an",
"error",
"if",
"an",
"attempt",
"to",
"write",
"to",
"the",
"configuration",
"is",
"made",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/config.go#L36-L41 | train |
git-lfs/git-lfs | git/config.go | FindGlobal | func (c *Configuration) FindGlobal(key string) string {
output, _ := c.gitConfig("--global", key)
return output
} | go | func (c *Configuration) FindGlobal(key string) string {
output, _ := c.gitConfig("--global", key)
return output
} | [
"func",
"(",
"c",
"*",
"Configuration",
")",
"FindGlobal",
"(",
"key",
"string",
")",
"string",
"{",
"output",
",",
"_",
":=",
"c",
".",
"gitConfig",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"return",
"output",
"\n",
"}"
] | // FindGlobal returns the git config value global scope for the key | [
"FindGlobal",
"returns",
"the",
"git",
"config",
"value",
"global",
"scope",
"for",
"the",
"key"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/config.go#L62-L65 | train |
git-lfs/git-lfs | git/config.go | FindSystem | func (c *Configuration) FindSystem(key string) string {
output, _ := c.gitConfig("--system", key)
return output
} | go | func (c *Configuration) FindSystem(key string) string {
output, _ := c.gitConfig("--system", key)
return output
} | [
"func",
"(",
"c",
"*",
"Configuration",
")",
"FindSystem",
"(",
"key",
"string",
")",
"string",
"{",
"output",
",",
"_",
":=",
"c",
".",
"gitConfig",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"return",
"output",
"\n",
"}"
] | // FindSystem returns the git config value in system scope for the key | [
"FindSystem",
"returns",
"the",
"git",
"config",
"value",
"in",
"system",
"scope",
"for",
"the",
"key"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/config.go#L68-L71 | train |
git-lfs/git-lfs | git/config.go | SetGlobal | func (c *Configuration) SetGlobal(key, val string) (string, error) {
return c.gitConfigWrite("--global", "--replace-all", key, val)
} | go | func (c *Configuration) SetGlobal(key, val string) (string, error) {
return c.gitConfigWrite("--global", "--replace-all", key, val)
} | [
"func",
"(",
"c",
"*",
"Configuration",
")",
"SetGlobal",
"(",
"key",
",",
"val",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"c",
".",
"gitConfigWrite",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"key",
",",
"val",
")",
"\n",
"}"
] | // SetGlobal sets the git config value for the key in the global config | [
"SetGlobal",
"sets",
"the",
"git",
"config",
"value",
"for",
"the",
"key",
"in",
"the",
"global",
"config"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/config.go#L80-L82 | train |
git-lfs/git-lfs | git/config.go | SetSystem | func (c *Configuration) SetSystem(key, val string) (string, error) {
return c.gitConfigWrite("--system", "--replace-all", key, val)
} | go | func (c *Configuration) SetSystem(key, val string) (string, error) {
return c.gitConfigWrite("--system", "--replace-all", key, val)
} | [
"func",
"(",
"c",
"*",
"Configuration",
")",
"SetSystem",
"(",
"key",
",",
"val",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"c",
".",
"gitConfigWrite",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"key",
",",
"val",
")",
"\n",
"}"
] | // SetSystem sets the git config value for the key in the system config | [
"SetSystem",
"sets",
"the",
"git",
"config",
"value",
"for",
"the",
"key",
"in",
"the",
"system",
"config"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/config.go#L85-L87 | train |
git-lfs/git-lfs | git/config.go | UnsetGlobalSection | func (c *Configuration) UnsetGlobalSection(key string) (string, error) {
return c.gitConfigWrite("--global", "--remove-section", key)
} | go | func (c *Configuration) UnsetGlobalSection(key string) (string, error) {
return c.gitConfigWrite("--global", "--remove-section", key)
} | [
"func",
"(",
"c",
"*",
"Configuration",
")",
"UnsetGlobalSection",
"(",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"c",
".",
"gitConfigWrite",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"key",
")",
"\n",
"}"
] | // UnsetGlobalSection removes the entire named section from the global config | [
"UnsetGlobalSection",
"removes",
"the",
"entire",
"named",
"section",
"from",
"the",
"global",
"config"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/config.go#L90-L92 | train |
git-lfs/git-lfs | git/config.go | UnsetSystemSection | func (c *Configuration) UnsetSystemSection(key string) (string, error) {
return c.gitConfigWrite("--system", "--remove-section", key)
} | go | func (c *Configuration) UnsetSystemSection(key string) (string, error) {
return c.gitConfigWrite("--system", "--remove-section", key)
} | [
"func",
"(",
"c",
"*",
"Configuration",
")",
"UnsetSystemSection",
"(",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"c",
".",
"gitConfigWrite",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"key",
")",
"\n",
"}"
] | // UnsetSystemSection removes the entire named section from the system config | [
"UnsetSystemSection",
"removes",
"the",
"entire",
"named",
"section",
"from",
"the",
"system",
"config"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/config.go#L95-L97 | train |
git-lfs/git-lfs | git/config.go | UnsetLocalSection | func (c *Configuration) UnsetLocalSection(key string) (string, error) {
return c.gitConfigWrite("--local", "--remove-section", key)
} | go | func (c *Configuration) UnsetLocalSection(key string) (string, error) {
return c.gitConfigWrite("--local", "--remove-section", key)
} | [
"func",
"(",
"c",
"*",
"Configuration",
")",
"UnsetLocalSection",
"(",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"c",
".",
"gitConfigWrite",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"key",
")",
"\n",
"}"
] | // UnsetLocalSection removes the entire named section from the system config | [
"UnsetLocalSection",
"removes",
"the",
"entire",
"named",
"section",
"from",
"the",
"system",
"config"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/config.go#L100-L102 | train |
git-lfs/git-lfs | git/config.go | SetLocal | func (c *Configuration) SetLocal(key, val string) (string, error) {
return c.gitConfigWrite("--replace-all", key, val)
} | go | func (c *Configuration) SetLocal(key, val string) (string, error) {
return c.gitConfigWrite("--replace-all", key, val)
} | [
"func",
"(",
"c",
"*",
"Configuration",
")",
"SetLocal",
"(",
"key",
",",
"val",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"c",
".",
"gitConfigWrite",
"(",
"\"",
"\"",
",",
"key",
",",
"val",
")",
"\n",
"}"
] | // SetLocal sets the git config value for the key in the specified config file | [
"SetLocal",
"sets",
"the",
"git",
"config",
"value",
"for",
"the",
"key",
"in",
"the",
"specified",
"config",
"file"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/config.go#L105-L107 | train |
git-lfs/git-lfs | git/config.go | UnsetLocalKey | func (c *Configuration) UnsetLocalKey(key string) (string, error) {
return c.gitConfigWrite("--unset", key)
} | go | func (c *Configuration) UnsetLocalKey(key string) (string, error) {
return c.gitConfigWrite("--unset", key)
} | [
"func",
"(",
"c",
"*",
"Configuration",
")",
"UnsetLocalKey",
"(",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"c",
".",
"gitConfigWrite",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"}"
] | // UnsetLocalKey removes the git config value for the key from the specified config file | [
"UnsetLocalKey",
"removes",
"the",
"git",
"config",
"value",
"for",
"the",
"key",
"from",
"the",
"specified",
"config",
"file"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/config.go#L110-L112 | train |
git-lfs/git-lfs | git/gitattr/macro.go | NewMacroProcessor | func NewMacroProcessor() *MacroProcessor {
macros := make(map[string][]*Attr)
// This is built into Git.
macros["binary"] = []*Attr{
&Attr{K: "diff", V: "false"},
&Attr{K: "merge", V: "false"},
&Attr{K: "text", V: "false"},
}
return &MacroProcessor{
macros: macros,
}
} | go | func NewMacroProcessor() *MacroProcessor {
macros := make(map[string][]*Attr)
// This is built into Git.
macros["binary"] = []*Attr{
&Attr{K: "diff", V: "false"},
&Attr{K: "merge", V: "false"},
&Attr{K: "text", V: "false"},
}
return &MacroProcessor{
macros: macros,
}
} | [
"func",
"NewMacroProcessor",
"(",
")",
"*",
"MacroProcessor",
"{",
"macros",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"*",
"Attr",
")",
"\n\n",
"// This is built into Git.",
"macros",
"[",
"\"",
"\"",
"]",
"=",
"[",
"]",
"*",
"Attr",
"{",
"&",
"Attr",
"{",
"K",
":",
"\"",
"\"",
",",
"V",
":",
"\"",
"\"",
"}",
",",
"&",
"Attr",
"{",
"K",
":",
"\"",
"\"",
",",
"V",
":",
"\"",
"\"",
"}",
",",
"&",
"Attr",
"{",
"K",
":",
"\"",
"\"",
",",
"V",
":",
"\"",
"\"",
"}",
",",
"}",
"\n\n",
"return",
"&",
"MacroProcessor",
"{",
"macros",
":",
"macros",
",",
"}",
"\n",
"}"
] | // NewMacroProcessor returns a new MacroProcessor object for parsing macros. | [
"NewMacroProcessor",
"returns",
"a",
"new",
"MacroProcessor",
"object",
"for",
"parsing",
"macros",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/gitattr/macro.go#L8-L21 | train |
git-lfs/git-lfs | git/gitattr/macro.go | ProcessLines | func (mp *MacroProcessor) ProcessLines(lines []*Line, readMacros bool) []*Line {
result := make([]*Line, 0, len(lines))
for _, line := range lines {
if line.Pattern != nil {
resultLine := Line{
Pattern: line.Pattern,
Attrs: make([]*Attr, 0, len(line.Attrs)),
}
for _, attr := range line.Attrs {
macros := mp.macros[attr.K]
if attr.V == "true" && macros != nil {
resultLine.Attrs = append(
resultLine.Attrs,
macros...,
)
}
// Git copies through aliases as well as
// expanding them.
resultLine.Attrs = append(
resultLine.Attrs,
attr,
)
}
result = append(result, &resultLine)
} else if readMacros {
mp.macros[line.Macro] = line.Attrs
}
}
return result
} | go | func (mp *MacroProcessor) ProcessLines(lines []*Line, readMacros bool) []*Line {
result := make([]*Line, 0, len(lines))
for _, line := range lines {
if line.Pattern != nil {
resultLine := Line{
Pattern: line.Pattern,
Attrs: make([]*Attr, 0, len(line.Attrs)),
}
for _, attr := range line.Attrs {
macros := mp.macros[attr.K]
if attr.V == "true" && macros != nil {
resultLine.Attrs = append(
resultLine.Attrs,
macros...,
)
}
// Git copies through aliases as well as
// expanding them.
resultLine.Attrs = append(
resultLine.Attrs,
attr,
)
}
result = append(result, &resultLine)
} else if readMacros {
mp.macros[line.Macro] = line.Attrs
}
}
return result
} | [
"func",
"(",
"mp",
"*",
"MacroProcessor",
")",
"ProcessLines",
"(",
"lines",
"[",
"]",
"*",
"Line",
",",
"readMacros",
"bool",
")",
"[",
"]",
"*",
"Line",
"{",
"result",
":=",
"make",
"(",
"[",
"]",
"*",
"Line",
",",
"0",
",",
"len",
"(",
"lines",
")",
")",
"\n",
"for",
"_",
",",
"line",
":=",
"range",
"lines",
"{",
"if",
"line",
".",
"Pattern",
"!=",
"nil",
"{",
"resultLine",
":=",
"Line",
"{",
"Pattern",
":",
"line",
".",
"Pattern",
",",
"Attrs",
":",
"make",
"(",
"[",
"]",
"*",
"Attr",
",",
"0",
",",
"len",
"(",
"line",
".",
"Attrs",
")",
")",
",",
"}",
"\n",
"for",
"_",
",",
"attr",
":=",
"range",
"line",
".",
"Attrs",
"{",
"macros",
":=",
"mp",
".",
"macros",
"[",
"attr",
".",
"K",
"]",
"\n",
"if",
"attr",
".",
"V",
"==",
"\"",
"\"",
"&&",
"macros",
"!=",
"nil",
"{",
"resultLine",
".",
"Attrs",
"=",
"append",
"(",
"resultLine",
".",
"Attrs",
",",
"macros",
"...",
",",
")",
"\n",
"}",
"\n\n",
"// Git copies through aliases as well as",
"// expanding them.",
"resultLine",
".",
"Attrs",
"=",
"append",
"(",
"resultLine",
".",
"Attrs",
",",
"attr",
",",
")",
"\n",
"}",
"\n",
"result",
"=",
"append",
"(",
"result",
",",
"&",
"resultLine",
")",
"\n",
"}",
"else",
"if",
"readMacros",
"{",
"mp",
".",
"macros",
"[",
"line",
".",
"Macro",
"]",
"=",
"line",
".",
"Attrs",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"result",
"\n",
"}"
] | // ProcessLines reads the specified lines, returning a new set of lines which
// all have a valid pattern. If readMacros is true, it additionally loads any
// macro lines as it reads them. | [
"ProcessLines",
"reads",
"the",
"specified",
"lines",
"returning",
"a",
"new",
"set",
"of",
"lines",
"which",
"all",
"have",
"a",
"valid",
"pattern",
".",
"If",
"readMacros",
"is",
"true",
"it",
"additionally",
"loads",
"any",
"macro",
"lines",
"as",
"it",
"reads",
"them",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/gitattr/macro.go#L26-L56 | train |
git-lfs/git-lfs | tasklog/task.go | Throttled | func (u *Update) Throttled(next time.Time) bool {
return !(u.Force || u.At.After(next))
} | go | func (u *Update) Throttled(next time.Time) bool {
return !(u.Force || u.At.After(next))
} | [
"func",
"(",
"u",
"*",
"Update",
")",
"Throttled",
"(",
"next",
"time",
".",
"Time",
")",
"bool",
"{",
"return",
"!",
"(",
"u",
".",
"Force",
"||",
"u",
".",
"At",
".",
"After",
"(",
"next",
")",
")",
"\n",
"}"
] | // Throttled determines whether this update should be throttled, based on the
// given earliest time of the next update. The caller should determine how often
// updates should be throttled. An Update with Force=true is never throttled. | [
"Throttled",
"determines",
"whether",
"this",
"update",
"should",
"be",
"throttled",
"based",
"on",
"the",
"given",
"earliest",
"time",
"of",
"the",
"next",
"update",
".",
"The",
"caller",
"should",
"determine",
"how",
"often",
"updates",
"should",
"be",
"throttled",
".",
"An",
"Update",
"with",
"Force",
"=",
"true",
"is",
"never",
"throttled",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tasklog/task.go#L33-L35 | train |
git-lfs/git-lfs | lfsapi/ntlm.go | ntlmReAuth | func (c *Client) ntlmReAuth(req *http.Request, credHelper creds.CredentialHelper, creds creds.Creds, retry bool) (*http.Response, error) {
ntmlCreds, err := ntlmGetCredentials(creds)
if err != nil {
return nil, err
}
res, err := c.ntlmAuthenticateRequest(req, ntmlCreds)
if err != nil && !errors.IsAuthError(err) {
return res, err
}
switch res.StatusCode {
case 401:
credHelper.Reject(creds)
if retry {
return c.ntlmReAuth(req, credHelper, creds, false)
}
case 403:
credHelper.Reject(creds)
default:
if res.StatusCode < 300 && res.StatusCode > 199 {
credHelper.Approve(creds)
}
}
return res, nil
} | go | func (c *Client) ntlmReAuth(req *http.Request, credHelper creds.CredentialHelper, creds creds.Creds, retry bool) (*http.Response, error) {
ntmlCreds, err := ntlmGetCredentials(creds)
if err != nil {
return nil, err
}
res, err := c.ntlmAuthenticateRequest(req, ntmlCreds)
if err != nil && !errors.IsAuthError(err) {
return res, err
}
switch res.StatusCode {
case 401:
credHelper.Reject(creds)
if retry {
return c.ntlmReAuth(req, credHelper, creds, false)
}
case 403:
credHelper.Reject(creds)
default:
if res.StatusCode < 300 && res.StatusCode > 199 {
credHelper.Approve(creds)
}
}
return res, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ntlmReAuth",
"(",
"req",
"*",
"http",
".",
"Request",
",",
"credHelper",
"creds",
".",
"CredentialHelper",
",",
"creds",
"creds",
".",
"Creds",
",",
"retry",
"bool",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"ntmlCreds",
",",
"err",
":=",
"ntlmGetCredentials",
"(",
"creds",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"res",
",",
"err",
":=",
"c",
".",
"ntlmAuthenticateRequest",
"(",
"req",
",",
"ntmlCreds",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"!",
"errors",
".",
"IsAuthError",
"(",
"err",
")",
"{",
"return",
"res",
",",
"err",
"\n",
"}",
"\n\n",
"switch",
"res",
".",
"StatusCode",
"{",
"case",
"401",
":",
"credHelper",
".",
"Reject",
"(",
"creds",
")",
"\n",
"if",
"retry",
"{",
"return",
"c",
".",
"ntlmReAuth",
"(",
"req",
",",
"credHelper",
",",
"creds",
",",
"false",
")",
"\n",
"}",
"\n",
"case",
"403",
":",
"credHelper",
".",
"Reject",
"(",
"creds",
")",
"\n",
"default",
":",
"if",
"res",
".",
"StatusCode",
"<",
"300",
"&&",
"res",
".",
"StatusCode",
">",
"199",
"{",
"credHelper",
".",
"Approve",
"(",
"creds",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"res",
",",
"nil",
"\n",
"}"
] | // If the status is 401 then we need to re-authenticate | [
"If",
"the",
"status",
"is",
"401",
"then",
"we",
"need",
"to",
"re",
"-",
"authenticate"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfsapi/ntlm.go#L36-L62 | train |
git-lfs/git-lfs | lfs/attribute.go | normalizeKey | func (a *Attribute) normalizeKey(relative string) string {
return strings.Join([]string{a.Section, relative}, ".")
} | go | func (a *Attribute) normalizeKey(relative string) string {
return strings.Join([]string{a.Section, relative}, ".")
} | [
"func",
"(",
"a",
"*",
"Attribute",
")",
"normalizeKey",
"(",
"relative",
"string",
")",
"string",
"{",
"return",
"strings",
".",
"Join",
"(",
"[",
"]",
"string",
"{",
"a",
".",
"Section",
",",
"relative",
"}",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // normalizeKey makes an absolute path out of a partial relative one. For a
// relative path of "foo", and a root Section of "bar", "bar.foo" will be returned. | [
"normalizeKey",
"makes",
"an",
"absolute",
"path",
"out",
"of",
"a",
"partial",
"relative",
"one",
".",
"For",
"a",
"relative",
"path",
"of",
"foo",
"and",
"a",
"root",
"Section",
"of",
"bar",
"bar",
".",
"foo",
"will",
"be",
"returned",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/attribute.go#L128-L130 | train |
git-lfs/git-lfs | lfs/attribute.go | Uninstall | func (a *Attribute) Uninstall(opt *FilterOptions) {
if opt.Local {
opt.GitConfig.UnsetLocalSection(a.Section)
} else if opt.System {
opt.GitConfig.UnsetSystemSection(a.Section)
} else {
opt.GitConfig.UnsetGlobalSection(a.Section)
}
} | go | func (a *Attribute) Uninstall(opt *FilterOptions) {
if opt.Local {
opt.GitConfig.UnsetLocalSection(a.Section)
} else if opt.System {
opt.GitConfig.UnsetSystemSection(a.Section)
} else {
opt.GitConfig.UnsetGlobalSection(a.Section)
}
} | [
"func",
"(",
"a",
"*",
"Attribute",
")",
"Uninstall",
"(",
"opt",
"*",
"FilterOptions",
")",
"{",
"if",
"opt",
".",
"Local",
"{",
"opt",
".",
"GitConfig",
".",
"UnsetLocalSection",
"(",
"a",
".",
"Section",
")",
"\n",
"}",
"else",
"if",
"opt",
".",
"System",
"{",
"opt",
".",
"GitConfig",
".",
"UnsetSystemSection",
"(",
"a",
".",
"Section",
")",
"\n",
"}",
"else",
"{",
"opt",
".",
"GitConfig",
".",
"UnsetGlobalSection",
"(",
"a",
".",
"Section",
")",
"\n",
"}",
"\n",
"}"
] | // Uninstall removes all properties in the path of this property. | [
"Uninstall",
"removes",
"all",
"properties",
"in",
"the",
"path",
"of",
"this",
"property",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/attribute.go#L165-L173 | train |
git-lfs/git-lfs | commands/lockverifier.go | Contains | func (lv *lockVerifier) Contains(name string) bool {
if lv == nil {
return false
}
_, ok := lv.theirLocks[name]
return ok
} | go | func (lv *lockVerifier) Contains(name string) bool {
if lv == nil {
return false
}
_, ok := lv.theirLocks[name]
return ok
} | [
"func",
"(",
"lv",
"*",
"lockVerifier",
")",
"Contains",
"(",
"name",
"string",
")",
"bool",
"{",
"if",
"lv",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"_",
",",
"ok",
":=",
"lv",
".",
"theirLocks",
"[",
"name",
"]",
"\n",
"return",
"ok",
"\n",
"}"
] | // Determines if a filename is lockable. Implements lfs.GitScannerSet | [
"Determines",
"if",
"a",
"filename",
"is",
"lockable",
".",
"Implements",
"lfs",
".",
"GitScannerSet"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/commands/lockverifier.go#L101-L107 | train |
git-lfs/git-lfs | commands/lockverifier.go | getVerifyStateFor | func getVerifyStateFor(rawurl string) verifyState {
uc := config.NewURLConfig(cfg.Git)
v, ok := uc.Get("lfs", rawurl, "locksverify")
if !ok {
if supportsLockingAPI(rawurl) {
return verifyStateEnabled
}
return verifyStateUnknown
}
if enabled, _ := strconv.ParseBool(v); enabled {
return verifyStateEnabled
}
return verifyStateDisabled
} | go | func getVerifyStateFor(rawurl string) verifyState {
uc := config.NewURLConfig(cfg.Git)
v, ok := uc.Get("lfs", rawurl, "locksverify")
if !ok {
if supportsLockingAPI(rawurl) {
return verifyStateEnabled
}
return verifyStateUnknown
}
if enabled, _ := strconv.ParseBool(v); enabled {
return verifyStateEnabled
}
return verifyStateDisabled
} | [
"func",
"getVerifyStateFor",
"(",
"rawurl",
"string",
")",
"verifyState",
"{",
"uc",
":=",
"config",
".",
"NewURLConfig",
"(",
"cfg",
".",
"Git",
")",
"\n\n",
"v",
",",
"ok",
":=",
"uc",
".",
"Get",
"(",
"\"",
"\"",
",",
"rawurl",
",",
"\"",
"\"",
")",
"\n",
"if",
"!",
"ok",
"{",
"if",
"supportsLockingAPI",
"(",
"rawurl",
")",
"{",
"return",
"verifyStateEnabled",
"\n",
"}",
"\n",
"return",
"verifyStateUnknown",
"\n",
"}",
"\n\n",
"if",
"enabled",
",",
"_",
":=",
"strconv",
".",
"ParseBool",
"(",
"v",
")",
";",
"enabled",
"{",
"return",
"verifyStateEnabled",
"\n",
"}",
"\n",
"return",
"verifyStateDisabled",
"\n",
"}"
] | // getVerifyStateFor returns whether or not lock verification is enabled for the
// given url. If no state has been explicitly set, an "unknown" state will be
// returned instead. | [
"getVerifyStateFor",
"returns",
"whether",
"or",
"not",
"lock",
"verification",
"is",
"enabled",
"for",
"the",
"given",
"url",
".",
"If",
"no",
"state",
"has",
"been",
"explicitly",
"set",
"an",
"unknown",
"state",
"will",
"be",
"returned",
"instead",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/commands/lockverifier.go#L229-L244 | train |
git-lfs/git-lfs | tq/basic_download.go | checkResumeDownload | func (a *basicDownloadAdapter) checkResumeDownload(t *Transfer) (outFile *os.File, fromByte int64, hashSoFar hash.Hash, e error) {
// lock the file by opening it for read/write, rather than checking Stat() etc
// which could be subject to race conditions by other processes
f, err := os.OpenFile(a.downloadFilename(t), os.O_RDWR, 0644)
if err != nil {
// Create a new file instead, must not already exist or error (permissions / race condition)
newfile, err := os.OpenFile(a.downloadFilename(t), os.O_CREATE|os.O_WRONLY|os.O_EXCL, 0644)
return newfile, 0, nil, err
}
// Successfully opened an existing file at this point
// Read any existing data into hash then return file handle at end
hash := tools.NewLfsContentHash()
n, err := io.Copy(hash, f)
if err != nil {
f.Close()
return nil, 0, nil, err
}
tracerx.Printf("xfer: Attempting to resume download of %q from byte %d", t.Oid, n)
return f, n, hash, nil
} | go | func (a *basicDownloadAdapter) checkResumeDownload(t *Transfer) (outFile *os.File, fromByte int64, hashSoFar hash.Hash, e error) {
// lock the file by opening it for read/write, rather than checking Stat() etc
// which could be subject to race conditions by other processes
f, err := os.OpenFile(a.downloadFilename(t), os.O_RDWR, 0644)
if err != nil {
// Create a new file instead, must not already exist or error (permissions / race condition)
newfile, err := os.OpenFile(a.downloadFilename(t), os.O_CREATE|os.O_WRONLY|os.O_EXCL, 0644)
return newfile, 0, nil, err
}
// Successfully opened an existing file at this point
// Read any existing data into hash then return file handle at end
hash := tools.NewLfsContentHash()
n, err := io.Copy(hash, f)
if err != nil {
f.Close()
return nil, 0, nil, err
}
tracerx.Printf("xfer: Attempting to resume download of %q from byte %d", t.Oid, n)
return f, n, hash, nil
} | [
"func",
"(",
"a",
"*",
"basicDownloadAdapter",
")",
"checkResumeDownload",
"(",
"t",
"*",
"Transfer",
")",
"(",
"outFile",
"*",
"os",
".",
"File",
",",
"fromByte",
"int64",
",",
"hashSoFar",
"hash",
".",
"Hash",
",",
"e",
"error",
")",
"{",
"// lock the file by opening it for read/write, rather than checking Stat() etc",
"// which could be subject to race conditions by other processes",
"f",
",",
"err",
":=",
"os",
".",
"OpenFile",
"(",
"a",
".",
"downloadFilename",
"(",
"t",
")",
",",
"os",
".",
"O_RDWR",
",",
"0644",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"// Create a new file instead, must not already exist or error (permissions / race condition)",
"newfile",
",",
"err",
":=",
"os",
".",
"OpenFile",
"(",
"a",
".",
"downloadFilename",
"(",
"t",
")",
",",
"os",
".",
"O_CREATE",
"|",
"os",
".",
"O_WRONLY",
"|",
"os",
".",
"O_EXCL",
",",
"0644",
")",
"\n",
"return",
"newfile",
",",
"0",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Successfully opened an existing file at this point",
"// Read any existing data into hash then return file handle at end",
"hash",
":=",
"tools",
".",
"NewLfsContentHash",
"(",
")",
"\n",
"n",
",",
"err",
":=",
"io",
".",
"Copy",
"(",
"hash",
",",
"f",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"f",
".",
"Close",
"(",
")",
"\n",
"return",
"nil",
",",
"0",
",",
"nil",
",",
"err",
"\n",
"}",
"\n",
"tracerx",
".",
"Printf",
"(",
"\"",
"\"",
",",
"t",
".",
"Oid",
",",
"n",
")",
"\n",
"return",
"f",
",",
"n",
",",
"hash",
",",
"nil",
"\n\n",
"}"
] | // Checks to see if a download can be resumed, and if so returns a non-nil locked file, byte start and hash | [
"Checks",
"to",
"see",
"if",
"a",
"download",
"can",
"be",
"resumed",
"and",
"if",
"so",
"returns",
"a",
"non",
"-",
"nil",
"locked",
"file",
"byte",
"start",
"and",
"hash"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tq/basic_download.go#L53-L75 | train |
git-lfs/git-lfs | tq/basic_download.go | downloadFilename | func (a *basicDownloadAdapter) downloadFilename(t *Transfer) string {
// Not a temp file since we will be resuming it
return filepath.Join(a.tempDir(), t.Oid+".tmp")
} | go | func (a *basicDownloadAdapter) downloadFilename(t *Transfer) string {
// Not a temp file since we will be resuming it
return filepath.Join(a.tempDir(), t.Oid+".tmp")
} | [
"func",
"(",
"a",
"*",
"basicDownloadAdapter",
")",
"downloadFilename",
"(",
"t",
"*",
"Transfer",
")",
"string",
"{",
"// Not a temp file since we will be resuming it",
"return",
"filepath",
".",
"Join",
"(",
"a",
".",
"tempDir",
"(",
")",
",",
"t",
".",
"Oid",
"+",
"\"",
"\"",
")",
"\n",
"}"
] | // Create or open a download file for resuming | [
"Create",
"or",
"open",
"a",
"download",
"file",
"for",
"resuming"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/tq/basic_download.go#L78-L81 | train |
git-lfs/git-lfs | errors/types.go | IsFatalError | func IsFatalError(err error) bool {
if e, ok := err.(interface {
Fatal() bool
}); ok {
return e.Fatal()
}
if parent := parentOf(err); parent != nil {
return IsFatalError(parent)
}
return false
} | go | func IsFatalError(err error) bool {
if e, ok := err.(interface {
Fatal() bool
}); ok {
return e.Fatal()
}
if parent := parentOf(err); parent != nil {
return IsFatalError(parent)
}
return false
} | [
"func",
"IsFatalError",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"e",
",",
"ok",
":=",
"err",
".",
"(",
"interface",
"{",
"Fatal",
"(",
")",
"bool",
"\n",
"}",
")",
";",
"ok",
"{",
"return",
"e",
".",
"Fatal",
"(",
")",
"\n",
"}",
"\n",
"if",
"parent",
":=",
"parentOf",
"(",
"err",
")",
";",
"parent",
"!=",
"nil",
"{",
"return",
"IsFatalError",
"(",
"parent",
")",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // IsFatalError indicates that the error is fatal and the process should exit
// immediately after handling the error. | [
"IsFatalError",
"indicates",
"that",
"the",
"error",
"is",
"fatal",
"and",
"the",
"process",
"should",
"exit",
"immediately",
"after",
"handling",
"the",
"error",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/errors/types.go#L14-L24 | train |
git-lfs/git-lfs | errors/types.go | IsSmudgeError | func IsSmudgeError(err error) bool {
if e, ok := err.(interface {
SmudgeError() bool
}); ok {
return e.SmudgeError()
}
if parent := parentOf(err); parent != nil {
return IsSmudgeError(parent)
}
return false
} | go | func IsSmudgeError(err error) bool {
if e, ok := err.(interface {
SmudgeError() bool
}); ok {
return e.SmudgeError()
}
if parent := parentOf(err); parent != nil {
return IsSmudgeError(parent)
}
return false
} | [
"func",
"IsSmudgeError",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"e",
",",
"ok",
":=",
"err",
".",
"(",
"interface",
"{",
"SmudgeError",
"(",
")",
"bool",
"\n",
"}",
")",
";",
"ok",
"{",
"return",
"e",
".",
"SmudgeError",
"(",
")",
"\n",
"}",
"\n",
"if",
"parent",
":=",
"parentOf",
"(",
"err",
")",
";",
"parent",
"!=",
"nil",
"{",
"return",
"IsSmudgeError",
"(",
"parent",
")",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // IsSmudgeError indicates an error while smudging a files. | [
"IsSmudgeError",
"indicates",
"an",
"error",
"while",
"smudging",
"a",
"files",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/errors/types.go#L55-L65 | train |
git-lfs/git-lfs | errors/types.go | IsCleanPointerError | func IsCleanPointerError(err error) bool {
if e, ok := err.(interface {
CleanPointerError() bool
}); ok {
return e.CleanPointerError()
}
if parent := parentOf(err); parent != nil {
return IsCleanPointerError(parent)
}
return false
} | go | func IsCleanPointerError(err error) bool {
if e, ok := err.(interface {
CleanPointerError() bool
}); ok {
return e.CleanPointerError()
}
if parent := parentOf(err); parent != nil {
return IsCleanPointerError(parent)
}
return false
} | [
"func",
"IsCleanPointerError",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"e",
",",
"ok",
":=",
"err",
".",
"(",
"interface",
"{",
"CleanPointerError",
"(",
")",
"bool",
"\n",
"}",
")",
";",
"ok",
"{",
"return",
"e",
".",
"CleanPointerError",
"(",
")",
"\n",
"}",
"\n",
"if",
"parent",
":=",
"parentOf",
"(",
"err",
")",
";",
"parent",
"!=",
"nil",
"{",
"return",
"IsCleanPointerError",
"(",
"parent",
")",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // IsCleanPointerError indicates an error while cleaning a file. | [
"IsCleanPointerError",
"indicates",
"an",
"error",
"while",
"cleaning",
"a",
"file",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/errors/types.go#L68-L78 | train |
git-lfs/git-lfs | errors/types.go | IsNotAPointerError | func IsNotAPointerError(err error) bool {
if e, ok := err.(interface {
NotAPointerError() bool
}); ok {
return e.NotAPointerError()
}
if parent := parentOf(err); parent != nil {
return IsNotAPointerError(parent)
}
return false
} | go | func IsNotAPointerError(err error) bool {
if e, ok := err.(interface {
NotAPointerError() bool
}); ok {
return e.NotAPointerError()
}
if parent := parentOf(err); parent != nil {
return IsNotAPointerError(parent)
}
return false
} | [
"func",
"IsNotAPointerError",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"e",
",",
"ok",
":=",
"err",
".",
"(",
"interface",
"{",
"NotAPointerError",
"(",
")",
"bool",
"\n",
"}",
")",
";",
"ok",
"{",
"return",
"e",
".",
"NotAPointerError",
"(",
")",
"\n",
"}",
"\n",
"if",
"parent",
":=",
"parentOf",
"(",
"err",
")",
";",
"parent",
"!=",
"nil",
"{",
"return",
"IsNotAPointerError",
"(",
"parent",
")",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // IsNotAPointerError indicates the parsed data is not an LFS pointer. | [
"IsNotAPointerError",
"indicates",
"the",
"parsed",
"data",
"is",
"not",
"an",
"LFS",
"pointer",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/errors/types.go#L81-L91 | train |
git-lfs/git-lfs | errors/types.go | IsBadPointerKeyError | func IsBadPointerKeyError(err error) bool {
if e, ok := err.(interface {
BadPointerKeyError() bool
}); ok {
return e.BadPointerKeyError()
}
if parent := parentOf(err); parent != nil {
return IsBadPointerKeyError(parent)
}
return false
} | go | func IsBadPointerKeyError(err error) bool {
if e, ok := err.(interface {
BadPointerKeyError() bool
}); ok {
return e.BadPointerKeyError()
}
if parent := parentOf(err); parent != nil {
return IsBadPointerKeyError(parent)
}
return false
} | [
"func",
"IsBadPointerKeyError",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"e",
",",
"ok",
":=",
"err",
".",
"(",
"interface",
"{",
"BadPointerKeyError",
"(",
")",
"bool",
"\n",
"}",
")",
";",
"ok",
"{",
"return",
"e",
".",
"BadPointerKeyError",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"parent",
":=",
"parentOf",
"(",
"err",
")",
";",
"parent",
"!=",
"nil",
"{",
"return",
"IsBadPointerKeyError",
"(",
"parent",
")",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // IsBadPointerKeyError indicates that the parsed data has an invalid key. | [
"IsBadPointerKeyError",
"indicates",
"that",
"the",
"parsed",
"data",
"has",
"an",
"invalid",
"key",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/errors/types.go#L94-L105 | train |
git-lfs/git-lfs | errors/types.go | StandardizeBadPointerError | func StandardizeBadPointerError(err error) error {
if IsBadPointerKeyError(err) {
badErr := err.(badPointerKeyError)
if badErr.Expected == "version" {
return NewNotAPointerError(err)
}
}
return err
} | go | func StandardizeBadPointerError(err error) error {
if IsBadPointerKeyError(err) {
badErr := err.(badPointerKeyError)
if badErr.Expected == "version" {
return NewNotAPointerError(err)
}
}
return err
} | [
"func",
"StandardizeBadPointerError",
"(",
"err",
"error",
")",
"error",
"{",
"if",
"IsBadPointerKeyError",
"(",
"err",
")",
"{",
"badErr",
":=",
"err",
".",
"(",
"badPointerKeyError",
")",
"\n",
"if",
"badErr",
".",
"Expected",
"==",
"\"",
"\"",
"{",
"return",
"NewNotAPointerError",
"(",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
] | // If an error is abad pointer error of any type, returns NotAPointerError | [
"If",
"an",
"error",
"is",
"abad",
"pointer",
"error",
"of",
"any",
"type",
"returns",
"NotAPointerError"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/errors/types.go#L108-L116 | train |
git-lfs/git-lfs | errors/types.go | IsUnprocessableEntityError | func IsUnprocessableEntityError(err error) bool {
if e, ok := err.(interface {
UnprocessableEntityError() bool
}); ok {
return e.UnprocessableEntityError()
}
if parent := parentOf(err); parent != nil {
return IsUnprocessableEntityError(parent)
}
return false
} | go | func IsUnprocessableEntityError(err error) bool {
if e, ok := err.(interface {
UnprocessableEntityError() bool
}); ok {
return e.UnprocessableEntityError()
}
if parent := parentOf(err); parent != nil {
return IsUnprocessableEntityError(parent)
}
return false
} | [
"func",
"IsUnprocessableEntityError",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"e",
",",
"ok",
":=",
"err",
".",
"(",
"interface",
"{",
"UnprocessableEntityError",
"(",
")",
"bool",
"\n",
"}",
")",
";",
"ok",
"{",
"return",
"e",
".",
"UnprocessableEntityError",
"(",
")",
"\n",
"}",
"\n",
"if",
"parent",
":=",
"parentOf",
"(",
"err",
")",
";",
"parent",
"!=",
"nil",
"{",
"return",
"IsUnprocessableEntityError",
"(",
"parent",
")",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // IsDownloadDeclinedError indicates that the upload operation failed because of
// an HTTP 422 response code. | [
"IsDownloadDeclinedError",
"indicates",
"that",
"the",
"upload",
"operation",
"failed",
"because",
"of",
"an",
"HTTP",
"422",
"response",
"code",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/errors/types.go#L134-L144 | train |
git-lfs/git-lfs | errors/types.go | IsRetriableError | func IsRetriableError(err error) bool {
if e, ok := err.(interface {
RetriableError() bool
}); ok {
return e.RetriableError()
}
if cause, ok := Cause(err).(*url.Error); ok {
return cause.Temporary() || cause.Timeout()
}
if parent := parentOf(err); parent != nil {
return IsRetriableError(parent)
}
return false
} | go | func IsRetriableError(err error) bool {
if e, ok := err.(interface {
RetriableError() bool
}); ok {
return e.RetriableError()
}
if cause, ok := Cause(err).(*url.Error); ok {
return cause.Temporary() || cause.Timeout()
}
if parent := parentOf(err); parent != nil {
return IsRetriableError(parent)
}
return false
} | [
"func",
"IsRetriableError",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"e",
",",
"ok",
":=",
"err",
".",
"(",
"interface",
"{",
"RetriableError",
"(",
")",
"bool",
"\n",
"}",
")",
";",
"ok",
"{",
"return",
"e",
".",
"RetriableError",
"(",
")",
"\n",
"}",
"\n",
"if",
"cause",
",",
"ok",
":=",
"Cause",
"(",
"err",
")",
".",
"(",
"*",
"url",
".",
"Error",
")",
";",
"ok",
"{",
"return",
"cause",
".",
"Temporary",
"(",
")",
"||",
"cause",
".",
"Timeout",
"(",
")",
"\n",
"}",
"\n",
"if",
"parent",
":=",
"parentOf",
"(",
"err",
")",
";",
"parent",
"!=",
"nil",
"{",
"return",
"IsRetriableError",
"(",
"parent",
")",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // IsRetriableError indicates the low level transfer had an error but the
// caller may retry the operation. | [
"IsRetriableError",
"indicates",
"the",
"low",
"level",
"transfer",
"had",
"an",
"error",
"but",
"the",
"caller",
"may",
"retry",
"the",
"operation",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/errors/types.go#L148-L161 | train |
git-lfs/git-lfs | errors/types.go | newWrappedError | func newWrappedError(err error, message string) *wrappedError {
if err == nil {
err = errors.New("Error")
}
var errWithCause errorWithCause
if len(message) > 0 {
errWithCause = errors.Wrap(err, message).(errorWithCause)
} else if ewc, ok := err.(errorWithCause); ok {
errWithCause = ewc
} else {
errWithCause = errors.Wrap(err, "LFS").(errorWithCause)
}
return &wrappedError{
context: make(map[string]interface{}),
errorWithCause: errWithCause,
}
} | go | func newWrappedError(err error, message string) *wrappedError {
if err == nil {
err = errors.New("Error")
}
var errWithCause errorWithCause
if len(message) > 0 {
errWithCause = errors.Wrap(err, message).(errorWithCause)
} else if ewc, ok := err.(errorWithCause); ok {
errWithCause = ewc
} else {
errWithCause = errors.Wrap(err, "LFS").(errorWithCause)
}
return &wrappedError{
context: make(map[string]interface{}),
errorWithCause: errWithCause,
}
} | [
"func",
"newWrappedError",
"(",
"err",
"error",
",",
"message",
"string",
")",
"*",
"wrappedError",
"{",
"if",
"err",
"==",
"nil",
"{",
"err",
"=",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"var",
"errWithCause",
"errorWithCause",
"\n\n",
"if",
"len",
"(",
"message",
")",
">",
"0",
"{",
"errWithCause",
"=",
"errors",
".",
"Wrap",
"(",
"err",
",",
"message",
")",
".",
"(",
"errorWithCause",
")",
"\n",
"}",
"else",
"if",
"ewc",
",",
"ok",
":=",
"err",
".",
"(",
"errorWithCause",
")",
";",
"ok",
"{",
"errWithCause",
"=",
"ewc",
"\n",
"}",
"else",
"{",
"errWithCause",
"=",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
".",
"(",
"errorWithCause",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"wrappedError",
"{",
"context",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
",",
"errorWithCause",
":",
"errWithCause",
",",
"}",
"\n",
"}"
] | // newWrappedError creates a wrappedError. | [
"newWrappedError",
"creates",
"a",
"wrappedError",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/errors/types.go#L190-L209 | train |
git-lfs/git-lfs | errors/types.go | Set | func (e wrappedError) Set(key string, val interface{}) {
e.context[key] = val
} | go | func (e wrappedError) Set(key string, val interface{}) {
e.context[key] = val
} | [
"func",
"(",
"e",
"wrappedError",
")",
"Set",
"(",
"key",
"string",
",",
"val",
"interface",
"{",
"}",
")",
"{",
"e",
".",
"context",
"[",
"key",
"]",
"=",
"val",
"\n",
"}"
] | // Set sets the value for the key in the context. | [
"Set",
"sets",
"the",
"value",
"for",
"the",
"key",
"in",
"the",
"context",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/errors/types.go#L212-L214 | train |
git-lfs/git-lfs | git/rev_list_scanner.go | Close | func (s *RevListScanner) Close() error {
if s.closeFn == nil {
return nil
}
return s.closeFn()
} | go | func (s *RevListScanner) Close() error {
if s.closeFn == nil {
return nil
}
return s.closeFn()
} | [
"func",
"(",
"s",
"*",
"RevListScanner",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"s",
".",
"closeFn",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"s",
".",
"closeFn",
"(",
")",
"\n",
"}"
] | // Close closes the RevListScanner by freeing any resources held by the
// instance while running, and returns any error encountered while doing so. | [
"Close",
"closes",
"the",
"RevListScanner",
"by",
"freeing",
"any",
"resources",
"held",
"by",
"the",
"instance",
"while",
"running",
"and",
"returns",
"any",
"error",
"encountered",
"while",
"doing",
"so",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/git/rev_list_scanner.go#L332-L337 | train |
git-lfs/git-lfs | lfs/gitscanner.go | Close | func (s *GitScanner) Close() {
s.mu.Lock()
defer s.mu.Unlock()
if s.closed {
return
}
s.closed = true
tracerx.PerformanceSince("scan", s.started)
} | go | func (s *GitScanner) Close() {
s.mu.Lock()
defer s.mu.Unlock()
if s.closed {
return
}
s.closed = true
tracerx.PerformanceSince("scan", s.started)
} | [
"func",
"(",
"s",
"*",
"GitScanner",
")",
"Close",
"(",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"s",
".",
"closed",
"{",
"return",
"\n",
"}",
"\n\n",
"s",
".",
"closed",
"=",
"true",
"\n",
"tracerx",
".",
"PerformanceSince",
"(",
"\"",
"\"",
",",
"s",
".",
"started",
")",
"\n",
"}"
] | // Close stops exits once all processing has stopped, and all resources are
// tracked and cleaned up. | [
"Close",
"stops",
"exits",
"once",
"all",
"processing",
"has",
"stopped",
"and",
"all",
"resources",
"are",
"tracked",
"and",
"cleaned",
"up",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/gitscanner.go#L50-L60 | train |
git-lfs/git-lfs | lfs/gitscanner.go | ScanRefs | func (s *GitScanner) ScanRefs(include, exclude []string, cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.FoundPointer)
if err != nil {
return err
}
opts := s.opts(ScanRefsMode)
opts.SkipDeletedBlobs = false
return scanRefsToChan(s, callback, include, exclude, opts)
} | go | func (s *GitScanner) ScanRefs(include, exclude []string, cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.FoundPointer)
if err != nil {
return err
}
opts := s.opts(ScanRefsMode)
opts.SkipDeletedBlobs = false
return scanRefsToChan(s, callback, include, exclude, opts)
} | [
"func",
"(",
"s",
"*",
"GitScanner",
")",
"ScanRefs",
"(",
"include",
",",
"exclude",
"[",
"]",
"string",
",",
"cb",
"GitScannerFoundPointer",
")",
"error",
"{",
"callback",
",",
"err",
":=",
"firstGitScannerCallback",
"(",
"cb",
",",
"s",
".",
"FoundPointer",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"opts",
":=",
"s",
".",
"opts",
"(",
"ScanRefsMode",
")",
"\n",
"opts",
".",
"SkipDeletedBlobs",
"=",
"false",
"\n",
"return",
"scanRefsToChan",
"(",
"s",
",",
"callback",
",",
"include",
",",
"exclude",
",",
"opts",
")",
"\n",
"}"
] | // ScanRefs through all commits reachable by refs contained in "include" and
// not reachable by any refs included in "excluded" | [
"ScanRefs",
"through",
"all",
"commits",
"reachable",
"by",
"refs",
"contained",
"in",
"include",
"and",
"not",
"reachable",
"by",
"any",
"refs",
"included",
"in",
"excluded"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/gitscanner.go#L97-L106 | train |
git-lfs/git-lfs | lfs/gitscanner.go | ScanRefRange | func (s *GitScanner) ScanRefRange(left, right string, cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.FoundPointer)
if err != nil {
return err
}
opts := s.opts(ScanRefsMode)
opts.SkipDeletedBlobs = false
return scanLeftRightToChan(s, callback, left, right, opts)
} | go | func (s *GitScanner) ScanRefRange(left, right string, cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.FoundPointer)
if err != nil {
return err
}
opts := s.opts(ScanRefsMode)
opts.SkipDeletedBlobs = false
return scanLeftRightToChan(s, callback, left, right, opts)
} | [
"func",
"(",
"s",
"*",
"GitScanner",
")",
"ScanRefRange",
"(",
"left",
",",
"right",
"string",
",",
"cb",
"GitScannerFoundPointer",
")",
"error",
"{",
"callback",
",",
"err",
":=",
"firstGitScannerCallback",
"(",
"cb",
",",
"s",
".",
"FoundPointer",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"opts",
":=",
"s",
".",
"opts",
"(",
"ScanRefsMode",
")",
"\n",
"opts",
".",
"SkipDeletedBlobs",
"=",
"false",
"\n",
"return",
"scanLeftRightToChan",
"(",
"s",
",",
"callback",
",",
"left",
",",
"right",
",",
"opts",
")",
"\n",
"}"
] | // ScanRefRange scans through all commits from the given left and right refs,
// including git objects that have been modified or deleted. | [
"ScanRefRange",
"scans",
"through",
"all",
"commits",
"from",
"the",
"given",
"left",
"and",
"right",
"refs",
"including",
"git",
"objects",
"that",
"have",
"been",
"modified",
"or",
"deleted",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/gitscanner.go#L110-L119 | train |
git-lfs/git-lfs | lfs/gitscanner.go | ScanRefWithDeleted | func (s *GitScanner) ScanRefWithDeleted(ref string, cb GitScannerFoundPointer) error {
return s.ScanRefRange(ref, "", cb)
} | go | func (s *GitScanner) ScanRefWithDeleted(ref string, cb GitScannerFoundPointer) error {
return s.ScanRefRange(ref, "", cb)
} | [
"func",
"(",
"s",
"*",
"GitScanner",
")",
"ScanRefWithDeleted",
"(",
"ref",
"string",
",",
"cb",
"GitScannerFoundPointer",
")",
"error",
"{",
"return",
"s",
".",
"ScanRefRange",
"(",
"ref",
",",
"\"",
"\"",
",",
"cb",
")",
"\n",
"}"
] | // ScanRefWithDeleted scans through all objects in the given ref, including
// git objects that have been modified or deleted. | [
"ScanRefWithDeleted",
"scans",
"through",
"all",
"objects",
"in",
"the",
"given",
"ref",
"including",
"git",
"objects",
"that",
"have",
"been",
"modified",
"or",
"deleted",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/gitscanner.go#L123-L125 | train |
git-lfs/git-lfs | lfs/gitscanner.go | ScanRef | func (s *GitScanner) ScanRef(ref string, cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.FoundPointer)
if err != nil {
return err
}
opts := s.opts(ScanRefsMode)
opts.SkipDeletedBlobs = true
return scanLeftRightToChan(s, callback, ref, "", opts)
} | go | func (s *GitScanner) ScanRef(ref string, cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.FoundPointer)
if err != nil {
return err
}
opts := s.opts(ScanRefsMode)
opts.SkipDeletedBlobs = true
return scanLeftRightToChan(s, callback, ref, "", opts)
} | [
"func",
"(",
"s",
"*",
"GitScanner",
")",
"ScanRef",
"(",
"ref",
"string",
",",
"cb",
"GitScannerFoundPointer",
")",
"error",
"{",
"callback",
",",
"err",
":=",
"firstGitScannerCallback",
"(",
"cb",
",",
"s",
".",
"FoundPointer",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"opts",
":=",
"s",
".",
"opts",
"(",
"ScanRefsMode",
")",
"\n",
"opts",
".",
"SkipDeletedBlobs",
"=",
"true",
"\n",
"return",
"scanLeftRightToChan",
"(",
"s",
",",
"callback",
",",
"ref",
",",
"\"",
"\"",
",",
"opts",
")",
"\n",
"}"
] | // ScanRef scans through all objects in the current ref, excluding git objects
// that have been modified or deleted before the ref. | [
"ScanRef",
"scans",
"through",
"all",
"objects",
"in",
"the",
"current",
"ref",
"excluding",
"git",
"objects",
"that",
"have",
"been",
"modified",
"or",
"deleted",
"before",
"the",
"ref",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/gitscanner.go#L129-L138 | train |
git-lfs/git-lfs | lfs/gitscanner.go | ScanAll | func (s *GitScanner) ScanAll(cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.FoundPointer)
if err != nil {
return err
}
opts := s.opts(ScanAllMode)
opts.SkipDeletedBlobs = false
return scanLeftRightToChan(s, callback, "", "", opts)
} | go | func (s *GitScanner) ScanAll(cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.FoundPointer)
if err != nil {
return err
}
opts := s.opts(ScanAllMode)
opts.SkipDeletedBlobs = false
return scanLeftRightToChan(s, callback, "", "", opts)
} | [
"func",
"(",
"s",
"*",
"GitScanner",
")",
"ScanAll",
"(",
"cb",
"GitScannerFoundPointer",
")",
"error",
"{",
"callback",
",",
"err",
":=",
"firstGitScannerCallback",
"(",
"cb",
",",
"s",
".",
"FoundPointer",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"opts",
":=",
"s",
".",
"opts",
"(",
"ScanAllMode",
")",
"\n",
"opts",
".",
"SkipDeletedBlobs",
"=",
"false",
"\n",
"return",
"scanLeftRightToChan",
"(",
"s",
",",
"callback",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"opts",
")",
"\n",
"}"
] | // ScanAll scans through all objects in the git repository. | [
"ScanAll",
"scans",
"through",
"all",
"objects",
"in",
"the",
"git",
"repository",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/gitscanner.go#L141-L150 | train |
git-lfs/git-lfs | lfs/gitscanner.go | ScanTree | func (s *GitScanner) ScanTree(ref string) error {
callback, err := firstGitScannerCallback(s.FoundPointer)
if err != nil {
return err
}
return runScanTree(callback, ref, s.Filter)
} | go | func (s *GitScanner) ScanTree(ref string) error {
callback, err := firstGitScannerCallback(s.FoundPointer)
if err != nil {
return err
}
return runScanTree(callback, ref, s.Filter)
} | [
"func",
"(",
"s",
"*",
"GitScanner",
")",
"ScanTree",
"(",
"ref",
"string",
")",
"error",
"{",
"callback",
",",
"err",
":=",
"firstGitScannerCallback",
"(",
"s",
".",
"FoundPointer",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"runScanTree",
"(",
"callback",
",",
"ref",
",",
"s",
".",
"Filter",
")",
"\n",
"}"
] | // ScanTree takes a ref and returns WrappedPointer objects in the tree at that
// ref. Differs from ScanRefs in that multiple files in the tree with the same
// content are all reported. | [
"ScanTree",
"takes",
"a",
"ref",
"and",
"returns",
"WrappedPointer",
"objects",
"in",
"the",
"tree",
"at",
"that",
"ref",
".",
"Differs",
"from",
"ScanRefs",
"in",
"that",
"multiple",
"files",
"in",
"the",
"tree",
"with",
"the",
"same",
"content",
"are",
"all",
"reported",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/gitscanner.go#L155-L161 | train |
git-lfs/git-lfs | lfs/gitscanner.go | ScanUnpushed | func (s *GitScanner) ScanUnpushed(remote string, cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.FoundPointer)
if err != nil {
return err
}
return scanUnpushed(callback, remote)
} | go | func (s *GitScanner) ScanUnpushed(remote string, cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.FoundPointer)
if err != nil {
return err
}
return scanUnpushed(callback, remote)
} | [
"func",
"(",
"s",
"*",
"GitScanner",
")",
"ScanUnpushed",
"(",
"remote",
"string",
",",
"cb",
"GitScannerFoundPointer",
")",
"error",
"{",
"callback",
",",
"err",
":=",
"firstGitScannerCallback",
"(",
"cb",
",",
"s",
".",
"FoundPointer",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"scanUnpushed",
"(",
"callback",
",",
"remote",
")",
"\n",
"}"
] | // ScanUnpushed scans history for all LFS pointers which have been added but not
// pushed to the named remote. remote can be left blank to mean 'any remote'. | [
"ScanUnpushed",
"scans",
"history",
"for",
"all",
"LFS",
"pointers",
"which",
"have",
"been",
"added",
"but",
"not",
"pushed",
"to",
"the",
"named",
"remote",
".",
"remote",
"can",
"be",
"left",
"blank",
"to",
"mean",
"any",
"remote",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/gitscanner.go#L165-L171 | train |
git-lfs/git-lfs | lfs/gitscanner.go | ScanIndex | func (s *GitScanner) ScanIndex(ref string, cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.FoundPointer)
if err != nil {
return err
}
return scanIndex(callback, ref, s.Filter)
} | go | func (s *GitScanner) ScanIndex(ref string, cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.FoundPointer)
if err != nil {
return err
}
return scanIndex(callback, ref, s.Filter)
} | [
"func",
"(",
"s",
"*",
"GitScanner",
")",
"ScanIndex",
"(",
"ref",
"string",
",",
"cb",
"GitScannerFoundPointer",
")",
"error",
"{",
"callback",
",",
"err",
":=",
"firstGitScannerCallback",
"(",
"cb",
",",
"s",
".",
"FoundPointer",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"scanIndex",
"(",
"callback",
",",
"ref",
",",
"s",
".",
"Filter",
")",
"\n",
"}"
] | // ScanIndex scans the git index for modified LFS objects. | [
"ScanIndex",
"scans",
"the",
"git",
"index",
"for",
"modified",
"LFS",
"objects",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/gitscanner.go#L186-L192 | train |
git-lfs/git-lfs | creds/netrc.go | newNetrcCredentialHelper | func newNetrcCredentialHelper(osEnv config.Environment) *netrcCredentialHelper {
netrcFinder, netrcfile, err := ParseNetrc(osEnv)
if err != nil {
tracerx.Printf("bad netrc file %s: %s", netrcfile, err)
return nil
}
if netrcFinder == nil {
netrcFinder = defaultNetrcFinder
}
return &netrcCredentialHelper{netrcFinder: netrcFinder, skip: make(map[string]bool)}
} | go | func newNetrcCredentialHelper(osEnv config.Environment) *netrcCredentialHelper {
netrcFinder, netrcfile, err := ParseNetrc(osEnv)
if err != nil {
tracerx.Printf("bad netrc file %s: %s", netrcfile, err)
return nil
}
if netrcFinder == nil {
netrcFinder = defaultNetrcFinder
}
return &netrcCredentialHelper{netrcFinder: netrcFinder, skip: make(map[string]bool)}
} | [
"func",
"newNetrcCredentialHelper",
"(",
"osEnv",
"config",
".",
"Environment",
")",
"*",
"netrcCredentialHelper",
"{",
"netrcFinder",
",",
"netrcfile",
",",
"err",
":=",
"ParseNetrc",
"(",
"osEnv",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"tracerx",
".",
"Printf",
"(",
"\"",
"\"",
",",
"netrcfile",
",",
"err",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"netrcFinder",
"==",
"nil",
"{",
"netrcFinder",
"=",
"defaultNetrcFinder",
"\n",
"}",
"\n\n",
"return",
"&",
"netrcCredentialHelper",
"{",
"netrcFinder",
":",
"netrcFinder",
",",
"skip",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",
"}",
"\n",
"}"
] | // NewNetrcCredentialHelper creates a new netrc credential helper using a
// .netrc file gleaned from the OS environment | [
"NewNetrcCredentialHelper",
"creates",
"a",
"new",
"netrc",
"credential",
"helper",
"using",
"a",
".",
"netrc",
"file",
"gleaned",
"from",
"the",
"OS",
"environment"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/creds/netrc.go#L49-L61 | train |
git-lfs/git-lfs | lfs/util.go | NewRepoToCurrentPathConverter | func NewRepoToCurrentPathConverter(cfg *config.Configuration) (PathConverter, error) {
r, c, p, err := pathConverterArgs(cfg)
if err != nil {
return nil, err
}
return &repoToCurrentPathConverter{
repoDir: r,
currDir: c,
passthrough: p,
}, nil
} | go | func NewRepoToCurrentPathConverter(cfg *config.Configuration) (PathConverter, error) {
r, c, p, err := pathConverterArgs(cfg)
if err != nil {
return nil, err
}
return &repoToCurrentPathConverter{
repoDir: r,
currDir: c,
passthrough: p,
}, nil
} | [
"func",
"NewRepoToCurrentPathConverter",
"(",
"cfg",
"*",
"config",
".",
"Configuration",
")",
"(",
"PathConverter",
",",
"error",
")",
"{",
"r",
",",
"c",
",",
"p",
",",
"err",
":=",
"pathConverterArgs",
"(",
"cfg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"repoToCurrentPathConverter",
"{",
"repoDir",
":",
"r",
",",
"currDir",
":",
"c",
",",
"passthrough",
":",
"p",
",",
"}",
",",
"nil",
"\n",
"}"
] | // Convert filenames expressed relative to the root of the repo relative to the
// current working dir. Useful when needing to calling git with results from a rooted command,
// but the user is in a subdir of their repo
// Pass in a channel which you will fill with relative files & receive a channel which will get results | [
"Convert",
"filenames",
"expressed",
"relative",
"to",
"the",
"root",
"of",
"the",
"repo",
"relative",
"to",
"the",
"current",
"working",
"dir",
".",
"Useful",
"when",
"needing",
"to",
"calling",
"git",
"with",
"results",
"from",
"a",
"rooted",
"command",
"but",
"the",
"user",
"is",
"in",
"a",
"subdir",
"of",
"their",
"repo",
"Pass",
"in",
"a",
"channel",
"which",
"you",
"will",
"fill",
"with",
"relative",
"files",
"&",
"receive",
"a",
"channel",
"which",
"will",
"get",
"results"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/util.go#L102-L113 | train |
git-lfs/git-lfs | lfs/util.go | NewCurrentToRepoPathConverter | func NewCurrentToRepoPathConverter(cfg *config.Configuration) (PathConverter, error) {
r, c, p, err := pathConverterArgs(cfg)
if err != nil {
return nil, err
}
return ¤tToRepoPathConverter{
repoDir: r,
currDir: c,
passthrough: p,
}, nil
} | go | func NewCurrentToRepoPathConverter(cfg *config.Configuration) (PathConverter, error) {
r, c, p, err := pathConverterArgs(cfg)
if err != nil {
return nil, err
}
return ¤tToRepoPathConverter{
repoDir: r,
currDir: c,
passthrough: p,
}, nil
} | [
"func",
"NewCurrentToRepoPathConverter",
"(",
"cfg",
"*",
"config",
".",
"Configuration",
")",
"(",
"PathConverter",
",",
"error",
")",
"{",
"r",
",",
"c",
",",
"p",
",",
"err",
":=",
"pathConverterArgs",
"(",
"cfg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"currentToRepoPathConverter",
"{",
"repoDir",
":",
"r",
",",
"currDir",
":",
"c",
",",
"passthrough",
":",
"p",
",",
"}",
",",
"nil",
"\n",
"}"
] | // Convert filenames expressed relative to the current directory to be
// relative to the repo root. Useful when calling git with arguments that requires them
// to be rooted but the user is in a subdir of their repo & expects to use relative args
// Pass in a channel which you will fill with relative files & receive a channel which will get results | [
"Convert",
"filenames",
"expressed",
"relative",
"to",
"the",
"current",
"directory",
"to",
"be",
"relative",
"to",
"the",
"repo",
"root",
".",
"Useful",
"when",
"calling",
"git",
"with",
"arguments",
"that",
"requires",
"them",
"to",
"be",
"rooted",
"but",
"the",
"user",
"is",
"in",
"a",
"subdir",
"of",
"their",
"repo",
"&",
"expects",
"to",
"use",
"relative",
"args",
"Pass",
"in",
"a",
"channel",
"which",
"you",
"will",
"fill",
"with",
"relative",
"files",
"&",
"receive",
"a",
"channel",
"which",
"will",
"get",
"results"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfs/util.go#L139-L150 | train |
git-lfs/git-lfs | config/os_fetcher.go | Get | func (o *OsFetcher) Get(key string) (val string, ok bool) {
o.vmu.Lock()
defer o.vmu.Unlock()
if i, ok := o.vals[key]; ok {
if i == nil {
return "", false
}
return *i, true
}
v, ok := os.LookupEnv(key)
if ok {
o.vals[key] = &v
} else {
o.vals[key] = nil
}
return v, ok
} | go | func (o *OsFetcher) Get(key string) (val string, ok bool) {
o.vmu.Lock()
defer o.vmu.Unlock()
if i, ok := o.vals[key]; ok {
if i == nil {
return "", false
}
return *i, true
}
v, ok := os.LookupEnv(key)
if ok {
o.vals[key] = &v
} else {
o.vals[key] = nil
}
return v, ok
} | [
"func",
"(",
"o",
"*",
"OsFetcher",
")",
"Get",
"(",
"key",
"string",
")",
"(",
"val",
"string",
",",
"ok",
"bool",
")",
"{",
"o",
".",
"vmu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"o",
".",
"vmu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"i",
",",
"ok",
":=",
"o",
".",
"vals",
"[",
"key",
"]",
";",
"ok",
"{",
"if",
"i",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"i",
",",
"true",
"\n",
"}",
"\n\n",
"v",
",",
"ok",
":=",
"os",
".",
"LookupEnv",
"(",
"key",
")",
"\n",
"if",
"ok",
"{",
"o",
".",
"vals",
"[",
"key",
"]",
"=",
"&",
"v",
"\n",
"}",
"else",
"{",
"o",
".",
"vals",
"[",
"key",
"]",
"=",
"nil",
"\n",
"}",
"\n\n",
"return",
"v",
",",
"ok",
"\n",
"}"
] | // Get returns the value associated with the given key as stored in the local
// cache, or in the operating system's environment variables.
//
// If there was a cache-hit, the value will be returned from the cache, skipping
// a check against os.Getenv. Otherwise, the value will be fetched from the
// system, stored in the cache, and then returned. If no value was present in
// the cache or in the system, an empty string will be returned.
//
// Get is safe to call across multiple goroutines. | [
"Get",
"returns",
"the",
"value",
"associated",
"with",
"the",
"given",
"key",
"as",
"stored",
"in",
"the",
"local",
"cache",
"or",
"in",
"the",
"operating",
"system",
"s",
"environment",
"variables",
".",
"If",
"there",
"was",
"a",
"cache",
"-",
"hit",
"the",
"value",
"will",
"be",
"returned",
"from",
"the",
"cache",
"skipping",
"a",
"check",
"against",
"os",
".",
"Getenv",
".",
"Otherwise",
"the",
"value",
"will",
"be",
"fetched",
"from",
"the",
"system",
"stored",
"in",
"the",
"cache",
"and",
"then",
"returned",
".",
"If",
"no",
"value",
"was",
"present",
"in",
"the",
"cache",
"or",
"in",
"the",
"system",
"an",
"empty",
"string",
"will",
"be",
"returned",
".",
"Get",
"is",
"safe",
"to",
"call",
"across",
"multiple",
"goroutines",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/config/os_fetcher.go#L36-L55 | train |
git-lfs/git-lfs | commands/run.go | Run | func Run() int {
log.SetOutput(ErrorWriter)
root := NewCommand("git-lfs", gitlfsCommand)
root.PreRun = nil
// Set up help/usage funcs based on manpage text
helpcmd := &cobra.Command{
Use: "help [command]",
Short: "Help about any command",
Long: `Help provides help for any command in the application.
Simply type ` + root.Name() + ` help [path to command] for full details.`,
Run: func(c *cobra.Command, args []string) {
cmd, _, e := c.Root().Find(args)
if cmd == nil || e != nil {
c.Printf("Unknown help topic %#q\n", args)
c.Root().Usage()
} else {
c.HelpFunc()(cmd, args)
}
},
}
root.SetHelpCommand(helpcmd)
root.SetHelpTemplate("{{.UsageString}}")
root.SetHelpFunc(helpCommand)
root.SetUsageFunc(usageCommand)
root.Flags().BoolVarP(&rootVersion, "version", "v", false, "")
cfg = config.New()
for _, f := range commandFuncs {
if cmd := f(); cmd != nil {
root.AddCommand(cmd)
}
}
err := root.Execute()
closeAPIClient()
if err != nil {
return 127
}
return 0
} | go | func Run() int {
log.SetOutput(ErrorWriter)
root := NewCommand("git-lfs", gitlfsCommand)
root.PreRun = nil
// Set up help/usage funcs based on manpage text
helpcmd := &cobra.Command{
Use: "help [command]",
Short: "Help about any command",
Long: `Help provides help for any command in the application.
Simply type ` + root.Name() + ` help [path to command] for full details.`,
Run: func(c *cobra.Command, args []string) {
cmd, _, e := c.Root().Find(args)
if cmd == nil || e != nil {
c.Printf("Unknown help topic %#q\n", args)
c.Root().Usage()
} else {
c.HelpFunc()(cmd, args)
}
},
}
root.SetHelpCommand(helpcmd)
root.SetHelpTemplate("{{.UsageString}}")
root.SetHelpFunc(helpCommand)
root.SetUsageFunc(usageCommand)
root.Flags().BoolVarP(&rootVersion, "version", "v", false, "")
cfg = config.New()
for _, f := range commandFuncs {
if cmd := f(); cmd != nil {
root.AddCommand(cmd)
}
}
err := root.Execute()
closeAPIClient()
if err != nil {
return 127
}
return 0
} | [
"func",
"Run",
"(",
")",
"int",
"{",
"log",
".",
"SetOutput",
"(",
"ErrorWriter",
")",
"\n\n",
"root",
":=",
"NewCommand",
"(",
"\"",
"\"",
",",
"gitlfsCommand",
")",
"\n",
"root",
".",
"PreRun",
"=",
"nil",
"\n\n",
"// Set up help/usage funcs based on manpage text",
"helpcmd",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Long",
":",
"`Help provides help for any command in the application.\nSimply type `",
"+",
"root",
".",
"Name",
"(",
")",
"+",
"` help [path to command] for full details.`",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"cmd",
",",
"_",
",",
"e",
":=",
"c",
".",
"Root",
"(",
")",
".",
"Find",
"(",
"args",
")",
"\n",
"if",
"cmd",
"==",
"nil",
"||",
"e",
"!=",
"nil",
"{",
"c",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"args",
")",
"\n",
"c",
".",
"Root",
"(",
")",
".",
"Usage",
"(",
")",
"\n",
"}",
"else",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"cmd",
",",
"args",
")",
"\n",
"}",
"\n",
"}",
",",
"}",
"\n\n",
"root",
".",
"SetHelpCommand",
"(",
"helpcmd",
")",
"\n\n",
"root",
".",
"SetHelpTemplate",
"(",
"\"",
"\"",
")",
"\n",
"root",
".",
"SetHelpFunc",
"(",
"helpCommand",
")",
"\n",
"root",
".",
"SetUsageFunc",
"(",
"usageCommand",
")",
"\n\n",
"root",
".",
"Flags",
"(",
")",
".",
"BoolVarP",
"(",
"&",
"rootVersion",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"false",
",",
"\"",
"\"",
")",
"\n\n",
"cfg",
"=",
"config",
".",
"New",
"(",
")",
"\n\n",
"for",
"_",
",",
"f",
":=",
"range",
"commandFuncs",
"{",
"if",
"cmd",
":=",
"f",
"(",
")",
";",
"cmd",
"!=",
"nil",
"{",
"root",
".",
"AddCommand",
"(",
"cmd",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"err",
":=",
"root",
".",
"Execute",
"(",
")",
"\n",
"closeAPIClient",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"127",
"\n",
"}",
"\n",
"return",
"0",
"\n",
"}"
] | // Run initializes the 'git-lfs' command and runs it with the given stdin and
// command line args.
//
// It returns an exit code. | [
"Run",
"initializes",
"the",
"git",
"-",
"lfs",
"command",
"and",
"runs",
"it",
"with",
"the",
"given",
"stdin",
"and",
"command",
"line",
"args",
".",
"It",
"returns",
"an",
"exit",
"code",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/commands/run.go#L57-L104 | train |
git-lfs/git-lfs | lfsapi/auth.go | DoWithAuth | func (c *Client) DoWithAuth(remote string, access Access, req *http.Request) (*http.Response, error) {
res, err := c.doWithAuth(remote, access, req, nil)
if errors.IsAuthError(err) {
if len(req.Header.Get("Authorization")) == 0 {
// This case represents a rejected request that
// should have been authenticated but wasn't. Do
// not count this against our redirection
// maximum.
newAccess := c.Endpoints.AccessFor(access.url)
tracerx.Printf("api: http response indicates %q authentication. Resubmitting...", newAccess.Mode())
return c.DoWithAuth(remote, newAccess, req)
}
}
return res, err
} | go | func (c *Client) DoWithAuth(remote string, access Access, req *http.Request) (*http.Response, error) {
res, err := c.doWithAuth(remote, access, req, nil)
if errors.IsAuthError(err) {
if len(req.Header.Get("Authorization")) == 0 {
// This case represents a rejected request that
// should have been authenticated but wasn't. Do
// not count this against our redirection
// maximum.
newAccess := c.Endpoints.AccessFor(access.url)
tracerx.Printf("api: http response indicates %q authentication. Resubmitting...", newAccess.Mode())
return c.DoWithAuth(remote, newAccess, req)
}
}
return res, err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DoWithAuth",
"(",
"remote",
"string",
",",
"access",
"Access",
",",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"res",
",",
"err",
":=",
"c",
".",
"doWithAuth",
"(",
"remote",
",",
"access",
",",
"req",
",",
"nil",
")",
"\n\n",
"if",
"errors",
".",
"IsAuthError",
"(",
"err",
")",
"{",
"if",
"len",
"(",
"req",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
")",
"==",
"0",
"{",
"// This case represents a rejected request that",
"// should have been authenticated but wasn't. Do",
"// not count this against our redirection",
"// maximum.",
"newAccess",
":=",
"c",
".",
"Endpoints",
".",
"AccessFor",
"(",
"access",
".",
"url",
")",
"\n",
"tracerx",
".",
"Printf",
"(",
"\"",
"\"",
",",
"newAccess",
".",
"Mode",
"(",
")",
")",
"\n",
"return",
"c",
".",
"DoWithAuth",
"(",
"remote",
",",
"newAccess",
",",
"req",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"res",
",",
"err",
"\n",
"}"
] | // DoWithAuth sends an HTTP request to get an HTTP response. It attempts to add
// authentication from netrc or git's credential helpers if necessary,
// supporting basic and ntlm authentication. | [
"DoWithAuth",
"sends",
"an",
"HTTP",
"request",
"to",
"get",
"an",
"HTTP",
"response",
".",
"It",
"attempts",
"to",
"add",
"authentication",
"from",
"netrc",
"or",
"git",
"s",
"credential",
"helpers",
"if",
"necessary",
"supporting",
"basic",
"and",
"ntlm",
"authentication",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfsapi/auth.go#L24-L40 | train |
git-lfs/git-lfs | lfsapi/auth.go | DoWithAuthNoRetry | func (c *Client) DoWithAuthNoRetry(remote string, access Access, req *http.Request) (*http.Response, error) {
return c.doWithAuth(remote, access, req, nil)
} | go | func (c *Client) DoWithAuthNoRetry(remote string, access Access, req *http.Request) (*http.Response, error) {
return c.doWithAuth(remote, access, req, nil)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DoWithAuthNoRetry",
"(",
"remote",
"string",
",",
"access",
"Access",
",",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"return",
"c",
".",
"doWithAuth",
"(",
"remote",
",",
"access",
",",
"req",
",",
"nil",
")",
"\n",
"}"
] | // DoWithAuthNoRetry sends an HTTP request to get an HTTP response. It works in
// the same way as DoWithAuth, but will not retry the request if it fails with
// an authorization error. | [
"DoWithAuthNoRetry",
"sends",
"an",
"HTTP",
"request",
"to",
"get",
"an",
"HTTP",
"response",
".",
"It",
"works",
"in",
"the",
"same",
"way",
"as",
"DoWithAuth",
"but",
"will",
"not",
"retry",
"the",
"request",
"if",
"it",
"fails",
"with",
"an",
"authorization",
"error",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfsapi/auth.go#L45-L47 | train |
git-lfs/git-lfs | lfsapi/auth.go | DoAPIRequestWithAuth | func (c *Client) DoAPIRequestWithAuth(remote string, req *http.Request) (*http.Response, error) {
operation := getReqOperation(req)
apiEndpoint := c.Endpoints.Endpoint(operation, remote)
access := c.Endpoints.AccessFor(apiEndpoint.Url)
return c.DoWithAuth(remote, access, req)
} | go | func (c *Client) DoAPIRequestWithAuth(remote string, req *http.Request) (*http.Response, error) {
operation := getReqOperation(req)
apiEndpoint := c.Endpoints.Endpoint(operation, remote)
access := c.Endpoints.AccessFor(apiEndpoint.Url)
return c.DoWithAuth(remote, access, req)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DoAPIRequestWithAuth",
"(",
"remote",
"string",
",",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"operation",
":=",
"getReqOperation",
"(",
"req",
")",
"\n",
"apiEndpoint",
":=",
"c",
".",
"Endpoints",
".",
"Endpoint",
"(",
"operation",
",",
"remote",
")",
"\n",
"access",
":=",
"c",
".",
"Endpoints",
".",
"AccessFor",
"(",
"apiEndpoint",
".",
"Url",
")",
"\n",
"return",
"c",
".",
"DoWithAuth",
"(",
"remote",
",",
"access",
",",
"req",
")",
"\n",
"}"
] | // DoAPIRequestWithAuth sends an HTTP request to get an HTTP response similarly
// to DoWithAuth, but using the LFS API endpoint for the provided remote and
// operation to determine the access mode. | [
"DoAPIRequestWithAuth",
"sends",
"an",
"HTTP",
"request",
"to",
"get",
"an",
"HTTP",
"response",
"similarly",
"to",
"DoWithAuth",
"but",
"using",
"the",
"LFS",
"API",
"endpoint",
"for",
"the",
"provided",
"remote",
"and",
"operation",
"to",
"determine",
"the",
"access",
"mode",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfsapi/auth.go#L52-L57 | train |
git-lfs/git-lfs | lfshttp/ssh.go | sshParseShellCommand | func sshParseShellCommand(command string, existing string) (ssh string, cmd string, needShell bool) {
ssh = existing
if cmdArgs := tools.QuotedFields(command); len(cmdArgs) > 0 {
needShell = true
ssh = cmdArgs[0]
cmd = command
}
return
} | go | func sshParseShellCommand(command string, existing string) (ssh string, cmd string, needShell bool) {
ssh = existing
if cmdArgs := tools.QuotedFields(command); len(cmdArgs) > 0 {
needShell = true
ssh = cmdArgs[0]
cmd = command
}
return
} | [
"func",
"sshParseShellCommand",
"(",
"command",
"string",
",",
"existing",
"string",
")",
"(",
"ssh",
"string",
",",
"cmd",
"string",
",",
"needShell",
"bool",
")",
"{",
"ssh",
"=",
"existing",
"\n",
"if",
"cmdArgs",
":=",
"tools",
".",
"QuotedFields",
"(",
"command",
")",
";",
"len",
"(",
"cmdArgs",
")",
">",
"0",
"{",
"needShell",
"=",
"true",
"\n",
"ssh",
"=",
"cmdArgs",
"[",
"0",
"]",
"\n",
"cmd",
"=",
"command",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // Parse command, and if it looks like a valid command, return the ssh binary
// name, the command to run, and whether we need a shell. If not, return
// existing as the ssh binary name. | [
"Parse",
"command",
"and",
"if",
"it",
"looks",
"like",
"a",
"valid",
"command",
"return",
"the",
"ssh",
"binary",
"name",
"the",
"command",
"to",
"run",
"and",
"whether",
"we",
"need",
"a",
"shell",
".",
"If",
"not",
"return",
"existing",
"as",
"the",
"ssh",
"binary",
"name",
"."
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfshttp/ssh.go#L141-L149 | train |
git-lfs/git-lfs | config/extension.go | SortExtensions | func SortExtensions(m map[string]Extension) ([]Extension, error) {
pMap := make(map[int]Extension)
priorities := make([]int, 0, len(m))
for n, ext := range m {
p := ext.Priority
if _, exist := pMap[p]; exist {
err := fmt.Errorf("duplicate priority %d on %s", p, n)
return nil, err
}
pMap[p] = ext
priorities = append(priorities, p)
}
sort.Ints(priorities)
result := make([]Extension, len(priorities))
for i, p := range priorities {
result[i] = pMap[p]
}
return result, nil
} | go | func SortExtensions(m map[string]Extension) ([]Extension, error) {
pMap := make(map[int]Extension)
priorities := make([]int, 0, len(m))
for n, ext := range m {
p := ext.Priority
if _, exist := pMap[p]; exist {
err := fmt.Errorf("duplicate priority %d on %s", p, n)
return nil, err
}
pMap[p] = ext
priorities = append(priorities, p)
}
sort.Ints(priorities)
result := make([]Extension, len(priorities))
for i, p := range priorities {
result[i] = pMap[p]
}
return result, nil
} | [
"func",
"SortExtensions",
"(",
"m",
"map",
"[",
"string",
"]",
"Extension",
")",
"(",
"[",
"]",
"Extension",
",",
"error",
")",
"{",
"pMap",
":=",
"make",
"(",
"map",
"[",
"int",
"]",
"Extension",
")",
"\n",
"priorities",
":=",
"make",
"(",
"[",
"]",
"int",
",",
"0",
",",
"len",
"(",
"m",
")",
")",
"\n",
"for",
"n",
",",
"ext",
":=",
"range",
"m",
"{",
"p",
":=",
"ext",
".",
"Priority",
"\n",
"if",
"_",
",",
"exist",
":=",
"pMap",
"[",
"p",
"]",
";",
"exist",
"{",
"err",
":=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"p",
",",
"n",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"pMap",
"[",
"p",
"]",
"=",
"ext",
"\n",
"priorities",
"=",
"append",
"(",
"priorities",
",",
"p",
")",
"\n",
"}",
"\n\n",
"sort",
".",
"Ints",
"(",
"priorities",
")",
"\n\n",
"result",
":=",
"make",
"(",
"[",
"]",
"Extension",
",",
"len",
"(",
"priorities",
")",
")",
"\n",
"for",
"i",
",",
"p",
":=",
"range",
"priorities",
"{",
"result",
"[",
"i",
"]",
"=",
"pMap",
"[",
"p",
"]",
"\n",
"}",
"\n\n",
"return",
"result",
",",
"nil",
"\n",
"}"
] | // SortExtensions sorts a map of extensions in ascending order by Priority | [
"SortExtensions",
"sorts",
"a",
"map",
"of",
"extensions",
"in",
"ascending",
"order",
"by",
"Priority"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/config/extension.go#L18-L39 | train |
git-lfs/git-lfs | lfshttp/certs.go | isCertVerificationDisabledForHost | func isCertVerificationDisabledForHost(c *Client, host string) bool {
hostSslVerify, _ := c.uc.Get("http", fmt.Sprintf("https://%v", host), "sslverify")
if hostSslVerify == "false" {
return true
}
return c.SkipSSLVerify
} | go | func isCertVerificationDisabledForHost(c *Client, host string) bool {
hostSslVerify, _ := c.uc.Get("http", fmt.Sprintf("https://%v", host), "sslverify")
if hostSslVerify == "false" {
return true
}
return c.SkipSSLVerify
} | [
"func",
"isCertVerificationDisabledForHost",
"(",
"c",
"*",
"Client",
",",
"host",
"string",
")",
"bool",
"{",
"hostSslVerify",
",",
"_",
":=",
"c",
".",
"uc",
".",
"Get",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"host",
")",
",",
"\"",
"\"",
")",
"\n",
"if",
"hostSslVerify",
"==",
"\"",
"\"",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"c",
".",
"SkipSSLVerify",
"\n",
"}"
] | // isCertVerificationDisabledForHost returns whether SSL certificate verification
// has been disabled for the given host, or globally | [
"isCertVerificationDisabledForHost",
"returns",
"whether",
"SSL",
"certificate",
"verification",
"has",
"been",
"disabled",
"for",
"the",
"given",
"host",
"or",
"globally"
] | fe8f7002c6efb083feadc0a078fa2fbb389127c7 | https://github.com/git-lfs/git-lfs/blob/fe8f7002c6efb083feadc0a078fa2fbb389127c7/lfshttp/certs.go#L18-L25 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.