From be550fcea5fba68b475c9910be3cc7b66e65a426 Mon Sep 17 00:00:00 2001 From: hyokeun Date: Fri, 21 Dec 2018 14:52:39 +0900 Subject: [PATCH] Imported Upstream version 2.5.2 --- CHANGELOG.md | 13 +++++++++++++ commands/command_track.go | 4 ++-- config/version.go | 2 +- debian/changelog | 6 ++++++ lfsapi/endpoint.go | 6 +++++- lfsapi/endpoint_finder_test.go | 12 ++++++++++++ rpm/SPECS/git-lfs.spec | 2 +- script/packagecloud.rb | 11 ++++++----- t/t-content-type.sh | 2 ++ t/t-track.sh | 25 +++++++++++++++++++++++++ t/t-untrack.sh | 32 ++++++++++++++++++++++++++++---- tq/basic_upload.go | 22 +++++++++++++--------- versioninfo.json | 4 ++-- 13 files changed, 116 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b98e9ac..74363c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Git LFS Changelog +## 2.5.2 (17 September, 2018) + +### Bugs + +* config: Treat [host:port]:path URLs correctly #3226 (@saschpe) +* tq: Always provide a Content-Type when uploading files #3201 (@bk2204) +* commands/track: Properly `lfs track` files with escaped characters in their + name #3192 (@leonid-s-usov) + +### Misc + +* packagecloud.rb: remove older versions #3210 (@andyneff) + ## 2.5.1 (2 August, 2018) This release contains miscellaneous bug fixes since v2.5.0. Most notably, diff --git a/commands/command_track.go b/commands/command_track.go index 8d160dc..56c49b6 100644 --- a/commands/command_track.go +++ b/commands/command_track.go @@ -72,7 +72,7 @@ ArgsLoop: pattern := trimCurrentPrefix(cleanRootPath(unsanitizedPattern)) if !trackNoModifyAttrsFlag { for _, known := range knownPatterns { - if known.Path == filepath.Join(relpath, pattern) && + if unescapeAttrPattern(known.Path) == filepath.Join(relpath, pattern) && ((trackLockableFlag && known.Lockable) || // enabling lockable & already lockable (no change) (trackNotLockableFlag && !known.Lockable) || // disabling lockable & not lockable (no change) (!trackLockableFlag && !trackNotLockableFlag)) { // leave lockable as-is in all cases @@ -132,7 +132,7 @@ ArgsLoop: continue } - pattern := fields[0] + pattern := unescapeAttrPattern(fields[0]) if newline, ok := changedAttribLines[pattern]; ok { // Replace this line (newline already embedded) attributesFile.WriteString(newline) diff --git a/config/version.go b/config/version.go index 16b6410..31eb8dc 100644 --- a/config/version.go +++ b/config/version.go @@ -12,7 +12,7 @@ var ( ) const ( - Version = "2.5.1" + Version = "2.5.2" ) func init() { diff --git a/debian/changelog b/debian/changelog index 1bb2e38..0137c33 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +git-lfs (2.5.2) stable; urgency=low + + * New upstream version + + -- Taylor Blau Mon, 17 Sep 2018 14:29:00 +0000 + git-lfs (2.5.1) stable; urgency=low * New upstream version diff --git a/lfsapi/endpoint.go b/lfsapi/endpoint.go index 7ecb159..e961a09 100644 --- a/lfsapi/endpoint.go +++ b/lfsapi/endpoint.go @@ -33,7 +33,8 @@ func endpointOperation(e Endpoint, method string) string { // endpointFromBareSshUrl constructs a new endpoint from a bare SSH URL: // -// user@host.com:path/to/repo.git +// user@host.com:path/to/repo.git or +// [user@host.com:port]:path/to/repo.git // func endpointFromBareSshUrl(rawurl string) Endpoint { parts := strings.Split(rawurl, ":") @@ -45,6 +46,9 @@ func endpointFromBareSshUrl(rawurl string) Endpoint { // Treat presence of ':' as a bare URL var newPath string if len(parts) > 2 { // port included; really should only ever be 3 parts + // Correctly handle [host:port]:path URLs + parts[0] = strings.TrimPrefix(parts[0], "[") + parts[1] = strings.TrimSuffix(parts[1], "]") newPath = fmt.Sprintf("%v:%v", parts[0], strings.Join(parts[1:], "/")) } else { newPath = strings.Join(parts, "/") diff --git a/lfsapi/endpoint_finder_test.go b/lfsapi/endpoint_finder_test.go index 3ff6f09..f9df4dc 100644 --- a/lfsapi/endpoint_finder_test.go +++ b/lfsapi/endpoint_finder_test.go @@ -177,6 +177,18 @@ func TestBareSSHEndpointAddsLfsSuffix(t *testing.T) { assert.Equal(t, "", e.SshPort) } +func TestBareSSSHEndpointWithCustomPortInBrackets(t *testing.T) { + finder := NewEndpointFinder(NewContext(nil, nil, map[string]string{ + "remote.origin.url": "[git@example.com:2222]:foo/bar.git", + })) + + e := finder.Endpoint("download", "") + assert.Equal(t, "https://example.com/foo/bar.git/info/lfs", e.Url) + assert.Equal(t, "git@example.com", e.SshUserAndHost) + assert.Equal(t, "foo/bar.git", e.SshPath) + assert.Equal(t, "2222", e.SshPort) +} + func TestSSHEndpointFromGlobalLfsUrl(t *testing.T) { finder := NewEndpointFinder(NewContext(nil, nil, map[string]string{ "lfs.url": "git@example.com:foo/bar.git", diff --git a/rpm/SPECS/git-lfs.spec b/rpm/SPECS/git-lfs.spec index c8cebdb..c509b67 100644 --- a/rpm/SPECS/git-lfs.spec +++ b/rpm/SPECS/git-lfs.spec @@ -1,5 +1,5 @@ Name: git-lfs -Version: 2.5.1 +Version: 2.5.2 Release: 1%{?dist} Summary: Git extension for versioning large files diff --git a/script/packagecloud.rb b/script/packagecloud.rb index 1b8b138..9563012 100644 --- a/script/packagecloud.rb +++ b/script/packagecloud.rb @@ -33,11 +33,11 @@ $distro_name_map = { ), "centos/7" => %w( el/7 - fedora/22 - fedora/23 - fedora/24 - fedora/25 - fedora/26 + fedora/27 + fedora/28 + opensuse/42.3 + sles/11.4 + sles/12.3 ), "debian/7" => %w( debian/wheezy @@ -58,6 +58,7 @@ $distro_name_map = { linuxmint/serena linuxmint/sonya linuxmint/sylvia + linuxmint/tara ubuntu/xenial ubuntu/yakkety ubuntu/zesty diff --git a/t/t-content-type.sh b/t/t-content-type.sh index 3b0faea..6c172fd 100755 --- a/t/t-content-type.sh +++ b/t/t-content-type.sh @@ -20,6 +20,7 @@ begin_test "content-type: is enabled by default" GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log [ 1 -eq "$(grep -c "Content-Type: application/x-gzip" push.log)" ] + [ 0 -eq "$(grep -c "Content-Type: application/octet-stream" push.log)" ] ) end_test @@ -42,6 +43,7 @@ begin_test "content-type: is disabled by configuration" GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log [ 0 -eq "$(grep -c "Content-Type: application/x-gzip" push.log)" ] + [ 1 -eq "$(grep -c "Content-Type: application/octet-stream" push.log)" ] ) end_test diff --git a/t/t-track.sh b/t/t-track.sh index 021ad49..1ae9835 100755 --- a/t/t-track.sh +++ b/t/t-track.sh @@ -595,3 +595,28 @@ begin_test "track (system gitattributes)" grep "*.dat" track.log ) end_test + +begin_test "track: escaped pattern in .gitattributes" +( + set -e + + reponame="track-escaped" + git init "$reponame" + cd "$reponame" + + filename="file with spaces.#" + + echo "I need escaping" > "$filename" + + [ "Tracking \"$filename\"" = "$(git lfs track "$filename")" ] + [ "\"$filename\" already supported" = "$(git lfs track "$filename")" ] + + #changing flags should track the file again + [ "Tracking \"$filename\"" = "$(git lfs track -l "$filename")" ] + + if [ 1 -ne "$(wc -l .gitattributes | awk '{ print $1 }')" ]; then + echo >&2 "changing flag for an existing tracked file shouldn't add another line" + exit 1 + fi +) +end_test diff --git a/t/t-untrack.sh b/t/t-untrack.sh index 60b285f..2cc1c1b 100755 --- a/t/t-untrack.sh +++ b/t/t-untrack.sh @@ -89,7 +89,7 @@ begin_test "untrack removes prefixed patterns (legacy)" git lfs untrack "./a.dat" if [ ! -z "$(cat .gitattributes)" ]; then - echo &>2 "fatal: expected 'git lfs untrack' to clear .gitattributes" + echo >&2 "fatal: expected 'git lfs untrack' to clear .gitattributes" exit 1 fi @@ -98,7 +98,7 @@ begin_test "untrack removes prefixed patterns (legacy)" git lfs untrack "a.dat" if [ ! -z "$(cat .gitattributes)" ]; then - echo &>2 "fatal: expected 'git lfs untrack' to clear .gitattributes" + echo >&2 "fatal: expected 'git lfs untrack' to clear .gitattributes" exit 1 fi ) @@ -120,7 +120,7 @@ begin_test "untrack removes prefixed patterns (modern)" git lfs untrack "./a.dat" if [ ! -z "$(cat .gitattributes)" ]; then - echo &>2 "fatal: expected 'git lfs untrack' to clear .gitattributes" + echo >&2 "fatal: expected 'git lfs untrack' to clear .gitattributes" exit 1 fi @@ -129,7 +129,31 @@ begin_test "untrack removes prefixed patterns (modern)" git lfs untrack "a.dat" if [ ! -z "$(cat .gitattributes)" ]; then - echo &>2 "fatal: expected 'git lfs untrack' to clear .gitattributes" + echo >&2 "fatal: expected 'git lfs untrack' to clear .gitattributes" + exit 1 + fi +) +end_test + +begin_test "untrack removes escaped pattern in .gitattributes" +( + set -e + + reponame="untrack-escaped" + git init "$reponame" + cd "$reponame" + + filename="file with spaces.#" + + # emulate multiple instances of the same file in gitattributes + echo 'file[[:space:]]with[[:space:]]spaces.\# filter=lfs diff=lfs merge=lfs -text' >> .gitattributes + echo 'file[[:space:]]with[[:space:]]spaces.\# filter=lfs diff=lfs merge=lfs -text' >> .gitattributes + echo 'file[[:space:]]with[[:space:]]spaces.\# filter=lfs diff=lfs merge=lfs -text' >> .gitattributes + + git lfs untrack "$filename" + + if [ ! -z "$(cat .gitattributes)" ]; then + echo >&2 "fatal: expected 'git lfs untrack' to clear .gitattributes even if the file name was escaped" exit 1 fi ) diff --git a/tq/basic_upload.go b/tq/basic_upload.go index 8557565..2cfb7ce 100644 --- a/tq/basic_upload.go +++ b/tq/basic_upload.go @@ -150,19 +150,23 @@ func (a *basicUploadAdapter) DoTransfer(ctx interface{}, t *Transfer, cb Progres func (a *adapterBase) setContentTypeFor(req *http.Request, r io.ReadSeeker) error { uc := config.NewURLConfig(a.apiClient.GitEnv()) disabled := !uc.Bool("lfs", req.URL.String(), "contenttype", true) - if len(req.Header.Get("Content-Type")) != 0 || disabled { + if len(req.Header.Get("Content-Type")) != 0 { return nil } - buffer := make([]byte, 512) - n, err := r.Read(buffer) - if err != nil && err != io.EOF { - return errors.Wrap(err, "content type detect") - } + var contentType string + + if !disabled { + buffer := make([]byte, 512) + n, err := r.Read(buffer) + if err != nil && err != io.EOF { + return errors.Wrap(err, "content type detect") + } - contentType := http.DetectContentType(buffer[:n]) - if _, err := r.Seek(0, 0); err != nil { - return errors.Wrap(err, "content type rewind") + contentType = http.DetectContentType(buffer[:n]) + if _, err := r.Seek(0, io.SeekStart); err != nil { + return errors.Wrap(err, "content type rewind") + } } if contentType == "" { diff --git a/versioninfo.json b/versioninfo.json index c181d24..6ed11b4 100644 --- a/versioninfo.json +++ b/versioninfo.json @@ -4,7 +4,7 @@ "FileVersion": { "Major": 2, "Minor": 5, - "Patch": 1, + "Patch": 2, "Build": 0 } }, @@ -13,7 +13,7 @@ "FileDescription": "Git LFS", "LegalCopyright": "GitHub, Inc. and Git LFS contributors", "ProductName": "Git Large File Storage (LFS)", - "ProductVersion": "2.5.1" + "ProductVersion": "2.5.2" }, "IconPath": "script/windows-installer/git-lfs-logo.ico" } -- 2.7.4