├── .gitignore ├── Gopkg.lock ├── Gopkg.toml ├── LICENSE ├── Makefile ├── README.md ├── cmd └── main.go ├── packfile ├── decoder.go ├── encoder.go └── object_walker.go ├── packproto ├── protocol.go └── txref.go ├── pktline ├── README.md ├── pktline.go └── pktline_test.go ├── repository ├── manager.go ├── reference.go ├── repository.go └── store.go ├── storage └── storage.go ├── transport ├── http.go ├── http_git.go ├── http_repo.go └── http_utils.go └── vendor ├── github.com ├── emirpasic │ └── gods │ │ ├── LICENSE │ │ ├── containers │ │ ├── containers.go │ │ ├── enumerable.go │ │ ├── iterator.go │ │ └── serialization.go │ │ ├── lists │ │ ├── arraylist │ │ │ ├── arraylist.go │ │ │ ├── enumerable.go │ │ │ ├── iterator.go │ │ │ └── serialization.go │ │ └── lists.go │ │ ├── trees │ │ ├── binaryheap │ │ │ ├── binaryheap.go │ │ │ ├── iterator.go │ │ │ └── serialization.go │ │ └── trees.go │ │ └── utils │ │ ├── comparator.go │ │ ├── sort.go │ │ └── utils.go ├── jbenet │ └── go-context │ │ ├── LICENSE │ │ └── io │ │ └── ctxio.go ├── kevinburke │ └── ssh_config │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── AUTHORS.txt │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── README.md │ │ ├── config.go │ │ ├── lexer.go │ │ ├── parser.go │ │ ├── position.go │ │ ├── token.go │ │ └── validators.go ├── mitchellh │ └── go-homedir │ │ ├── LICENSE │ │ ├── README.md │ │ ├── go.mod │ │ └── homedir.go ├── pelletier │ └── go-buffruneio │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── README.md │ │ └── buffruneio.go ├── sergi │ └── go-diff │ │ ├── AUTHORS │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ └── diffmatchpatch │ │ ├── diff.go │ │ ├── diffmatchpatch.go │ │ ├── match.go │ │ ├── mathutil.go │ │ ├── patch.go │ │ └── stringutil.go ├── src-d │ └── gcfg │ │ ├── LICENSE │ │ ├── README │ │ ├── doc.go │ │ ├── errors.go │ │ ├── go1_0.go │ │ ├── go1_2.go │ │ ├── read.go │ │ ├── scanner │ │ ├── errors.go │ │ └── scanner.go │ │ ├── set.go │ │ ├── token │ │ ├── position.go │ │ ├── serialize.go │ │ └── token.go │ │ └── types │ │ ├── bool.go │ │ ├── doc.go │ │ ├── enum.go │ │ ├── int.go │ │ └── scan.go └── xanzy │ └── ssh-agent │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── pageant_windows.go │ ├── sshagent.go │ └── sshagent_windows.go ├── golang.org └── x │ ├── crypto │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ ├── cast5 │ │ └── cast5.go │ ├── curve25519 │ │ ├── const_amd64.h │ │ ├── const_amd64.s │ │ ├── cswap_amd64.s │ │ ├── curve25519.go │ │ ├── doc.go │ │ ├── freeze_amd64.s │ │ ├── ladderstep_amd64.s │ │ ├── mont25519_amd64.go │ │ ├── mul_amd64.s │ │ └── square_amd64.s │ ├── ed25519 │ │ ├── ed25519.go │ │ └── internal │ │ │ └── edwards25519 │ │ │ ├── const.go │ │ │ └── edwards25519.go │ ├── internal │ │ ├── chacha20 │ │ │ ├── chacha_generic.go │ │ │ ├── chacha_noasm.go │ │ │ ├── chacha_s390x.go │ │ │ ├── chacha_s390x.s │ │ │ └── xor.go │ │ └── subtle │ │ │ ├── aliasing.go │ │ │ └── aliasing_appengine.go │ ├── openpgp │ │ ├── armor │ │ │ ├── armor.go │ │ │ └── encode.go │ │ ├── canonical_text.go │ │ ├── elgamal │ │ │ └── elgamal.go │ │ ├── errors │ │ │ └── errors.go │ │ ├── keys.go │ │ ├── packet │ │ │ ├── compressed.go │ │ │ ├── config.go │ │ │ ├── encrypted_key.go │ │ │ ├── literal.go │ │ │ ├── ocfb.go │ │ │ ├── one_pass_signature.go │ │ │ ├── opaque.go │ │ │ ├── packet.go │ │ │ ├── private_key.go │ │ │ ├── public_key.go │ │ │ ├── public_key_v3.go │ │ │ ├── reader.go │ │ │ ├── signature.go │ │ │ ├── signature_v3.go │ │ │ ├── symmetric_key_encrypted.go │ │ │ ├── symmetrically_encrypted.go │ │ │ ├── userattribute.go │ │ │ └── userid.go │ │ ├── read.go │ │ ├── s2k │ │ │ └── s2k.go │ │ └── write.go │ ├── poly1305 │ │ ├── poly1305.go │ │ ├── sum_amd64.go │ │ ├── sum_amd64.s │ │ ├── sum_arm.go │ │ ├── sum_arm.s │ │ ├── sum_noasm.go │ │ ├── sum_ref.go │ │ ├── sum_s390x.go │ │ ├── sum_s390x.s │ │ └── sum_vmsl_s390x.s │ └── ssh │ │ ├── agent │ │ ├── client.go │ │ ├── forward.go │ │ ├── keyring.go │ │ └── server.go │ │ ├── buffer.go │ │ ├── certs.go │ │ ├── channel.go │ │ ├── cipher.go │ │ ├── client.go │ │ ├── client_auth.go │ │ ├── common.go │ │ ├── connection.go │ │ ├── doc.go │ │ ├── handshake.go │ │ ├── kex.go │ │ ├── keys.go │ │ ├── knownhosts │ │ └── knownhosts.go │ │ ├── mac.go │ │ ├── messages.go │ │ ├── mux.go │ │ ├── server.go │ │ ├── session.go │ │ ├── streamlocal.go │ │ ├── tcpip.go │ │ └── transport.go │ ├── net │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ └── context │ │ ├── context.go │ │ ├── go17.go │ │ ├── go19.go │ │ ├── pre_go17.go │ │ └── pre_go19.go │ ├── sys │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ └── windows │ │ ├── aliases.go │ │ ├── asm_windows_386.s │ │ ├── asm_windows_amd64.s │ │ ├── asm_windows_arm.s │ │ ├── dll_windows.go │ │ ├── env_windows.go │ │ ├── eventlog.go │ │ ├── exec_windows.go │ │ ├── memory_windows.go │ │ ├── mksyscall.go │ │ ├── race.go │ │ ├── race0.go │ │ ├── security_windows.go │ │ ├── service.go │ │ ├── str.go │ │ ├── syscall.go │ │ ├── syscall_windows.go │ │ ├── types_windows.go │ │ ├── types_windows_386.go │ │ ├── types_windows_amd64.go │ │ ├── types_windows_arm.go │ │ └── zsyscall_windows.go │ └── text │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ ├── internal │ ├── gen │ │ ├── code.go │ │ └── gen.go │ ├── triegen │ │ ├── compact.go │ │ ├── print.go │ │ └── triegen.go │ └── ucd │ │ └── ucd.go │ ├── transform │ └── transform.go │ └── unicode │ ├── cldr │ ├── base.go │ ├── cldr.go │ ├── collate.go │ ├── decode.go │ ├── makexml.go │ ├── resolve.go │ ├── slice.go │ └── xml.go │ └── norm │ ├── composition.go │ ├── forminfo.go │ ├── input.go │ ├── iter.go │ ├── maketables.go │ ├── normalize.go │ ├── readwriter.go │ ├── tables10.0.0.go │ ├── tables9.0.0.go │ ├── transform.go │ ├── trie.go │ └── triegen.go └── gopkg.in ├── src-d ├── go-billy.v4 │ ├── .gitignore │ ├── .travis.yml │ ├── DCO │ ├── LICENSE │ ├── MAINTAINERS │ ├── Makefile │ ├── README.md │ ├── appveyor.yml │ ├── fs.go │ ├── go.mod │ ├── helper │ │ ├── chroot │ │ │ └── chroot.go │ │ └── polyfill │ │ │ └── polyfill.go │ ├── osfs │ │ ├── os.go │ │ ├── os_posix.go │ │ └── os_windows.go │ └── util │ │ ├── glob.go │ │ └── util.go └── go-git.v4 │ ├── .gitignore │ ├── .travis.yml │ ├── CODE_OF_CONDUCT.md │ ├── COMPATIBILITY.md │ ├── CONTRIBUTING.md │ ├── DCO │ ├── LICENSE │ ├── MAINTAINERS │ ├── Makefile │ ├── README.md │ ├── appveyor.yml │ ├── blame.go │ ├── common.go │ ├── config │ ├── branch.go │ ├── config.go │ ├── modules.go │ └── refspec.go │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── internal │ └── revision │ │ ├── parser.go │ │ ├── scanner.go │ │ └── token.go │ ├── object_walker.go │ ├── options.go │ ├── plumbing │ ├── cache │ │ ├── buffer_lru.go │ │ ├── common.go │ │ └── object_lru.go │ ├── error.go │ ├── filemode │ │ └── filemode.go │ ├── format │ │ ├── config │ │ │ ├── common.go │ │ │ ├── decoder.go │ │ │ ├── doc.go │ │ │ ├── encoder.go │ │ │ ├── option.go │ │ │ └── section.go │ │ ├── diff │ │ │ ├── patch.go │ │ │ └── unified_encoder.go │ │ ├── gitignore │ │ │ ├── dir.go │ │ │ ├── doc.go │ │ │ ├── matcher.go │ │ │ └── pattern.go │ │ ├── idxfile │ │ │ ├── decoder.go │ │ │ ├── doc.go │ │ │ ├── encoder.go │ │ │ ├── idxfile.go │ │ │ └── writer.go │ │ ├── index │ │ │ ├── decoder.go │ │ │ ├── doc.go │ │ │ ├── encoder.go │ │ │ ├── index.go │ │ │ └── match.go │ │ ├── objfile │ │ │ ├── doc.go │ │ │ ├── reader.go │ │ │ └── writer.go │ │ ├── packfile │ │ │ ├── common.go │ │ │ ├── delta_index.go │ │ │ ├── delta_selector.go │ │ │ ├── diff_delta.go │ │ │ ├── doc.go │ │ │ ├── encoder.go │ │ │ ├── error.go │ │ │ ├── fsobject.go │ │ │ ├── object_pack.go │ │ │ ├── packfile.go │ │ │ ├── parser.go │ │ │ ├── patch_delta.go │ │ │ └── scanner.go │ │ └── pktline │ │ │ ├── encoder.go │ │ │ └── scanner.go │ ├── hash.go │ ├── memory.go │ ├── object.go │ ├── object │ │ ├── blob.go │ │ ├── change.go │ │ ├── change_adaptor.go │ │ ├── commit.go │ │ ├── commit_walker.go │ │ ├── commit_walker_bfs.go │ │ ├── commit_walker_ctime.go │ │ ├── commit_walker_file.go │ │ ├── difftree.go │ │ ├── file.go │ │ ├── object.go │ │ ├── patch.go │ │ ├── tag.go │ │ ├── tree.go │ │ └── treenoder.go │ ├── protocol │ │ └── packp │ │ │ ├── advrefs.go │ │ │ ├── advrefs_decode.go │ │ │ ├── advrefs_encode.go │ │ │ ├── capability │ │ │ ├── capability.go │ │ │ └── list.go │ │ │ ├── common.go │ │ │ ├── doc.go │ │ │ ├── report_status.go │ │ │ ├── shallowupd.go │ │ │ ├── sideband │ │ │ ├── common.go │ │ │ ├── demux.go │ │ │ ├── doc.go │ │ │ └── muxer.go │ │ │ ├── srvresp.go │ │ │ ├── ulreq.go │ │ │ ├── ulreq_decode.go │ │ │ ├── ulreq_encode.go │ │ │ ├── updreq.go │ │ │ ├── updreq_decode.go │ │ │ ├── updreq_encode.go │ │ │ ├── uppackreq.go │ │ │ └── uppackresp.go │ ├── reference.go │ ├── revision.go │ ├── revlist │ │ └── revlist.go │ ├── storer │ │ ├── doc.go │ │ ├── index.go │ │ ├── object.go │ │ ├── reference.go │ │ ├── shallow.go │ │ └── storer.go │ └── transport │ │ ├── client │ │ └── client.go │ │ ├── common.go │ │ ├── file │ │ ├── client.go │ │ └── server.go │ │ ├── git │ │ └── common.go │ │ ├── http │ │ ├── common.go │ │ ├── receive_pack.go │ │ └── upload_pack.go │ │ ├── internal │ │ └── common │ │ │ ├── common.go │ │ │ └── server.go │ │ ├── server │ │ ├── loader.go │ │ └── server.go │ │ └── ssh │ │ ├── auth_method.go │ │ └── common.go │ ├── prune.go │ ├── references.go │ ├── remote.go │ ├── repository.go │ ├── status.go │ ├── storage │ ├── filesystem │ │ ├── config.go │ │ ├── deltaobject.go │ │ ├── dotgit │ │ │ ├── dotgit.go │ │ │ ├── dotgit_rewrite_packed_refs.go │ │ │ ├── dotgit_setref.go │ │ │ ├── dotgit_setref_norwfs.go │ │ │ └── writers.go │ │ ├── index.go │ │ ├── module.go │ │ ├── object.go │ │ ├── reference.go │ │ ├── shallow.go │ │ └── storage.go │ ├── memory │ │ └── storage.go │ └── storer.go │ ├── submodule.go │ ├── utils │ ├── binary │ │ ├── read.go │ │ └── write.go │ ├── diff │ │ └── diff.go │ ├── ioutil │ │ └── common.go │ └── merkletrie │ │ ├── change.go │ │ ├── difftree.go │ │ ├── doc.go │ │ ├── doubleiter.go │ │ ├── filesystem │ │ └── node.go │ │ ├── index │ │ └── node.go │ │ ├── internal │ │ └── frame │ │ │ └── frame.go │ │ ├── iter.go │ │ └── noder │ │ ├── noder.go │ │ └── path.go │ ├── worktree.go │ ├── worktree_bsd.go │ ├── worktree_commit.go │ ├── worktree_linux.go │ ├── worktree_status.go │ └── worktree_windows.go └── warnings.v0 ├── LICENSE ├── README └── warnings.go /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | tmp/ 3 | -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- 1 | # Gopkg.toml example 2 | # 3 | # Refer to https://golang.github.io/dep/docs/Gopkg.toml.html 4 | # for detailed Gopkg.toml documentation. 5 | # 6 | # required = ["github.com/user/thing/cmd/thing"] 7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 8 | # 9 | # [[constraint]] 10 | # name = "github.com/user/project" 11 | # version = "1.0.0" 12 | # 13 | # [[constraint]] 14 | # name = "github.com/user/project2" 15 | # branch = "dev" 16 | # source = "github.com/myfork/project2" 17 | # 18 | # [[override]] 19 | # name = "github.com/x/y" 20 | # version = "2.4.0" 21 | # 22 | # [prune] 23 | # non-go = false 24 | # go-tests = true 25 | # unused-packages = true 26 | 27 | 28 | [[constraint]] 29 | name = "gopkg.in/src-d/go-billy.v4" 30 | version = "4.3.0" 31 | 32 | [[constraint]] 33 | name = "gopkg.in/src-d/go-git.v4" 34 | version = "4.7.1" 35 | 36 | [prune] 37 | go-tests = true 38 | unused-packages = true 39 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | .PHONY: 3 | prep: 4 | glide install 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # go-git-server 2 | 3 | Git server-side protocol over http in golang. This is meant to be used as a library. 4 | 5 | The protocol itself is broken out and with a http server and repository server. 6 | 7 | ## Versions 8 | 9 | If you were using the older version, it is still available under the v1.0.0 tag. 10 | -------------------------------------------------------------------------------- /cmd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "log" 7 | "os" 8 | 9 | "github.com/euforia/go-git-server/repository" 10 | "github.com/euforia/go-git-server/storage" 11 | "github.com/euforia/go-git-server/transport" 12 | ) 13 | 14 | var ( 15 | httpAddr = "127.0.0.1:12345" 16 | dataDir = flag.String("data-dir", "", "dir") 17 | ) 18 | 19 | func init() { 20 | log.SetFlags(log.LstdFlags | log.Lshortfile) 21 | } 22 | 23 | func makeManager() *repository.Manager { 24 | os.MkdirAll(*dataDir, 0755) 25 | repoStore := repository.NewFilesystemRepoStore(*dataDir) 26 | gitRepoMgr := repository.NewGitRepoManager(*dataDir) 27 | return repository.NewManager(repoStore, gitRepoMgr) 28 | } 29 | 30 | func main() { 31 | flag.Parse() 32 | if *dataDir == "" { 33 | fmt.Println("-data-dir required!") 34 | os.Exit(1) 35 | } 36 | 37 | objStore := storage.NewFilesystemGitRepoStorage(*dataDir) 38 | gh := transport.NewGitHTTPService(objStore) 39 | 40 | mgr := makeManager() 41 | rh := transport.NewRepoHTTPService(mgr) 42 | 43 | server := transport.NewHTTPTransport(gh, rh) 44 | if err := server.ListenAndServe(httpAddr); err != nil { 45 | log.Println(err) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /packproto/txref.go: -------------------------------------------------------------------------------- 1 | package packproto 2 | 3 | import ( 4 | "errors" 5 | "strings" 6 | 7 | "gopkg.in/src-d/go-git.v4/plumbing" 8 | ) 9 | 10 | // TxRef is a transaction to update a repo reference 11 | type txRef struct { 12 | oldHash plumbing.Hash 13 | newHash plumbing.Hash 14 | ref string 15 | } 16 | 17 | // Parses old hash, new hash, and ref from a line in that order 18 | func newTxRefFromBytes(line []byte) (rt txRef, err error) { 19 | arr := strings.Split(string(line), " ") 20 | if len(arr) < 3 { 21 | err = errors.New("invalid line: " + string(line)) 22 | return 23 | } 24 | 25 | rt = txRef{ 26 | oldHash: plumbing.NewHash(arr[0]), 27 | newHash: plumbing.NewHash(arr[1]), 28 | ref: strings.TrimSuffix(arr[2], string([]byte{0})), 29 | } 30 | 31 | return 32 | } 33 | 34 | // Old returns the old Reference object 35 | func (tx *txRef) old() *plumbing.Reference { 36 | return plumbing.NewHashReference(plumbing.ReferenceName(tx.ref), tx.oldHash) 37 | } 38 | 39 | // New returns the new Reference object 40 | func (tx *txRef) new() *plumbing.Reference { 41 | return plumbing.NewHashReference(plumbing.ReferenceName(tx.ref), tx.newHash) 42 | } 43 | -------------------------------------------------------------------------------- /pktline/README.md: -------------------------------------------------------------------------------- 1 | # pktline 2 | 3 | Package pktline implements pkt-line format encoding used by Git's transfer protocol. 4 | https://github.com/git/git/blob/master/Documentation/technical/protocol-common.txt 5 | 6 | ```shell 7 | import "github.com/euforia/go-git-server/pktline" 8 | ``` 9 | -------------------------------------------------------------------------------- /pktline/pktline_test.go: -------------------------------------------------------------------------------- 1 | package pktline 2 | 3 | import ( 4 | "reflect" 5 | "strings" 6 | "testing" 7 | ) 8 | 9 | var readFromTestCases = []struct { 10 | desc string 11 | in string 12 | out string 13 | isFlush bool 14 | }{ 15 | { 16 | desc: "flush", 17 | in: "0000", 18 | isFlush: true, 19 | }, 20 | { 21 | desc: "empty", 22 | in: "0004", 23 | out: "", 24 | }, 25 | { 26 | desc: "simple", 27 | in: "000asimple", 28 | out: "simple", 29 | }, 30 | } 31 | 32 | func TestDecodeEncode(t *testing.T) { 33 | for _, tt := range readFromTestCases { 34 | out, err := Decode([]byte(tt.in)) 35 | if err != nil { 36 | t.Errorf("%s: unexpected error: %v", tt.desc, err) 37 | } else if tt.isFlush { 38 | if out != nil { 39 | t.Errorf("%s: expected flush pkt instead of %v", tt.desc, out) 40 | } 41 | } else if !reflect.DeepEqual(out, []byte(tt.out)) { 42 | t.Errorf("%s: invalid output %v", tt.desc, out) 43 | } else { 44 | enc, err := Encode(out) 45 | if err != nil { 46 | t.Errorf("%s: unexpected error in encode: %v", tt.desc, err) 47 | } 48 | recode, err := Decode(enc) 49 | if err != nil { 50 | t.Errorf("%s: unexpected error in recode: %v", tt.desc, err) 51 | } else if !reflect.DeepEqual(out, recode) { 52 | t.Errorf("%s: out %q is different from Decode(Encode(out))=%q", tt.desc, out, recode) 53 | } 54 | } 55 | } 56 | } 57 | 58 | func TestMultiple(t *testing.T) { 59 | reader := NewDecoder(strings.NewReader( 60 | "0005A" + 61 | "0006BC" + 62 | "0008\000\001\002\003" + 63 | "0000" + 64 | "0004" + 65 | "0004")) 66 | expectedLines := [][]byte{ 67 | []byte("A"), 68 | []byte("BC"), 69 | []byte("\000\001\002\003"), 70 | nil, 71 | []byte(""), 72 | []byte(""), 73 | } 74 | for i, expected := range expectedLines { 75 | var actual []byte 76 | err := reader.Decode(&actual) 77 | if err != nil { 78 | t.Errorf("%d: unexpected error %v", i, err) 79 | } else if !reflect.DeepEqual(expected, actual) { 80 | t.Errorf("%d: expected %v, got %v", i, expected, actual) 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /repository/manager.go: -------------------------------------------------------------------------------- 1 | package repository 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | 7 | "gopkg.in/src-d/go-git.v4" 8 | ) 9 | 10 | // Manager wraps an underlying repo store with a git repo manager 11 | // to initialize repos 12 | type Manager struct { 13 | RepositoryStore 14 | rmgr *GitRepoManager 15 | } 16 | 17 | func NewManager(s RepositoryStore, mgr *GitRepoManager) *Manager { 18 | return &Manager{RepositoryStore: s, rmgr: mgr} 19 | } 20 | 21 | func (s *Manager) CreateRepo(repo *Repository) error { 22 | err := s.rmgr.CreateRepo(repo.ID) 23 | if err == nil { 24 | err = s.RepositoryStore.CreateRepo(repo) 25 | } 26 | return err 27 | } 28 | 29 | type GitRepoManager struct { 30 | datadir string 31 | } 32 | 33 | func NewGitRepoManager(dir string) *GitRepoManager { 34 | return &GitRepoManager{datadir: dir} 35 | } 36 | 37 | func (m *GitRepoManager) CreateRepo(id string) error { 38 | path := filepath.Join(m.datadir, id) 39 | _, err := os.Stat(path) 40 | if err == nil { 41 | return ErrExists 42 | } 43 | _, err = git.PlainInit(path, true) 44 | return err 45 | } 46 | 47 | func (m *GitRepoManager) GetRepo(id string) (*git.Repository, error) { 48 | path := filepath.Join(m.datadir, id) 49 | return git.PlainOpen(path) 50 | } 51 | 52 | func (m *GitRepoManager) RemoveRepo(id string) error { 53 | path := filepath.Join(m.datadir, id) 54 | _, err := os.Stat(path) 55 | if err != nil { 56 | return ErrNotFound 57 | } 58 | 59 | return os.RemoveAll(path) 60 | } 61 | -------------------------------------------------------------------------------- /repository/repository.go: -------------------------------------------------------------------------------- 1 | package repository 2 | 3 | // Repository represents a single repo. 4 | type Repository struct { 5 | ID string `json:"id"` 6 | Refs *RepositoryReferences `json:"refs"` 7 | } 8 | 9 | // NewRepository instantiates an empty repo. 10 | func NewRepository(id string) *Repository { 11 | return &Repository{ID: id, Refs: NewRepositoryReferences()} 12 | } 13 | 14 | func (repo *Repository) String() string { 15 | return repo.ID 16 | } 17 | -------------------------------------------------------------------------------- /storage/storage.go: -------------------------------------------------------------------------------- 1 | package storage 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | "sync" 7 | 8 | "gopkg.in/src-d/go-billy.v4/osfs" 9 | "gopkg.in/src-d/go-git.v4/plumbing/cache" 10 | "gopkg.in/src-d/go-git.v4/plumbing/storer" 11 | "gopkg.in/src-d/go-git.v4/storage/filesystem" 12 | "gopkg.in/src-d/go-git.v4/storage/memory" 13 | ) 14 | 15 | // GitRepoStorage implements an interface to store objects for repos 16 | type GitRepoStorage interface { 17 | // GetStore gets an object store given the id where the id is the namespace 18 | // for storage 19 | GetStore(string) storer.Storer 20 | } 21 | 22 | // MemGitRepoStorage manages objects stores by id i.e. repo 23 | type MemGitRepoStorage struct { 24 | mu sync.Mutex 25 | m map[string]storer.Storer 26 | } 27 | 28 | // NewMemGitRepoStorage returns a new instance of MemGitRepoStorage 29 | func NewMemGitRepoStorage() *MemGitRepoStorage { 30 | return &MemGitRepoStorage{m: map[string]storer.Storer{}} 31 | } 32 | 33 | // GetStore for the given id. Create one if it does not exist 34 | func (mos *MemGitRepoStorage) GetStore(id string) storer.Storer { 35 | mos.mu.Lock() 36 | defer mos.mu.Unlock() 37 | 38 | if v, ok := mos.m[id]; ok { 39 | return v 40 | } 41 | 42 | mem := memory.NewStorage() 43 | mos.m[id] = mem 44 | return mem 45 | } 46 | 47 | // FilesystemGitRepoStorage manages objects stores by id i.e. repo 48 | type FilesystemGitRepoStorage struct { 49 | mu sync.Mutex 50 | datadir string 51 | m map[string]storer.Storer 52 | } 53 | 54 | // NewFilesystemGitRepoStorage returns an new instance of FilesystemGitRepoStorage 55 | func NewFilesystemGitRepoStorage(dir string) *FilesystemGitRepoStorage { 56 | return &FilesystemGitRepoStorage{ 57 | datadir: dir, 58 | m: map[string]storer.Storer{}, 59 | } 60 | } 61 | 62 | // GetStore for the given id. Create one if it does not exist 63 | func (mos *FilesystemGitRepoStorage) GetStore(id string) storer.Storer { 64 | mos.mu.Lock() 65 | defer mos.mu.Unlock() 66 | 67 | if v, ok := mos.m[id]; ok { 68 | return v 69 | } 70 | 71 | dir := filepath.Join(mos.datadir, id) 72 | _, err := os.Stat(dir) 73 | if err != nil { 74 | return nil 75 | } 76 | 77 | fs := filesystem.NewStorage(osfs.New(dir), cache.NewObjectLRUDefault()) 78 | mos.m[id] = fs 79 | return fs 80 | } 81 | -------------------------------------------------------------------------------- /transport/http_repo.go: -------------------------------------------------------------------------------- 1 | package transport 2 | 3 | import ( 4 | "encoding/json" 5 | "io" 6 | "net/http" 7 | "strings" 8 | 9 | "github.com/euforia/go-git-server/repository" 10 | ) 11 | 12 | type RepoHTTPService struct { 13 | repos repository.RepositoryStore 14 | } 15 | 16 | func NewRepoHTTPService(store repository.RepositoryStore) *RepoHTTPService { 17 | return &RepoHTTPService{repos: store} 18 | } 19 | 20 | func (svr *RepoHTTPService) ServeHTTP(w http.ResponseWriter, r *http.Request) { 21 | repoID := r.Context().Value(ctxKeyRepo).(string) 22 | // Must be namespaced 23 | if !strings.Contains(repoID, "/") { 24 | w.WriteHeader(404) 25 | return 26 | } 27 | 28 | var ( 29 | code = 400 30 | err error 31 | repo *repository.Repository 32 | ) 33 | 34 | switch r.Method { 35 | case "GET": 36 | repo, err = svr.repos.GetRepo(repoID) 37 | 38 | case "PUT": 39 | // Create 40 | dec := json.NewDecoder(r.Body) 41 | defer r.Body.Close() 42 | 43 | repo = repository.NewRepository(repoID) 44 | if err = dec.Decode(&repo); err == nil || err == io.EOF { 45 | if err = svr.repos.CreateRepo(repo); err == repository.ErrExists { 46 | code = 409 47 | } 48 | } 49 | 50 | case "POST": 51 | // Update 52 | dec := json.NewDecoder(r.Body) 53 | defer r.Body.Close() 54 | 55 | // Get existing 56 | if repo, err = svr.repos.GetRepo(repoID); err == nil { 57 | // Unmarshal on to existing 58 | if err = dec.Decode(repo); err == nil { 59 | if err = svr.repos.UpdateRepo(repo); err == repository.ErrNotFound { 60 | code = 404 61 | } 62 | } 63 | } 64 | } 65 | 66 | w.Header().Set("Content-Type", "application/json") 67 | 68 | if err != nil { 69 | w.WriteHeader(code) 70 | w.Write([]byte(`{"error":"` + err.Error() + `"}`)) 71 | } else { 72 | b, _ := json.Marshal(repo) 73 | w.WriteHeader(200) 74 | w.Write(b) 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /transport/http_utils.go: -------------------------------------------------------------------------------- 1 | package transport 2 | 3 | import ( 4 | "net/http" 5 | "strings" 6 | 7 | "github.com/euforia/go-git-server/packproto" 8 | ) 9 | 10 | func isListRefRequest(r *http.Request) (repo string, service string, ok bool) { 11 | ss := r.URL.Query()["service"] 12 | if len(ss) < 1 || (ss[0] != packproto.GitRecvPack && ss[0] != packproto.GitUploadPack) { 13 | return 14 | } 15 | service = ss[0] 16 | 17 | if strings.HasSuffix(r.URL.Path, "/info/refs") { 18 | repo = strings.TrimPrefix(strings.TrimSuffix(r.URL.Path, "/info/refs"), "/") 19 | ok = true 20 | } 21 | 22 | return 23 | } 24 | 25 | func isPackfileRequest(r *http.Request) (repo string, service string, ok bool) { 26 | switch { 27 | case strings.HasSuffix(r.URL.Path, "/"+packproto.GitRecvPack): 28 | repo = strings.TrimPrefix(strings.TrimSuffix(r.URL.Path, "/"+packproto.GitRecvPack), "/") 29 | service = packproto.GitRecvPack 30 | ok = true 31 | 32 | case strings.HasSuffix(r.URL.Path, "/"+packproto.GitUploadPack): 33 | repo = strings.TrimPrefix(strings.TrimSuffix(r.URL.Path, "/"+packproto.GitUploadPack), "/") 34 | service = packproto.GitUploadPack 35 | ok = true 36 | } 37 | 38 | return 39 | } 40 | 41 | func isUIRequest(r *http.Request) bool { 42 | agent := r.Header.Get("User-Agent") 43 | switch { 44 | case strings.Contains(agent, "Chrome"), 45 | strings.Contains(agent, "Safari"), 46 | strings.Contains(agent, "FireFox"), 47 | strings.Contains(agent, "Mozilla"): 48 | return true 49 | } 50 | 51 | return false 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/emirpasic/gods/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Emir Pasic 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | ------------------------------------------------------------------------------- 26 | 27 | AVL Tree: 28 | 29 | Copyright (c) 2017 Benjamin Scher Purcell 30 | 31 | Permission to use, copy, modify, and distribute this software for any 32 | purpose with or without fee is hereby granted, provided that the above 33 | copyright notice and this permission notice appear in all copies. 34 | 35 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 36 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 37 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 38 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 39 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 40 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 41 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 42 | -------------------------------------------------------------------------------- /vendor/github.com/emirpasic/gods/containers/containers.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Emir Pasic. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package containers provides core interfaces and functions for data structures. 6 | // 7 | // Container is the base interface for all data structures to implement. 8 | // 9 | // Iterators provide stateful iterators. 10 | // 11 | // Enumerable provides Ruby inspired (each, select, map, find, any?, etc.) container functions. 12 | // 13 | // Serialization provides serializers (marshalers) and deserializers (unmarshalers). 14 | package containers 15 | 16 | import "github.com/emirpasic/gods/utils" 17 | 18 | // Container is base interface that all data structures implement. 19 | type Container interface { 20 | Empty() bool 21 | Size() int 22 | Clear() 23 | Values() []interface{} 24 | } 25 | 26 | // GetSortedValues returns sorted container's elements with respect to the passed comparator. 27 | // Does not effect the ordering of elements within the container. 28 | func GetSortedValues(container Container, comparator utils.Comparator) []interface{} { 29 | values := container.Values() 30 | if len(values) < 2 { 31 | return values 32 | } 33 | utils.Sort(values, comparator) 34 | return values 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/emirpasic/gods/containers/serialization.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Emir Pasic. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package containers 6 | 7 | // JSONSerializer provides JSON serialization 8 | type JSONSerializer interface { 9 | // ToJSON outputs the JSON representation of containers's elements. 10 | ToJSON() ([]byte, error) 11 | } 12 | 13 | // JSONDeserializer provides JSON deserialization 14 | type JSONDeserializer interface { 15 | // FromJSON populates containers's elements from the input JSON representation. 16 | FromJSON([]byte) error 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/emirpasic/gods/lists/arraylist/serialization.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Emir Pasic. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package arraylist 6 | 7 | import ( 8 | "encoding/json" 9 | "github.com/emirpasic/gods/containers" 10 | ) 11 | 12 | func assertSerializationImplementation() { 13 | var _ containers.JSONSerializer = (*List)(nil) 14 | var _ containers.JSONDeserializer = (*List)(nil) 15 | } 16 | 17 | // ToJSON outputs the JSON representation of list's elements. 18 | func (list *List) ToJSON() ([]byte, error) { 19 | return json.Marshal(list.elements[:list.size]) 20 | } 21 | 22 | // FromJSON populates list's elements from the input JSON representation. 23 | func (list *List) FromJSON(data []byte) error { 24 | err := json.Unmarshal(data, &list.elements) 25 | if err == nil { 26 | list.size = len(list.elements) 27 | } 28 | return err 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/emirpasic/gods/lists/lists.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Emir Pasic. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package lists provides an abstract List interface. 6 | // 7 | // In computer science, a list or sequence is an abstract data type that represents an ordered sequence of values, where the same value may occur more than once. An instance of a list is a computer representation of the mathematical concept of a finite sequence; the (potentially) infinite analog of a list is a stream. Lists are a basic example of containers, as they contain other values. If the same value occurs multiple times, each occurrence is considered a distinct item. 8 | // 9 | // Reference: https://en.wikipedia.org/wiki/List_%28abstract_data_type%29 10 | package lists 11 | 12 | import ( 13 | "github.com/emirpasic/gods/containers" 14 | "github.com/emirpasic/gods/utils" 15 | ) 16 | 17 | // List interface that all lists implement 18 | type List interface { 19 | Get(index int) (interface{}, bool) 20 | Remove(index int) 21 | Add(values ...interface{}) 22 | Contains(values ...interface{}) bool 23 | Sort(comparator utils.Comparator) 24 | Swap(index1, index2 int) 25 | Insert(index int, values ...interface{}) 26 | Set(index int, value interface{}) 27 | 28 | containers.Container 29 | // Empty() bool 30 | // Size() int 31 | // Clear() 32 | // Values() []interface{} 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/emirpasic/gods/trees/binaryheap/serialization.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Emir Pasic. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package binaryheap 6 | 7 | import "github.com/emirpasic/gods/containers" 8 | 9 | func assertSerializationImplementation() { 10 | var _ containers.JSONSerializer = (*Heap)(nil) 11 | var _ containers.JSONDeserializer = (*Heap)(nil) 12 | } 13 | 14 | // ToJSON outputs the JSON representation of the heap. 15 | func (heap *Heap) ToJSON() ([]byte, error) { 16 | return heap.list.ToJSON() 17 | } 18 | 19 | // FromJSON populates the heap from the input JSON representation. 20 | func (heap *Heap) FromJSON(data []byte) error { 21 | return heap.list.FromJSON(data) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/emirpasic/gods/trees/trees.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Emir Pasic. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package trees provides an abstract Tree interface. 6 | // 7 | // In computer science, a tree is a widely used abstract data type (ADT) or data structure implementing this ADT that simulates a hierarchical tree structure, with a root value and subtrees of children with a parent node, represented as a set of linked nodes. 8 | // 9 | // Reference: https://en.wikipedia.org/wiki/Tree_%28data_structure%29 10 | package trees 11 | 12 | import "github.com/emirpasic/gods/containers" 13 | 14 | // Tree interface that all trees implement 15 | type Tree interface { 16 | containers.Container 17 | // Empty() bool 18 | // Size() int 19 | // Clear() 20 | // Values() []interface{} 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/emirpasic/gods/utils/sort.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Emir Pasic. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package utils 6 | 7 | import "sort" 8 | 9 | // Sort sorts values (in-place) with respect to the given comparator. 10 | // 11 | // Uses Go's sort (hybrid of quicksort for large and then insertion sort for smaller slices). 12 | func Sort(values []interface{}, comparator Comparator) { 13 | sort.Sort(sortable{values, comparator}) 14 | } 15 | 16 | type sortable struct { 17 | values []interface{} 18 | comparator Comparator 19 | } 20 | 21 | func (s sortable) Len() int { 22 | return len(s.values) 23 | } 24 | func (s sortable) Swap(i, j int) { 25 | s.values[i], s.values[j] = s.values[j], s.values[i] 26 | } 27 | func (s sortable) Less(i, j int) bool { 28 | return s.comparator(s.values[i], s.values[j]) < 0 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/emirpasic/gods/utils/utils.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Emir Pasic. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package utils provides common utility functions. 6 | // 7 | // Provided functionalities: 8 | // - sorting 9 | // - comparators 10 | package utils 11 | 12 | import ( 13 | "fmt" 14 | "strconv" 15 | ) 16 | 17 | // ToString converts a value to string. 18 | func ToString(value interface{}) string { 19 | switch value.(type) { 20 | case string: 21 | return value.(string) 22 | case int8: 23 | return strconv.FormatInt(int64(value.(int8)), 10) 24 | case int16: 25 | return strconv.FormatInt(int64(value.(int16)), 10) 26 | case int32: 27 | return strconv.FormatInt(int64(value.(int32)), 10) 28 | case int64: 29 | return strconv.FormatInt(int64(value.(int64)), 10) 30 | case uint8: 31 | return strconv.FormatUint(uint64(value.(uint8)), 10) 32 | case uint16: 33 | return strconv.FormatUint(uint64(value.(uint16)), 10) 34 | case uint32: 35 | return strconv.FormatUint(uint64(value.(uint32)), 10) 36 | case uint64: 37 | return strconv.FormatUint(uint64(value.(uint64)), 10) 38 | case float32: 39 | return strconv.FormatFloat(float64(value.(float32)), 'g', -1, 64) 40 | case float64: 41 | return strconv.FormatFloat(float64(value.(float64)), 'g', -1, 64) 42 | case bool: 43 | return strconv.FormatBool(value.(bool)) 44 | default: 45 | return fmt.Sprintf("%+v", value) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/jbenet/go-context/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Juan Batiz-Benet 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/kevinburke/ssh_config/.gitattributes: -------------------------------------------------------------------------------- 1 | testdata/dos-lines eol=crlf 2 | -------------------------------------------------------------------------------- /vendor/github.com/kevinburke/ssh_config/.gitignore: -------------------------------------------------------------------------------- 1 | /bazel-* 2 | -------------------------------------------------------------------------------- /vendor/github.com/kevinburke/ssh_config/.travis.yml: -------------------------------------------------------------------------------- 1 | go_import_path: github.com/kevinburke/ssh_config 2 | 3 | language: go 4 | 5 | go: 6 | - 1.9.x 7 | - 1.10.x 8 | - 1.11.x 9 | - master 10 | 11 | before_script: 12 | - go get -u ./... 13 | 14 | script: 15 | - make race-test 16 | -------------------------------------------------------------------------------- /vendor/github.com/kevinburke/ssh_config/AUTHORS.txt: -------------------------------------------------------------------------------- 1 | Eugene Terentev 2 | Kevin Burke 3 | Sergey Lukjanov 4 | Wayne Ashley Berry 5 | -------------------------------------------------------------------------------- /vendor/github.com/kevinburke/ssh_config/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 Kevin Burke. 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | =================== 25 | 26 | The lexer and parser borrow heavily from github.com/pelletier/go-toml. The 27 | license for that project is copied below. 28 | 29 | The MIT License (MIT) 30 | 31 | Copyright (c) 2013 - 2017 Thomas Pelletier, Eric Anderton 32 | 33 | Permission is hereby granted, free of charge, to any person obtaining a copy 34 | of this software and associated documentation files (the "Software"), to deal 35 | in the Software without restriction, including without limitation the rights 36 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 37 | copies of the Software, and to permit persons to whom the Software is 38 | furnished to do so, subject to the following conditions: 39 | 40 | The above copyright notice and this permission notice shall be included in all 41 | copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 44 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 45 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 46 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 47 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 48 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 49 | SOFTWARE. 50 | -------------------------------------------------------------------------------- /vendor/github.com/kevinburke/ssh_config/Makefile: -------------------------------------------------------------------------------- 1 | BUMP_VERSION := $(GOPATH)/bin/bump_version 2 | MEGACHECK := $(GOPATH)/bin/megacheck 3 | WRITE_MAILMAP := $(GOPATH)/bin/write_mailmap 4 | 5 | IGNORES := 'github.com/kevinburke/ssh_config/config.go:U1000 github.com/kevinburke/ssh_config/config.go:S1002 github.com/kevinburke/ssh_config/token.go:U1000' 6 | 7 | $(MEGACHECK): 8 | go get honnef.co/go/tools/cmd/megacheck 9 | 10 | lint: $(MEGACHECK) 11 | go vet ./... 12 | $(MEGACHECK) --ignore=$(IGNORES) ./... 13 | 14 | test: lint 15 | @# the timeout helps guard against infinite recursion 16 | go test -timeout=250ms ./... 17 | 18 | race-test: lint 19 | go test -timeout=500ms -race ./... 20 | 21 | $(BUMP_VERSION): 22 | go get -u github.com/kevinburke/bump_version 23 | 24 | release: test | $(BUMP_VERSION) 25 | $(BUMP_VERSION) minor config.go 26 | 27 | force: ; 28 | 29 | AUTHORS.txt: force | $(WRITE_MAILMAP) 30 | $(WRITE_MAILMAP) > AUTHORS.txt 31 | 32 | authors: AUTHORS.txt 33 | -------------------------------------------------------------------------------- /vendor/github.com/kevinburke/ssh_config/position.go: -------------------------------------------------------------------------------- 1 | package ssh_config 2 | 3 | import "fmt" 4 | 5 | // Position of a document element within a SSH document. 6 | // 7 | // Line and Col are both 1-indexed positions for the element's line number and 8 | // column number, respectively. Values of zero or less will cause Invalid(), 9 | // to return true. 10 | type Position struct { 11 | Line uint32 // line within the document 12 | Col uint16 // column within the line 13 | } 14 | 15 | // String representation of the position. 16 | // Displays 1-indexed line and column numbers. 17 | func (p Position) String() string { 18 | return fmt.Sprintf("(%d, %d)", p.Line, p.Col) 19 | } 20 | 21 | // Invalid returns whether or not the position is valid (i.e. with negative or 22 | // null values) 23 | func (p Position) Invalid() bool { 24 | return p.Line <= 0 || p.Col <= 0 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/kevinburke/ssh_config/token.go: -------------------------------------------------------------------------------- 1 | package ssh_config 2 | 3 | import "fmt" 4 | 5 | type token struct { 6 | Position 7 | typ tokenType 8 | val string 9 | } 10 | 11 | func (t token) String() string { 12 | switch t.typ { 13 | case tokenEOF: 14 | return "EOF" 15 | } 16 | return fmt.Sprintf("%q", t.val) 17 | } 18 | 19 | type tokenType int 20 | 21 | const ( 22 | eof = -(iota + 1) 23 | ) 24 | 25 | const ( 26 | tokenError tokenType = iota 27 | tokenEOF 28 | tokenEmptyLine 29 | tokenComment 30 | tokenKey 31 | tokenEquals 32 | tokenString 33 | ) 34 | 35 | func isSpace(r rune) bool { 36 | return r == ' ' || r == '\t' 37 | } 38 | 39 | func isKeyStartChar(r rune) bool { 40 | return !(isSpace(r) || r == '\r' || r == '\n' || r == eof) 41 | } 42 | 43 | // I'm not sure that this is correct 44 | func isKeyChar(r rune) bool { 45 | // Keys start with the first character that isn't whitespace or [ and end 46 | // with the last non-whitespace character before the equals sign. Keys 47 | // cannot contain a # character." 48 | return !(r == '\r' || r == '\n' || r == eof || r == '=') 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/go-homedir/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Mitchell Hashimoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/go-homedir/README.md: -------------------------------------------------------------------------------- 1 | # go-homedir 2 | 3 | This is a Go library for detecting the user's home directory without 4 | the use of cgo, so the library can be used in cross-compilation environments. 5 | 6 | Usage is incredibly simple, just call `homedir.Dir()` to get the home directory 7 | for a user, and `homedir.Expand()` to expand the `~` in a path to the home 8 | directory. 9 | 10 | **Why not just use `os/user`?** The built-in `os/user` package requires 11 | cgo on Darwin systems. This means that any Go code that uses that package 12 | cannot cross compile. But 99% of the time the use for `os/user` is just to 13 | retrieve the home directory, which we can do for the current user without 14 | cgo. This library does that, enabling cross-compilation. 15 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/go-homedir/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/mitchellh/go-homedir 2 | -------------------------------------------------------------------------------- /vendor/github.com/pelletier/go-buffruneio/.gitignore: -------------------------------------------------------------------------------- 1 | *.test -------------------------------------------------------------------------------- /vendor/github.com/pelletier/go-buffruneio/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | go: 4 | - 1.3.3 5 | - 1.4.3 6 | - 1.5.3 7 | - tip 8 | -------------------------------------------------------------------------------- /vendor/github.com/pelletier/go-buffruneio/README.md: -------------------------------------------------------------------------------- 1 | # buffruneio 2 | 3 | [![Tests Status](https://travis-ci.org/pelletier/go-buffruneio.svg?branch=master)](https://travis-ci.org/pelletier/go-buffruneio) 4 | [![GoDoc](https://godoc.org/github.com/pelletier/go-buffruneio?status.svg)](https://godoc.org/github.com/pelletier/go-buffruneio) 5 | 6 | Buffruneio is a wrapper around bufio to provide buffered runes access with 7 | unlimited unreads. 8 | 9 | ```go 10 | import "github.com/pelletier/go-buffruneio" 11 | ``` 12 | 13 | ## Examples 14 | 15 | ```go 16 | import ( 17 | "fmt" 18 | "github.com/pelletier/go-buffruneio" 19 | "strings" 20 | ) 21 | 22 | reader := buffruneio.NewReader(strings.NewReader("abcd")) 23 | fmt.Println(reader.ReadRune()) // 'a' 24 | fmt.Println(reader.ReadRune()) // 'b' 25 | fmt.Println(reader.ReadRune()) // 'c' 26 | reader.UnreadRune() 27 | reader.UnreadRune() 28 | fmt.Println(reader.ReadRune()) // 'b' 29 | fmt.Println(reader.ReadRune()) // 'c' 30 | ``` 31 | 32 | ## Documentation 33 | 34 | The documentation and additional examples are available at 35 | [godoc.org](http://godoc.org/github.com/pelletier/go-buffruneio). 36 | 37 | ## Contribute 38 | 39 | Feel free to report bugs and patches using GitHub's pull requests system on 40 | [pelletier/go-toml](https://github.com/pelletier/go-buffruneio). Any feedback is 41 | much appreciated! 42 | 43 | ## LICENSE 44 | 45 | Copyright (c) 2016 Thomas Pelletier 46 | 47 | Permission is hereby granted, free of charge, to any person obtaining a copy of 48 | this software and associated documentation files (the "Software"), to deal in 49 | the Software without restriction, including without limitation the rights to 50 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 51 | the Software, and to permit persons to whom the Software is furnished to do so, 52 | subject to the following conditions: 53 | 54 | The above copyright notice and this permission notice shall be included in all 55 | copies or substantial portions of the Software. 56 | 57 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 58 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 59 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 60 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 61 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 62 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 63 | -------------------------------------------------------------------------------- /vendor/github.com/sergi/go-diff/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of go-diff authors for copyright purposes. 2 | # This file is distinct from the CONTRIBUTORS files. 3 | # See the latter for an explanation. 4 | 5 | # Names should be added to this file as 6 | # Name or Organization 7 | # The email address is not required for organizations. 8 | 9 | # Please keep the list sorted. 10 | 11 | Danny Yoo 12 | James Kolb 13 | Jonathan Amsterdam 14 | Markus Zimmermann 15 | Matt Kovars 16 | Örjan Persson 17 | Osman Masood 18 | Robert Carlsen 19 | Rory Flynn 20 | Sergi Mansilla 21 | Shatrugna Sadhu 22 | Shawn Smith 23 | Stas Maksimov 24 | Tor Arvid Lund 25 | Zac Bergquist 26 | -------------------------------------------------------------------------------- /vendor/github.com/sergi/go-diff/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This is the official list of people who can contribute 2 | # (and typically have contributed) code to the go-diff 3 | # repository. 4 | # 5 | # The AUTHORS file lists the copyright holders; this file 6 | # lists people. For example, ACME Inc. employees would be listed here 7 | # but not in AUTHORS, because ACME Inc. would hold the copyright. 8 | # 9 | # When adding J Random Contributor's name to this file, 10 | # either J's name or J's organization's name should be 11 | # added to the AUTHORS file. 12 | # 13 | # Names should be added to this file like so: 14 | # Name 15 | # 16 | # Please keep the list sorted. 17 | 18 | Danny Yoo 19 | James Kolb 20 | Jonathan Amsterdam 21 | Markus Zimmermann 22 | Matt Kovars 23 | Örjan Persson 24 | Osman Masood 25 | Robert Carlsen 26 | Rory Flynn 27 | Sergi Mansilla 28 | Shatrugna Sadhu 29 | Shawn Smith 30 | Stas Maksimov 31 | Tor Arvid Lund 32 | Zac Bergquist 33 | -------------------------------------------------------------------------------- /vendor/github.com/sergi/go-diff/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2016 The go-diff Authors. All rights reserved. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a 4 | copy of this software and associated documentation files (the "Software"), 5 | to deal in the Software without restriction, including without limitation 6 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | and/or sell copies of the Software, and to permit persons to whom the 8 | Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included 11 | in all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | DEALINGS IN THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /vendor/github.com/sergi/go-diff/diffmatchpatch/diffmatchpatch.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2016 The go-diff authors. All rights reserved. 2 | // https://github.com/sergi/go-diff 3 | // See the included LICENSE file for license details. 4 | // 5 | // go-diff is a Go implementation of Google's Diff, Match, and Patch library 6 | // Original library is Copyright (c) 2006 Google Inc. 7 | // http://code.google.com/p/google-diff-match-patch/ 8 | 9 | // Package diffmatchpatch offers robust algorithms to perform the operations required for synchronizing plain text. 10 | package diffmatchpatch 11 | 12 | import ( 13 | "time" 14 | ) 15 | 16 | // DiffMatchPatch holds the configuration for diff-match-patch operations. 17 | type DiffMatchPatch struct { 18 | // Number of seconds to map a diff before giving up (0 for infinity). 19 | DiffTimeout time.Duration 20 | // Cost of an empty edit operation in terms of edit characters. 21 | DiffEditCost int 22 | // How far to search for a match (0 = exact location, 1000+ = broad match). A match this many characters away from the expected location will add 1.0 to the score (0.0 is a perfect match). 23 | MatchDistance int 24 | // When deleting a large block of text (over ~64 characters), how close do the contents have to be to match the expected contents. (0.0 = perfection, 1.0 = very loose). Note that MatchThreshold controls how closely the end points of a delete need to match. 25 | PatchDeleteThreshold float64 26 | // Chunk size for context length. 27 | PatchMargin int 28 | // The number of bits in an int. 29 | MatchMaxBits int 30 | // At what point is no match declared (0.0 = perfection, 1.0 = very loose). 31 | MatchThreshold float64 32 | } 33 | 34 | // New creates a new DiffMatchPatch object with default parameters. 35 | func New() *DiffMatchPatch { 36 | // Defaults. 37 | return &DiffMatchPatch{ 38 | DiffTimeout: time.Second, 39 | DiffEditCost: 4, 40 | MatchThreshold: 0.5, 41 | MatchDistance: 1000, 42 | PatchDeleteThreshold: 0.5, 43 | PatchMargin: 4, 44 | MatchMaxBits: 32, 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/sergi/go-diff/diffmatchpatch/mathutil.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2016 The go-diff authors. All rights reserved. 2 | // https://github.com/sergi/go-diff 3 | // See the included LICENSE file for license details. 4 | // 5 | // go-diff is a Go implementation of Google's Diff, Match, and Patch library 6 | // Original library is Copyright (c) 2006 Google Inc. 7 | // http://code.google.com/p/google-diff-match-patch/ 8 | 9 | package diffmatchpatch 10 | 11 | func min(x, y int) int { 12 | if x < y { 13 | return x 14 | } 15 | return y 16 | } 17 | 18 | func max(x, y int) int { 19 | if x > y { 20 | return x 21 | } 22 | return y 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Péter Surányi. Portions Copyright (c) 2009 The Go 2 | Authors. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/README: -------------------------------------------------------------------------------- 1 | Gcfg reads INI-style configuration files into Go structs; 2 | supports user-defined types and subsections. 3 | 4 | Package docs: https://godoc.org/gopkg.in/gcfg.v1 5 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/errors.go: -------------------------------------------------------------------------------- 1 | package gcfg 2 | 3 | import ( 4 | "gopkg.in/warnings.v0" 5 | ) 6 | 7 | // FatalOnly filters the results of a Read*Into invocation and returns only 8 | // fatal errors. That is, errors (warnings) indicating data for unknown 9 | // sections / variables is ignored. Example invocation: 10 | // 11 | // err := gcfg.FatalOnly(gcfg.ReadFileInto(&cfg, configFile)) 12 | // if err != nil { 13 | // ... 14 | // 15 | func FatalOnly(err error) error { 16 | return warnings.FatalOnly(err) 17 | } 18 | 19 | func isFatal(err error) bool { 20 | _, ok := err.(extraData) 21 | return !ok 22 | } 23 | 24 | type extraData struct { 25 | section string 26 | subsection *string 27 | variable *string 28 | } 29 | 30 | func (e extraData) Error() string { 31 | s := "can't store data at section \"" + e.section + "\"" 32 | if e.subsection != nil { 33 | s += ", subsection \"" + *e.subsection + "\"" 34 | } 35 | if e.variable != nil { 36 | s += ", variable \"" + *e.variable + "\"" 37 | } 38 | return s 39 | } 40 | 41 | var _ error = extraData{} 42 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/go1_0.go: -------------------------------------------------------------------------------- 1 | // +build !go1.2 2 | 3 | package gcfg 4 | 5 | type textUnmarshaler interface { 6 | UnmarshalText(text []byte) error 7 | } 8 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/go1_2.go: -------------------------------------------------------------------------------- 1 | // +build go1.2 2 | 3 | package gcfg 4 | 5 | import ( 6 | "encoding" 7 | ) 8 | 9 | type textUnmarshaler encoding.TextUnmarshaler 10 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/token/serialize.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package token 6 | 7 | type serializedFile struct { 8 | // fields correspond 1:1 to fields with same (lower-case) name in File 9 | Name string 10 | Base int 11 | Size int 12 | Lines []int 13 | Infos []lineInfo 14 | } 15 | 16 | type serializedFileSet struct { 17 | Base int 18 | Files []serializedFile 19 | } 20 | 21 | // Read calls decode to deserialize a file set into s; s must not be nil. 22 | func (s *FileSet) Read(decode func(interface{}) error) error { 23 | var ss serializedFileSet 24 | if err := decode(&ss); err != nil { 25 | return err 26 | } 27 | 28 | s.mutex.Lock() 29 | s.base = ss.Base 30 | files := make([]*File, len(ss.Files)) 31 | for i := 0; i < len(ss.Files); i++ { 32 | f := &ss.Files[i] 33 | files[i] = &File{s, f.Name, f.Base, f.Size, f.Lines, f.Infos} 34 | } 35 | s.files = files 36 | s.last = nil 37 | s.mutex.Unlock() 38 | 39 | return nil 40 | } 41 | 42 | // Write calls encode to serialize the file set s. 43 | func (s *FileSet) Write(encode func(interface{}) error) error { 44 | var ss serializedFileSet 45 | 46 | s.mutex.Lock() 47 | ss.Base = s.base 48 | files := make([]serializedFile, len(s.files)) 49 | for i, f := range s.files { 50 | files[i] = serializedFile{f.name, f.base, f.size, f.lines, f.infos} 51 | } 52 | ss.Files = files 53 | s.mutex.Unlock() 54 | 55 | return encode(ss) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/token/token.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package token defines constants representing the lexical tokens of the gcfg 6 | // configuration syntax and basic operations on tokens (printing, predicates). 7 | // 8 | // Note that the API for the token package may change to accommodate new 9 | // features or implementation changes in gcfg. 10 | // 11 | package token 12 | 13 | import "strconv" 14 | 15 | // Token is the set of lexical tokens of the gcfg configuration syntax. 16 | type Token int 17 | 18 | // The list of tokens. 19 | const ( 20 | // Special tokens 21 | ILLEGAL Token = iota 22 | EOF 23 | COMMENT 24 | 25 | literal_beg 26 | // Identifiers and basic type literals 27 | // (these tokens stand for classes of literals) 28 | IDENT // section-name, variable-name 29 | STRING // "subsection-name", variable value 30 | literal_end 31 | 32 | operator_beg 33 | // Operators and delimiters 34 | ASSIGN // = 35 | LBRACK // [ 36 | RBRACK // ] 37 | EOL // \n 38 | operator_end 39 | ) 40 | 41 | var tokens = [...]string{ 42 | ILLEGAL: "ILLEGAL", 43 | 44 | EOF: "EOF", 45 | COMMENT: "COMMENT", 46 | 47 | IDENT: "IDENT", 48 | STRING: "STRING", 49 | 50 | ASSIGN: "=", 51 | LBRACK: "[", 52 | RBRACK: "]", 53 | EOL: "\n", 54 | } 55 | 56 | // String returns the string corresponding to the token tok. 57 | // For operators and delimiters, the string is the actual token character 58 | // sequence (e.g., for the token ASSIGN, the string is "="). For all other 59 | // tokens the string corresponds to the token constant name (e.g. for the 60 | // token IDENT, the string is "IDENT"). 61 | // 62 | func (tok Token) String() string { 63 | s := "" 64 | if 0 <= tok && tok < Token(len(tokens)) { 65 | s = tokens[tok] 66 | } 67 | if s == "" { 68 | s = "token(" + strconv.Itoa(int(tok)) + ")" 69 | } 70 | return s 71 | } 72 | 73 | // Predicates 74 | 75 | // IsLiteral returns true for tokens corresponding to identifiers 76 | // and basic type literals; it returns false otherwise. 77 | // 78 | func (tok Token) IsLiteral() bool { return literal_beg < tok && tok < literal_end } 79 | 80 | // IsOperator returns true for tokens corresponding to operators and 81 | // delimiters; it returns false otherwise. 82 | // 83 | func (tok Token) IsOperator() bool { return operator_beg < tok && tok < operator_end } 84 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/types/bool.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // BoolValues defines the name and value mappings for ParseBool. 4 | var BoolValues = map[string]interface{}{ 5 | "true": true, "yes": true, "on": true, "1": true, 6 | "false": false, "no": false, "off": false, "0": false, 7 | } 8 | 9 | var boolParser = func() *EnumParser { 10 | ep := &EnumParser{} 11 | ep.AddVals(BoolValues) 12 | return ep 13 | }() 14 | 15 | // ParseBool parses bool values according to the definitions in BoolValues. 16 | // Parsing is case-insensitive. 17 | func ParseBool(s string) (bool, error) { 18 | v, err := boolParser.Parse(s) 19 | if err != nil { 20 | return false, err 21 | } 22 | return v.(bool), nil 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/types/doc.go: -------------------------------------------------------------------------------- 1 | // Package types defines helpers for type conversions. 2 | // 3 | // The API for this package is not finalized yet. 4 | package types 5 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/types/enum.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | "strings" 7 | ) 8 | 9 | // EnumParser parses "enum" values; i.e. a predefined set of strings to 10 | // predefined values. 11 | type EnumParser struct { 12 | Type string // type name; if not set, use type of first value added 13 | CaseMatch bool // if true, matching of strings is case-sensitive 14 | // PrefixMatch bool 15 | vals map[string]interface{} 16 | } 17 | 18 | // AddVals adds strings and values to an EnumParser. 19 | func (ep *EnumParser) AddVals(vals map[string]interface{}) { 20 | if ep.vals == nil { 21 | ep.vals = make(map[string]interface{}) 22 | } 23 | for k, v := range vals { 24 | if ep.Type == "" { 25 | ep.Type = reflect.TypeOf(v).Name() 26 | } 27 | if !ep.CaseMatch { 28 | k = strings.ToLower(k) 29 | } 30 | ep.vals[k] = v 31 | } 32 | } 33 | 34 | // Parse parses the string and returns the value or an error. 35 | func (ep EnumParser) Parse(s string) (interface{}, error) { 36 | if !ep.CaseMatch { 37 | s = strings.ToLower(s) 38 | } 39 | v, ok := ep.vals[s] 40 | if !ok { 41 | return false, fmt.Errorf("failed to parse %s %#q", ep.Type, s) 42 | } 43 | return v, nil 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/types/int.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | // An IntMode is a mode for parsing integer values, representing a set of 9 | // accepted bases. 10 | type IntMode uint8 11 | 12 | // IntMode values for ParseInt; can be combined using binary or. 13 | const ( 14 | Dec IntMode = 1 << iota 15 | Hex 16 | Oct 17 | ) 18 | 19 | // String returns a string representation of IntMode; e.g. `IntMode(Dec|Hex)`. 20 | func (m IntMode) String() string { 21 | var modes []string 22 | if m&Dec != 0 { 23 | modes = append(modes, "Dec") 24 | } 25 | if m&Hex != 0 { 26 | modes = append(modes, "Hex") 27 | } 28 | if m&Oct != 0 { 29 | modes = append(modes, "Oct") 30 | } 31 | return "IntMode(" + strings.Join(modes, "|") + ")" 32 | } 33 | 34 | var errIntAmbig = fmt.Errorf("ambiguous integer value; must include '0' prefix") 35 | 36 | func prefix0(val string) bool { 37 | return strings.HasPrefix(val, "0") || strings.HasPrefix(val, "-0") 38 | } 39 | 40 | func prefix0x(val string) bool { 41 | return strings.HasPrefix(val, "0x") || strings.HasPrefix(val, "-0x") 42 | } 43 | 44 | // ParseInt parses val using mode into intptr, which must be a pointer to an 45 | // integer kind type. Non-decimal value require prefix `0` or `0x` in the cases 46 | // when mode permits ambiguity of base; otherwise the prefix can be omitted. 47 | func ParseInt(intptr interface{}, val string, mode IntMode) error { 48 | val = strings.TrimSpace(val) 49 | verb := byte(0) 50 | switch mode { 51 | case Dec: 52 | verb = 'd' 53 | case Dec + Hex: 54 | if prefix0x(val) { 55 | verb = 'v' 56 | } else { 57 | verb = 'd' 58 | } 59 | case Dec + Oct: 60 | if prefix0(val) && !prefix0x(val) { 61 | verb = 'v' 62 | } else { 63 | verb = 'd' 64 | } 65 | case Dec + Hex + Oct: 66 | verb = 'v' 67 | case Hex: 68 | if prefix0x(val) { 69 | verb = 'v' 70 | } else { 71 | verb = 'x' 72 | } 73 | case Oct: 74 | verb = 'o' 75 | case Hex + Oct: 76 | if prefix0(val) { 77 | verb = 'v' 78 | } else { 79 | return errIntAmbig 80 | } 81 | } 82 | if verb == 0 { 83 | panic("unsupported mode") 84 | } 85 | return ScanFully(intptr, val, verb) 86 | } 87 | -------------------------------------------------------------------------------- /vendor/github.com/src-d/gcfg/types/scan.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "reflect" 7 | ) 8 | 9 | // ScanFully uses fmt.Sscanf with verb to fully scan val into ptr. 10 | func ScanFully(ptr interface{}, val string, verb byte) error { 11 | t := reflect.ValueOf(ptr).Elem().Type() 12 | // attempt to read extra bytes to make sure the value is consumed 13 | var b []byte 14 | n, err := fmt.Sscanf(val, "%"+string(verb)+"%s", ptr, &b) 15 | switch { 16 | case n < 1 || n == 1 && err != io.EOF: 17 | return fmt.Errorf("failed to parse %q as %v: %v", val, t, err) 18 | case n > 1: 19 | return fmt.Errorf("failed to parse %q as %v: extra characters %q", val, t, string(b)) 20 | } 21 | // n == 1 && err == io.EOF 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/xanzy/ssh-agent/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | -------------------------------------------------------------------------------- /vendor/github.com/xanzy/ssh-agent/README.md: -------------------------------------------------------------------------------- 1 | # ssh-agent 2 | 3 | Create a new [agent.Agent](https://godoc.org/golang.org/x/crypto/ssh/agent#Agent) on any type of OS (so including Windows) from any [Go](https://golang.org) application. 4 | 5 | ## Limitations 6 | 7 | When compiled for Windows, it will only support [Pageant](http://the.earth.li/~sgtatham/putty/0.66/htmldoc/Chapter9.html#pageant) as the SSH authentication agent. 8 | 9 | ## Credits 10 | 11 | Big thanks to [Давид Мзареулян (David Mzareulyan)](https://github.com/davidmz) for creating the [go-pageant](https://github.com/davidmz/go-pageant) package! 12 | 13 | ## Issues 14 | 15 | If you have an issue: report it on the [issue tracker](https://github.com/xanzy/ssh-agent/issues) 16 | 17 | ## Author 18 | 19 | Sander van Harmelen () 20 | 21 | ## License 22 | 23 | The files `pageant_windows.go` and `sshagent_windows.go` have their own license (see file headers). The rest of this package is licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 24 | -------------------------------------------------------------------------------- /vendor/github.com/xanzy/ssh-agent/sshagent.go: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2015, Sander van Harmelen 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | // +build !windows 18 | 19 | package sshagent 20 | 21 | import ( 22 | "errors" 23 | "fmt" 24 | "net" 25 | "os" 26 | 27 | "golang.org/x/crypto/ssh/agent" 28 | ) 29 | 30 | // New returns a new agent.Agent that uses a unix socket 31 | func New() (agent.Agent, net.Conn, error) { 32 | if !Available() { 33 | return nil, nil, errors.New("SSH agent requested but SSH_AUTH_SOCK not-specified") 34 | } 35 | 36 | sshAuthSock := os.Getenv("SSH_AUTH_SOCK") 37 | 38 | conn, err := net.Dial("unix", sshAuthSock) 39 | if err != nil { 40 | return nil, nil, fmt.Errorf("Error connecting to SSH_AUTH_SOCK: %v", err) 41 | } 42 | 43 | return agent.NewClient(conn), conn, nil 44 | } 45 | 46 | // Available returns true is a auth socket is defined 47 | func Available() bool { 48 | return os.Getenv("SSH_AUTH_SOCK") != "" 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/xanzy/ssh-agent/sshagent_windows.go: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2014 David Mzareulyan 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software 5 | // and associated documentation files (the "Software"), to deal in the Software without restriction, 6 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software 8 | // is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all copies or substantial 11 | // portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 14 | // BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | // 19 | 20 | // +build windows 21 | 22 | package sshagent 23 | 24 | import ( 25 | "errors" 26 | "io" 27 | "net" 28 | "sync" 29 | 30 | "golang.org/x/crypto/ssh/agent" 31 | ) 32 | 33 | // New returns a new agent.Agent and the (custom) connection it uses 34 | // to communicate with a running pagent.exe instance (see README.md) 35 | func New() (agent.Agent, net.Conn, error) { 36 | if !Available() { 37 | return nil, nil, errors.New("SSH agent requested but Pageant not running") 38 | } 39 | 40 | return agent.NewClient(&conn{}), nil, nil 41 | } 42 | 43 | type conn struct { 44 | sync.Mutex 45 | buf []byte 46 | } 47 | 48 | func (c *conn) Close() { 49 | c.Lock() 50 | defer c.Unlock() 51 | c.buf = nil 52 | } 53 | 54 | func (c *conn) Write(p []byte) (int, error) { 55 | c.Lock() 56 | defer c.Unlock() 57 | 58 | resp, err := query(p) 59 | if err != nil { 60 | return 0, err 61 | } 62 | 63 | c.buf = append(c.buf, resp...) 64 | 65 | return len(p), nil 66 | } 67 | 68 | func (c *conn) Read(p []byte) (int, error) { 69 | c.Lock() 70 | defer c.Unlock() 71 | 72 | if len(c.buf) == 0 { 73 | return 0, io.EOF 74 | } 75 | 76 | n := copy(p, c.buf) 77 | c.buf = c.buf[n:] 78 | 79 | return n, nil 80 | } 81 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at https://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at https://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/const_amd64.h: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html 7 | 8 | #define REDMASK51 0x0007FFFFFFFFFFFF 9 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/const_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html 7 | 8 | // +build amd64,!gccgo,!appengine 9 | 10 | // These constants cannot be encoded in non-MOVQ immediates. 11 | // We access them directly from memory instead. 12 | 13 | DATA ·_121666_213(SB)/8, $996687872 14 | GLOBL ·_121666_213(SB), 8, $8 15 | 16 | DATA ·_2P0(SB)/8, $0xFFFFFFFFFFFDA 17 | GLOBL ·_2P0(SB), 8, $8 18 | 19 | DATA ·_2P1234(SB)/8, $0xFFFFFFFFFFFFE 20 | GLOBL ·_2P1234(SB), 8, $8 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/cswap_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,!gccgo,!appengine 6 | 7 | // func cswap(inout *[4][5]uint64, v uint64) 8 | TEXT ·cswap(SB),7,$0 9 | MOVQ inout+0(FP),DI 10 | MOVQ v+8(FP),SI 11 | 12 | SUBQ $1, SI 13 | NOTQ SI 14 | MOVQ SI, X15 15 | PSHUFD $0x44, X15, X15 16 | 17 | MOVOU 0(DI), X0 18 | MOVOU 16(DI), X2 19 | MOVOU 32(DI), X4 20 | MOVOU 48(DI), X6 21 | MOVOU 64(DI), X8 22 | MOVOU 80(DI), X1 23 | MOVOU 96(DI), X3 24 | MOVOU 112(DI), X5 25 | MOVOU 128(DI), X7 26 | MOVOU 144(DI), X9 27 | 28 | MOVO X1, X10 29 | MOVO X3, X11 30 | MOVO X5, X12 31 | MOVO X7, X13 32 | MOVO X9, X14 33 | 34 | PXOR X0, X10 35 | PXOR X2, X11 36 | PXOR X4, X12 37 | PXOR X6, X13 38 | PXOR X8, X14 39 | PAND X15, X10 40 | PAND X15, X11 41 | PAND X15, X12 42 | PAND X15, X13 43 | PAND X15, X14 44 | PXOR X10, X0 45 | PXOR X10, X1 46 | PXOR X11, X2 47 | PXOR X11, X3 48 | PXOR X12, X4 49 | PXOR X12, X5 50 | PXOR X13, X6 51 | PXOR X13, X7 52 | PXOR X14, X8 53 | PXOR X14, X9 54 | 55 | MOVOU X0, 0(DI) 56 | MOVOU X2, 16(DI) 57 | MOVOU X4, 32(DI) 58 | MOVOU X6, 48(DI) 59 | MOVOU X8, 64(DI) 60 | MOVOU X1, 80(DI) 61 | MOVOU X3, 96(DI) 62 | MOVOU X5, 112(DI) 63 | MOVOU X7, 128(DI) 64 | MOVOU X9, 144(DI) 65 | RET 66 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package curve25519 provides an implementation of scalar multiplication on 6 | // the elliptic curve known as curve25519. See https://cr.yp.to/ecdh.html 7 | package curve25519 // import "golang.org/x/crypto/curve25519" 8 | 9 | // basePoint is the x coordinate of the generator of the curve. 10 | var basePoint = [32]byte{9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 11 | 12 | // ScalarMult sets dst to the product in*base where dst and base are the x 13 | // coordinates of group points and all values are in little-endian form. 14 | func ScalarMult(dst, in, base *[32]byte) { 15 | scalarMult(dst, in, base) 16 | } 17 | 18 | // ScalarBaseMult sets dst to the product in*base where dst and base are the x 19 | // coordinates of group points, base is the standard generator and all values 20 | // are in little-endian form. 21 | func ScalarBaseMult(dst, in *[32]byte) { 22 | ScalarMult(dst, in, &basePoint) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/freeze_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html 7 | 8 | // +build amd64,!gccgo,!appengine 9 | 10 | #include "const_amd64.h" 11 | 12 | // func freeze(inout *[5]uint64) 13 | TEXT ·freeze(SB),7,$0-8 14 | MOVQ inout+0(FP), DI 15 | 16 | MOVQ 0(DI),SI 17 | MOVQ 8(DI),DX 18 | MOVQ 16(DI),CX 19 | MOVQ 24(DI),R8 20 | MOVQ 32(DI),R9 21 | MOVQ $REDMASK51,AX 22 | MOVQ AX,R10 23 | SUBQ $18,R10 24 | MOVQ $3,R11 25 | REDUCELOOP: 26 | MOVQ SI,R12 27 | SHRQ $51,R12 28 | ANDQ AX,SI 29 | ADDQ R12,DX 30 | MOVQ DX,R12 31 | SHRQ $51,R12 32 | ANDQ AX,DX 33 | ADDQ R12,CX 34 | MOVQ CX,R12 35 | SHRQ $51,R12 36 | ANDQ AX,CX 37 | ADDQ R12,R8 38 | MOVQ R8,R12 39 | SHRQ $51,R12 40 | ANDQ AX,R8 41 | ADDQ R12,R9 42 | MOVQ R9,R12 43 | SHRQ $51,R12 44 | ANDQ AX,R9 45 | IMUL3Q $19,R12,R12 46 | ADDQ R12,SI 47 | SUBQ $1,R11 48 | JA REDUCELOOP 49 | MOVQ $1,R12 50 | CMPQ R10,SI 51 | CMOVQLT R11,R12 52 | CMPQ AX,DX 53 | CMOVQNE R11,R12 54 | CMPQ AX,CX 55 | CMOVQNE R11,R12 56 | CMPQ AX,R8 57 | CMOVQNE R11,R12 58 | CMPQ AX,R9 59 | CMOVQNE R11,R12 60 | NEGQ R12 61 | ANDQ R12,AX 62 | ANDQ R12,R10 63 | SUBQ R10,SI 64 | SUBQ AX,DX 65 | SUBQ AX,CX 66 | SUBQ AX,R8 67 | SUBQ AX,R9 68 | MOVQ SI,0(DI) 69 | MOVQ DX,8(DI) 70 | MOVQ CX,16(DI) 71 | MOVQ R8,24(DI) 72 | MOVQ R9,32(DI) 73 | RET 74 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/chacha20/chacha_noasm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !s390x gccgo appengine 6 | 7 | package chacha20 8 | 9 | const ( 10 | bufSize = 64 11 | haveAsm = false 12 | ) 13 | 14 | func (*Cipher) xorKeyStreamAsm(dst, src []byte) { 15 | panic("not implemented") 16 | } 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/chacha20/chacha_s390x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x,!gccgo,!appengine 6 | 7 | package chacha20 8 | 9 | var haveAsm = hasVectorFacility() 10 | 11 | const bufSize = 256 12 | 13 | // hasVectorFacility reports whether the machine supports the vector 14 | // facility (vx). 15 | // Implementation in asm_s390x.s. 16 | func hasVectorFacility() bool 17 | 18 | // xorKeyStreamVX is an assembly implementation of XORKeyStream. It must only 19 | // be called when the vector facility is available. 20 | // Implementation in asm_s390x.s. 21 | //go:noescape 22 | func xorKeyStreamVX(dst, src []byte, key *[8]uint32, nonce *[3]uint32, counter *uint32, buf *[256]byte, len *int) 23 | 24 | func (c *Cipher) xorKeyStreamAsm(dst, src []byte) { 25 | xorKeyStreamVX(dst, src, &c.key, &c.nonce, &c.counter, &c.buf, &c.len) 26 | } 27 | 28 | // EXRL targets, DO NOT CALL! 29 | func mvcSrcToBuf() 30 | func mvcBufToDst() 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/chacha20/xor.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found src the LICENSE file. 4 | 5 | package chacha20 6 | 7 | import ( 8 | "runtime" 9 | ) 10 | 11 | // Platforms that have fast unaligned 32-bit little endian accesses. 12 | const unaligned = runtime.GOARCH == "386" || 13 | runtime.GOARCH == "amd64" || 14 | runtime.GOARCH == "arm64" || 15 | runtime.GOARCH == "ppc64le" || 16 | runtime.GOARCH == "s390x" 17 | 18 | // xor reads a little endian uint32 from src, XORs it with u and 19 | // places the result in little endian byte order in dst. 20 | func xor(dst, src []byte, u uint32) { 21 | _, _ = src[3], dst[3] // eliminate bounds checks 22 | if unaligned { 23 | // The compiler should optimize this code into 24 | // 32-bit unaligned little endian loads and stores. 25 | // TODO: delete once the compiler does a reliably 26 | // good job with the generic code below. 27 | // See issue #25111 for more details. 28 | v := uint32(src[0]) 29 | v |= uint32(src[1]) << 8 30 | v |= uint32(src[2]) << 16 31 | v |= uint32(src[3]) << 24 32 | v ^= u 33 | dst[0] = byte(v) 34 | dst[1] = byte(v >> 8) 35 | dst[2] = byte(v >> 16) 36 | dst[3] = byte(v >> 24) 37 | } else { 38 | dst[0] = src[0] ^ byte(u) 39 | dst[1] = src[1] ^ byte(u>>8) 40 | dst[2] = src[2] ^ byte(u>>16) 41 | dst[3] = src[3] ^ byte(u>>24) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/subtle/aliasing.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !appengine 6 | 7 | // Package subtle implements functions that are often useful in cryptographic 8 | // code but require careful thought to use correctly. 9 | package subtle // import "golang.org/x/crypto/internal/subtle" 10 | 11 | import "unsafe" 12 | 13 | // AnyOverlap reports whether x and y share memory at any (not necessarily 14 | // corresponding) index. The memory beyond the slice length is ignored. 15 | func AnyOverlap(x, y []byte) bool { 16 | return len(x) > 0 && len(y) > 0 && 17 | uintptr(unsafe.Pointer(&x[0])) <= uintptr(unsafe.Pointer(&y[len(y)-1])) && 18 | uintptr(unsafe.Pointer(&y[0])) <= uintptr(unsafe.Pointer(&x[len(x)-1])) 19 | } 20 | 21 | // InexactOverlap reports whether x and y share memory at any non-corresponding 22 | // index. The memory beyond the slice length is ignored. Note that x and y can 23 | // have different lengths and still not have any inexact overlap. 24 | // 25 | // InexactOverlap can be used to implement the requirements of the crypto/cipher 26 | // AEAD, Block, BlockMode and Stream interfaces. 27 | func InexactOverlap(x, y []byte) bool { 28 | if len(x) == 0 || len(y) == 0 || &x[0] == &y[0] { 29 | return false 30 | } 31 | return AnyOverlap(x, y) 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/subtle/aliasing_appengine.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build appengine 6 | 7 | // Package subtle implements functions that are often useful in cryptographic 8 | // code but require careful thought to use correctly. 9 | package subtle // import "golang.org/x/crypto/internal/subtle" 10 | 11 | // This is the Google App Engine standard variant based on reflect 12 | // because the unsafe package and cgo are disallowed. 13 | 14 | import "reflect" 15 | 16 | // AnyOverlap reports whether x and y share memory at any (not necessarily 17 | // corresponding) index. The memory beyond the slice length is ignored. 18 | func AnyOverlap(x, y []byte) bool { 19 | return len(x) > 0 && len(y) > 0 && 20 | reflect.ValueOf(&x[0]).Pointer() <= reflect.ValueOf(&y[len(y)-1]).Pointer() && 21 | reflect.ValueOf(&y[0]).Pointer() <= reflect.ValueOf(&x[len(x)-1]).Pointer() 22 | } 23 | 24 | // InexactOverlap reports whether x and y share memory at any non-corresponding 25 | // index. The memory beyond the slice length is ignored. Note that x and y can 26 | // have different lengths and still not have any inexact overlap. 27 | // 28 | // InexactOverlap can be used to implement the requirements of the crypto/cipher 29 | // AEAD, Block, BlockMode and Stream interfaces. 30 | func InexactOverlap(x, y []byte) bool { 31 | if len(x) == 0 || len(y) == 0 || &x[0] == &y[0] { 32 | return false 33 | } 34 | return AnyOverlap(x, y) 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/openpgp/canonical_text.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package openpgp 6 | 7 | import "hash" 8 | 9 | // NewCanonicalTextHash reformats text written to it into the canonical 10 | // form and then applies the hash h. See RFC 4880, section 5.2.1. 11 | func NewCanonicalTextHash(h hash.Hash) hash.Hash { 12 | return &canonicalTextHash{h, 0} 13 | } 14 | 15 | type canonicalTextHash struct { 16 | h hash.Hash 17 | s int 18 | } 19 | 20 | var newline = []byte{'\r', '\n'} 21 | 22 | func (cth *canonicalTextHash) Write(buf []byte) (int, error) { 23 | start := 0 24 | 25 | for i, c := range buf { 26 | switch cth.s { 27 | case 0: 28 | if c == '\r' { 29 | cth.s = 1 30 | } else if c == '\n' { 31 | cth.h.Write(buf[start:i]) 32 | cth.h.Write(newline) 33 | start = i + 1 34 | } 35 | case 1: 36 | cth.s = 0 37 | } 38 | } 39 | 40 | cth.h.Write(buf[start:]) 41 | return len(buf), nil 42 | } 43 | 44 | func (cth *canonicalTextHash) Sum(in []byte) []byte { 45 | return cth.h.Sum(in) 46 | } 47 | 48 | func (cth *canonicalTextHash) Reset() { 49 | cth.h.Reset() 50 | cth.s = 0 51 | } 52 | 53 | func (cth *canonicalTextHash) Size() int { 54 | return cth.h.Size() 55 | } 56 | 57 | func (cth *canonicalTextHash) BlockSize() int { 58 | return cth.h.BlockSize() 59 | } 60 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/openpgp/errors/errors.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package errors contains common error types for the OpenPGP packages. 6 | package errors // import "golang.org/x/crypto/openpgp/errors" 7 | 8 | import ( 9 | "strconv" 10 | ) 11 | 12 | // A StructuralError is returned when OpenPGP data is found to be syntactically 13 | // invalid. 14 | type StructuralError string 15 | 16 | func (s StructuralError) Error() string { 17 | return "openpgp: invalid data: " + string(s) 18 | } 19 | 20 | // UnsupportedError indicates that, although the OpenPGP data is valid, it 21 | // makes use of currently unimplemented features. 22 | type UnsupportedError string 23 | 24 | func (s UnsupportedError) Error() string { 25 | return "openpgp: unsupported feature: " + string(s) 26 | } 27 | 28 | // InvalidArgumentError indicates that the caller is in error and passed an 29 | // incorrect value. 30 | type InvalidArgumentError string 31 | 32 | func (i InvalidArgumentError) Error() string { 33 | return "openpgp: invalid argument: " + string(i) 34 | } 35 | 36 | // SignatureError indicates that a syntactically valid signature failed to 37 | // validate. 38 | type SignatureError string 39 | 40 | func (b SignatureError) Error() string { 41 | return "openpgp: invalid signature: " + string(b) 42 | } 43 | 44 | type keyIncorrectError int 45 | 46 | func (ki keyIncorrectError) Error() string { 47 | return "openpgp: incorrect key" 48 | } 49 | 50 | var ErrKeyIncorrect error = keyIncorrectError(0) 51 | 52 | type unknownIssuerError int 53 | 54 | func (unknownIssuerError) Error() string { 55 | return "openpgp: signature made by unknown entity" 56 | } 57 | 58 | var ErrUnknownIssuer error = unknownIssuerError(0) 59 | 60 | type keyRevokedError int 61 | 62 | func (keyRevokedError) Error() string { 63 | return "openpgp: signature made by revoked key" 64 | } 65 | 66 | var ErrKeyRevoked error = keyRevokedError(0) 67 | 68 | type UnknownPacketTypeError uint8 69 | 70 | func (upte UnknownPacketTypeError) Error() string { 71 | return "openpgp: unknown packet type: " + strconv.Itoa(int(upte)) 72 | } 73 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/openpgp/packet/literal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package packet 6 | 7 | import ( 8 | "encoding/binary" 9 | "io" 10 | ) 11 | 12 | // LiteralData represents an encrypted file. See RFC 4880, section 5.9. 13 | type LiteralData struct { 14 | IsBinary bool 15 | FileName string 16 | Time uint32 // Unix epoch time. Either creation time or modification time. 0 means undefined. 17 | Body io.Reader 18 | } 19 | 20 | // ForEyesOnly returns whether the contents of the LiteralData have been marked 21 | // as especially sensitive. 22 | func (l *LiteralData) ForEyesOnly() bool { 23 | return l.FileName == "_CONSOLE" 24 | } 25 | 26 | func (l *LiteralData) parse(r io.Reader) (err error) { 27 | var buf [256]byte 28 | 29 | _, err = readFull(r, buf[:2]) 30 | if err != nil { 31 | return 32 | } 33 | 34 | l.IsBinary = buf[0] == 'b' 35 | fileNameLen := int(buf[1]) 36 | 37 | _, err = readFull(r, buf[:fileNameLen]) 38 | if err != nil { 39 | return 40 | } 41 | 42 | l.FileName = string(buf[:fileNameLen]) 43 | 44 | _, err = readFull(r, buf[:4]) 45 | if err != nil { 46 | return 47 | } 48 | 49 | l.Time = binary.BigEndian.Uint32(buf[:4]) 50 | l.Body = r 51 | return 52 | } 53 | 54 | // SerializeLiteral serializes a literal data packet to w and returns a 55 | // WriteCloser to which the data itself can be written and which MUST be closed 56 | // on completion. The fileName is truncated to 255 bytes. 57 | func SerializeLiteral(w io.WriteCloser, isBinary bool, fileName string, time uint32) (plaintext io.WriteCloser, err error) { 58 | var buf [4]byte 59 | buf[0] = 't' 60 | if isBinary { 61 | buf[0] = 'b' 62 | } 63 | if len(fileName) > 255 { 64 | fileName = fileName[:255] 65 | } 66 | buf[1] = byte(len(fileName)) 67 | 68 | inner, err := serializeStreamHeader(w, packetTypeLiteralData) 69 | if err != nil { 70 | return 71 | } 72 | 73 | _, err = inner.Write(buf[:2]) 74 | if err != nil { 75 | return 76 | } 77 | _, err = inner.Write([]byte(fileName)) 78 | if err != nil { 79 | return 80 | } 81 | binary.BigEndian.PutUint32(buf[:], time) 82 | _, err = inner.Write(buf[:]) 83 | if err != nil { 84 | return 85 | } 86 | 87 | plaintext = inner 88 | return 89 | } 90 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/openpgp/packet/one_pass_signature.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package packet 6 | 7 | import ( 8 | "crypto" 9 | "encoding/binary" 10 | "golang.org/x/crypto/openpgp/errors" 11 | "golang.org/x/crypto/openpgp/s2k" 12 | "io" 13 | "strconv" 14 | ) 15 | 16 | // OnePassSignature represents a one-pass signature packet. See RFC 4880, 17 | // section 5.4. 18 | type OnePassSignature struct { 19 | SigType SignatureType 20 | Hash crypto.Hash 21 | PubKeyAlgo PublicKeyAlgorithm 22 | KeyId uint64 23 | IsLast bool 24 | } 25 | 26 | const onePassSignatureVersion = 3 27 | 28 | func (ops *OnePassSignature) parse(r io.Reader) (err error) { 29 | var buf [13]byte 30 | 31 | _, err = readFull(r, buf[:]) 32 | if err != nil { 33 | return 34 | } 35 | if buf[0] != onePassSignatureVersion { 36 | err = errors.UnsupportedError("one-pass-signature packet version " + strconv.Itoa(int(buf[0]))) 37 | } 38 | 39 | var ok bool 40 | ops.Hash, ok = s2k.HashIdToHash(buf[2]) 41 | if !ok { 42 | return errors.UnsupportedError("hash function: " + strconv.Itoa(int(buf[2]))) 43 | } 44 | 45 | ops.SigType = SignatureType(buf[1]) 46 | ops.PubKeyAlgo = PublicKeyAlgorithm(buf[3]) 47 | ops.KeyId = binary.BigEndian.Uint64(buf[4:12]) 48 | ops.IsLast = buf[12] != 0 49 | return 50 | } 51 | 52 | // Serialize marshals the given OnePassSignature to w. 53 | func (ops *OnePassSignature) Serialize(w io.Writer) error { 54 | var buf [13]byte 55 | buf[0] = onePassSignatureVersion 56 | buf[1] = uint8(ops.SigType) 57 | var ok bool 58 | buf[2], ok = s2k.HashToHashId(ops.Hash) 59 | if !ok { 60 | return errors.UnsupportedError("hash type: " + strconv.Itoa(int(ops.Hash))) 61 | } 62 | buf[3] = uint8(ops.PubKeyAlgo) 63 | binary.BigEndian.PutUint64(buf[4:12], ops.KeyId) 64 | if ops.IsLast { 65 | buf[12] = 1 66 | } 67 | 68 | if err := serializeHeader(w, packetTypeOnePassSignature, len(buf)); err != nil { 69 | return err 70 | } 71 | _, err := w.Write(buf[:]) 72 | return err 73 | } 74 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/poly1305/poly1305.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package poly1305 implements Poly1305 one-time message authentication code as 7 | specified in https://cr.yp.to/mac/poly1305-20050329.pdf. 8 | 9 | Poly1305 is a fast, one-time authentication function. It is infeasible for an 10 | attacker to generate an authenticator for a message without the key. However, a 11 | key must only be used for a single message. Authenticating two different 12 | messages with the same key allows an attacker to forge authenticators for other 13 | messages with the same key. 14 | 15 | Poly1305 was originally coupled with AES in order to make Poly1305-AES. AES was 16 | used with a fixed key in order to generate one-time keys from an nonce. 17 | However, in this package AES isn't used and the one-time key is specified 18 | directly. 19 | */ 20 | package poly1305 // import "golang.org/x/crypto/poly1305" 21 | 22 | import "crypto/subtle" 23 | 24 | // TagSize is the size, in bytes, of a poly1305 authenticator. 25 | const TagSize = 16 26 | 27 | // Verify returns true if mac is a valid authenticator for m with the given 28 | // key. 29 | func Verify(mac *[16]byte, m []byte, key *[32]byte) bool { 30 | var tmp [16]byte 31 | Sum(&tmp, m, key) 32 | return subtle.ConstantTimeCompare(tmp[:], mac[:]) == 1 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/poly1305/sum_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,!gccgo,!appengine 6 | 7 | package poly1305 8 | 9 | // This function is implemented in sum_amd64.s 10 | //go:noescape 11 | func poly1305(out *[16]byte, m *byte, mlen uint64, key *[32]byte) 12 | 13 | // Sum generates an authenticator for m using a one-time key and puts the 14 | // 16-byte result into out. Authenticating two different messages with the same 15 | // key allows an attacker to forge messages at will. 16 | func Sum(out *[16]byte, m []byte, key *[32]byte) { 17 | var mPtr *byte 18 | if len(m) > 0 { 19 | mPtr = &m[0] 20 | } 21 | poly1305(out, mPtr, uint64(len(m)), key) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/poly1305/sum_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,!gccgo,!appengine,!nacl 6 | 7 | package poly1305 8 | 9 | // This function is implemented in sum_arm.s 10 | //go:noescape 11 | func poly1305_auth_armv6(out *[16]byte, m *byte, mlen uint32, key *[32]byte) 12 | 13 | // Sum generates an authenticator for m using a one-time key and puts the 14 | // 16-byte result into out. Authenticating two different messages with the same 15 | // key allows an attacker to forge messages at will. 16 | func Sum(out *[16]byte, m []byte, key *[32]byte) { 17 | var mPtr *byte 18 | if len(m) > 0 { 19 | mPtr = &m[0] 20 | } 21 | poly1305_auth_armv6(out, mPtr, uint32(len(m)), key) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/poly1305/sum_noasm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x,!go1.11 !arm,!amd64,!s390x gccgo appengine nacl 6 | 7 | package poly1305 8 | 9 | // Sum generates an authenticator for msg using a one-time key and puts the 10 | // 16-byte result into out. Authenticating two different messages with the same 11 | // key allows an attacker to forge messages at will. 12 | func Sum(out *[TagSize]byte, msg []byte, key *[32]byte) { 13 | sumGeneric(out, msg, key) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/poly1305/sum_s390x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x,go1.11,!gccgo,!appengine 6 | 7 | package poly1305 8 | 9 | // hasVectorFacility reports whether the machine supports 10 | // the vector facility (vx). 11 | func hasVectorFacility() bool 12 | 13 | // hasVMSLFacility reports whether the machine supports 14 | // Vector Multiply Sum Logical (VMSL). 15 | func hasVMSLFacility() bool 16 | 17 | var hasVX = hasVectorFacility() 18 | var hasVMSL = hasVMSLFacility() 19 | 20 | // poly1305vx is an assembly implementation of Poly1305 that uses vector 21 | // instructions. It must only be called if the vector facility (vx) is 22 | // available. 23 | //go:noescape 24 | func poly1305vx(out *[16]byte, m *byte, mlen uint64, key *[32]byte) 25 | 26 | // poly1305vmsl is an assembly implementation of Poly1305 that uses vector 27 | // instructions, including VMSL. It must only be called if the vector facility (vx) is 28 | // available and if VMSL is supported. 29 | //go:noescape 30 | func poly1305vmsl(out *[16]byte, m *byte, mlen uint64, key *[32]byte) 31 | 32 | // Sum generates an authenticator for m using a one-time key and puts the 33 | // 16-byte result into out. Authenticating two different messages with the same 34 | // key allows an attacker to forge messages at will. 35 | func Sum(out *[16]byte, m []byte, key *[32]byte) { 36 | if hasVX { 37 | var mPtr *byte 38 | if len(m) > 0 { 39 | mPtr = &m[0] 40 | } 41 | if hasVMSL && len(m) > 256 { 42 | poly1305vmsl(out, mPtr, uint64(len(m)), key) 43 | } else { 44 | poly1305vx(out, mPtr, uint64(len(m)), key) 45 | } 46 | } else { 47 | sumGeneric(out, m, key) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package ssh implements an SSH client and server. 7 | 8 | SSH is a transport security protocol, an authentication protocol and a 9 | family of application protocols. The most typical application level 10 | protocol is a remote shell and this is specifically implemented. However, 11 | the multiplexed nature of SSH is exposed to users that wish to support 12 | others. 13 | 14 | References: 15 | [PROTOCOL.certkeys]: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.certkeys?rev=HEAD 16 | [SSH-PARAMETERS]: http://www.iana.org/assignments/ssh-parameters/ssh-parameters.xml#ssh-parameters-1 17 | 18 | This package does not fall under the stability promise of the Go language itself, 19 | so its API may be changed when pressing needs arise. 20 | */ 21 | package ssh // import "golang.org/x/crypto/ssh" 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/mac.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ssh 6 | 7 | // Message authentication support 8 | 9 | import ( 10 | "crypto/hmac" 11 | "crypto/sha1" 12 | "crypto/sha256" 13 | "hash" 14 | ) 15 | 16 | type macMode struct { 17 | keySize int 18 | etm bool 19 | new func(key []byte) hash.Hash 20 | } 21 | 22 | // truncatingMAC wraps around a hash.Hash and truncates the output digest to 23 | // a given size. 24 | type truncatingMAC struct { 25 | length int 26 | hmac hash.Hash 27 | } 28 | 29 | func (t truncatingMAC) Write(data []byte) (int, error) { 30 | return t.hmac.Write(data) 31 | } 32 | 33 | func (t truncatingMAC) Sum(in []byte) []byte { 34 | out := t.hmac.Sum(in) 35 | return out[:len(in)+t.length] 36 | } 37 | 38 | func (t truncatingMAC) Reset() { 39 | t.hmac.Reset() 40 | } 41 | 42 | func (t truncatingMAC) Size() int { 43 | return t.length 44 | } 45 | 46 | func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() } 47 | 48 | var macModes = map[string]*macMode{ 49 | "hmac-sha2-256-etm@openssh.com": {32, true, func(key []byte) hash.Hash { 50 | return hmac.New(sha256.New, key) 51 | }}, 52 | "hmac-sha2-256": {32, false, func(key []byte) hash.Hash { 53 | return hmac.New(sha256.New, key) 54 | }}, 55 | "hmac-sha1": {20, false, func(key []byte) hash.Hash { 56 | return hmac.New(sha1.New, key) 57 | }}, 58 | "hmac-sha1-96": {20, false, func(key []byte) hash.Hash { 59 | return truncatingMAC{12, hmac.New(sha1.New, key)} 60 | }}, 61 | } 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/go19.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.9 6 | 7 | package context 8 | 9 | import "context" // standard library's context, as of Go 1.7 10 | 11 | // A Context carries a deadline, a cancelation signal, and other values across 12 | // API boundaries. 13 | // 14 | // Context's methods may be called by multiple goroutines simultaneously. 15 | type Context = context.Context 16 | 17 | // A CancelFunc tells an operation to abandon its work. 18 | // A CancelFunc does not wait for the work to stop. 19 | // After the first call, subsequent calls to a CancelFunc do nothing. 20 | type CancelFunc = context.CancelFunc 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/aliases.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | // +build go1.9 7 | 8 | package windows 9 | 10 | import "syscall" 11 | 12 | type Errno = syscall.Errno 13 | type SysProcAttr = syscall.SysProcAttr 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/asm_windows_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // 6 | // System calls for 386, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-16 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-12 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/asm_windows_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // 6 | // System calls for amd64, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-32 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-24 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/asm_windows_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | #include "textflag.h" 6 | 7 | TEXT ·getprocaddress(SB),NOSPLIT,$0 8 | B syscall·getprocaddress(SB) 9 | 10 | TEXT ·loadlibrary(SB),NOSPLIT,$0 11 | B syscall·loadlibrary(SB) 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/env_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Windows environment variables. 6 | 7 | package windows 8 | 9 | import "syscall" 10 | 11 | func Getenv(key string) (value string, found bool) { 12 | return syscall.Getenv(key) 13 | } 14 | 15 | func Setenv(key, value string) error { 16 | return syscall.Setenv(key, value) 17 | } 18 | 19 | func Clearenv() { 20 | syscall.Clearenv() 21 | } 22 | 23 | func Environ() []string { 24 | return syscall.Environ() 25 | } 26 | 27 | func Unsetenv(key string) error { 28 | return syscall.Unsetenv(key) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/eventlog.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package windows 8 | 9 | const ( 10 | EVENTLOG_SUCCESS = 0 11 | EVENTLOG_ERROR_TYPE = 1 12 | EVENTLOG_WARNING_TYPE = 2 13 | EVENTLOG_INFORMATION_TYPE = 4 14 | EVENTLOG_AUDIT_SUCCESS = 8 15 | EVENTLOG_AUDIT_FAILURE = 16 16 | ) 17 | 18 | //sys RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) [failretval==0] = advapi32.RegisterEventSourceW 19 | //sys DeregisterEventSource(handle Handle) (err error) = advapi32.DeregisterEventSource 20 | //sys ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) = advapi32.ReportEventW 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/exec_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Fork, exec, wait, etc. 6 | 7 | package windows 8 | 9 | // EscapeArg rewrites command line argument s as prescribed 10 | // in http://msdn.microsoft.com/en-us/library/ms880421. 11 | // This function returns "" (2 double quotes) if s is empty. 12 | // Alternatively, these transformations are done: 13 | // - every back slash (\) is doubled, but only if immediately 14 | // followed by double quote ("); 15 | // - every double quote (") is escaped by back slash (\); 16 | // - finally, s is wrapped with double quotes (arg -> "arg"), 17 | // but only if there is space or tab inside s. 18 | func EscapeArg(s string) string { 19 | if len(s) == 0 { 20 | return "\"\"" 21 | } 22 | n := len(s) 23 | hasSpace := false 24 | for i := 0; i < len(s); i++ { 25 | switch s[i] { 26 | case '"', '\\': 27 | n++ 28 | case ' ', '\t': 29 | hasSpace = true 30 | } 31 | } 32 | if hasSpace { 33 | n += 2 34 | } 35 | if n == len(s) { 36 | return s 37 | } 38 | 39 | qs := make([]byte, n) 40 | j := 0 41 | if hasSpace { 42 | qs[j] = '"' 43 | j++ 44 | } 45 | slashes := 0 46 | for i := 0; i < len(s); i++ { 47 | switch s[i] { 48 | default: 49 | slashes = 0 50 | qs[j] = s[i] 51 | case '\\': 52 | slashes++ 53 | qs[j] = s[i] 54 | case '"': 55 | for ; slashes > 0; slashes-- { 56 | qs[j] = '\\' 57 | j++ 58 | } 59 | qs[j] = '\\' 60 | j++ 61 | qs[j] = s[i] 62 | } 63 | j++ 64 | } 65 | if hasSpace { 66 | for ; slashes > 0; slashes-- { 67 | qs[j] = '\\' 68 | j++ 69 | } 70 | qs[j] = '"' 71 | j++ 72 | } 73 | return string(qs[:j]) 74 | } 75 | 76 | func CloseOnExec(fd Handle) { 77 | SetHandleInformation(Handle(fd), HANDLE_FLAG_INHERIT, 0) 78 | } 79 | 80 | // FullPath retrieves the full path of the specified file. 81 | func FullPath(name string) (path string, err error) { 82 | p, err := UTF16PtrFromString(name) 83 | if err != nil { 84 | return "", err 85 | } 86 | n := uint32(100) 87 | for { 88 | buf := make([]uint16, n) 89 | n, err = GetFullPathName(p, uint32(len(buf)), &buf[0], nil) 90 | if err != nil { 91 | return "", err 92 | } 93 | if n <= uint32(len(buf)) { 94 | return UTF16ToString(buf[:n]), nil 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/memory_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | const ( 8 | MEM_COMMIT = 0x00001000 9 | MEM_RESERVE = 0x00002000 10 | MEM_DECOMMIT = 0x00004000 11 | MEM_RELEASE = 0x00008000 12 | MEM_RESET = 0x00080000 13 | MEM_TOP_DOWN = 0x00100000 14 | MEM_WRITE_WATCH = 0x00200000 15 | MEM_PHYSICAL = 0x00400000 16 | MEM_RESET_UNDO = 0x01000000 17 | MEM_LARGE_PAGES = 0x20000000 18 | 19 | PAGE_NOACCESS = 0x01 20 | PAGE_READONLY = 0x02 21 | PAGE_READWRITE = 0x04 22 | PAGE_WRITECOPY = 0x08 23 | PAGE_EXECUTE_READ = 0x20 24 | PAGE_EXECUTE_READWRITE = 0x40 25 | PAGE_EXECUTE_WRITECOPY = 0x80 26 | ) 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/mksyscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go 8 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows,race 6 | 7 | package windows 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows,!race 6 | 7 | package windows 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package windows 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + itoa(-val) 12 | } 13 | var buf [32]byte // big enough for int64 14 | i := len(buf) - 1 15 | for val >= 10 { 16 | buf[i] = byte(val%10 + '0') 17 | i-- 18 | val /= 10 19 | } 20 | buf[i] = byte(val + '0') 21 | return string(buf[i:]) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/types_windows_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | Description [WSADESCRIPTION_LEN + 1]byte 11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 12 | MaxSockets uint16 13 | MaxUdpDg uint16 14 | VendorInfo *byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Port uint16 21 | Proto *byte 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/types_windows_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | MaxSockets uint16 11 | MaxUdpDg uint16 12 | VendorInfo *byte 13 | Description [WSADESCRIPTION_LEN + 1]byte 14 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Proto *byte 21 | Port uint16 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/types_windows_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | Description [WSADESCRIPTION_LEN + 1]byte 11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 12 | MaxSockets uint16 13 | MaxUdpDg uint16 14 | VendorInfo *byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Port uint16 21 | Proto *byte 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/triegen/compact.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package triegen 6 | 7 | // This file defines Compacter and its implementations. 8 | 9 | import "io" 10 | 11 | // A Compacter generates an alternative, more space-efficient way to store a 12 | // trie value block. A trie value block holds all possible values for the last 13 | // byte of a UTF-8 encoded rune. Excluding ASCII characters, a trie value block 14 | // always has 64 values, as a UTF-8 encoding ends with a byte in [0x80, 0xC0). 15 | type Compacter interface { 16 | // Size returns whether the Compacter could encode the given block as well 17 | // as its size in case it can. len(v) is always 64. 18 | Size(v []uint64) (sz int, ok bool) 19 | 20 | // Store stores the block using the Compacter's compression method. 21 | // It returns a handle with which the block can be retrieved. 22 | // len(v) is always 64. 23 | Store(v []uint64) uint32 24 | 25 | // Print writes the data structures associated to the given store to w. 26 | Print(w io.Writer) error 27 | 28 | // Handler returns the name of a function that gets called during trie 29 | // lookup for blocks generated by the Compacter. The function should be of 30 | // the form func (n uint32, b byte) uint64, where n is the index returned by 31 | // the Compacter's Store method and b is the last byte of the UTF-8 32 | // encoding, where 0x80 <= b < 0xC0, for which to do the lookup in the 33 | // block. 34 | Handler() string 35 | } 36 | 37 | // simpleCompacter is the default Compacter used by builder. It implements a 38 | // normal trie block. 39 | type simpleCompacter builder 40 | 41 | func (b *simpleCompacter) Size([]uint64) (sz int, ok bool) { 42 | return blockSize * b.ValueSize, true 43 | } 44 | 45 | func (b *simpleCompacter) Store(v []uint64) uint32 { 46 | h := uint32(len(b.ValueBlocks) - blockOffset) 47 | b.ValueBlocks = append(b.ValueBlocks, v) 48 | return h 49 | } 50 | 51 | func (b *simpleCompacter) Print(io.Writer) error { 52 | // Structures are printed in print.go. 53 | return nil 54 | } 55 | 56 | func (b *simpleCompacter) Handler() string { 57 | panic("Handler should be special-cased for this Compacter") 58 | } 59 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/unicode/norm/trie.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm 6 | 7 | type valueRange struct { 8 | value uint16 // header: value:stride 9 | lo, hi byte // header: lo:n 10 | } 11 | 12 | type sparseBlocks struct { 13 | values []valueRange 14 | offset []uint16 15 | } 16 | 17 | var nfcSparse = sparseBlocks{ 18 | values: nfcSparseValues[:], 19 | offset: nfcSparseOffset[:], 20 | } 21 | 22 | var nfkcSparse = sparseBlocks{ 23 | values: nfkcSparseValues[:], 24 | offset: nfkcSparseOffset[:], 25 | } 26 | 27 | var ( 28 | nfcData = newNfcTrie(0) 29 | nfkcData = newNfkcTrie(0) 30 | ) 31 | 32 | // lookupValue determines the type of block n and looks up the value for b. 33 | // For n < t.cutoff, the block is a simple lookup table. Otherwise, the block 34 | // is a list of ranges with an accompanying value. Given a matching range r, 35 | // the value for b is by r.value + (b - r.lo) * stride. 36 | func (t *sparseBlocks) lookup(n uint32, b byte) uint16 { 37 | offset := t.offset[n] 38 | header := t.values[offset] 39 | lo := offset + 1 40 | hi := lo + uint16(header.lo) 41 | for lo < hi { 42 | m := lo + (hi-lo)/2 43 | r := t.values[m] 44 | if r.lo <= b && b <= r.hi { 45 | return r.value + uint16(b-r.lo)*header.value 46 | } 47 | if b < r.lo { 48 | hi = m 49 | } else { 50 | lo = m + 1 51 | } 52 | } 53 | return 0 54 | } 55 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-billy.v4/.gitignore: -------------------------------------------------------------------------------- 1 | /coverage.txt 2 | /vendor 3 | Gopkg.lock 4 | Gopkg.toml 5 | go.sum 6 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-billy.v4/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.9.x 5 | - 1.10.x 6 | 7 | go_import_path: gopkg.in/src-d/go-billy.v4 8 | 9 | install: 10 | - go get -v -t ./... 11 | 12 | script: 13 | - make test-coverage 14 | 15 | after_success: 16 | - bash <(curl -s https://codecov.io/bash) 17 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-billy.v4/DCO: -------------------------------------------------------------------------------- 1 | Developer's Certificate of Origin 1.1 2 | 3 | By making a contribution to this project, I certify that: 4 | 5 | (a) The contribution was created in whole or in part by me and I 6 | have the right to submit it under the open source license 7 | indicated in the file; or 8 | 9 | (b) The contribution is based upon previous work that, to the best 10 | of my knowledge, is covered under an appropriate open source 11 | license and I have the right under that license to submit that 12 | work with modifications, whether created in whole or in part 13 | by me, under the same open source license (unless I am 14 | permitted to submit under a different license), as indicated 15 | in the file; or 16 | 17 | (c) The contribution was provided directly to me by some other 18 | person who certified (a), (b) or (c) and I have not modified 19 | it. 20 | 21 | (d) I understand and agree that this project and the contribution 22 | are public and that a record of the contribution (including all 23 | personal information I submit with it, including my sign-off) is 24 | maintained indefinitely and may be redistributed consistent with 25 | this project or the open source license(s) involved. 26 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-billy.v4/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Máximo Cuadros (@mcuadros) 2 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-billy.v4/Makefile: -------------------------------------------------------------------------------- 1 | # General 2 | WORKDIR = $(PWD) 3 | 4 | # Go parameters 5 | GOCMD = go 6 | GOTEST = $(GOCMD) test -v 7 | 8 | # Coverage 9 | COVERAGE_REPORT = coverage.txt 10 | COVERAGE_PROFILE = profile.out 11 | COVERAGE_MODE = atomic 12 | 13 | test-coverage: 14 | cd $(WORKDIR); \ 15 | echo "" > $(COVERAGE_REPORT); \ 16 | for dir in `find . -name "*.go" | grep -o '.*/' | sort | uniq`; do \ 17 | $(GOTEST) $$dir -coverprofile=$(COVERAGE_PROFILE) -covermode=$(COVERAGE_MODE); \ 18 | if [ $$? != 0 ]; then \ 19 | exit 2; \ 20 | fi; \ 21 | if [ -f $(COVERAGE_PROFILE) ]; then \ 22 | cat $(COVERAGE_PROFILE) >> $(COVERAGE_REPORT); \ 23 | rm $(COVERAGE_PROFILE); \ 24 | fi; \ 25 | done; \ 26 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-billy.v4/README.md: -------------------------------------------------------------------------------- 1 | # go-billy [![GoDoc](https://godoc.org/gopkg.in/src-d/go-billy.v4?status.svg)](https://godoc.org/gopkg.in/src-d/go-billy.v4) [![Build Status](https://travis-ci.org/src-d/go-billy.svg)](https://travis-ci.org/src-d/go-billy) [![Build status](https://ci.appveyor.com/api/projects/status/vx2qn6vlakbi724t?svg=true)](https://ci.appveyor.com/project/mcuadros/go-billy) [![codecov](https://codecov.io/gh/src-d/go-billy/branch/master/graph/badge.svg)](https://codecov.io/gh/src-d/go-billy) 2 | 3 | The missing interface filesystem abstraction for Go. 4 | Billy implements an interface based on the `os` standard library, allowing to develop applications without dependency on the underlying storage. Makes it virtually free to implement mocks and testing over filesystem operations. 5 | 6 | Billy was born as part of [src-d/go-git](https://github.com/src-d/go-git) project. 7 | 8 | ## Installation 9 | 10 | ```go 11 | go get -u gopkg.in/src-d/go-billy.v4/... 12 | ``` 13 | 14 | ## Usage 15 | 16 | Billy exposes filesystems using the 17 | [`Filesystem` interface](https://godoc.org/github.com/src-d/go-billy#Filesystem). 18 | Each filesystem implementation gives you a `New` method, whose arguments depend on 19 | the implementation itself, that returns a new `Filesystem`. 20 | 21 | The following example caches in memory all readable files in a directory from any 22 | billy's filesystem implementation. 23 | 24 | ```go 25 | func LoadToMemory(origin billy.Filesystem, path string) (*memory.Memory, error) { 26 | memory := memory.New() 27 | 28 | files, err := origin.ReadDir("/") 29 | if err != nil { 30 | return nil, err 31 | } 32 | 33 | for _, file := range files { 34 | if file.IsDir() { 35 | continue 36 | } 37 | 38 | src, err := origin.Open(file.Name()) 39 | if err != nil { 40 | return nil, err 41 | } 42 | 43 | dst, err := memory.Create(file.Name()) 44 | if err != nil { 45 | return nil, err 46 | } 47 | 48 | if _, err = io.Copy(dst, src); err != nil { 49 | return nil, err 50 | } 51 | 52 | if err := dst.Close(); err != nil { 53 | return nil, err 54 | } 55 | 56 | if err := src.Close(); err != nil { 57 | return nil, err 58 | } 59 | } 60 | 61 | return memory, nil 62 | } 63 | ``` 64 | 65 | ## Why billy? 66 | 67 | The library billy deals with storage systems and Billy is the name of a well-known, IKEA 68 | bookcase. That's it. 69 | 70 | ## License 71 | 72 | Apache License Version 2.0, see [LICENSE](LICENSE) 73 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-billy.v4/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | platform: x64 3 | 4 | clone_folder: c:\gopath\src\gopkg.in\src-d\go-billy.v4 5 | 6 | environment: 7 | GOPATH: c:\gopath 8 | 9 | install: 10 | - set PATH=%GOPATH%\bin;c:\go\bin;%PATH% 11 | - go version 12 | - go get -v -t ./... 13 | 14 | build_script: 15 | - go test -v ./... 16 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-billy.v4/go.mod: -------------------------------------------------------------------------------- 1 | module gopkg.in/src-d/go-billy.v4 2 | 3 | require ( 4 | github.com/kr/pretty v0.1.0 // indirect 5 | golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9 6 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 7 | ) 8 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-billy.v4/osfs/os_posix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package osfs 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | func (f *file) Lock() error { 10 | f.m.Lock() 11 | defer f.m.Unlock() 12 | 13 | return syscall.Flock(int(f.File.Fd()), syscall.LOCK_EX) 14 | } 15 | 16 | func (f *file) Unlock() error { 17 | f.m.Lock() 18 | defer f.m.Unlock() 19 | 20 | return syscall.Flock(int(f.File.Fd()), syscall.LOCK_UN) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-billy.v4/osfs/os_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package osfs 4 | 5 | import ( 6 | "os" 7 | "runtime" 8 | "unsafe" 9 | 10 | "golang.org/x/sys/windows" 11 | ) 12 | 13 | type fileInfo struct { 14 | os.FileInfo 15 | name string 16 | } 17 | 18 | func (fi *fileInfo) Name() string { 19 | return fi.name 20 | } 21 | 22 | var ( 23 | kernel32DLL = windows.NewLazySystemDLL("kernel32.dll") 24 | lockFileExProc = kernel32DLL.NewProc("LockFileEx") 25 | unlockFileProc = kernel32DLL.NewProc("UnlockFile") 26 | ) 27 | 28 | const ( 29 | lockfileExclusiveLock = 0x2 30 | ) 31 | 32 | func (f *file) Lock() error { 33 | f.m.Lock() 34 | defer f.m.Unlock() 35 | 36 | var overlapped windows.Overlapped 37 | // err is always non-nil as per sys/windows semantics. 38 | ret, _, err := lockFileExProc.Call(f.File.Fd(), lockfileExclusiveLock, 0, 0xFFFFFFFF, 0, 39 | uintptr(unsafe.Pointer(&overlapped))) 40 | runtime.KeepAlive(&overlapped) 41 | if ret == 0 { 42 | return err 43 | } 44 | return nil 45 | } 46 | 47 | func (f *file) Unlock() error { 48 | f.m.Lock() 49 | defer f.m.Unlock() 50 | 51 | // err is always non-nil as per sys/windows semantics. 52 | ret, _, err := unlockFileProc.Call(f.File.Fd(), 0, 0, 0xFFFFFFFF, 0) 53 | if ret == 0 { 54 | return err 55 | } 56 | return nil 57 | } 58 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/.gitignore: -------------------------------------------------------------------------------- 1 | coverage.out 2 | *~ 3 | coverage.txt 4 | profile.out 5 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - "1.10" 5 | - "1.11" 6 | 7 | go_import_path: gopkg.in/src-d/go-git.v4 8 | 9 | env: 10 | - GIT_VERSION=master 11 | - GIT_VERSION=v1.9.3 12 | - GIT_VERSION=v2.11.0 13 | 14 | cache: 15 | directories: 16 | - $HOME/.git-dist 17 | 18 | before_script: 19 | - export GIT_DIST_PATH=$HOME/.git-dist 20 | - make build-git 21 | 22 | before_install: 23 | - git config --global user.email "travis@example.com" 24 | - git config --global user.name "Travis CI" 25 | 26 | install: 27 | - go get -v -t ./... 28 | 29 | script: 30 | - export GIT_EXEC_PATH=$GIT_DIST_PATH 31 | - export PATH=$GIT_DIST_PATH:$PATH 32 | - git version 33 | - make test-coverage 34 | - go vet ./... 35 | 36 | after_success: 37 | - bash <(curl -s https://codecov.io/bash) 38 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/DCO: -------------------------------------------------------------------------------- 1 | Developer Certificate of Origin 2 | Version 1.1 3 | 4 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 5 | 660 York Street, Suite 102, 6 | San Francisco, CA 94110 USA 7 | 8 | Everyone is permitted to copy and distribute verbatim copies of this 9 | license document, but changing it is not allowed. 10 | 11 | 12 | Developer's Certificate of Origin 1.1 13 | 14 | By making a contribution to this project, I certify that: 15 | 16 | (a) The contribution was created in whole or in part by me and I 17 | have the right to submit it under the open source license 18 | indicated in the file; or 19 | 20 | (b) The contribution is based upon previous work that, to the best 21 | of my knowledge, is covered under an appropriate open source 22 | license and I have the right under that license to submit that 23 | work with modifications, whether created in whole or in part 24 | by me, under the same open source license (unless I am 25 | permitted to submit under a different license), as indicated 26 | in the file; or 27 | 28 | (c) The contribution was provided directly to me by some other 29 | person who certified (a), (b) or (c) and I have not modified 30 | it. 31 | 32 | (d) I understand and agree that this project and the contribution 33 | are public and that a record of the contribution (including all 34 | personal information I submit with it, including my sign-off) is 35 | maintained indefinitely and may be redistributed consistent with 36 | this project or the open source license(s) involved. -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Máximo Cuadros (@mcuadros) 2 | Jeremy Stribling (@strib) 3 | Ori Rawlings (@orirawlings) 4 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/Makefile: -------------------------------------------------------------------------------- 1 | # General 2 | WORKDIR = $(PWD) 3 | 4 | # Go parameters 5 | GOCMD = go 6 | GOTEST = $(GOCMD) test -v 7 | 8 | # Git config 9 | GIT_VERSION ?= 10 | GIT_DIST_PATH ?= $(PWD)/.git-dist 11 | GIT_REPOSITORY = http://github.com/git/git.git 12 | 13 | # Coverage 14 | COVERAGE_REPORT = coverage.txt 15 | COVERAGE_PROFILE = profile.out 16 | COVERAGE_MODE = atomic 17 | 18 | ifneq ($(origin CI), undefined) 19 | WORKDIR := $(GOPATH)/src/gopkg.in/src-d/go-git.v4 20 | endif 21 | 22 | build-git: 23 | @if [ -f $(GIT_DIST_PATH)/git ]; then \ 24 | echo "nothing to do, using cache $(GIT_DIST_PATH)"; \ 25 | else \ 26 | git clone $(GIT_REPOSITORY) -b $(GIT_VERSION) --depth 1 --single-branch $(GIT_DIST_PATH); \ 27 | cd $(GIT_DIST_PATH); \ 28 | make configure; \ 29 | ./configure; \ 30 | make all; \ 31 | fi 32 | 33 | test: 34 | @cd $(WORKDIR); \ 35 | $(GOTEST) ./... 36 | 37 | test-coverage: 38 | @cd $(WORKDIR); \ 39 | echo "" > $(COVERAGE_REPORT); \ 40 | for dir in `find . -name "*.go" | grep -o '.*/' | sort | uniq`; do \ 41 | $(GOTEST) $$dir -coverprofile=$(COVERAGE_PROFILE) -covermode=$(COVERAGE_MODE); \ 42 | if [ $$? != 0 ]; then \ 43 | exit 2; \ 44 | fi; \ 45 | if [ -f $(COVERAGE_PROFILE) ]; then \ 46 | cat $(COVERAGE_PROFILE) >> $(COVERAGE_REPORT); \ 47 | rm $(COVERAGE_PROFILE); \ 48 | fi; \ 49 | done; \ 50 | 51 | clean: 52 | rm -rf $(GIT_DIST_PATH) -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | platform: x64 3 | 4 | matrix: 5 | allow_failures: 6 | - platform: x64 7 | 8 | clone_folder: c:\gopath\src\gopkg.in\src-d\go-git.v4 9 | 10 | environment: 11 | GOPATH: c:\gopath 12 | 13 | install: 14 | - set PATH=%GOPATH%\bin;c:\go\bin;"C:\Program Files\Git\mingw64\bin";%PATH% 15 | - go version 16 | - go get -v -t ./... 17 | - git config --global user.email "travis@example.com" 18 | - git config --global user.name "Travis CI 19 | 20 | build_script: 21 | - go test -v ./... 22 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/common.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import "strings" 4 | 5 | const defaultDotGitPath = ".git" 6 | 7 | // countLines returns the number of lines in a string à la git, this is 8 | // The newline character is assumed to be '\n'. The empty string 9 | // contains 0 lines. If the last line of the string doesn't end with a 10 | // newline, it will still be considered a line. 11 | func countLines(s string) int { 12 | if s == "" { 13 | return 0 14 | } 15 | 16 | nEOL := strings.Count(s, "\n") 17 | if strings.HasSuffix(s, "\n") { 18 | return nEOL 19 | } 20 | 21 | return nEOL + 1 22 | } 23 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/config/branch.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "errors" 5 | 6 | "gopkg.in/src-d/go-git.v4/plumbing" 7 | format "gopkg.in/src-d/go-git.v4/plumbing/format/config" 8 | ) 9 | 10 | var ( 11 | errBranchEmptyName = errors.New("branch config: empty name") 12 | errBranchInvalidMerge = errors.New("branch config: invalid merge") 13 | ) 14 | 15 | // Branch contains information on the 16 | // local branches and which remote to track 17 | type Branch struct { 18 | // Name of branch 19 | Name string 20 | // Remote name of remote to track 21 | Remote string 22 | // Merge is the local refspec for the branch 23 | Merge plumbing.ReferenceName 24 | 25 | raw *format.Subsection 26 | } 27 | 28 | // Validate validates fields of branch 29 | func (b *Branch) Validate() error { 30 | if b.Name == "" { 31 | return errBranchEmptyName 32 | } 33 | 34 | if b.Merge != "" && !b.Merge.IsBranch() { 35 | return errBranchInvalidMerge 36 | } 37 | 38 | return nil 39 | } 40 | 41 | func (b *Branch) marshal() *format.Subsection { 42 | if b.raw == nil { 43 | b.raw = &format.Subsection{} 44 | } 45 | 46 | b.raw.Name = b.Name 47 | 48 | if b.Remote == "" { 49 | b.raw.RemoveOption(remoteSection) 50 | } else { 51 | b.raw.SetOption(remoteSection, b.Remote) 52 | } 53 | 54 | if b.Merge == "" { 55 | b.raw.RemoveOption(mergeKey) 56 | } else { 57 | b.raw.SetOption(mergeKey, string(b.Merge)) 58 | } 59 | 60 | return b.raw 61 | } 62 | 63 | func (b *Branch) unmarshal(s *format.Subsection) error { 64 | b.raw = s 65 | 66 | b.Name = b.raw.Name 67 | b.Remote = b.raw.Options.Get(remoteSection) 68 | b.Merge = plumbing.ReferenceName(b.raw.Options.Get(mergeKey)) 69 | 70 | return b.Validate() 71 | } 72 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/doc.go: -------------------------------------------------------------------------------- 1 | // A highly extensible git implementation in pure Go. 2 | // 3 | // go-git aims to reach the completeness of libgit2 or jgit, nowadays covers the 4 | // majority of the plumbing read operations and some of the main write 5 | // operations, but lacks the main porcelain operations such as merges. 6 | // 7 | // It is highly extensible, we have been following the open/close principle in 8 | // its design to facilitate extensions, mainly focusing the efforts on the 9 | // persistence of the objects. 10 | package git // import "gopkg.in/src-d/go-git.v4" 11 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/go.mod: -------------------------------------------------------------------------------- 1 | module gopkg.in/src-d/go-git.v4 2 | 3 | require ( 4 | github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 // indirect 5 | github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 // indirect 6 | github.com/davecgh/go-spew v1.1.1 // indirect 7 | github.com/emirpasic/gods v1.9.0 8 | github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect 9 | github.com/gliderlabs/ssh v0.1.1 10 | github.com/google/go-cmp v0.2.0 11 | github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 12 | github.com/jessevdk/go-flags v1.4.0 13 | github.com/kevinburke/ssh_config v0.0.0-20180830205328-81db2a75821e 14 | github.com/mitchellh/go-homedir v1.0.0 15 | github.com/pelletier/go-buffruneio v0.2.0 // indirect 16 | github.com/pkg/errors v0.8.0 // indirect 17 | github.com/pmezard/go-difflib v1.0.0 // indirect 18 | github.com/sergi/go-diff v1.0.0 19 | github.com/src-d/gcfg v1.3.0 20 | github.com/stretchr/testify v1.2.2 // indirect 21 | github.com/xanzy/ssh-agent v0.2.0 22 | golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 23 | golang.org/x/net v0.0.0-20180906233101-161cd47e91fd // indirect 24 | golang.org/x/text v0.3.0 25 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 26 | gopkg.in/src-d/go-billy.v4 v4.2.1 27 | gopkg.in/src-d/go-git-fixtures.v3 v3.1.1 28 | gopkg.in/warnings.v0 v0.1.2 // indirect 29 | ) 30 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/internal/revision/token.go: -------------------------------------------------------------------------------- 1 | package revision 2 | 3 | // token represents a entity extracted from string parsing 4 | type token int 5 | 6 | const ( 7 | eof token = iota 8 | 9 | aslash 10 | asterisk 11 | at 12 | caret 13 | cbrace 14 | colon 15 | control 16 | dot 17 | emark 18 | minus 19 | number 20 | obrace 21 | obracket 22 | qmark 23 | slash 24 | space 25 | tilde 26 | tokenError 27 | word 28 | ) 29 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/cache/common.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import "gopkg.in/src-d/go-git.v4/plumbing" 4 | 5 | const ( 6 | Byte FileSize = 1 << (iota * 10) 7 | KiByte 8 | MiByte 9 | GiByte 10 | ) 11 | 12 | type FileSize int64 13 | 14 | const DefaultMaxSize FileSize = 96 * MiByte 15 | 16 | // Object is an interface to a object cache. 17 | type Object interface { 18 | // Put puts the given object into the cache. Whether this object will 19 | // actually be put into the cache or not is implementation specific. 20 | Put(o plumbing.EncodedObject) 21 | // Get gets an object from the cache given its hash. The second return value 22 | // is true if the object was returned, and false otherwise. 23 | Get(k plumbing.Hash) (plumbing.EncodedObject, bool) 24 | // Clear clears every object from the cache. 25 | Clear() 26 | } 27 | 28 | // Buffer is an interface to a buffer cache. 29 | type Buffer interface { 30 | // Put puts a buffer into the cache. If the buffer is already in the cache, 31 | // it will be marked as used. Otherwise, it will be inserted. Buffer might 32 | // be evicted to make room for the new one. 33 | Put(key int64, slice []byte) 34 | // Get returns a buffer by its key. It marks the buffer as used. If the 35 | // buffer is not in the cache, (nil, false) will be returned. 36 | Get(key int64) ([]byte, bool) 37 | // Clear clears every object from the cache. 38 | Clear() 39 | } 40 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/error.go: -------------------------------------------------------------------------------- 1 | package plumbing 2 | 3 | import "fmt" 4 | 5 | type PermanentError struct { 6 | Err error 7 | } 8 | 9 | func NewPermanentError(err error) *PermanentError { 10 | if err == nil { 11 | return nil 12 | } 13 | 14 | return &PermanentError{Err: err} 15 | } 16 | 17 | func (e *PermanentError) Error() string { 18 | return fmt.Sprintf("permanent client error: %s", e.Err.Error()) 19 | } 20 | 21 | type UnexpectedError struct { 22 | Err error 23 | } 24 | 25 | func NewUnexpectedError(err error) *UnexpectedError { 26 | if err == nil { 27 | return nil 28 | } 29 | 30 | return &UnexpectedError{Err: err} 31 | } 32 | 33 | func (e *UnexpectedError) Error() string { 34 | return fmt.Sprintf("unexpected client error: %s", e.Err.Error()) 35 | } 36 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/format/config/decoder.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "io" 5 | 6 | "github.com/src-d/gcfg" 7 | ) 8 | 9 | // A Decoder reads and decodes config files from an input stream. 10 | type Decoder struct { 11 | io.Reader 12 | } 13 | 14 | // NewDecoder returns a new decoder that reads from r. 15 | func NewDecoder(r io.Reader) *Decoder { 16 | return &Decoder{r} 17 | } 18 | 19 | // Decode reads the whole config from its input and stores it in the 20 | // value pointed to by config. 21 | func (d *Decoder) Decode(config *Config) error { 22 | cb := func(s string, ss string, k string, v string, bv bool) error { 23 | if ss == "" && k == "" { 24 | config.Section(s) 25 | return nil 26 | } 27 | 28 | if ss != "" && k == "" { 29 | config.Section(s).Subsection(ss) 30 | return nil 31 | } 32 | 33 | config.AddOption(s, ss, k, v) 34 | return nil 35 | } 36 | return gcfg.ReadWithCallback(d, cb) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/format/config/encoder.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "strings" 7 | ) 8 | 9 | // An Encoder writes config files to an output stream. 10 | type Encoder struct { 11 | w io.Writer 12 | } 13 | 14 | // NewEncoder returns a new encoder that writes to w. 15 | func NewEncoder(w io.Writer) *Encoder { 16 | return &Encoder{w} 17 | } 18 | 19 | // Encode writes the config in git config format to the stream of the encoder. 20 | func (e *Encoder) Encode(cfg *Config) error { 21 | for _, s := range cfg.Sections { 22 | if err := e.encodeSection(s); err != nil { 23 | return err 24 | } 25 | } 26 | 27 | return nil 28 | } 29 | 30 | func (e *Encoder) encodeSection(s *Section) error { 31 | if len(s.Options) > 0 { 32 | if err := e.printf("[%s]\n", s.Name); err != nil { 33 | return err 34 | } 35 | 36 | if err := e.encodeOptions(s.Options); err != nil { 37 | return err 38 | } 39 | } 40 | 41 | for _, ss := range s.Subsections { 42 | if err := e.encodeSubsection(s.Name, ss); err != nil { 43 | return err 44 | } 45 | } 46 | 47 | return nil 48 | } 49 | 50 | func (e *Encoder) encodeSubsection(sectionName string, s *Subsection) error { 51 | //TODO: escape 52 | if err := e.printf("[%s \"%s\"]\n", sectionName, s.Name); err != nil { 53 | return err 54 | } 55 | 56 | return e.encodeOptions(s.Options) 57 | } 58 | 59 | func (e *Encoder) encodeOptions(opts Options) error { 60 | for _, o := range opts { 61 | pattern := "\t%s = %s\n" 62 | if strings.Contains(o.Value, "\\") { 63 | pattern = "\t%s = %q\n" 64 | } 65 | 66 | if err := e.printf(pattern, o.Key, o.Value); err != nil { 67 | return err 68 | } 69 | } 70 | 71 | return nil 72 | } 73 | 74 | func (e *Encoder) printf(msg string, args ...interface{}) error { 75 | _, err := fmt.Fprintf(e.w, msg, args...) 76 | return err 77 | } 78 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/format/diff/patch.go: -------------------------------------------------------------------------------- 1 | package diff 2 | 3 | import ( 4 | "gopkg.in/src-d/go-git.v4/plumbing" 5 | "gopkg.in/src-d/go-git.v4/plumbing/filemode" 6 | ) 7 | 8 | // Operation defines the operation of a diff item. 9 | type Operation int 10 | 11 | const ( 12 | // Equal item represents a equals diff. 13 | Equal Operation = iota 14 | // Add item represents an insert diff. 15 | Add 16 | // Delete item represents a delete diff. 17 | Delete 18 | ) 19 | 20 | // Patch represents a collection of steps to transform several files. 21 | type Patch interface { 22 | // FilePatches returns a slice of patches per file. 23 | FilePatches() []FilePatch 24 | // Message returns an optional message that can be at the top of the 25 | // Patch representation. 26 | Message() string 27 | } 28 | 29 | // FilePatch represents the necessary steps to transform one file to another. 30 | type FilePatch interface { 31 | // IsBinary returns true if this patch is representing a binary file. 32 | IsBinary() bool 33 | // Files returns the from and to Files, with all the necessary metadata to 34 | // about them. If the patch creates a new file, "from" will be nil. 35 | // If the patch deletes a file, "to" will be nil. 36 | Files() (from, to File) 37 | // Chunks returns a slice of ordered changes to transform "from" File to 38 | // "to" File. If the file is a binary one, Chunks will be empty. 39 | Chunks() []Chunk 40 | } 41 | 42 | // File contains all the file metadata necessary to print some patch formats. 43 | type File interface { 44 | // Hash returns the File Hash. 45 | Hash() plumbing.Hash 46 | // Mode returns the FileMode. 47 | Mode() filemode.FileMode 48 | // Path returns the complete Path to the file, including the filename. 49 | Path() string 50 | } 51 | 52 | // Chunk represents a portion of a file transformation to another. 53 | type Chunk interface { 54 | // Content contains the portion of the file. 55 | Content() string 56 | // Type contains the Operation to do with this Chunk. 57 | Type() Operation 58 | } 59 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/format/gitignore/matcher.go: -------------------------------------------------------------------------------- 1 | package gitignore 2 | 3 | // Matcher defines a global multi-pattern matcher for gitignore patterns 4 | type Matcher interface { 5 | // Match matches patterns in the order of priorities. As soon as an inclusion or 6 | // exclusion is found, not further matching is performed. 7 | Match(path []string, isDir bool) bool 8 | } 9 | 10 | // NewMatcher constructs a new global matcher. Patterns must be given in the order of 11 | // increasing priority. That is most generic settings files first, then the content of 12 | // the repo .gitignore, then content of .gitignore down the path or the repo and then 13 | // the content command line arguments. 14 | func NewMatcher(ps []Pattern) Matcher { 15 | return &matcher{ps} 16 | } 17 | 18 | type matcher struct { 19 | patterns []Pattern 20 | } 21 | 22 | func (m *matcher) Match(path []string, isDir bool) bool { 23 | n := len(m.patterns) 24 | for i := n - 1; i >= 0; i-- { 25 | if match := m.patterns[i].Match(path, isDir); match > NoMatch { 26 | return match == Exclude 27 | } 28 | } 29 | return false 30 | } 31 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/format/objfile/doc.go: -------------------------------------------------------------------------------- 1 | // Package objfile implements encoding and decoding of object files. 2 | package objfile 3 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/format/packfile/common.go: -------------------------------------------------------------------------------- 1 | package packfile 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | "sync" 7 | 8 | "gopkg.in/src-d/go-git.v4/plumbing/storer" 9 | "gopkg.in/src-d/go-git.v4/utils/ioutil" 10 | ) 11 | 12 | var signature = []byte{'P', 'A', 'C', 'K'} 13 | 14 | const ( 15 | // VersionSupported is the packfile version supported by this package 16 | VersionSupported uint32 = 2 17 | 18 | firstLengthBits = uint8(4) // the first byte into object header has 4 bits to store the length 19 | lengthBits = uint8(7) // subsequent bytes has 7 bits to store the length 20 | maskFirstLength = 15 // 0000 1111 21 | maskContinue = 0x80 // 1000 0000 22 | maskLength = uint8(127) // 0111 1111 23 | maskType = uint8(112) // 0111 0000 24 | ) 25 | 26 | // UpdateObjectStorage updates the storer with the objects in the given 27 | // packfile. 28 | func UpdateObjectStorage(s storer.Storer, packfile io.Reader) error { 29 | if pw, ok := s.(storer.PackfileWriter); ok { 30 | return WritePackfileToObjectStorage(pw, packfile) 31 | } 32 | 33 | p, err := NewParserWithStorage(NewScanner(packfile), s) 34 | if err != nil { 35 | return err 36 | } 37 | 38 | _, err = p.Parse() 39 | return err 40 | } 41 | 42 | // WritePackfileToObjectStorage writes all the packfile objects into the given 43 | // object storage. 44 | func WritePackfileToObjectStorage( 45 | sw storer.PackfileWriter, 46 | packfile io.Reader, 47 | ) (err error) { 48 | w, err := sw.PackfileWriter() 49 | if err != nil { 50 | return err 51 | } 52 | 53 | defer ioutil.CheckClose(w, &err) 54 | _, err = io.Copy(w, packfile) 55 | return err 56 | } 57 | 58 | var bufPool = sync.Pool{ 59 | New: func() interface{} { 60 | return bytes.NewBuffer(nil) 61 | }, 62 | } 63 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/format/packfile/doc.go: -------------------------------------------------------------------------------- 1 | // Package packfile implements encoding and decoding of packfile format. 2 | // 3 | // == pack-*.pack files have the following format: 4 | // 5 | // - A header appears at the beginning and consists of the following: 6 | // 7 | // 4-byte signature: 8 | // The signature is: {'P', 'A', 'C', 'K'} 9 | // 10 | // 4-byte version number (network byte order): 11 | // GIT currently accepts version number 2 or 3 but 12 | // generates version 2 only. 13 | // 14 | // 4-byte number of objects contained in the pack (network byte order) 15 | // 16 | // Observation: we cannot have more than 4G versions ;-) and 17 | // more than 4G objects in a pack. 18 | // 19 | // - The header is followed by number of object entries, each of 20 | // which looks like this: 21 | // 22 | // (undeltified representation) 23 | // n-byte type and length (3-bit type, (n-1)*7+4-bit length) 24 | // compressed data 25 | // 26 | // (deltified representation) 27 | // n-byte type and length (3-bit type, (n-1)*7+4-bit length) 28 | // 20-byte base object name 29 | // compressed delta data 30 | // 31 | // Observation: length of each object is encoded in a variable 32 | // length format and is not constrained to 32-bit or anything. 33 | // 34 | // - The trailer records 20-byte SHA1 checksum of all of the above. 35 | // 36 | // 37 | // Source: 38 | // https://www.kernel.org/pub/software/scm/git/docs/v1.7.5/technical/pack-protocol.txt 39 | package packfile 40 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/format/packfile/error.go: -------------------------------------------------------------------------------- 1 | package packfile 2 | 3 | import "fmt" 4 | 5 | // Error specifies errors returned during packfile parsing. 6 | type Error struct { 7 | reason, details string 8 | } 9 | 10 | // NewError returns a new error. 11 | func NewError(reason string) *Error { 12 | return &Error{reason: reason} 13 | } 14 | 15 | // Error returns a text representation of the error. 16 | func (e *Error) Error() string { 17 | if e.details == "" { 18 | return e.reason 19 | } 20 | 21 | return fmt.Sprintf("%s: %s", e.reason, e.details) 22 | } 23 | 24 | // AddDetails adds details to an error, with additional text. 25 | func (e *Error) AddDetails(format string, args ...interface{}) *Error { 26 | return &Error{ 27 | reason: e.reason, 28 | details: fmt.Sprintf(format, args...), 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/hash.go: -------------------------------------------------------------------------------- 1 | package plumbing 2 | 3 | import ( 4 | "bytes" 5 | "crypto/sha1" 6 | "encoding/hex" 7 | "hash" 8 | "sort" 9 | "strconv" 10 | ) 11 | 12 | // Hash SHA1 hased content 13 | type Hash [20]byte 14 | 15 | // ZeroHash is Hash with value zero 16 | var ZeroHash Hash 17 | 18 | // ComputeHash compute the hash for a given ObjectType and content 19 | func ComputeHash(t ObjectType, content []byte) Hash { 20 | h := NewHasher(t, int64(len(content))) 21 | h.Write(content) 22 | return h.Sum() 23 | } 24 | 25 | // NewHash return a new Hash from a hexadecimal hash representation 26 | func NewHash(s string) Hash { 27 | b, _ := hex.DecodeString(s) 28 | 29 | var h Hash 30 | copy(h[:], b) 31 | 32 | return h 33 | } 34 | 35 | func (h Hash) IsZero() bool { 36 | var empty Hash 37 | return h == empty 38 | } 39 | 40 | func (h Hash) String() string { 41 | return hex.EncodeToString(h[:]) 42 | } 43 | 44 | type Hasher struct { 45 | hash.Hash 46 | } 47 | 48 | func NewHasher(t ObjectType, size int64) Hasher { 49 | h := Hasher{sha1.New()} 50 | h.Write(t.Bytes()) 51 | h.Write([]byte(" ")) 52 | h.Write([]byte(strconv.FormatInt(size, 10))) 53 | h.Write([]byte{0}) 54 | return h 55 | } 56 | 57 | func (h Hasher) Sum() (hash Hash) { 58 | copy(hash[:], h.Hash.Sum(nil)) 59 | return 60 | } 61 | 62 | // HashesSort sorts a slice of Hashes in increasing order. 63 | func HashesSort(a []Hash) { 64 | sort.Sort(HashSlice(a)) 65 | } 66 | 67 | // HashSlice attaches the methods of sort.Interface to []Hash, sorting in 68 | // increasing order. 69 | type HashSlice []Hash 70 | 71 | func (p HashSlice) Len() int { return len(p) } 72 | func (p HashSlice) Less(i, j int) bool { return bytes.Compare(p[i][:], p[j][:]) < 0 } 73 | func (p HashSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } 74 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/memory.go: -------------------------------------------------------------------------------- 1 | package plumbing 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | "io/ioutil" 7 | ) 8 | 9 | // MemoryObject on memory Object implementation 10 | type MemoryObject struct { 11 | t ObjectType 12 | h Hash 13 | cont []byte 14 | sz int64 15 | } 16 | 17 | // Hash returns the object Hash, the hash is calculated on-the-fly the first 18 | // time it's called, in all subsequent calls the same Hash is returned even 19 | // if the type or the content have changed. The Hash is only generated if the 20 | // size of the content is exactly the object size. 21 | func (o *MemoryObject) Hash() Hash { 22 | if o.h == ZeroHash && int64(len(o.cont)) == o.sz { 23 | o.h = ComputeHash(o.t, o.cont) 24 | } 25 | 26 | return o.h 27 | } 28 | 29 | // Type return the ObjectType 30 | func (o *MemoryObject) Type() ObjectType { return o.t } 31 | 32 | // SetType sets the ObjectType 33 | func (o *MemoryObject) SetType(t ObjectType) { o.t = t } 34 | 35 | // Size return the size of the object 36 | func (o *MemoryObject) Size() int64 { return o.sz } 37 | 38 | // SetSize set the object size, a content of the given size should be written 39 | // afterwards 40 | func (o *MemoryObject) SetSize(s int64) { o.sz = s } 41 | 42 | // Reader returns a ObjectReader used to read the object's content. 43 | func (o *MemoryObject) Reader() (io.ReadCloser, error) { 44 | return ioutil.NopCloser(bytes.NewBuffer(o.cont)), nil 45 | } 46 | 47 | // Writer returns a ObjectWriter used to write the object's content. 48 | func (o *MemoryObject) Writer() (io.WriteCloser, error) { 49 | return o, nil 50 | } 51 | 52 | func (o *MemoryObject) Write(p []byte) (n int, err error) { 53 | o.cont = append(o.cont, p...) 54 | o.sz = int64(len(o.cont)) 55 | 56 | return len(p), nil 57 | } 58 | 59 | // Close releases any resources consumed by the object when it is acting as a 60 | // ObjectWriter. 61 | func (o *MemoryObject) Close() error { return nil } 62 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/object/change_adaptor.go: -------------------------------------------------------------------------------- 1 | package object 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | 7 | "gopkg.in/src-d/go-git.v4/utils/merkletrie" 8 | "gopkg.in/src-d/go-git.v4/utils/merkletrie/noder" 9 | ) 10 | 11 | // The following functions transform changes types form the merkletrie 12 | // package to changes types from this package. 13 | 14 | func newChange(c merkletrie.Change) (*Change, error) { 15 | ret := &Change{} 16 | 17 | var err error 18 | if ret.From, err = newChangeEntry(c.From); err != nil { 19 | return nil, fmt.Errorf("From field: %s", err) 20 | } 21 | 22 | if ret.To, err = newChangeEntry(c.To); err != nil { 23 | return nil, fmt.Errorf("To field: %s", err) 24 | } 25 | 26 | return ret, nil 27 | } 28 | 29 | func newChangeEntry(p noder.Path) (ChangeEntry, error) { 30 | if p == nil { 31 | return empty, nil 32 | } 33 | 34 | asTreeNoder, ok := p.Last().(*treeNoder) 35 | if !ok { 36 | return ChangeEntry{}, errors.New("cannot transform non-TreeNoders") 37 | } 38 | 39 | return ChangeEntry{ 40 | Name: p.String(), 41 | Tree: asTreeNoder.parent, 42 | TreeEntry: TreeEntry{ 43 | Name: asTreeNoder.name, 44 | Mode: asTreeNoder.mode, 45 | Hash: asTreeNoder.hash, 46 | }, 47 | }, nil 48 | } 49 | 50 | func newChanges(src merkletrie.Changes) (Changes, error) { 51 | ret := make(Changes, len(src)) 52 | var err error 53 | for i, e := range src { 54 | ret[i], err = newChange(e) 55 | if err != nil { 56 | return nil, fmt.Errorf("change #%d: %s", i, err) 57 | } 58 | } 59 | 60 | return ret, nil 61 | } 62 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/object/difftree.go: -------------------------------------------------------------------------------- 1 | package object 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | 7 | "gopkg.in/src-d/go-git.v4/utils/merkletrie" 8 | "gopkg.in/src-d/go-git.v4/utils/merkletrie/noder" 9 | ) 10 | 11 | // DiffTree compares the content and mode of the blobs found via two 12 | // tree objects. 13 | func DiffTree(a, b *Tree) (Changes, error) { 14 | return DiffTreeContext(context.Background(), a, b) 15 | } 16 | 17 | // DiffTree compares the content and mode of the blobs found via two 18 | // tree objects. Provided context must be non-nil. 19 | // An error will be return if context expires 20 | func DiffTreeContext(ctx context.Context, a, b *Tree) (Changes, error) { 21 | from := NewTreeRootNode(a) 22 | to := NewTreeRootNode(b) 23 | 24 | hashEqual := func(a, b noder.Hasher) bool { 25 | return bytes.Equal(a.Hash(), b.Hash()) 26 | } 27 | 28 | merkletrieChanges, err := merkletrie.DiffTreeContext(ctx, from, to, hashEqual) 29 | if err != nil { 30 | if err == merkletrie.ErrCanceled { 31 | return nil, ErrCanceled 32 | } 33 | return nil, err 34 | } 35 | 36 | return newChanges(merkletrieChanges) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/protocol/packp/common.go: -------------------------------------------------------------------------------- 1 | package packp 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type stateFn func() stateFn 8 | 9 | const ( 10 | // common 11 | hashSize = 40 12 | 13 | // advrefs 14 | head = "HEAD" 15 | noHead = "capabilities^{}" 16 | ) 17 | 18 | var ( 19 | // common 20 | sp = []byte(" ") 21 | eol = []byte("\n") 22 | eq = []byte{'='} 23 | 24 | // advertised-refs 25 | null = []byte("\x00") 26 | peeled = []byte("^{}") 27 | noHeadMark = []byte(" capabilities^{}\x00") 28 | 29 | // upload-request 30 | want = []byte("want ") 31 | shallow = []byte("shallow ") 32 | deepen = []byte("deepen") 33 | deepenCommits = []byte("deepen ") 34 | deepenSince = []byte("deepen-since ") 35 | deepenReference = []byte("deepen-not ") 36 | 37 | // shallow-update 38 | unshallow = []byte("unshallow ") 39 | 40 | // server-response 41 | ack = []byte("ACK") 42 | nak = []byte("NAK") 43 | 44 | // updreq 45 | shallowNoSp = []byte("shallow") 46 | ) 47 | 48 | func isFlush(payload []byte) bool { 49 | return len(payload) == 0 50 | } 51 | 52 | // ErrUnexpectedData represents an unexpected data decoding a message 53 | type ErrUnexpectedData struct { 54 | Msg string 55 | Data []byte 56 | } 57 | 58 | // NewErrUnexpectedData returns a new ErrUnexpectedData containing the data and 59 | // the message given 60 | func NewErrUnexpectedData(msg string, data []byte) error { 61 | return &ErrUnexpectedData{Msg: msg, Data: data} 62 | } 63 | 64 | func (err *ErrUnexpectedData) Error() string { 65 | if len(err.Data) == 0 { 66 | return err.Msg 67 | } 68 | 69 | return fmt.Sprintf("%s (%s)", err.Msg, err.Data) 70 | } 71 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/protocol/packp/shallowupd.go: -------------------------------------------------------------------------------- 1 | package packp 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io" 7 | 8 | "gopkg.in/src-d/go-git.v4/plumbing" 9 | "gopkg.in/src-d/go-git.v4/plumbing/format/pktline" 10 | ) 11 | 12 | const ( 13 | shallowLineLen = 48 14 | unshallowLineLen = 50 15 | ) 16 | 17 | type ShallowUpdate struct { 18 | Shallows []plumbing.Hash 19 | Unshallows []plumbing.Hash 20 | } 21 | 22 | func (r *ShallowUpdate) Decode(reader io.Reader) error { 23 | s := pktline.NewScanner(reader) 24 | 25 | for s.Scan() { 26 | line := s.Bytes() 27 | line = bytes.TrimSpace(line) 28 | 29 | var err error 30 | switch { 31 | case bytes.HasPrefix(line, shallow): 32 | err = r.decodeShallowLine(line) 33 | case bytes.HasPrefix(line, unshallow): 34 | err = r.decodeUnshallowLine(line) 35 | case bytes.Equal(line, pktline.Flush): 36 | return nil 37 | } 38 | 39 | if err != nil { 40 | return err 41 | } 42 | } 43 | 44 | return s.Err() 45 | } 46 | 47 | func (r *ShallowUpdate) decodeShallowLine(line []byte) error { 48 | hash, err := r.decodeLine(line, shallow, shallowLineLen) 49 | if err != nil { 50 | return err 51 | } 52 | 53 | r.Shallows = append(r.Shallows, hash) 54 | return nil 55 | } 56 | 57 | func (r *ShallowUpdate) decodeUnshallowLine(line []byte) error { 58 | hash, err := r.decodeLine(line, unshallow, unshallowLineLen) 59 | if err != nil { 60 | return err 61 | } 62 | 63 | r.Unshallows = append(r.Unshallows, hash) 64 | return nil 65 | } 66 | 67 | func (r *ShallowUpdate) decodeLine(line, prefix []byte, expLen int) (plumbing.Hash, error) { 68 | if len(line) != expLen { 69 | return plumbing.ZeroHash, fmt.Errorf("malformed %s%q", prefix, line) 70 | } 71 | 72 | raw := string(line[expLen-40 : expLen]) 73 | return plumbing.NewHash(raw), nil 74 | } 75 | 76 | func (r *ShallowUpdate) Encode(w io.Writer) error { 77 | e := pktline.NewEncoder(w) 78 | 79 | for _, h := range r.Shallows { 80 | if err := e.Encodef("%s%s\n", shallow, h.String()); err != nil { 81 | return err 82 | } 83 | } 84 | 85 | for _, h := range r.Unshallows { 86 | if err := e.Encodef("%s%s\n", unshallow, h.String()); err != nil { 87 | return err 88 | } 89 | } 90 | 91 | return e.Flush() 92 | } 93 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/protocol/packp/sideband/common.go: -------------------------------------------------------------------------------- 1 | package sideband 2 | 3 | // Type sideband type "side-band" or "side-band-64k" 4 | type Type int8 5 | 6 | const ( 7 | // Sideband legacy sideband type up to 1000-byte messages 8 | Sideband Type = iota 9 | // Sideband64k sideband type up to 65519-byte messages 10 | Sideband64k Type = iota 11 | 12 | // MaxPackedSize for Sideband type 13 | MaxPackedSize = 1000 14 | // MaxPackedSize64k for Sideband64k type 15 | MaxPackedSize64k = 65520 16 | ) 17 | 18 | // Channel sideband channel 19 | type Channel byte 20 | 21 | // WithPayload encode the payload as a message 22 | func (ch Channel) WithPayload(payload []byte) []byte { 23 | return append([]byte{byte(ch)}, payload...) 24 | } 25 | 26 | const ( 27 | // PackData packfile content 28 | PackData Channel = 1 29 | // ProgressMessage progress messages 30 | ProgressMessage Channel = 2 31 | // ErrorMessage fatal error message just before stream aborts 32 | ErrorMessage Channel = 3 33 | ) 34 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/protocol/packp/sideband/doc.go: -------------------------------------------------------------------------------- 1 | // Package sideband implements a sideband mutiplex/demultiplexer 2 | package sideband 3 | 4 | // If 'side-band' or 'side-band-64k' capabilities have been specified by 5 | // the client, the server will send the packfile data multiplexed. 6 | // 7 | // Either mode indicates that the packfile data will be streamed broken 8 | // up into packets of up to either 1000 bytes in the case of 'side_band', 9 | // or 65520 bytes in the case of 'side_band_64k'. Each packet is made up 10 | // of a leading 4-byte pkt-line length of how much data is in the packet, 11 | // followed by a 1-byte stream code, followed by the actual data. 12 | // 13 | // The stream code can be one of: 14 | // 15 | // 1 - pack data 16 | // 2 - progress messages 17 | // 3 - fatal error message just before stream aborts 18 | // 19 | // The "side-band-64k" capability came about as a way for newer clients 20 | // that can handle much larger packets to request packets that are 21 | // actually crammed nearly full, while maintaining backward compatibility 22 | // for the older clients. 23 | // 24 | // Further, with side-band and its up to 1000-byte messages, it's actually 25 | // 999 bytes of payload and 1 byte for the stream code. With side-band-64k, 26 | // same deal, you have up to 65519 bytes of data and 1 byte for the stream 27 | // code. 28 | // 29 | // The client MUST send only maximum of one of "side-band" and "side- 30 | // band-64k". Server MUST diagnose it as an error if client requests 31 | // both. 32 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/protocol/packp/sideband/muxer.go: -------------------------------------------------------------------------------- 1 | package sideband 2 | 3 | import ( 4 | "io" 5 | 6 | "gopkg.in/src-d/go-git.v4/plumbing/format/pktline" 7 | ) 8 | 9 | // Muxer multiplex the packfile along with the progress messages and the error 10 | // information. The multiplex is perform using pktline format. 11 | type Muxer struct { 12 | max int 13 | e *pktline.Encoder 14 | } 15 | 16 | const chLen = 1 17 | 18 | // NewMuxer returns a new Muxer for the given t that writes on w. 19 | // 20 | // If t is equal to `Sideband` the max pack size is set to MaxPackedSize, in any 21 | // other value is given, max pack is set to MaxPackedSize64k, that is the 22 | // maximum length of a line in pktline format. 23 | func NewMuxer(t Type, w io.Writer) *Muxer { 24 | max := MaxPackedSize64k 25 | if t == Sideband { 26 | max = MaxPackedSize 27 | } 28 | 29 | return &Muxer{ 30 | max: max - chLen, 31 | e: pktline.NewEncoder(w), 32 | } 33 | } 34 | 35 | // Write writes p in the PackData channel 36 | func (m *Muxer) Write(p []byte) (int, error) { 37 | return m.WriteChannel(PackData, p) 38 | } 39 | 40 | // WriteChannel writes p in the given channel. This method can be used with any 41 | // channel, but is recommend use it only for the ProgressMessage and 42 | // ErrorMessage channels and use Write for the PackData channel 43 | func (m *Muxer) WriteChannel(t Channel, p []byte) (int, error) { 44 | wrote := 0 45 | size := len(p) 46 | for wrote < size { 47 | n, err := m.doWrite(t, p[wrote:]) 48 | wrote += n 49 | 50 | if err != nil { 51 | return wrote, err 52 | } 53 | } 54 | 55 | return wrote, nil 56 | } 57 | 58 | func (m *Muxer) doWrite(ch Channel, p []byte) (int, error) { 59 | sz := len(p) 60 | if sz > m.max { 61 | sz = m.max 62 | } 63 | 64 | return sz, m.e.Encode(ch.WithPayload(p[:sz])) 65 | } 66 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/protocol/packp/updreq_encode.go: -------------------------------------------------------------------------------- 1 | package packp 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | 7 | "gopkg.in/src-d/go-git.v4/plumbing" 8 | "gopkg.in/src-d/go-git.v4/plumbing/format/pktline" 9 | "gopkg.in/src-d/go-git.v4/plumbing/protocol/packp/capability" 10 | ) 11 | 12 | var ( 13 | zeroHashString = plumbing.ZeroHash.String() 14 | ) 15 | 16 | // Encode writes the ReferenceUpdateRequest encoding to the stream. 17 | func (r *ReferenceUpdateRequest) Encode(w io.Writer) error { 18 | if err := r.validate(); err != nil { 19 | return err 20 | } 21 | 22 | e := pktline.NewEncoder(w) 23 | 24 | if err := r.encodeShallow(e, r.Shallow); err != nil { 25 | return err 26 | } 27 | 28 | if err := r.encodeCommands(e, r.Commands, r.Capabilities); err != nil { 29 | return err 30 | } 31 | 32 | if r.Packfile != nil { 33 | if _, err := io.Copy(w, r.Packfile); err != nil { 34 | return err 35 | } 36 | 37 | return r.Packfile.Close() 38 | } 39 | 40 | return nil 41 | } 42 | 43 | func (r *ReferenceUpdateRequest) encodeShallow(e *pktline.Encoder, 44 | h *plumbing.Hash) error { 45 | 46 | if h == nil { 47 | return nil 48 | } 49 | 50 | objId := []byte(h.String()) 51 | return e.Encodef("%s%s", shallow, objId) 52 | } 53 | 54 | func (r *ReferenceUpdateRequest) encodeCommands(e *pktline.Encoder, 55 | cmds []*Command, cap *capability.List) error { 56 | 57 | if err := e.Encodef("%s\x00%s", 58 | formatCommand(cmds[0]), cap.String()); err != nil { 59 | return err 60 | } 61 | 62 | for _, cmd := range cmds[1:] { 63 | if err := e.Encodef(formatCommand(cmd)); err != nil { 64 | return err 65 | } 66 | } 67 | 68 | return e.Flush() 69 | } 70 | 71 | func formatCommand(cmd *Command) string { 72 | o := cmd.Old.String() 73 | n := cmd.New.String() 74 | return fmt.Sprintf("%s %s %s", o, n, cmd.Name) 75 | } 76 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/revision.go: -------------------------------------------------------------------------------- 1 | package plumbing 2 | 3 | // Revision represents a git revision 4 | // to get more details about git revisions 5 | // please check git manual page : 6 | // https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html 7 | type Revision string 8 | 9 | func (r Revision) String() string { 10 | return string(r) 11 | } 12 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/storer/doc.go: -------------------------------------------------------------------------------- 1 | // Package storer defines the interfaces to store objects, references, etc. 2 | package storer 3 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/storer/index.go: -------------------------------------------------------------------------------- 1 | package storer 2 | 3 | import "gopkg.in/src-d/go-git.v4/plumbing/format/index" 4 | 5 | // IndexStorer generic storage of index.Index 6 | type IndexStorer interface { 7 | SetIndex(*index.Index) error 8 | Index() (*index.Index, error) 9 | } 10 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/storer/shallow.go: -------------------------------------------------------------------------------- 1 | package storer 2 | 3 | import "gopkg.in/src-d/go-git.v4/plumbing" 4 | 5 | // ShallowStorer is a storage of references to shallow commits by hash, 6 | // meaning that these commits have missing parents because of a shallow fetch. 7 | type ShallowStorer interface { 8 | SetShallow([]plumbing.Hash) error 9 | Shallow() ([]plumbing.Hash, error) 10 | } 11 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/storer/storer.go: -------------------------------------------------------------------------------- 1 | package storer 2 | 3 | // Storer is a basic storer for encoded objects and references. 4 | type Storer interface { 5 | EncodedObjectStorer 6 | ReferenceStorer 7 | } 8 | 9 | // Initializer should be implemented by storers that require to perform any 10 | // operation when creating a new repository (i.e. git init). 11 | type Initializer interface { 12 | // Init performs initialization of the storer and returns the error, if 13 | // any. 14 | Init() error 15 | } 16 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/transport/client/client.go: -------------------------------------------------------------------------------- 1 | // Package client contains helper function to deal with the different client 2 | // protocols. 3 | package client 4 | 5 | import ( 6 | "fmt" 7 | 8 | "gopkg.in/src-d/go-git.v4/plumbing/transport" 9 | "gopkg.in/src-d/go-git.v4/plumbing/transport/file" 10 | "gopkg.in/src-d/go-git.v4/plumbing/transport/git" 11 | "gopkg.in/src-d/go-git.v4/plumbing/transport/http" 12 | "gopkg.in/src-d/go-git.v4/plumbing/transport/ssh" 13 | ) 14 | 15 | // Protocols are the protocols supported by default. 16 | var Protocols = map[string]transport.Transport{ 17 | "http": http.DefaultClient, 18 | "https": http.DefaultClient, 19 | "ssh": ssh.DefaultClient, 20 | "git": git.DefaultClient, 21 | "file": file.DefaultClient, 22 | } 23 | 24 | // InstallProtocol adds or modifies an existing protocol. 25 | func InstallProtocol(scheme string, c transport.Transport) { 26 | if c == nil { 27 | delete(Protocols, scheme) 28 | return 29 | } 30 | 31 | Protocols[scheme] = c 32 | } 33 | 34 | // NewClient returns the appropriate client among of the set of known protocols: 35 | // http://, https://, ssh:// and file://. 36 | // See `InstallProtocol` to add or modify protocols. 37 | func NewClient(endpoint *transport.Endpoint) (transport.Transport, error) { 38 | f, ok := Protocols[endpoint.Protocol] 39 | if !ok { 40 | return nil, fmt.Errorf("unsupported scheme %q", endpoint.Protocol) 41 | } 42 | 43 | if f == nil { 44 | return nil, fmt.Errorf("malformed client for scheme %q, client is defined as nil", endpoint.Protocol) 45 | } 46 | 47 | return f, nil 48 | } 49 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/transport/file/server.go: -------------------------------------------------------------------------------- 1 | package file 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "gopkg.in/src-d/go-git.v4/plumbing/transport" 8 | "gopkg.in/src-d/go-git.v4/plumbing/transport/internal/common" 9 | "gopkg.in/src-d/go-git.v4/plumbing/transport/server" 10 | "gopkg.in/src-d/go-git.v4/utils/ioutil" 11 | ) 12 | 13 | // ServeUploadPack serves a git-upload-pack request using standard output, input 14 | // and error. This is meant to be used when implementing a git-upload-pack 15 | // command. 16 | func ServeUploadPack(path string) error { 17 | ep, err := transport.NewEndpoint(path) 18 | if err != nil { 19 | return err 20 | } 21 | 22 | // TODO: define and implement a server-side AuthMethod 23 | s, err := server.DefaultServer.NewUploadPackSession(ep, nil) 24 | if err != nil { 25 | return fmt.Errorf("error creating session: %s", err) 26 | } 27 | 28 | return common.ServeUploadPack(srvCmd, s) 29 | } 30 | 31 | // ServeReceivePack serves a git-receive-pack request using standard output, 32 | // input and error. This is meant to be used when implementing a 33 | // git-receive-pack command. 34 | func ServeReceivePack(path string) error { 35 | ep, err := transport.NewEndpoint(path) 36 | if err != nil { 37 | return err 38 | } 39 | 40 | // TODO: define and implement a server-side AuthMethod 41 | s, err := server.DefaultServer.NewReceivePackSession(ep, nil) 42 | if err != nil { 43 | return fmt.Errorf("error creating session: %s", err) 44 | } 45 | 46 | return common.ServeReceivePack(srvCmd, s) 47 | } 48 | 49 | var srvCmd = common.ServerCommand{ 50 | Stdin: os.Stdin, 51 | Stdout: ioutil.WriteNopCloser(os.Stdout), 52 | Stderr: os.Stderr, 53 | } 54 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/transport/internal/common/server.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "io" 7 | 8 | "gopkg.in/src-d/go-git.v4/plumbing/protocol/packp" 9 | "gopkg.in/src-d/go-git.v4/plumbing/transport" 10 | "gopkg.in/src-d/go-git.v4/utils/ioutil" 11 | ) 12 | 13 | // ServerCommand is used for a single server command execution. 14 | type ServerCommand struct { 15 | Stderr io.Writer 16 | Stdout io.WriteCloser 17 | Stdin io.Reader 18 | } 19 | 20 | func ServeUploadPack(cmd ServerCommand, s transport.UploadPackSession) (err error) { 21 | ioutil.CheckClose(cmd.Stdout, &err) 22 | 23 | ar, err := s.AdvertisedReferences() 24 | if err != nil { 25 | return err 26 | } 27 | 28 | if err := ar.Encode(cmd.Stdout); err != nil { 29 | return err 30 | } 31 | 32 | req := packp.NewUploadPackRequest() 33 | if err := req.Decode(cmd.Stdin); err != nil { 34 | return err 35 | } 36 | 37 | var resp *packp.UploadPackResponse 38 | resp, err = s.UploadPack(context.TODO(), req) 39 | if err != nil { 40 | return err 41 | } 42 | 43 | return resp.Encode(cmd.Stdout) 44 | } 45 | 46 | func ServeReceivePack(cmd ServerCommand, s transport.ReceivePackSession) error { 47 | ar, err := s.AdvertisedReferences() 48 | if err != nil { 49 | return fmt.Errorf("internal error in advertised references: %s", err) 50 | } 51 | 52 | if err := ar.Encode(cmd.Stdout); err != nil { 53 | return fmt.Errorf("error in advertised references encoding: %s", err) 54 | } 55 | 56 | req := packp.NewReferenceUpdateRequest() 57 | if err := req.Decode(cmd.Stdin); err != nil { 58 | return fmt.Errorf("error decoding: %s", err) 59 | } 60 | 61 | rs, err := s.ReceivePack(context.TODO(), req) 62 | if rs != nil { 63 | if err := rs.Encode(cmd.Stdout); err != nil { 64 | return fmt.Errorf("error in encoding report status %s", err) 65 | } 66 | } 67 | 68 | if err != nil { 69 | return fmt.Errorf("error in receive pack: %s", err) 70 | } 71 | 72 | return nil 73 | } 74 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/plumbing/transport/server/loader.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "gopkg.in/src-d/go-git.v4/plumbing/cache" 5 | "gopkg.in/src-d/go-git.v4/plumbing/storer" 6 | "gopkg.in/src-d/go-git.v4/plumbing/transport" 7 | "gopkg.in/src-d/go-git.v4/storage/filesystem" 8 | 9 | "gopkg.in/src-d/go-billy.v4" 10 | "gopkg.in/src-d/go-billy.v4/osfs" 11 | ) 12 | 13 | // DefaultLoader is a filesystem loader ignoring host and resolving paths to /. 14 | var DefaultLoader = NewFilesystemLoader(osfs.New("")) 15 | 16 | // Loader loads repository's storer.Storer based on an optional host and a path. 17 | type Loader interface { 18 | // Load loads a storer.Storer given a transport.Endpoint. 19 | // Returns transport.ErrRepositoryNotFound if the repository does not 20 | // exist. 21 | Load(ep *transport.Endpoint) (storer.Storer, error) 22 | } 23 | 24 | type fsLoader struct { 25 | base billy.Filesystem 26 | } 27 | 28 | // NewFilesystemLoader creates a Loader that ignores host and resolves paths 29 | // with a given base filesystem. 30 | func NewFilesystemLoader(base billy.Filesystem) Loader { 31 | return &fsLoader{base} 32 | } 33 | 34 | // Load looks up the endpoint's path in the base file system and returns a 35 | // storer for it. Returns transport.ErrRepositoryNotFound if a repository does 36 | // not exist in the given path. 37 | func (l *fsLoader) Load(ep *transport.Endpoint) (storer.Storer, error) { 38 | fs, err := l.base.Chroot(ep.Path) 39 | if err != nil { 40 | return nil, err 41 | } 42 | 43 | if _, err := fs.Stat("config"); err != nil { 44 | return nil, transport.ErrRepositoryNotFound 45 | } 46 | 47 | return filesystem.NewStorage(fs, cache.NewObjectLRUDefault()), nil 48 | } 49 | 50 | // MapLoader is a Loader that uses a lookup map of storer.Storer by 51 | // transport.Endpoint. 52 | type MapLoader map[string]storer.Storer 53 | 54 | // Load returns a storer.Storer for given a transport.Endpoint by looking it up 55 | // in the map. Returns transport.ErrRepositoryNotFound if the endpoint does not 56 | // exist. 57 | func (l MapLoader) Load(ep *transport.Endpoint) (storer.Storer, error) { 58 | s, ok := l[ep.String()] 59 | if !ok { 60 | return nil, transport.ErrRepositoryNotFound 61 | } 62 | 63 | return s, nil 64 | } 65 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/prune.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "errors" 5 | "time" 6 | 7 | "gopkg.in/src-d/go-git.v4/plumbing" 8 | "gopkg.in/src-d/go-git.v4/plumbing/storer" 9 | ) 10 | 11 | type PruneHandler func(unreferencedObjectHash plumbing.Hash) error 12 | type PruneOptions struct { 13 | // OnlyObjectsOlderThan if set to non-zero value 14 | // selects only objects older than the time provided. 15 | OnlyObjectsOlderThan time.Time 16 | // Handler is called on matching objects 17 | Handler PruneHandler 18 | } 19 | 20 | var ErrLooseObjectsNotSupported = errors.New("Loose objects not supported") 21 | 22 | // DeleteObject deletes an object from a repository. 23 | // The type conveniently matches PruneHandler. 24 | func (r *Repository) DeleteObject(hash plumbing.Hash) error { 25 | los, ok := r.Storer.(storer.LooseObjectStorer) 26 | if !ok { 27 | return ErrLooseObjectsNotSupported 28 | } 29 | 30 | return los.DeleteLooseObject(hash) 31 | } 32 | 33 | func (r *Repository) Prune(opt PruneOptions) error { 34 | los, ok := r.Storer.(storer.LooseObjectStorer) 35 | if !ok { 36 | return ErrLooseObjectsNotSupported 37 | } 38 | 39 | pw := newObjectWalker(r.Storer) 40 | err := pw.walkAllRefs() 41 | if err != nil { 42 | return err 43 | } 44 | // Now walk all (loose) objects in storage. 45 | return los.ForEachObjectHash(func(hash plumbing.Hash) error { 46 | // Get out if we have seen this object. 47 | if pw.isSeen(hash) { 48 | return nil 49 | } 50 | // Otherwise it is a candidate for pruning. 51 | // Check out for too new objects next. 52 | if !opt.OnlyObjectsOlderThan.IsZero() { 53 | // Errors here are non-fatal. The object may be e.g. packed. 54 | // Or concurrently deleted. Skip such objects. 55 | t, err := los.LooseObjectTime(hash) 56 | if err != nil { 57 | return nil 58 | } 59 | // Skip too new objects. 60 | if !t.Before(opt.OnlyObjectsOlderThan) { 61 | return nil 62 | } 63 | } 64 | return opt.Handler(hash) 65 | }) 66 | } 67 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/status.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "path/filepath" 7 | ) 8 | 9 | // Status represents the current status of a Worktree. 10 | // The key of the map is the path of the file. 11 | type Status map[string]*FileStatus 12 | 13 | // File returns the FileStatus for a given path, if the FileStatus doesn't 14 | // exists a new FileStatus is added to the map using the path as key. 15 | func (s Status) File(path string) *FileStatus { 16 | if _, ok := (s)[path]; !ok { 17 | s[path] = &FileStatus{Worktree: Untracked, Staging: Untracked} 18 | } 19 | 20 | return s[path] 21 | } 22 | 23 | // IsUntracked checks if file for given path is 'Untracked' 24 | func (s Status) IsUntracked(path string) bool { 25 | stat, ok := (s)[filepath.ToSlash(path)] 26 | return ok && stat.Worktree == Untracked 27 | } 28 | 29 | // IsClean returns true if all the files are in Unmodified status. 30 | func (s Status) IsClean() bool { 31 | for _, status := range s { 32 | if status.Worktree != Unmodified || status.Staging != Unmodified { 33 | return false 34 | } 35 | } 36 | 37 | return true 38 | } 39 | 40 | func (s Status) String() string { 41 | buf := bytes.NewBuffer(nil) 42 | for path, status := range s { 43 | if status.Staging == Unmodified && status.Worktree == Unmodified { 44 | continue 45 | } 46 | 47 | if status.Staging == Renamed { 48 | path = fmt.Sprintf("%s -> %s", path, status.Extra) 49 | } 50 | 51 | fmt.Fprintf(buf, "%c%c %s\n", status.Staging, status.Worktree, path) 52 | } 53 | 54 | return buf.String() 55 | } 56 | 57 | // FileStatus contains the status of a file in the worktree 58 | type FileStatus struct { 59 | // Staging is the status of a file in the staging area 60 | Staging StatusCode 61 | // Worktree is the status of a file in the worktree 62 | Worktree StatusCode 63 | // Extra contains extra information, such as the previous name in a rename 64 | Extra string 65 | } 66 | 67 | // StatusCode status code of a file in the Worktree 68 | type StatusCode byte 69 | 70 | const ( 71 | Unmodified StatusCode = ' ' 72 | Untracked StatusCode = '?' 73 | Modified StatusCode = 'M' 74 | Added StatusCode = 'A' 75 | Deleted StatusCode = 'D' 76 | Renamed StatusCode = 'R' 77 | Copied StatusCode = 'C' 78 | UpdatedButUnmerged StatusCode = 'U' 79 | ) 80 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/storage/filesystem/config.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | stdioutil "io/ioutil" 5 | "os" 6 | 7 | "gopkg.in/src-d/go-git.v4/config" 8 | "gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit" 9 | "gopkg.in/src-d/go-git.v4/utils/ioutil" 10 | ) 11 | 12 | type ConfigStorage struct { 13 | dir *dotgit.DotGit 14 | } 15 | 16 | func (c *ConfigStorage) Config() (conf *config.Config, err error) { 17 | cfg := config.NewConfig() 18 | 19 | f, err := c.dir.Config() 20 | if err != nil { 21 | if os.IsNotExist(err) { 22 | return cfg, nil 23 | } 24 | 25 | return nil, err 26 | } 27 | 28 | defer ioutil.CheckClose(f, &err) 29 | 30 | b, err := stdioutil.ReadAll(f) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | if err = cfg.Unmarshal(b); err != nil { 36 | return nil, err 37 | } 38 | 39 | return cfg, err 40 | } 41 | 42 | func (c *ConfigStorage) SetConfig(cfg *config.Config) (err error) { 43 | if err = cfg.Validate(); err != nil { 44 | return err 45 | } 46 | 47 | f, err := c.dir.ConfigWriter() 48 | if err != nil { 49 | return err 50 | } 51 | 52 | defer ioutil.CheckClose(f, &err) 53 | 54 | b, err := cfg.Marshal() 55 | if err != nil { 56 | return err 57 | } 58 | 59 | _, err = f.Write(b) 60 | return err 61 | } 62 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/storage/filesystem/deltaobject.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | "gopkg.in/src-d/go-git.v4/plumbing" 5 | ) 6 | 7 | type deltaObject struct { 8 | plumbing.EncodedObject 9 | base plumbing.Hash 10 | hash plumbing.Hash 11 | size int64 12 | } 13 | 14 | func newDeltaObject( 15 | obj plumbing.EncodedObject, 16 | hash plumbing.Hash, 17 | base plumbing.Hash, 18 | size int64) plumbing.DeltaObject { 19 | return &deltaObject{ 20 | EncodedObject: obj, 21 | hash: hash, 22 | base: base, 23 | size: size, 24 | } 25 | } 26 | 27 | func (o *deltaObject) BaseHash() plumbing.Hash { 28 | return o.base 29 | } 30 | 31 | func (o *deltaObject) ActualSize() int64 { 32 | return o.size 33 | } 34 | 35 | func (o *deltaObject) ActualHash() plumbing.Hash { 36 | return o.hash 37 | } 38 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit/dotgit_rewrite_packed_refs.go: -------------------------------------------------------------------------------- 1 | package dotgit 2 | 3 | import ( 4 | "io" 5 | "os" 6 | "runtime" 7 | 8 | "gopkg.in/src-d/go-billy.v4" 9 | "gopkg.in/src-d/go-git.v4/utils/ioutil" 10 | ) 11 | 12 | func (d *DotGit) openAndLockPackedRefsMode() int { 13 | if billy.CapabilityCheck(d.fs, billy.ReadAndWriteCapability) { 14 | return os.O_RDWR 15 | } 16 | 17 | return os.O_RDONLY 18 | } 19 | 20 | func (d *DotGit) rewritePackedRefsWhileLocked( 21 | tmp billy.File, pr billy.File) error { 22 | // Try plain rename. If we aren't using the bare Windows filesystem as the 23 | // storage layer, we might be able to get away with a rename over a locked 24 | // file. 25 | err := d.fs.Rename(tmp.Name(), pr.Name()) 26 | if err == nil { 27 | return nil 28 | } 29 | 30 | // If we are in a filesystem that does not support rename (e.g. sivafs) 31 | // a full copy is done. 32 | if err == billy.ErrNotSupported { 33 | return d.copyNewFile(tmp, pr) 34 | } 35 | 36 | if runtime.GOOS != "windows" { 37 | return err 38 | } 39 | 40 | // Otherwise, Windows doesn't let us rename over a locked file, so 41 | // we have to do a straight copy. Unfortunately this could result 42 | // in a partially-written file if the process fails before the 43 | // copy completes. 44 | return d.copyToExistingFile(tmp, pr) 45 | } 46 | 47 | func (d *DotGit) copyToExistingFile(tmp, pr billy.File) error { 48 | _, err := pr.Seek(0, io.SeekStart) 49 | if err != nil { 50 | return err 51 | } 52 | err = pr.Truncate(0) 53 | if err != nil { 54 | return err 55 | } 56 | _, err = tmp.Seek(0, io.SeekStart) 57 | if err != nil { 58 | return err 59 | } 60 | _, err = io.Copy(pr, tmp) 61 | 62 | return err 63 | } 64 | 65 | func (d *DotGit) copyNewFile(tmp billy.File, pr billy.File) (err error) { 66 | prWrite, err := d.fs.Create(pr.Name()) 67 | if err != nil { 68 | return err 69 | } 70 | 71 | defer ioutil.CheckClose(prWrite, &err) 72 | 73 | _, err = tmp.Seek(0, io.SeekStart) 74 | if err != nil { 75 | return err 76 | } 77 | 78 | _, err = io.Copy(prWrite, tmp) 79 | 80 | return err 81 | } 82 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit/dotgit_setref.go: -------------------------------------------------------------------------------- 1 | // +build !norwfs 2 | 3 | package dotgit 4 | 5 | import ( 6 | "os" 7 | 8 | "gopkg.in/src-d/go-git.v4/plumbing" 9 | "gopkg.in/src-d/go-git.v4/utils/ioutil" 10 | ) 11 | 12 | func (d *DotGit) setRef(fileName, content string, old *plumbing.Reference) (err error) { 13 | // If we are not checking an old ref, just truncate the file. 14 | mode := os.O_RDWR | os.O_CREATE 15 | if old == nil { 16 | mode |= os.O_TRUNC 17 | } 18 | 19 | f, err := d.fs.OpenFile(fileName, mode, 0666) 20 | if err != nil { 21 | return err 22 | } 23 | 24 | defer ioutil.CheckClose(f, &err) 25 | 26 | // Lock is unlocked by the deferred Close above. This is because Unlock 27 | // does not imply a fsync and thus there would be a race between 28 | // Unlock+Close and other concurrent writers. Adding Sync to go-billy 29 | // could work, but this is better (and avoids superfluous syncs). 30 | err = f.Lock() 31 | if err != nil { 32 | return err 33 | } 34 | 35 | // this is a no-op to call even when old is nil. 36 | err = d.checkReferenceAndTruncate(f, old) 37 | if err != nil { 38 | return err 39 | } 40 | 41 | _, err = f.Write([]byte(content)) 42 | return err 43 | } 44 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit/dotgit_setref_norwfs.go: -------------------------------------------------------------------------------- 1 | // +build norwfs 2 | 3 | package dotgit 4 | 5 | import ( 6 | "fmt" 7 | 8 | "gopkg.in/src-d/go-git.v4/plumbing" 9 | ) 10 | 11 | // There are some filesystems that don't support opening files in RDWD mode. 12 | // In these filesystems the standard SetRef function can not be used as i 13 | // reads the reference file to check that it's not modified before updating it. 14 | // 15 | // This version of the function writes the reference without extra checks 16 | // making it compatible with these simple filesystems. This is usually not 17 | // a problem as they should be accessed by only one process at a time. 18 | func (d *DotGit) setRef(fileName, content string, old *plumbing.Reference) error { 19 | _, err := d.fs.Stat(fileName) 20 | if err == nil && old != nil { 21 | fRead, err := d.fs.Open(fileName) 22 | if err != nil { 23 | return err 24 | } 25 | 26 | ref, err := d.readReferenceFrom(fRead, old.Name().String()) 27 | fRead.Close() 28 | 29 | if err != nil { 30 | return err 31 | } 32 | 33 | if ref.Hash() != old.Hash() { 34 | return fmt.Errorf("reference has changed concurrently") 35 | } 36 | } 37 | 38 | f, err := d.fs.Create(fileName) 39 | if err != nil { 40 | return err 41 | } 42 | 43 | defer f.Close() 44 | 45 | _, err = f.Write([]byte(content)) 46 | return err 47 | } 48 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/storage/filesystem/index.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | "os" 5 | 6 | "gopkg.in/src-d/go-git.v4/plumbing/format/index" 7 | "gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit" 8 | "gopkg.in/src-d/go-git.v4/utils/ioutil" 9 | ) 10 | 11 | type IndexStorage struct { 12 | dir *dotgit.DotGit 13 | } 14 | 15 | func (s *IndexStorage) SetIndex(idx *index.Index) (err error) { 16 | f, err := s.dir.IndexWriter() 17 | if err != nil { 18 | return err 19 | } 20 | 21 | defer ioutil.CheckClose(f, &err) 22 | 23 | e := index.NewEncoder(f) 24 | err = e.Encode(idx) 25 | return err 26 | } 27 | 28 | func (s *IndexStorage) Index() (i *index.Index, err error) { 29 | idx := &index.Index{ 30 | Version: 2, 31 | } 32 | 33 | f, err := s.dir.Index() 34 | if err != nil { 35 | if os.IsNotExist(err) { 36 | return idx, nil 37 | } 38 | 39 | return nil, err 40 | } 41 | 42 | defer ioutil.CheckClose(f, &err) 43 | 44 | d := index.NewDecoder(f) 45 | err = d.Decode(idx) 46 | return idx, err 47 | } 48 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/storage/filesystem/module.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | "gopkg.in/src-d/go-git.v4/plumbing/cache" 5 | "gopkg.in/src-d/go-git.v4/storage" 6 | "gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit" 7 | ) 8 | 9 | type ModuleStorage struct { 10 | dir *dotgit.DotGit 11 | } 12 | 13 | func (s *ModuleStorage) Module(name string) (storage.Storer, error) { 14 | fs, err := s.dir.Module(name) 15 | if err != nil { 16 | return nil, err 17 | } 18 | 19 | return NewStorage(fs, cache.NewObjectLRUDefault()), nil 20 | } 21 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/storage/filesystem/reference.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | "gopkg.in/src-d/go-git.v4/plumbing" 5 | "gopkg.in/src-d/go-git.v4/plumbing/storer" 6 | "gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit" 7 | ) 8 | 9 | type ReferenceStorage struct { 10 | dir *dotgit.DotGit 11 | } 12 | 13 | func (r *ReferenceStorage) SetReference(ref *plumbing.Reference) error { 14 | return r.dir.SetRef(ref, nil) 15 | } 16 | 17 | func (r *ReferenceStorage) CheckAndSetReference(ref, old *plumbing.Reference) error { 18 | return r.dir.SetRef(ref, old) 19 | } 20 | 21 | func (r *ReferenceStorage) Reference(n plumbing.ReferenceName) (*plumbing.Reference, error) { 22 | return r.dir.Ref(n) 23 | } 24 | 25 | func (r *ReferenceStorage) IterReferences() (storer.ReferenceIter, error) { 26 | refs, err := r.dir.Refs() 27 | if err != nil { 28 | return nil, err 29 | } 30 | 31 | return storer.NewReferenceSliceIter(refs), nil 32 | } 33 | 34 | func (r *ReferenceStorage) RemoveReference(n plumbing.ReferenceName) error { 35 | return r.dir.RemoveRef(n) 36 | } 37 | 38 | func (r *ReferenceStorage) CountLooseRefs() (int, error) { 39 | return r.dir.CountLooseRefs() 40 | } 41 | 42 | func (r *ReferenceStorage) PackRefs() error { 43 | return r.dir.PackRefs() 44 | } 45 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/storage/filesystem/shallow.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | 7 | "gopkg.in/src-d/go-git.v4/plumbing" 8 | "gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit" 9 | "gopkg.in/src-d/go-git.v4/utils/ioutil" 10 | ) 11 | 12 | // ShallowStorage where the shallow commits are stored, an internal to 13 | // manipulate the shallow file 14 | type ShallowStorage struct { 15 | dir *dotgit.DotGit 16 | } 17 | 18 | // SetShallow save the shallows in the shallow file in the .git folder as one 19 | // commit per line represented by 40-byte hexadecimal object terminated by a 20 | // newline. 21 | func (s *ShallowStorage) SetShallow(commits []plumbing.Hash) error { 22 | f, err := s.dir.ShallowWriter() 23 | if err != nil { 24 | return err 25 | } 26 | 27 | defer ioutil.CheckClose(f, &err) 28 | for _, h := range commits { 29 | if _, err := fmt.Fprintf(f, "%s\n", h); err != nil { 30 | return err 31 | } 32 | } 33 | 34 | return err 35 | } 36 | 37 | // Shallow return the shallow commits reading from shallo file from .git 38 | func (s *ShallowStorage) Shallow() ([]plumbing.Hash, error) { 39 | f, err := s.dir.Shallow() 40 | if f == nil || err != nil { 41 | return nil, err 42 | } 43 | 44 | defer ioutil.CheckClose(f, &err) 45 | 46 | var hash []plumbing.Hash 47 | 48 | scn := bufio.NewScanner(f) 49 | for scn.Scan() { 50 | hash = append(hash, plumbing.NewHash(scn.Text())) 51 | } 52 | 53 | return hash, scn.Err() 54 | } 55 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/storage/filesystem/storage.go: -------------------------------------------------------------------------------- 1 | // Package filesystem is a storage backend base on filesystems 2 | package filesystem 3 | 4 | import ( 5 | "gopkg.in/src-d/go-git.v4/plumbing/cache" 6 | "gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit" 7 | 8 | "gopkg.in/src-d/go-billy.v4" 9 | ) 10 | 11 | // Storage is an implementation of git.Storer that stores data on disk in the 12 | // standard git format (this is, the .git directory). Zero values of this type 13 | // are not safe to use, see the NewStorage function below. 14 | type Storage struct { 15 | fs billy.Filesystem 16 | dir *dotgit.DotGit 17 | 18 | ObjectStorage 19 | ReferenceStorage 20 | IndexStorage 21 | ShallowStorage 22 | ConfigStorage 23 | ModuleStorage 24 | } 25 | 26 | // Options holds configuration for the storage. 27 | type Options struct { 28 | // ExclusiveAccess means that the filesystem is not modified externally 29 | // while the repo is open. 30 | ExclusiveAccess bool 31 | // KeepDescriptors makes the file descriptors to be reused but they will 32 | // need to be manually closed calling Close(). 33 | KeepDescriptors bool 34 | } 35 | 36 | // NewStorage returns a new Storage backed by a given `fs.Filesystem` and cache. 37 | func NewStorage(fs billy.Filesystem, cache cache.Object) *Storage { 38 | return NewStorageWithOptions(fs, cache, Options{}) 39 | } 40 | 41 | // NewStorageWithOptions returns a new Storage with extra options, 42 | // backed by a given `fs.Filesystem` and cache. 43 | func NewStorageWithOptions(fs billy.Filesystem, cache cache.Object, ops Options) *Storage { 44 | dirOps := dotgit.Options{ 45 | ExclusiveAccess: ops.ExclusiveAccess, 46 | KeepDescriptors: ops.KeepDescriptors, 47 | } 48 | dir := dotgit.NewWithOptions(fs, dirOps) 49 | 50 | return &Storage{ 51 | fs: fs, 52 | dir: dir, 53 | 54 | ObjectStorage: ObjectStorage{ 55 | options: ops, 56 | deltaBaseCache: cache, 57 | dir: dir, 58 | }, 59 | ReferenceStorage: ReferenceStorage{dir: dir}, 60 | IndexStorage: IndexStorage{dir: dir}, 61 | ShallowStorage: ShallowStorage{dir: dir}, 62 | ConfigStorage: ConfigStorage{dir: dir}, 63 | ModuleStorage: ModuleStorage{dir: dir}, 64 | } 65 | } 66 | 67 | // Filesystem returns the underlying filesystem 68 | func (s *Storage) Filesystem() billy.Filesystem { 69 | return s.fs 70 | } 71 | 72 | // Init initializes .git directory 73 | func (s *Storage) Init() error { 74 | return s.dir.Initialize() 75 | } 76 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/storage/storer.go: -------------------------------------------------------------------------------- 1 | package storage 2 | 3 | import ( 4 | "gopkg.in/src-d/go-git.v4/config" 5 | "gopkg.in/src-d/go-git.v4/plumbing/storer" 6 | ) 7 | 8 | // Storer is a generic storage of objects, references and any information 9 | // related to a particular repository. The package gopkg.in/src-d/go-git.v4/storage 10 | // contains two implementation a filesystem base implementation (such as `.git`) 11 | // and a memory implementations being ephemeral 12 | type Storer interface { 13 | storer.EncodedObjectStorer 14 | storer.ReferenceStorer 15 | storer.ShallowStorer 16 | storer.IndexStorer 17 | config.ConfigStorer 18 | ModuleStorer 19 | } 20 | 21 | // ModuleStorer allows interact with the modules' Storers 22 | type ModuleStorer interface { 23 | // Module returns a Storer representing a submodule, if not exists returns a 24 | // new empty Storer is returned 25 | Module(name string) (Storer, error) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/utils/binary/write.go: -------------------------------------------------------------------------------- 1 | package binary 2 | 3 | import ( 4 | "encoding/binary" 5 | "io" 6 | ) 7 | 8 | // Write writes the binary representation of data into w, using BigEndian order 9 | // https://golang.org/pkg/encoding/binary/#Write 10 | func Write(w io.Writer, data ...interface{}) error { 11 | for _, v := range data { 12 | if err := binary.Write(w, binary.BigEndian, v); err != nil { 13 | return err 14 | } 15 | } 16 | 17 | return nil 18 | } 19 | 20 | func WriteVariableWidthInt(w io.Writer, n int64) error { 21 | buf := []byte{byte(n & 0x7f)} 22 | n >>= 7 23 | for n != 0 { 24 | n-- 25 | buf = append([]byte{0x80 | (byte(n & 0x7f))}, buf...) 26 | n >>= 7 27 | } 28 | 29 | _, err := w.Write(buf) 30 | 31 | return err 32 | } 33 | 34 | // WriteUint64 writes the binary representation of a uint64 into w, in BigEndian 35 | // order 36 | func WriteUint64(w io.Writer, value uint64) error { 37 | return binary.Write(w, binary.BigEndian, value) 38 | } 39 | 40 | // WriteUint32 writes the binary representation of a uint32 into w, in BigEndian 41 | // order 42 | func WriteUint32(w io.Writer, value uint32) error { 43 | return binary.Write(w, binary.BigEndian, value) 44 | } 45 | 46 | // WriteUint16 writes the binary representation of a uint16 into w, in BigEndian 47 | // order 48 | func WriteUint16(w io.Writer, value uint16) error { 49 | return binary.Write(w, binary.BigEndian, value) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/utils/diff/diff.go: -------------------------------------------------------------------------------- 1 | // Package diff implements line oriented diffs, similar to the ancient 2 | // Unix diff command. 3 | // 4 | // The current implementation is just a wrapper around Sergi's 5 | // go-diff/diffmatchpatch library, which is a go port of Neil 6 | // Fraser's google-diff-match-patch code 7 | package diff 8 | 9 | import ( 10 | "bytes" 11 | 12 | "github.com/sergi/go-diff/diffmatchpatch" 13 | ) 14 | 15 | // Do computes the (line oriented) modifications needed to turn the src 16 | // string into the dst string. 17 | func Do(src, dst string) (diffs []diffmatchpatch.Diff) { 18 | dmp := diffmatchpatch.New() 19 | wSrc, wDst, warray := dmp.DiffLinesToRunes(src, dst) 20 | diffs = dmp.DiffMainRunes(wSrc, wDst, false) 21 | diffs = dmp.DiffCharsToLines(diffs, warray) 22 | return diffs 23 | } 24 | 25 | // Dst computes and returns the destination text. 26 | func Dst(diffs []diffmatchpatch.Diff) string { 27 | var text bytes.Buffer 28 | for _, d := range diffs { 29 | if d.Type != diffmatchpatch.DiffDelete { 30 | text.WriteString(d.Text) 31 | } 32 | } 33 | return text.String() 34 | } 35 | 36 | // Src computes and returns the source text 37 | func Src(diffs []diffmatchpatch.Diff) string { 38 | var text bytes.Buffer 39 | for _, d := range diffs { 40 | if d.Type != diffmatchpatch.DiffInsert { 41 | text.WriteString(d.Text) 42 | } 43 | } 44 | return text.String() 45 | } 46 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/utils/merkletrie/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package merkletrie provides support for n-ary trees that are at the same 3 | time Merkle trees and Radix trees (tries). 4 | 5 | Git trees are Radix n-ary trees in virtue of the names of their 6 | tree entries. At the same time, git trees are Merkle trees thanks to 7 | their hashes. 8 | 9 | This package defines Merkle tries as nodes that should have: 10 | 11 | - a hash: the Merkle part of the Merkle trie 12 | 13 | - a key: the Radix part of the Merkle trie 14 | 15 | The Merkle hash condition is not enforced by this package though. This 16 | means that the hash of a node doesn't have to take into account the hashes of 17 | their children, which is good for testing purposes. 18 | 19 | Nodes in the Merkle trie are abstracted by the Noder interface. The 20 | intended use is that git trees implements this interface, either 21 | directly or using a simple wrapper. 22 | 23 | This package provides an iterator for merkletries that can skip whole 24 | directory-like noders and an efficient merkletrie comparison algorithm. 25 | 26 | When comparing git trees, the simple approach of alphabetically sorting 27 | their elements and comparing the resulting lists is too slow as it 28 | depends linearly on the number of files in the trees: When a directory 29 | has lots of files but none of them has been modified, this approach is 30 | very expensive. We can do better by prunning whole directories that 31 | have not change, just by looking at their hashes. This package provides 32 | the tools to do exactly that. 33 | */ 34 | package merkletrie 35 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/utils/merkletrie/index/node.go: -------------------------------------------------------------------------------- 1 | package index 2 | 3 | import ( 4 | "path" 5 | "strings" 6 | 7 | "gopkg.in/src-d/go-git.v4/plumbing/format/index" 8 | "gopkg.in/src-d/go-git.v4/utils/merkletrie/noder" 9 | ) 10 | 11 | // The node represents a index.Entry or a directory inferred from the path 12 | // of all entries. It implements the interface noder.Noder of merkletrie 13 | // package. 14 | // 15 | // This implementation implements a "standard" hash method being able to be 16 | // compared with any other noder.Noder implementation inside of go-git 17 | type node struct { 18 | path string 19 | entry *index.Entry 20 | children []noder.Noder 21 | isDir bool 22 | } 23 | 24 | // NewRootNode returns the root node of a computed tree from a index.Index, 25 | func NewRootNode(idx *index.Index) noder.Noder { 26 | const rootNode = "" 27 | 28 | m := map[string]*node{rootNode: {isDir: true}} 29 | 30 | for _, e := range idx.Entries { 31 | parts := strings.Split(e.Name, string("/")) 32 | 33 | var fullpath string 34 | for _, part := range parts { 35 | parent := fullpath 36 | fullpath = path.Join(fullpath, part) 37 | 38 | if _, ok := m[fullpath]; ok { 39 | continue 40 | } 41 | 42 | n := &node{path: fullpath} 43 | if fullpath == e.Name { 44 | n.entry = e 45 | } else { 46 | n.isDir = true 47 | } 48 | 49 | m[n.path] = n 50 | m[parent].children = append(m[parent].children, n) 51 | } 52 | } 53 | 54 | return m[rootNode] 55 | } 56 | 57 | func (n *node) String() string { 58 | return n.path 59 | } 60 | 61 | // Hash the hash of a filesystem is a 24-byte slice, is the result of 62 | // concatenating the computed plumbing.Hash of the file as a Blob and its 63 | // plumbing.FileMode; that way the difftree algorithm will detect changes in the 64 | // contents of files and also in their mode. 65 | // 66 | // If the node is computed and not based on a index.Entry the hash is equals 67 | // to a 24-bytes slices of zero values. 68 | func (n *node) Hash() []byte { 69 | if n.entry == nil { 70 | return make([]byte, 24) 71 | } 72 | 73 | return append(n.entry.Hash[:], n.entry.Mode.Bytes()...) 74 | } 75 | 76 | func (n *node) Name() string { 77 | return path.Base(n.path) 78 | } 79 | 80 | func (n *node) IsDir() bool { 81 | return n.isDir 82 | } 83 | 84 | func (n *node) Children() ([]noder.Noder, error) { 85 | return n.children, nil 86 | } 87 | 88 | func (n *node) NumChildren() (int, error) { 89 | return len(n.children), nil 90 | } 91 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/utils/merkletrie/internal/frame/frame.go: -------------------------------------------------------------------------------- 1 | package frame 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "sort" 7 | "strings" 8 | 9 | "gopkg.in/src-d/go-git.v4/utils/merkletrie/noder" 10 | ) 11 | 12 | // A Frame is a collection of siblings in a trie, sorted alphabetically 13 | // by name. 14 | type Frame struct { 15 | // siblings, sorted in reverse alphabetical order by name 16 | stack []noder.Noder 17 | } 18 | 19 | type byName []noder.Noder 20 | 21 | func (a byName) Len() int { return len(a) } 22 | func (a byName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } 23 | func (a byName) Less(i, j int) bool { 24 | return strings.Compare(a[i].Name(), a[j].Name()) < 0 25 | } 26 | 27 | // New returns a frame with the children of the provided node. 28 | func New(n noder.Noder) (*Frame, error) { 29 | children, err := n.Children() 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | sort.Sort(sort.Reverse(byName(children))) 35 | return &Frame{ 36 | stack: children, 37 | }, nil 38 | } 39 | 40 | // String returns the quoted names of the noders in the frame sorted in 41 | // alphabeticall order by name, surrounded by square brackets and 42 | // separated by comas. 43 | // 44 | // Examples: 45 | // [] 46 | // ["a", "b"] 47 | func (f *Frame) String() string { 48 | var buf bytes.Buffer 49 | _ = buf.WriteByte('[') 50 | 51 | sep := "" 52 | for i := f.Len() - 1; i >= 0; i-- { 53 | _, _ = buf.WriteString(sep) 54 | sep = ", " 55 | _, _ = buf.WriteString(fmt.Sprintf("%q", f.stack[i].Name())) 56 | } 57 | 58 | _ = buf.WriteByte(']') 59 | 60 | return buf.String() 61 | } 62 | 63 | // First returns, but dont extract, the noder with the alphabetically 64 | // smaller name in the frame and true if the frame was not empy. 65 | // Otherwise it returns nil and false. 66 | func (f *Frame) First() (noder.Noder, bool) { 67 | if f.Len() == 0 { 68 | return nil, false 69 | } 70 | 71 | top := f.Len() - 1 72 | 73 | return f.stack[top], true 74 | } 75 | 76 | // Drop extracts the noder with the alphabetically smaller name in the 77 | // frame or does nothing if the frame was empty. 78 | func (f *Frame) Drop() { 79 | if f.Len() == 0 { 80 | return 81 | } 82 | 83 | top := f.Len() - 1 84 | f.stack[top] = nil 85 | f.stack = f.stack[:top] 86 | } 87 | 88 | // Len returns the number of noders in the frame. 89 | func (f *Frame) Len() int { 90 | return len(f.stack) 91 | } 92 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/utils/merkletrie/noder/noder.go: -------------------------------------------------------------------------------- 1 | // Package noder provide an interface for defining nodes in a 2 | // merkletrie, their hashes and their paths (a noders and its 3 | // ancestors). 4 | // 5 | // The hasher interface is easy to implement naively by elements that 6 | // already have a hash, like git blobs and trees. More sophisticated 7 | // implementations can implement the Equal function in exotic ways 8 | // though: for instance, comparing the modification time of directories 9 | // in a filesystem. 10 | package noder 11 | 12 | import "fmt" 13 | 14 | // Hasher interface is implemented by types that can tell you 15 | // their hash. 16 | type Hasher interface { 17 | Hash() []byte 18 | } 19 | 20 | // Equal functions take two hashers and return if they are equal. 21 | // 22 | // These functions are expected to be faster than reflect.Equal or 23 | // reflect.DeepEqual because they can compare just the hash of the 24 | // objects, instead of their contents, so they are expected to be O(1). 25 | type Equal func(a, b Hasher) bool 26 | 27 | // The Noder interface is implemented by the elements of a Merkle Trie. 28 | // 29 | // There are two types of elements in a Merkle Trie: 30 | // 31 | // - file-like nodes: they cannot have children. 32 | // 33 | // - directory-like nodes: they can have 0 or more children and their 34 | // hash is calculated by combining their children hashes. 35 | type Noder interface { 36 | Hasher 37 | fmt.Stringer // for testing purposes 38 | // Name returns the name of an element (relative, not its full 39 | // path). 40 | Name() string 41 | // IsDir returns true if the element is a directory-like node or 42 | // false if it is a file-like node. 43 | IsDir() bool 44 | // Children returns the children of the element. Note that empty 45 | // directory-like noders and file-like noders will both return 46 | // NoChildren. 47 | Children() ([]Noder, error) 48 | // NumChildren returns the number of children this element has. 49 | // 50 | // This method is an optimization: the number of children is easily 51 | // calculated as the length of the value returned by the Children 52 | // method (above); yet, some implementations will be able to 53 | // implement NumChildren in O(1) while Children is usually more 54 | // complex. 55 | NumChildren() (int, error) 56 | } 57 | 58 | // NoChildren represents the children of a noder without children. 59 | var NoChildren = []Noder{} 60 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/utils/merkletrie/noder/path.go: -------------------------------------------------------------------------------- 1 | package noder 2 | 3 | import ( 4 | "bytes" 5 | "strings" 6 | 7 | "golang.org/x/text/unicode/norm" 8 | ) 9 | 10 | // Path values represent a noder and its ancestors. The root goes first 11 | // and the actual final noder the path is referring to will be the last. 12 | // 13 | // A path implements the Noder interface, redirecting all the interface 14 | // calls to its final noder. 15 | // 16 | // Paths build from an empty Noder slice are not valid paths and should 17 | // not be used. 18 | type Path []Noder 19 | 20 | // String returns the full path of the final noder as a string, using 21 | // "/" as the separator. 22 | func (p Path) String() string { 23 | var buf bytes.Buffer 24 | sep := "" 25 | for _, e := range p { 26 | _, _ = buf.WriteString(sep) 27 | sep = "/" 28 | _, _ = buf.WriteString(e.Name()) 29 | } 30 | 31 | return buf.String() 32 | } 33 | 34 | // Last returns the final noder in the path. 35 | func (p Path) Last() Noder { 36 | return p[len(p)-1] 37 | } 38 | 39 | // Hash returns the hash of the final noder of the path. 40 | func (p Path) Hash() []byte { 41 | return p.Last().Hash() 42 | } 43 | 44 | // Name returns the name of the final noder of the path. 45 | func (p Path) Name() string { 46 | return p.Last().Name() 47 | } 48 | 49 | // IsDir returns if the final noder of the path is a directory-like 50 | // noder. 51 | func (p Path) IsDir() bool { 52 | return p.Last().IsDir() 53 | } 54 | 55 | // Children returns the children of the final noder in the path. 56 | func (p Path) Children() ([]Noder, error) { 57 | return p.Last().Children() 58 | } 59 | 60 | // NumChildren returns the number of children the final noder of the 61 | // path has. 62 | func (p Path) NumChildren() (int, error) { 63 | return p.Last().NumChildren() 64 | } 65 | 66 | // Compare returns -1, 0 or 1 if the path p is smaller, equal or bigger 67 | // than other, in "directory order"; for example: 68 | // 69 | // "a" < "b" 70 | // "a/b/c/d/z" < "b" 71 | // "a/b/a" > "a/b" 72 | func (p Path) Compare(other Path) int { 73 | i := 0 74 | for { 75 | switch { 76 | case len(other) == len(p) && i == len(p): 77 | return 0 78 | case i == len(other): 79 | return 1 80 | case i == len(p): 81 | return -1 82 | default: 83 | form := norm.Form(norm.NFC) 84 | this := form.String(p[i].Name()) 85 | that := form.String(other[i].Name()) 86 | 87 | cmp := strings.Compare(this, that) 88 | if cmp != 0 { 89 | return cmp 90 | } 91 | } 92 | i++ 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/worktree_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd netbsd openbsd 2 | 3 | package git 4 | 5 | import ( 6 | "syscall" 7 | "time" 8 | 9 | "gopkg.in/src-d/go-git.v4/plumbing/format/index" 10 | ) 11 | 12 | func init() { 13 | fillSystemInfo = func(e *index.Entry, sys interface{}) { 14 | if os, ok := sys.(*syscall.Stat_t); ok { 15 | e.CreatedAt = time.Unix(int64(os.Atimespec.Sec), int64(os.Atimespec.Nsec)) 16 | e.Dev = uint32(os.Dev) 17 | e.Inode = uint32(os.Ino) 18 | e.GID = os.Gid 19 | e.UID = os.Uid 20 | } 21 | } 22 | } 23 | 24 | func isSymlinkWindowsNonAdmin(err error) bool { 25 | return false 26 | } 27 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/worktree_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | 3 | package git 4 | 5 | import ( 6 | "syscall" 7 | "time" 8 | 9 | "gopkg.in/src-d/go-git.v4/plumbing/format/index" 10 | ) 11 | 12 | func init() { 13 | fillSystemInfo = func(e *index.Entry, sys interface{}) { 14 | if os, ok := sys.(*syscall.Stat_t); ok { 15 | e.CreatedAt = time.Unix(int64(os.Ctim.Sec), int64(os.Ctim.Nsec)) 16 | e.Dev = uint32(os.Dev) 17 | e.Inode = uint32(os.Ino) 18 | e.GID = os.Gid 19 | e.UID = os.Uid 20 | } 21 | } 22 | } 23 | 24 | func isSymlinkWindowsNonAdmin(err error) bool { 25 | return false 26 | } 27 | -------------------------------------------------------------------------------- /vendor/gopkg.in/src-d/go-git.v4/worktree_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package git 4 | 5 | import ( 6 | "os" 7 | "syscall" 8 | "time" 9 | 10 | "gopkg.in/src-d/go-git.v4/plumbing/format/index" 11 | ) 12 | 13 | func init() { 14 | fillSystemInfo = func(e *index.Entry, sys interface{}) { 15 | if os, ok := sys.(*syscall.Win32FileAttributeData); ok { 16 | seconds := os.CreationTime.Nanoseconds() / 1000000000 17 | nanoseconds := os.CreationTime.Nanoseconds() - seconds*1000000000 18 | e.CreatedAt = time.Unix(seconds, nanoseconds) 19 | } 20 | } 21 | } 22 | 23 | func isSymlinkWindowsNonAdmin(err error) bool { 24 | const ERROR_PRIVILEGE_NOT_HELD syscall.Errno = 1314 25 | 26 | if err != nil { 27 | if errLink, ok := err.(*os.LinkError); ok { 28 | if errNo, ok := errLink.Err.(syscall.Errno); ok { 29 | return errNo == ERROR_PRIVILEGE_NOT_HELD 30 | } 31 | } 32 | } 33 | 34 | return false 35 | } 36 | -------------------------------------------------------------------------------- /vendor/gopkg.in/warnings.v0/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Péter Surányi. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | --------------------------------------------------------------------------------