Skip to content

Commit

Permalink
config,lfsapi: return last element of gitconfig, not first
Browse files Browse the repository at this point in the history
  • Loading branch information
ttaylorr committed Apr 14, 2017
1 parent 8b2964f commit 34d590c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions config/git_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func ReadGitConfig(configs ...*GitConfig) (gf *GitFetcher, extensions map[string
key, val := strings.ToLower(pieces[0]), pieces[1]

if origKey, ok := uniqKeys[key]; ok {
if ShowConfigWarnings && len(vals[key]) > 0 && vals[key][0] != val && strings.HasPrefix(key, gitConfigWarningPrefix) {
if ShowConfigWarnings && len(vals[key]) > 0 && vals[key][len(vals[key])-1] != val && strings.HasPrefix(key, gitConfigWarningPrefix) {
fmt.Fprintf(os.Stderr, "WARNING: These git config values clash:\n")
fmt.Fprintf(os.Stderr, " git config %q = %q\n", origKey, vals[key])
fmt.Fprintf(os.Stderr, " git config %q = %q\n", pieces[0], val)
Expand Down Expand Up @@ -124,7 +124,7 @@ func (g *GitFetcher) Get(key string) (val string, ok bool) {
if len(all) == 0 {
return "", false
}
return all[0], true
return all[len(all)-1], true
}

func (g *GitFetcher) GetAll(key string) []string {
Expand Down
2 changes: 1 addition & 1 deletion config/map_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (m mapFetcher) Get(key string) (val string, ok bool) {
if len(all) == 0 {
return "", false
}
return all[0], true
return all[len(all)-1], true
}

// Get implements the func `Fetcher.GetAll`.
Expand Down
4 changes: 2 additions & 2 deletions lfsapi/endpoint_finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ func initAliases(e *endpointGitFinder, git Env) {
if len(gitval) == 0 || !(strings.HasPrefix(gitkey, prefix) && strings.HasSuffix(gitkey, suffix)) {
continue
}
if _, ok := e.aliases[gitval[0]]; ok {
if _, ok := e.aliases[gitval[len(gitval)-1]]; ok {
fmt.Fprintf(os.Stderr, "WARNING: Multiple 'url.*.insteadof' keys with the same alias: %q\n", gitval)
}
e.aliases[gitval[0]] = gitkey[len(prefix) : len(gitkey)-len(suffix)]
e.aliases[gitval[len(gitval)-1]] = gitkey[len(prefix) : len(gitkey)-len(suffix)]
}
}
2 changes: 1 addition & 1 deletion lfsapi/lfsapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (e TestEnv) Get(key string) (string, bool) {
if len(all) == 0 {
return "", false
}
return all[0], true
return all[len(all)-1], true
}

func (e TestEnv) GetAll(key string) []string {
Expand Down

0 comments on commit 34d590c

Please sign in to comment.