├── .github └── workflows │ ├── crosscompile.yml │ ├── gogetmoduletest.yml │ ├── gogettest.yml │ ├── gotest.yml │ └── officialgittests.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── cmd ├── add.go ├── apply.go ├── archive.go ├── branch.go ├── catfile.go ├── checkignore.go ├── checkout.go ├── checkoutindex.go ├── clean.go ├── clone.go ├── commit.go ├── committree.go ├── commondiff.go ├── config.go ├── diff.go ├── difffiles.go ├── diffindex.go ├── difftree.go ├── fetch.go ├── fetchpack.go ├── flag.go ├── flag_test.go ├── fsck.go ├── grep.go ├── hashobject.go ├── indexpack.go ├── init.go ├── log.go ├── log_test.go ├── lsfiles.go ├── lsremote.go ├── lstree.go ├── main_test.go ├── merge.go ├── mergebase.go ├── mergefile.go ├── mktag.go ├── mktree.go ├── packobjects.go ├── pull.go ├── push.go ├── readtree.go ├── reflog.go ├── remote.go ├── reset.go ├── rev-list.go ├── rev-list_test.go ├── rev-parse.go ├── revert.go ├── rm.go ├── send-pack.go ├── show.go ├── showref.go ├── status.go ├── submodule.go ├── symbolicref.go ├── tag.go ├── unpackobjects.go ├── updateindex.go ├── updateindex_test.go ├── updateref.go ├── var.go └── writetree.go ├── git ├── add.go ├── apply.go ├── apply_test.go ├── archive.go ├── auth.go ├── branch.go ├── catfile.go ├── checkout.go ├── checkout_test.go ├── checkoutindex.go ├── checkoutindex_test.go ├── clean.go ├── client.go ├── clone.go ├── commit.go ├── commit_test.go ├── commitmessage_test.go ├── committree.go ├── committree_test.go ├── config.go ├── consts.go ├── consts_plan9.go ├── delta │ ├── calculator.go │ ├── calculator_test.go │ ├── doc.go │ └── reader.go ├── diff.go ├── difffiles.go ├── diffindex.go ├── difftree.go ├── editor.go ├── editor_plan9.go ├── entrymode.go ├── errors.go ├── expandtree.go ├── fetch.go ├── fetchpack.go ├── file.go ├── file_ctime_darwin.go ├── file_ctime_netbsd.go ├── file_ctime_other.go ├── file_ctime_unix.go ├── file_inode_darwin.go ├── file_inode_other.go ├── file_inode_unix.go ├── file_mtime.go ├── file_mtime_plan9.go ├── foreachref.go ├── fsck.go ├── gitconn.go ├── grep.go ├── grep_test.go ├── hashdiff.go ├── hashobject.go ├── hashobject_test.go ├── httpconn.go ├── ignore.go ├── ignore_test.go ├── index.go ├── indexpack.go ├── indexpack_test.go ├── init.go ├── init_test.go ├── interactive.go ├── interactive_test.go ├── localconn.go ├── lsfiles.go ├── lsfiles_test.go ├── lsremote.go ├── lstree.go ├── main_test.go ├── merge.go ├── mergebase.go ├── mergebase_test.go ├── mergefile.go ├── mktag.go ├── mktree.go ├── objects.go ├── packfile.go ├── packfile_test.go ├── packiterator.go ├── packobjects.go ├── password_other.go ├── password_plan9.go ├── pktline_test.go ├── progressf.go ├── progressf_plan9.go ├── protectfs.go ├── protectfs_darwin.go ├── protectfs_windows.go ├── pull.go ├── push.go ├── readtree.go ├── readtree_test.go ├── reflog.go ├── refspec.go ├── refspec_test.go ├── remote.go ├── reset.go ├── reset_test.go ├── retrieve.go ├── revert.go ├── revert_test.go ├── revlist.go ├── revparse.go ├── rm.go ├── sendpack.go ├── sha1.go ├── sha1_test.go ├── show.go ├── showref.go ├── ssh_other.go ├── ssh_plan9.go ├── ssh_unix.go ├── sshconn.go ├── status.go ├── status_test.go ├── symbolicref.go ├── tag.go ├── unpackobjects.go ├── updateindex.go ├── updateindex_test.go ├── updateref.go ├── writetree.go └── writetree_test.go ├── go-get-modules-tests.sh ├── go-get-tests.sh ├── go.mod ├── go.sum ├── issues ├── Status-should-be-refactored │ └── Description └── need-git-pull-[options]-repo │ └── Description ├── main.go ├── official-git ├── .gitignore ├── fix-checkout-branch.patch ├── force-official-git-pack-objects.patch ├── git-init └── run-tests.sh ├── status.txt ├── vendor ├── 9fans.net │ └── go │ │ ├── LICENSE │ │ └── plan9 │ │ ├── Makefile │ │ ├── bit.go │ │ ├── client │ │ ├── Makefile │ │ ├── conn.go │ │ ├── dial.go │ │ ├── fid.go │ │ └── fsys.go │ │ ├── const.go │ │ ├── dir.go │ │ └── fcall.go ├── github.com │ ├── Plan9-Archive │ │ └── libauth │ │ │ ├── common.go │ │ │ ├── getuserpasswd.go │ │ │ ├── os_plan9.go │ │ │ ├── os_unix.go │ │ │ └── rpc.go │ └── hashicorp │ │ └── golang-lru │ │ ├── .gitignore │ │ ├── 2q.go │ │ ├── LICENSE │ │ ├── README.md │ │ ├── arc.go │ │ ├── doc.go │ │ ├── go.mod │ │ ├── lru.go │ │ └── simplelru │ │ ├── lru.go │ │ └── lru_interface.go ├── golang.org │ └── x │ │ ├── crypto │ │ ├── AUTHORS │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ ├── PATENTS │ │ ├── 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 │ │ ├── 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 │ │ │ ├── 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 │ │ │ ├── mac.go │ │ │ ├── messages.go │ │ │ ├── mux.go │ │ │ ├── server.go │ │ │ ├── session.go │ │ │ ├── streamlocal.go │ │ │ ├── tcpip.go │ │ │ ├── terminal │ │ │ ├── terminal.go │ │ │ ├── util.go │ │ │ ├── util_bsd.go │ │ │ ├── util_linux.go │ │ │ ├── util_plan9.go │ │ │ ├── util_solaris.go │ │ │ └── util_windows.go │ │ │ └── transport.go │ │ └── sys │ │ ├── AUTHORS │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ ├── PATENTS │ │ ├── unix │ │ ├── .gitignore │ │ ├── README.md │ │ ├── affinity_linux.go │ │ ├── aliases.go │ │ ├── asm_darwin_386.s │ │ ├── asm_darwin_amd64.s │ │ ├── asm_darwin_arm.s │ │ ├── asm_darwin_arm64.s │ │ ├── asm_dragonfly_amd64.s │ │ ├── asm_freebsd_386.s │ │ ├── asm_freebsd_amd64.s │ │ ├── asm_freebsd_arm.s │ │ ├── asm_linux_386.s │ │ ├── asm_linux_amd64.s │ │ ├── asm_linux_arm.s │ │ ├── asm_linux_arm64.s │ │ ├── asm_linux_mips64x.s │ │ ├── asm_linux_mipsx.s │ │ ├── asm_linux_ppc64x.s │ │ ├── asm_linux_s390x.s │ │ ├── asm_netbsd_386.s │ │ ├── asm_netbsd_amd64.s │ │ ├── asm_netbsd_arm.s │ │ ├── asm_openbsd_386.s │ │ ├── asm_openbsd_amd64.s │ │ ├── asm_openbsd_arm.s │ │ ├── asm_solaris_amd64.s │ │ ├── bluetooth_linux.go │ │ ├── cap_freebsd.go │ │ ├── constants.go │ │ ├── dev_aix_ppc.go │ │ ├── dev_aix_ppc64.go │ │ ├── dev_darwin.go │ │ ├── dev_dragonfly.go │ │ ├── dev_freebsd.go │ │ ├── dev_linux.go │ │ ├── dev_netbsd.go │ │ ├── dev_openbsd.go │ │ ├── dirent.go │ │ ├── endian_big.go │ │ ├── endian_little.go │ │ ├── env_unix.go │ │ ├── errors_freebsd_386.go │ │ ├── errors_freebsd_amd64.go │ │ ├── errors_freebsd_arm.go │ │ ├── fcntl.go │ │ ├── fcntl_linux_32bit.go │ │ ├── gccgo.go │ │ ├── gccgo_c.c │ │ ├── gccgo_linux_amd64.go │ │ ├── ioctl.go │ │ ├── mkall.sh │ │ ├── mkerrors.sh │ │ ├── mksyscall.pl │ │ ├── mksyscall_aix.pl │ │ ├── mksyscall_solaris.pl │ │ ├── mksysctl_openbsd.pl │ │ ├── mksysnum_darwin.pl │ │ ├── mksysnum_dragonfly.pl │ │ ├── mksysnum_freebsd.pl │ │ ├── mksysnum_netbsd.pl │ │ ├── mksysnum_openbsd.pl │ │ ├── openbsd_pledge.go │ │ ├── pagesize_unix.go │ │ ├── race.go │ │ ├── race0.go │ │ ├── sockcmsg_linux.go │ │ ├── sockcmsg_unix.go │ │ ├── str.go │ │ ├── syscall.go │ │ ├── syscall_aix.go │ │ ├── syscall_aix_ppc.go │ │ ├── syscall_aix_ppc64.go │ │ ├── syscall_bsd.go │ │ ├── syscall_darwin.go │ │ ├── syscall_darwin_386.go │ │ ├── syscall_darwin_amd64.go │ │ ├── syscall_darwin_arm.go │ │ ├── syscall_darwin_arm64.go │ │ ├── syscall_dragonfly.go │ │ ├── syscall_dragonfly_amd64.go │ │ ├── syscall_freebsd.go │ │ ├── syscall_freebsd_386.go │ │ ├── syscall_freebsd_amd64.go │ │ ├── syscall_freebsd_arm.go │ │ ├── syscall_linux.go │ │ ├── syscall_linux_386.go │ │ ├── syscall_linux_amd64.go │ │ ├── syscall_linux_amd64_gc.go │ │ ├── syscall_linux_arm.go │ │ ├── syscall_linux_arm64.go │ │ ├── syscall_linux_gc.go │ │ ├── syscall_linux_gc_386.go │ │ ├── syscall_linux_gccgo_386.go │ │ ├── syscall_linux_gccgo_arm.go │ │ ├── syscall_linux_mips64x.go │ │ ├── syscall_linux_mipsx.go │ │ ├── syscall_linux_ppc64x.go │ │ ├── syscall_linux_riscv64.go │ │ ├── syscall_linux_s390x.go │ │ ├── syscall_linux_sparc64.go │ │ ├── syscall_netbsd.go │ │ ├── syscall_netbsd_386.go │ │ ├── syscall_netbsd_amd64.go │ │ ├── syscall_netbsd_arm.go │ │ ├── syscall_openbsd.go │ │ ├── syscall_openbsd_386.go │ │ ├── syscall_openbsd_amd64.go │ │ ├── syscall_openbsd_arm.go │ │ ├── syscall_solaris.go │ │ ├── syscall_solaris_amd64.go │ │ ├── syscall_unix.go │ │ ├── syscall_unix_gc.go │ │ ├── timestruct.go │ │ ├── xattr_bsd.go │ │ ├── zerrors_aix_ppc.go │ │ ├── zerrors_aix_ppc64.go │ │ ├── zerrors_darwin_386.go │ │ ├── zerrors_darwin_amd64.go │ │ ├── zerrors_darwin_arm.go │ │ ├── zerrors_darwin_arm64.go │ │ ├── zerrors_dragonfly_amd64.go │ │ ├── zerrors_freebsd_386.go │ │ ├── zerrors_freebsd_amd64.go │ │ ├── zerrors_freebsd_arm.go │ │ ├── zerrors_linux_386.go │ │ ├── zerrors_linux_amd64.go │ │ ├── zerrors_linux_arm.go │ │ ├── zerrors_linux_arm64.go │ │ ├── zerrors_linux_mips.go │ │ ├── zerrors_linux_mips64.go │ │ ├── zerrors_linux_mips64le.go │ │ ├── zerrors_linux_mipsle.go │ │ ├── zerrors_linux_ppc64.go │ │ ├── zerrors_linux_ppc64le.go │ │ ├── zerrors_linux_riscv64.go │ │ ├── zerrors_linux_s390x.go │ │ ├── zerrors_linux_sparc64.go │ │ ├── zerrors_netbsd_386.go │ │ ├── zerrors_netbsd_amd64.go │ │ ├── zerrors_netbsd_arm.go │ │ ├── zerrors_openbsd_386.go │ │ ├── zerrors_openbsd_amd64.go │ │ ├── zerrors_openbsd_arm.go │ │ ├── zerrors_solaris_amd64.go │ │ ├── zptrace386_linux.go │ │ ├── zptracearm_linux.go │ │ ├── zptracemips_linux.go │ │ ├── zptracemipsle_linux.go │ │ ├── zsyscall_aix_ppc.go │ │ ├── zsyscall_aix_ppc64.go │ │ ├── zsyscall_darwin_386.go │ │ ├── zsyscall_darwin_amd64.go │ │ ├── zsyscall_darwin_arm.go │ │ ├── zsyscall_darwin_arm64.go │ │ ├── zsyscall_dragonfly_amd64.go │ │ ├── zsyscall_freebsd_386.go │ │ ├── zsyscall_freebsd_amd64.go │ │ ├── zsyscall_freebsd_arm.go │ │ ├── zsyscall_linux_386.go │ │ ├── zsyscall_linux_amd64.go │ │ ├── zsyscall_linux_arm.go │ │ ├── zsyscall_linux_arm64.go │ │ ├── zsyscall_linux_mips.go │ │ ├── zsyscall_linux_mips64.go │ │ ├── zsyscall_linux_mips64le.go │ │ ├── zsyscall_linux_mipsle.go │ │ ├── zsyscall_linux_ppc64.go │ │ ├── zsyscall_linux_ppc64le.go │ │ ├── zsyscall_linux_riscv64.go │ │ ├── zsyscall_linux_s390x.go │ │ ├── zsyscall_linux_sparc64.go │ │ ├── zsyscall_netbsd_386.go │ │ ├── zsyscall_netbsd_amd64.go │ │ ├── zsyscall_netbsd_arm.go │ │ ├── zsyscall_openbsd_386.go │ │ ├── zsyscall_openbsd_amd64.go │ │ ├── zsyscall_openbsd_arm.go │ │ ├── zsyscall_solaris_amd64.go │ │ ├── zsysctl_openbsd_386.go │ │ ├── zsysctl_openbsd_amd64.go │ │ ├── zsysctl_openbsd_arm.go │ │ ├── zsysnum_darwin_386.go │ │ ├── zsysnum_darwin_amd64.go │ │ ├── zsysnum_darwin_arm.go │ │ ├── zsysnum_darwin_arm64.go │ │ ├── zsysnum_dragonfly_amd64.go │ │ ├── zsysnum_freebsd_386.go │ │ ├── zsysnum_freebsd_amd64.go │ │ ├── zsysnum_freebsd_arm.go │ │ ├── zsysnum_linux_386.go │ │ ├── zsysnum_linux_amd64.go │ │ ├── zsysnum_linux_arm.go │ │ ├── zsysnum_linux_arm64.go │ │ ├── zsysnum_linux_mips.go │ │ ├── zsysnum_linux_mips64.go │ │ ├── zsysnum_linux_mips64le.go │ │ ├── zsysnum_linux_mipsle.go │ │ ├── zsysnum_linux_ppc64.go │ │ ├── zsysnum_linux_ppc64le.go │ │ ├── zsysnum_linux_riscv64.go │ │ ├── zsysnum_linux_s390x.go │ │ ├── zsysnum_linux_sparc64.go │ │ ├── zsysnum_netbsd_386.go │ │ ├── zsysnum_netbsd_amd64.go │ │ ├── zsysnum_netbsd_arm.go │ │ ├── zsysnum_openbsd_386.go │ │ ├── zsysnum_openbsd_amd64.go │ │ ├── zsysnum_openbsd_arm.go │ │ ├── ztypes_aix_ppc.go │ │ ├── ztypes_aix_ppc64.go │ │ ├── ztypes_darwin_386.go │ │ ├── ztypes_darwin_amd64.go │ │ ├── ztypes_darwin_arm.go │ │ ├── ztypes_darwin_arm64.go │ │ ├── ztypes_dragonfly_amd64.go │ │ ├── ztypes_freebsd_386.go │ │ ├── ztypes_freebsd_amd64.go │ │ ├── ztypes_freebsd_arm.go │ │ ├── ztypes_linux_386.go │ │ ├── ztypes_linux_amd64.go │ │ ├── ztypes_linux_arm.go │ │ ├── ztypes_linux_arm64.go │ │ ├── ztypes_linux_mips.go │ │ ├── ztypes_linux_mips64.go │ │ ├── ztypes_linux_mips64le.go │ │ ├── ztypes_linux_mipsle.go │ │ ├── ztypes_linux_ppc64.go │ │ ├── ztypes_linux_ppc64le.go │ │ ├── ztypes_linux_riscv64.go │ │ ├── ztypes_linux_s390x.go │ │ ├── ztypes_linux_sparc64.go │ │ ├── ztypes_netbsd_386.go │ │ ├── ztypes_netbsd_amd64.go │ │ ├── ztypes_netbsd_arm.go │ │ ├── ztypes_openbsd_386.go │ │ ├── ztypes_openbsd_amd64.go │ │ ├── ztypes_openbsd_arm.go │ │ └── ztypes_solaris_amd64.go │ │ └── 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 └── modules.txt └── zlib ├── README.md ├── reader.go └── writer.go /.github/workflows/crosscompile.yml: -------------------------------------------------------------------------------- 1 | name: Cross-compile dgit 2 | 3 | on: 4 | - push 5 | - pull_request 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | strategy: 11 | matrix: 12 | buildplatform: ['darwin', 'netbsd', 'plan9', 'windows'] 13 | # Go 1.11 is the first one with module support. Building without module 14 | # support didn't survive the switch from Travis CI -> GitHub actions, but 15 | # 1.11 was released in 2018, so it's probably fair to drop support for <=1.10 16 | go: ['1.11', '1.12', '1.13', '1.14', '1.15', '1.16', '1.17', '1.18', '1.19'] 17 | 18 | steps: 19 | 20 | - uses: actions/checkout@v3 21 | - name: Setup Go 22 | uses: actions/setup-go@v3 23 | with: 24 | go-version: ${{ matrix.go }} 25 | 26 | - name: Build dgit 27 | run: GOOS=${{ matrix.buildplatform }} go build 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /.github/workflows/gogetmoduletest.yml: -------------------------------------------------------------------------------- 1 | name: SKIPPED -- Go get modules tests 2 | 3 | on: 4 | - push 5 | - pull_request 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | strategy: 11 | matrix: 12 | go: ['1.11', '1.15'] 13 | 14 | steps: 15 | 16 | - uses: actions/checkout@v3 17 | - name: Setup Go 18 | uses: actions/setup-go@v3 19 | with: 20 | go-version: ${{ matrix.go }} 21 | 22 | - name: Build dgit 23 | run: go build 24 | 25 | - name: Run tests for go get with modules 26 | # run: ./go-get-modules-tests.sh 27 | run: echo 'Skipping go-get-modules-tests under GitHub Actions until it works' 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /.github/workflows/gogettest.yml: -------------------------------------------------------------------------------- 1 | name: Go get tests 2 | 3 | on: 4 | - push 5 | - pull_request 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | strategy: 11 | matrix: 12 | go: ['1.11', '1.15', '1.16', '1.18', '1.19'] 13 | 14 | steps: 15 | 16 | - uses: actions/checkout@v3 17 | - name: Setup Go 18 | uses: actions/setup-go@v3 19 | with: 20 | go-version: ${{ matrix.go }} 21 | 22 | - name: Build dgit 23 | run: go build 24 | 25 | - name: Run tests for go get command 26 | run: ./go-get-tests.sh 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /.github/workflows/gotest.yml: -------------------------------------------------------------------------------- 1 | name: Go test 2 | 3 | on: 4 | - push 5 | - pull_request 6 | 7 | env: 8 | SkipKnownFailures: true 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | strategy: 14 | matrix: 15 | # Go 1.11 is the first one with module support. Building without module 16 | # support didn't survive the switch from Travis CI -> GitHub actions, but 17 | # 1.11 was released in 2018, so it's probably fair to drop support for <=1.10 18 | go: ['1.11', '1.12', '1.13', '1.14', '1.15', '1.16', '1.17', '1.18', '1.19'] 19 | 20 | steps: 21 | 22 | - uses: actions/checkout@v3 23 | - name: Setup Go 24 | uses: actions/setup-go@v3 25 | with: 26 | go-version: ${{ matrix.go }} 27 | 28 | - name: Build dgit 29 | run: go build 30 | 31 | # Go test is relatively fast, so run it on all the platforms 32 | - name: Go test ./... 33 | run: go test -v ./... 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /.github/workflows/officialgittests.yml: -------------------------------------------------------------------------------- 1 | name: Official Git tests 2 | 3 | on: 4 | - push 5 | - pull_request 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | strategy: 11 | matrix: 12 | # The official git tests are very heavy, so we only run 13 | # it with the latest version of go 14 | go: ['1.19'] 15 | 16 | steps: 17 | 18 | - uses: actions/checkout@v3 19 | - name: Setup Go 20 | uses: actions/setup-go@v3 21 | with: 22 | go-version: ${{ matrix.go }} 23 | 24 | - name: Build dgit 25 | run: go build 26 | 27 | 28 | - name: Install git building dependencies 29 | run: sudo apt-get install libcurl4-openssl-dev gettext 30 | 31 | - name: Test suite from the official git client 32 | run: ./official-git/run-tests.sh 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .*un~ 2 | dgit 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Dave MacFarlane 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 all 13 | 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 THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![travis ci](https://api.travis-ci.org/driusan/dgit.svg?branch=master) (Note: Travis currently runs dgit against (a subset of) the git 2.10.0 test suite) 2 | 3 | This repo contains a pure Go implementation of the command 4 | line git client. 5 | 6 | Its primary purpose is to enable users of operating systems 7 | where Go is supported but the canonical git implementation 8 | is not (ie. Plan 9) to use git. 9 | 10 | *IT IS NOWHERE NEAR READY* 11 | 12 | ## Roadmap 13 | 14 | The main goal is to enable `go get` to work by doing a real 15 | checkout without any hacks such as downloading a .zip from 16 | GitHub and pretending it is a checkout. (This should be done, 17 | and any breakages with `go get` if you rename the binary from 18 | `dgit` to `git` and put it on your path should be reported 19 | as an issue.) 20 | 21 | The secondary goal is to enable just enough of the git 22 | command line to allow simple development (ie. simple usages of 23 | git add/commit/push/status/diff/log.) 24 | 25 | The third, stretch goal, is to have a complete command-line 26 | compatible implementation of git that can be used as a drop-in 27 | replacement for git. 28 | 29 | ## Pronunciation 30 | 31 | The dgit tool is pronounced dee-git. The extra letter is there 32 | to distinguish it from the standard git implementation. The 33 | letter 'd' was chosen because it is on the home row of the 34 | keyboard, which makes it easier to type. 35 | -------------------------------------------------------------------------------- /cmd/diff.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | "os/exec" 8 | 9 | "github.com/driusan/dgit/git" 10 | ) 11 | 12 | func Diff(c *git.Client, args []string) error { 13 | flags := flag.NewFlagSet("diff", flag.ExitOnError) 14 | flags.SetOutput(flag.CommandLine.Output()) 15 | flags.Usage = func() { 16 | flag.Usage() 17 | fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") 18 | flags.PrintDefaults() 19 | } 20 | options := git.DiffOptions{} 21 | 22 | var staged bool 23 | flags.BoolVar(&staged, "staged", false, "Synonym for cached") 24 | var cached bool 25 | flags.BoolVar(&cached, "cached", false, "Display changes staged for commit") 26 | flags.BoolVar(&options.NoIndex, "no-index", false, "Use diff to display difference between files on the filesystem") 27 | 28 | args, err := parseCommonDiffFlags(c, &options.DiffCommonOptions, true, flags, args) 29 | 30 | if staged || cached { 31 | options.Staged = true 32 | } 33 | 34 | files := make([]git.File, len(args), len(args)) 35 | for i := range args { 36 | files[i] = git.File(args[i]) 37 | } 38 | diffs, err := git.Diff(c, options, files) 39 | if err != nil { 40 | if options.NoIndex { 41 | switch e := err.(type) { 42 | case *exec.ExitError: 43 | if e.Exited() { 44 | // We don't want the exit status printed by returning it, 45 | // so we just call os.Exit. 46 | // (If there were no diffs err will be nil) 47 | os.Exit(1) 48 | } 49 | 50 | default: 51 | } 52 | } 53 | return err 54 | } 55 | return printDiffs(c, options.DiffCommonOptions, diffs) 56 | } 57 | -------------------------------------------------------------------------------- /cmd/difffiles.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | 7 | "github.com/driusan/dgit/git" 8 | ) 9 | 10 | func DiffFiles(c *git.Client, args []string) error { 11 | flags := flag.NewFlagSet("diff-files", flag.ExitOnError) 12 | flags.SetOutput(flag.CommandLine.Output()) 13 | flags.Usage = func() { 14 | flag.Usage() 15 | fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") 16 | flags.PrintDefaults() 17 | } 18 | options := git.DiffFilesOptions{} 19 | args, err := parseCommonDiffFlags(c, &options.DiffCommonOptions, false, flags, args) 20 | files := make([]git.File, len(args), len(args)) 21 | for i := range args { 22 | files[i] = git.File(args[i]) 23 | } 24 | diffs, err := git.DiffFiles(c, options, files) 25 | if err != nil { 26 | return err 27 | } 28 | return printDiffs(c, options.DiffCommonOptions, diffs) 29 | } 30 | -------------------------------------------------------------------------------- /cmd/diffindex.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/driusan/dgit/git" 9 | ) 10 | 11 | func DiffIndex(c *git.Client, args []string) error { 12 | flags := flag.NewFlagSet("diff-index", flag.ExitOnError) 13 | flags.SetOutput(flag.CommandLine.Output()) 14 | flags.Usage = func() { 15 | flag.Usage() 16 | fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") 17 | flags.PrintDefaults() 18 | } 19 | 20 | options := git.DiffIndexOptions{} 21 | flags.BoolVar(&options.Cached, "cached", false, "Do not compare the filesystem, only the index") 22 | 23 | args, err := parseCommonDiffFlags(c, &options.DiffCommonOptions, false, flags, args) 24 | if err != nil { 25 | return err 26 | } 27 | 28 | if len(args) < 1 { 29 | fmt.Fprintf(flag.CommandLine.Output(), "Must provide a treeish to git diff-index\n") 30 | flags.Usage() 31 | os.Exit(2) 32 | } 33 | 34 | treeish, err := git.RevParseCommit(c, &git.RevParseOptions{}, args[0]) 35 | if err != nil { 36 | return err 37 | } 38 | 39 | files := make([]git.File, len(args)-1, len(args)-1) 40 | for i, f := range args[1:] { 41 | files[i] = git.File(f) 42 | } 43 | index, _ := c.GitDir.ReadIndex() 44 | diffs, err := git.DiffIndex(c, options, index, treeish, files) 45 | if err != nil { 46 | return err 47 | } 48 | return printDiffs(c, options.DiffCommonOptions, diffs) 49 | } 50 | -------------------------------------------------------------------------------- /cmd/fetchpack.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/driusan/dgit/git" 7 | ) 8 | 9 | func FetchPack(c *git.Client, args []string) error { 10 | flags := newFlagSet("fetch-pack") 11 | opts := git.FetchPackOptions{} 12 | flags.BoolVar(&opts.All, "all", false, "Fetch all remote refs") 13 | flags.BoolVar(&opts.Quiet, "quiet", false, "Do not print indexing status") 14 | flags.BoolVar(&opts.Quiet, "q", false, "Alias of --quiet") 15 | flags.BoolVar(&opts.Keep, "keep", false, "Not implemented") 16 | flags.BoolVar(&opts.Keep, "k", false, "Not implemented") 17 | flags.BoolVar(&opts.Thin, "thin", false, "Fetches a thin pack (Not implemented)") 18 | flags.BoolVar(&opts.IncludeTag, "include-tag", false, "Send annotated tags along with other objects") 19 | flags.BoolVar(&opts.NoProgress, "no-progress", false, "Do not show progress information") 20 | flags.StringVar(&opts.UploadPack, "upload-pack", "", "Execute upload-pack instead of git-upload-pack") 21 | flags.StringVar(&opts.UploadPack, "exec", "", "Execute upload-pack instead of git-upload-pack") 22 | depth := flags.Int("depth", 2147483647, "Not implemented") 23 | _ = flags.String("shallow-since", "", "Not implemented") 24 | _ = flags.String("shallow-exclude", "", "Not implemented") 25 | flags.BoolVar(&opts.DeepenRelative, "deepen-relative", false, "Not implemented") 26 | flags.BoolVar(&opts.CheckSelfContainedAndConnected, "check-self-contained-and-connected", false, "Not implemented") 27 | flags.BoolVar(&opts.Verbose, "verbose", false, "Be more verbose") 28 | flags.BoolVar(&opts.Verbose, "v", false, "Alias of verbose") 29 | flags.Parse(args) 30 | args = flags.Args() 31 | opts.Depth = int32(*depth) 32 | if len(args) < 1 { 33 | flags.Usage() 34 | return fmt.Errorf("Invalid flag usage") 35 | } 36 | rmt := git.Remote(args[0]) 37 | var wants []git.Refname 38 | for _, name := range args[1:] { 39 | wants = append(wants, git.Refname(name)) 40 | } 41 | _, err := git.FetchPack(c, opts, rmt, wants) 42 | return err 43 | } 44 | -------------------------------------------------------------------------------- /cmd/flag_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "testing" 6 | ) 7 | 8 | func TestAliasedStringValue(t *testing.T) { 9 | flags := flag.NewFlagSet("test1", flag.ContinueOnError) 10 | v := "" // Start as zero value 11 | flags.Var(newAliasedStringValue(&v, ""), "foo", "") 12 | flags.Var(newAliasedStringValue(&v, ""), "bar", "") 13 | 14 | err := flags.Parse([]string{"--foo=one"}) 15 | if err != nil { 16 | panic(err) 17 | } 18 | if v != "one" { 19 | t.Fail() 20 | } 21 | 22 | err = flags.Parse([]string{"--foo=one", "--bar=two"}) 23 | if err == nil { 24 | t.Fail() 25 | } 26 | 27 | err = flags.Parse([]string{"--foo=one", "--foo=two"}) 28 | if err == nil { 29 | t.Fail() 30 | } 31 | } 32 | 33 | func TestMultiStringValue(t *testing.T) { 34 | flags := flag.NewFlagSet("test2", flag.ContinueOnError) 35 | var v []string // Start as a zero value 36 | flags.Var(NewMultiStringValue(&v), "foo", "") 37 | 38 | err := flags.Parse([]string{"--foo=one", "--foo=two"}) 39 | if err != nil { 40 | panic(err) 41 | } 42 | 43 | if len(v) != 2 { 44 | t.Fail() 45 | } 46 | if v[0] != "one" || v[1] != "two" { 47 | t.Fail() 48 | } 49 | } 50 | 51 | func TestNotImplStringValue(t *testing.T) { 52 | flags := flag.NewFlagSet("test3", flag.ContinueOnError) 53 | flags.Var(newNotimplStringValue(), "foo", "Not implemented") 54 | 55 | err := flags.Parse([]string{"path1"}) 56 | 57 | if err != nil { 58 | panic(err) 59 | } 60 | 61 | err = flags.Parse([]string{"--foo=bar"}) 62 | if err == nil { 63 | t.Fail() 64 | } 65 | } 66 | 67 | func TestNotImplBoolValue(t *testing.T) { 68 | flags := flag.NewFlagSet("test4", flag.ContinueOnError) 69 | flags.Var(newNotimplBoolValue(), "foo", "Not implemented") 70 | 71 | err := flags.Parse([]string{"path1"}) 72 | if err != nil { 73 | panic(err) 74 | } 75 | 76 | err = flags.Parse([]string{"--foo"}) 77 | if err == nil { 78 | t.Fail() 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /cmd/init.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | "path/filepath" 8 | 9 | "github.com/driusan/dgit/git" 10 | ) 11 | 12 | func Init(c *git.Client, args []string) error { 13 | flags := flag.NewFlagSet("status", flag.ExitOnError) 14 | flags.SetOutput(flag.CommandLine.Output()) 15 | flags.Usage = func() { 16 | flag.Usage() 17 | fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") 18 | flags.PrintDefaults() 19 | } 20 | 21 | opts := git.InitOptions{} 22 | 23 | flags.BoolVar(&opts.Bare, "bare", false, "Create bare repository") 24 | flags.BoolVar(&opts.Quiet, "quiet", false, "Only print errors or warnings") 25 | flags.BoolVar(&opts.Quiet, "q", false, "Alias of --quiet") 26 | var template string 27 | flags.StringVar(&template, "template", "", "Specify the template directory that will be used") 28 | 29 | flags.Parse(args) 30 | args = flags.Args() 31 | var dir string 32 | switch len(args) { 33 | case 0: 34 | dir = "." 35 | case 1: 36 | dir = args[0] 37 | default: 38 | fmt.Fprintf(flag.CommandLine.Output(), "Invalid init command. Must only provide one directory.\n") 39 | flags.Usage() 40 | os.Exit(2) 41 | } 42 | 43 | if template != "" { 44 | if !filepath.IsAbs(template) { 45 | wd, err := os.Getwd() 46 | if err != nil { 47 | return err 48 | } 49 | template = filepath.Join(wd, template) 50 | } 51 | opts.Template = git.File(template) 52 | } 53 | 54 | _, err := git.Init(c, opts, dir) 55 | return err 56 | } 57 | -------------------------------------------------------------------------------- /cmd/log_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/driusan/dgit/git" 7 | ) 8 | 9 | func BenchmarkLogHead(b *testing.B) { 10 | c, err := git.NewClient("../.git", ".") 11 | if err != nil { 12 | panic(err) 13 | } 14 | for n := 0; n < b.N; n++ { 15 | if err := Log(c, []string{}); err != nil { 16 | panic(err) 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /cmd/main_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "io/ioutil" 6 | "log" 7 | "os" 8 | "testing" 9 | ) 10 | 11 | func TestMain(m *testing.M) { 12 | log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile) 13 | flag.Parse() 14 | if !testing.Verbose() { 15 | log.SetOutput(ioutil.Discard) 16 | } 17 | code := m.Run() 18 | os.Exit(code) 19 | } 20 | -------------------------------------------------------------------------------- /cmd/merge.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/driusan/dgit/git" 9 | ) 10 | 11 | // These are merge flags that can be shared with other subcommands, such as pull 12 | func addSharedMergeFlags(flags *flag.FlagSet, options *git.MergeOptions) { 13 | flags.BoolVar(&options.FastForwardOnly, "ff-only", false, "Only allow fast-forward merges") 14 | flags.BoolVar(&options.NoFastForward, "no-ff", false, "Create a merge commit even when it's a fast-forward merge.") 15 | } 16 | 17 | func Merge(c *git.Client, args []string) error { 18 | flags := flag.NewFlagSet("merge", flag.ExitOnError) 19 | flags.SetOutput(flag.CommandLine.Output()) 20 | flags.Usage = func() { 21 | flag.Usage() 22 | fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") 23 | flags.PrintDefaults() 24 | } 25 | options := git.MergeOptions{} 26 | addSharedMergeFlags(flags, &options) 27 | 28 | // Add flags here that should only work when merge is invoked directly and 29 | // not from another subcommand such as pull. 30 | abort := flag.Bool("abort", false, "Abort an in-progress merge") 31 | flags.Parse(args) 32 | 33 | if *abort { 34 | return git.MergeAbort(c, options) 35 | } 36 | merges := flags.Args() 37 | if len(merges) < 1 { 38 | flags.Usage() 39 | os.Exit(2) 40 | } 41 | 42 | others := make([]git.Commitish, 0, len(merges)) 43 | for _, name := range merges { 44 | c, err := git.RevParseCommitish(c, &git.RevParseOptions{}, name) 45 | if err != nil { 46 | return err 47 | } 48 | others = append(others, c) 49 | } 50 | return git.Merge(c, options, others) 51 | } 52 | -------------------------------------------------------------------------------- /cmd/mergebase.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "errors" 5 | "flag" 6 | "fmt" 7 | "os" 8 | 9 | "github.com/driusan/dgit/git" 10 | ) 11 | 12 | var Ancestor error = errors.New("Commit is an ancestor") 13 | var NonAncestor error = errors.New("Commit not an ancestor") 14 | 15 | func MergeBase(c *git.Client, args []string) (git.CommitID, error) { 16 | flags := flag.NewFlagSet("merge-base", flag.ExitOnError) 17 | flags.SetOutput(flag.CommandLine.Output()) 18 | flags.Usage = func() { 19 | flag.Usage() 20 | fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") 21 | flags.PrintDefaults() 22 | } 23 | var options git.MergeBaseOptions 24 | 25 | flags.BoolVar(&options.Octopus, "octopus", false, "Compute the common ancestor of all supplied commits") 26 | ancestor := flags.Bool("is-ancestor", false, "Determine if two commits are ancestors") 27 | flags.Parse(args) 28 | args = flags.Args() 29 | 30 | if len(args) < 1 { 31 | flags.Usage() 32 | os.Exit(2) 33 | } 34 | if *ancestor { 35 | commits, _, err := RevParse(c, args) 36 | if err != nil { 37 | return git.CommitID{}, err 38 | } 39 | if commits[1].IsAncestor(c, commits[0]) { 40 | return git.CommitID{}, Ancestor 41 | } 42 | return git.CommitID{}, NonAncestor 43 | } 44 | 45 | commits, _, err := RevParse(c, args) 46 | if err != nil { 47 | return git.CommitID{}, err 48 | } 49 | 50 | // RevParse returns ParsedRevisions, which are Commitish, but slices 51 | // can't be passed in terms of interfaces without converting them 52 | // first. 53 | var asCommitish []git.Commitish 54 | for _, c := range commits { 55 | asCommitish = append(asCommitish, c) 56 | } 57 | 58 | return git.MergeBase(c, options, asCommitish) 59 | } 60 | -------------------------------------------------------------------------------- /cmd/mergefile.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "github.com/driusan/dgit/git" 7 | "io" 8 | "os" 9 | ) 10 | 11 | func MergeFile(c *git.Client, args []string) error { 12 | flags := flag.NewFlagSet("merge-file", flag.ExitOnError) 13 | flags.SetOutput(flag.CommandLine.Output()) 14 | options := git.MergeFileOptions{} 15 | 16 | flags.Parse(args) 17 | args = flags.Args() 18 | 19 | if len(args) <= 1 { 20 | flag.Usage() 21 | return fmt.Errorf("Invalid usage of merge-file") 22 | } 23 | 24 | // -L may be specified multiple times, so we need to manually look for it instead of 25 | // using flag 26 | nEls := 0 27 | LabelLoop: 28 | for args[0] == "-L" { 29 | if len(args) < 2 { 30 | break LabelLoop 31 | } 32 | switch nEls { 33 | case 0: 34 | options.Current.Label = args[1] 35 | case 1: 36 | options.Base.Label = args[1] 37 | 38 | case 2: 39 | options.Other.Label = args[1] 40 | default: 41 | flag.Usage() 42 | return fmt.Errorf("May only specify -L up to three times.") 43 | } 44 | nEls++ 45 | } 46 | if len(args) != 3 { 47 | flag.Usage() 48 | return fmt.Errorf("Invalid usage of merge-file") 49 | } 50 | for i, file := range args { 51 | switch i { 52 | case 0: 53 | options.Current.Filename = git.File(file) 54 | case 1: 55 | options.Base.Filename = git.File(file) 56 | case 2: 57 | options.Other.Filename = git.File(file) 58 | } 59 | } 60 | newcontent, err := git.MergeFile(c, options) 61 | if newcontent != nil { 62 | if options.Stdout { 63 | io.Copy(os.Stdout, newcontent) 64 | } else { 65 | f, err := os.Create(options.Current.Filename.String()) 66 | if err != nil { 67 | println("Error opening") 68 | return err 69 | } 70 | 71 | io.Copy(f, newcontent) 72 | 73 | f.Close() 74 | } 75 | } 76 | return err 77 | } 78 | -------------------------------------------------------------------------------- /cmd/mktag.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/driusan/dgit/git" 9 | ) 10 | 11 | // Implements the git mktag command line parsing. 12 | func Mktag(c *git.Client, args []string) (git.Sha1, error) { 13 | flags := flag.NewFlagSet("tag", flag.ExitOnError) 14 | flags.SetOutput(flag.CommandLine.Output()) 15 | flags.Usage = func() { 16 | flag.Usage() 17 | fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") 18 | flags.PrintDefaults() 19 | } 20 | 21 | flags.Parse(args) 22 | if len(flags.Args()) > 0 { 23 | // There are no options for mktag 24 | flags.Usage() 25 | os.Exit(1) 26 | } 27 | return git.Mktag(c, os.Stdin) 28 | } 29 | -------------------------------------------------------------------------------- /cmd/mktree.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/driusan/dgit/git" 8 | ) 9 | 10 | func MkTree(c *git.Client, args []string) error { 11 | flags := newFlagSet("mktree") 12 | opts := git.MkTreeOptions{} 13 | 14 | flags.BoolVar(&opts.NilTerminate, "z", false, "Use nil to terminate lines") 15 | flags.BoolVar(&opts.AllowMissing, "missing", false, "Allow missing objects in the tree") 16 | flags.BoolVar(&opts.Batch, "batch", false, "Build more than one tree, separated by blank lines") 17 | 18 | flags.Parse(args) 19 | 20 | if opts.Batch { 21 | return git.MkTreeBatch(c, opts, os.Stdin, os.Stdout) 22 | } 23 | tree, err := git.MkTree(c, opts, os.Stdin) 24 | if err != nil { 25 | return err 26 | } 27 | fmt.Println(tree) 28 | return nil 29 | } 30 | -------------------------------------------------------------------------------- /cmd/pull.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/driusan/dgit/git" 9 | ) 10 | 11 | func Pull(c *git.Client, args []string) error { 12 | flags := flag.NewFlagSet("pull", flag.ExitOnError) 13 | flags.SetOutput(flag.CommandLine.Output()) 14 | flags.Usage = func() { 15 | flag.Usage() 16 | fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") 17 | flags.PrintDefaults() 18 | } 19 | 20 | opts := git.PullOptions{} 21 | addSharedFetchFlags(flags, &opts.FetchOptions) 22 | addSharedMergeFlags(flags, &opts.MergeOptions) 23 | flags.Parse(args) 24 | 25 | var repository git.Remote 26 | var remotebranches []string 27 | config, err := git.LoadLocalConfig(c) 28 | if err != nil { 29 | return err 30 | } 31 | 32 | if flags.NArg() < 1 { 33 | // TODO simplistic, probably won't work in all cases 34 | // Instead the branch information should be retrieved from the merge config 35 | headbranch := c.GetHeadBranch().BranchName() 36 | r, _ := config.GetConfig("branch." + headbranch + ".remote") 37 | repository = git.Remote(r) 38 | //mergeremote, _ := config.GetConfig("branch." + head + ".merge") 39 | remotebranches = []string{fmt.Sprintf("%s/%s", repository, headbranch)} 40 | } else if flags.NArg() == 1 { 41 | repository = git.Remote(flags.Arg(0)) 42 | // Instead the branch information should be retrieved from the merge config 43 | headbranch := c.GetHeadBranch().BranchName() 44 | //mergeremote, _ := config.GetConfig("branch." + headbranch + ".merge") 45 | remotebranches = []string{fmt.Sprintf("%s/%s", repository, headbranch)} 46 | } else if flags.NArg() >= 2 { 47 | repository = git.Remote(flag.Arg(0)) 48 | remotebranches = flag.Args()[1:] 49 | } else { 50 | flags.Usage() 51 | os.Exit(1) 52 | } 53 | 54 | return git.Pull(c, opts, repository, remotebranches) 55 | } 56 | -------------------------------------------------------------------------------- /cmd/reflog.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/driusan/dgit/git" 8 | ) 9 | 10 | func Reflog(c *git.Client, args []string) error { 11 | // flags := newFlagSet("reflog") 12 | subcmd := "show" 13 | if len(args) > 0 { 14 | switch act := args[0]; act { 15 | case "show": 16 | // show should be an alias of log -g -abbrev-commit 17 | // -pretty=oneline, and just delegate there, but log 18 | // -g isn't implemented. 19 | subcmd = "show" 20 | case "expire": 21 | subcmd = "expire" 22 | case "delete": 23 | subcmd = "delete" 24 | case "exists": 25 | subcmd = "exists" 26 | default: 27 | if len(act) > 0 && act[0] == '-' { 28 | // It was an option, so fallback on show 29 | break 30 | } 31 | return fmt.Errorf("Invalid reflog subcommand: %v", args) 32 | } 33 | 34 | } 35 | switch subcmd { 36 | case "show", "delete": 37 | return fmt.Errorf("reflog subcommand %v not implemented", subcmd) 38 | case "expire": 39 | // FIXME: parse and pass params 40 | return git.ReflogExpire(c, git.ReflogExpireOptions{Expire: "now", All: true}, nil) 41 | case "exists": 42 | if len(args) != 2 { 43 | return fmt.Errorf("usage: %v reflog exists ", os.Args[0]) 44 | } 45 | if git.ReflogExists(c, git.Refname(args[1])) { 46 | os.Exit(0) 47 | } 48 | os.Exit(1) 49 | // without this go complains about no return at the end of 50 | // the function 51 | panic("unreachable") 52 | default: 53 | panic("Unknown reflog subcommand. This should be unreachable.") 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /cmd/reset.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | 7 | "github.com/driusan/dgit/git" 8 | ) 9 | 10 | func Reset(c *git.Client, args []string) error { 11 | flags := flag.NewFlagSet("reset", flag.ExitOnError) 12 | flags.SetOutput(flag.CommandLine.Output()) 13 | flags.Usage = func() { 14 | flag.Usage() 15 | fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") 16 | flags.PrintDefaults() 17 | } 18 | 19 | opts := git.ResetOptions{} 20 | 21 | flags.BoolVar(&opts.Quiet, "q", false, "Only report errors") 22 | 23 | flags.BoolVar(&opts.Soft, "soft", false, "Do not touch the index or working tree, but reset the head to commit") 24 | flags.BoolVar(&opts.Mixed, "mixed", false, "Reset the index but not the working tree") 25 | flags.BoolVar(&opts.Hard, "hard", false, "Reset both the index and working tree.") 26 | flags.BoolVar(&opts.Merge, "merge", false, "Reset the index and update working tree for files different between and HEAD, but not those different between index and working tree") 27 | flags.BoolVar(&opts.Keep, "keep", false, "Like --merge, but abort if any files have local changes instead of leaving them") 28 | 29 | flags.Parse(args) 30 | 31 | args = flags.Args() 32 | files := make([]git.File, 0, len(args)) 33 | for _, f := range args { 34 | files = append(files, git.File(f)) 35 | } 36 | return git.Reset(c, opts, files) 37 | } 38 | -------------------------------------------------------------------------------- /cmd/rev-list.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/driusan/dgit/git" 9 | ) 10 | 11 | func RevList(c *git.Client, args []string) error { 12 | flags := flag.NewFlagSet("rev-list", flag.ExitOnError) 13 | flags.SetOutput(flag.CommandLine.Output()) 14 | flags.Usage = func() { 15 | flag.Usage() 16 | fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") 17 | flags.PrintDefaults() 18 | } 19 | 20 | opts := git.RevListOptions{} 21 | flags.BoolVar(&opts.Objects, "objects", false, "include non-commit objects in output") 22 | flags.BoolVar(&opts.Quiet, "quiet", false, "prevent printing of revisions") 23 | flags.BoolVar(&opts.VerifyObjects, "verify-objects", false, "verify objects instead of printing them") 24 | flags.BoolVar(&opts.All, "all", false, "pretend as if all refs were passed on the command line") 25 | 26 | flags.Parse(args) 27 | args = flags.Args() 28 | if opts.VerifyObjects { 29 | opts.Objects = true 30 | } 31 | // First get a map of excluded commitIDs 32 | var excludes []git.Commitish 33 | var includes []git.Commitish 34 | for _, rev := range args { 35 | if rev == "" { 36 | continue 37 | } 38 | if rev[0] == '^' && len(rev) > 1 { 39 | commits, _, err := RevParse(c, []string{rev[1:]}) 40 | if err != nil { 41 | return fmt.Errorf("%s:%v", rev, err) 42 | } 43 | for _, cmt := range commits { 44 | excludes = append(excludes, cmt) 45 | } 46 | } else { 47 | commits, _, err := RevParse(c, []string{rev}) 48 | if err != nil { 49 | return fmt.Errorf("%s:%v", rev, err) 50 | } 51 | for _, cmt := range commits { 52 | includes = append(includes, cmt) 53 | } 54 | } 55 | } 56 | _, err := git.RevList(c, opts, os.Stdout, includes, excludes) 57 | return err 58 | } 59 | -------------------------------------------------------------------------------- /cmd/rev-list_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/driusan/dgit/git" 7 | ) 8 | 9 | func BenchmarkRevListHead(b *testing.B) { 10 | c, err := git.NewClient("../.git", ".") 11 | if err != nil { 12 | panic(err) 13 | } 14 | for n := 0; n < b.N; n++ { 15 | if err := RevList(c, []string{"--quiet", "HEAD"}); err != nil { 16 | panic(err) 17 | } 18 | } 19 | } 20 | 21 | func BenchmarkRevListHeadExclude(b *testing.B) { 22 | c, err := git.NewClient("../.git", ".") 23 | if err != nil { 24 | panic(err) 25 | } 26 | for n := 0; n < b.N; n++ { 27 | if err := RevList(c, []string{"--quiet", "HEAD", "^HEAD^"}); err != nil { 28 | panic(err) 29 | } 30 | } 31 | } 32 | 33 | func BenchmarkRevListHeadExcludeObjects(b *testing.B) { 34 | c, err := git.NewClient("../.git", ".") 35 | if err != nil { 36 | panic(err) 37 | } 38 | for n := 0; n < b.N; n++ { 39 | if err := RevList(c, []string{"--quiet", "--objects", "HEAD", "^HEAD^"}); err != nil { 40 | panic(err) 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /cmd/rev-parse.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/driusan/dgit/git" 9 | ) 10 | 11 | func RevParse(c *git.Client, args []string) ([]git.ParsedRevision, git.RevParseOptions, error) { 12 | // We need to manually parse flags, because they're context sensitive. 13 | opts := git.RevParseOptions{} 14 | 15 | var parsedargs []string 16 | for i := 0; i < len(args); i++ { 17 | switch args[i] { 18 | case "--quiet", "-q": 19 | opts.Quiet = true 20 | case "--verify": 21 | opts.Verify = true 22 | case "--default": 23 | switch i { 24 | case len(args) - 1: 25 | return nil, opts, fmt.Errorf("Must provide parameter for --default") 26 | default: 27 | opts.Default = args[i+1] 28 | i++ 29 | } 30 | case "--help": 31 | flag.Usage() 32 | os.Exit(0) 33 | default: 34 | parsedargs = append(parsedargs, args[i]) 35 | } 36 | } 37 | 38 | commits, err := git.RevParse(c, opts, parsedargs) 39 | return commits, opts, err 40 | } 41 | -------------------------------------------------------------------------------- /cmd/rm.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/driusan/dgit/git" 9 | ) 10 | 11 | func Rm(c *git.Client, args []string) error { 12 | flags := flag.NewFlagSet("rm", flag.ExitOnError) 13 | flags.SetOutput(flag.CommandLine.Output()) 14 | flags.Usage = func() { 15 | flag.Usage() 16 | fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") 17 | flags.PrintDefaults() 18 | } 19 | 20 | var opts git.RmOptions 21 | flags.BoolVar(&opts.Force, "force", false, "Override the up to date check") 22 | flags.BoolVar(&opts.Force, "f", false, "Alias of force") 23 | flags.BoolVar(&opts.DryRun, "dry-run", false, "Do not actually remove file or update index") 24 | flags.BoolVar(&opts.DryRun, "n", false, "Alias of dry-run") 25 | flags.BoolVar(&opts.Recursive, "r", false, "Allow recursive removal of directories") 26 | flags.BoolVar(&opts.Cached, "cached", false, "Only remove from the index, not the filesystem") 27 | flags.BoolVar(&opts.IgnoreUnmatched, "ignore-unmatched", false, "Exit with a success even if no files matched") 28 | flags.BoolVar(&opts.Quiet, "quiet", false, "Do not output the name of removed files") 29 | flags.BoolVar(&opts.Quiet, "q", false, "Alias of quiet") 30 | 31 | flags.Parse(args) 32 | sfiles := flags.Args() 33 | if len(sfiles) < 1 { 34 | flags.Usage() 35 | os.Exit(1) 36 | } 37 | files := make([]git.File, 0, len(sfiles)) 38 | for _, f := range sfiles { 39 | files = append(files, git.File(f)) 40 | } 41 | return git.Rm(c, opts, files) 42 | } 43 | -------------------------------------------------------------------------------- /cmd/send-pack.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | //"os" 7 | //"strings" 8 | "github.com/driusan/dgit/git" 9 | ) 10 | 11 | func SendPack(c *git.Client, args []string) error { 12 | flags := flag.NewFlagSet("send-pack", flag.ExitOnError) 13 | flags.SetOutput(flag.CommandLine.Output()) 14 | flags.Usage = func() { 15 | flag.Usage() 16 | fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") 17 | flags.PrintDefaults() 18 | } 19 | 20 | opts := git.SendPackOptions{} 21 | flags.BoolVar(&opts.All, "all", false, "Update all refs that exist locally") 22 | flags.BoolVar(&opts.DryRun, "dry-run", false, "Do not send pack") 23 | flags.BoolVar(&opts.Force, "force", false, "Update remote ref even if not a fast-forward") 24 | flags.StringVar(&opts.ReceivePack, "receive-pack", "", "Invoke non-standard path to receive-pack on remote") 25 | flags.BoolVar(&opts.Verbose, "verbose", false, "Be more chatty") 26 | flags.BoolVar(&opts.Thin, "thin", false, "Send a thin pack") 27 | flags.BoolVar(&opts.Atomic, "Atomic", false, "Atomicly update refs on remote") 28 | flags.BoolVar(&opts.Signed, "Signed", false, "GPG sign the push request") 29 | flags.Parse(args) 30 | args = flags.Args() 31 | if len(args) < 1 { 32 | return fmt.Errorf("Invalid send-pack") 33 | } 34 | remote := git.Remote(args[0]) 35 | var refs []git.Refname = make([]git.Refname, 0, len(args)-1) 36 | for _, ref := range args[1:] { 37 | refs = append(refs, git.Refname(ref)) 38 | } 39 | return git.SendPack(c, opts, remote, refs) 40 | } 41 | -------------------------------------------------------------------------------- /cmd/show.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | 7 | "github.com/driusan/dgit/git" 8 | ) 9 | 10 | func Show(c *git.Client, args []string) error { 11 | flags := flag.NewFlagSet("show", flag.ExitOnError) 12 | flags.SetOutput(flag.CommandLine.Output()) 13 | flags.Usage = func() { 14 | flag.Usage() 15 | fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") 16 | flags.PrintDefaults() 17 | } 18 | 19 | opts := git.ShowOptions{} 20 | flags.Var(newAliasedStringValue((*string)(&opts.Format), ""), "format", "Print the contents of commit logs in a specified format") 21 | flags.Var(newAliasedStringValue((*string)(&opts.Format), ""), "pretty", "Alias for --format") 22 | flags.Parse(args) 23 | 24 | objects := flags.Args() 25 | return git.Show(c, opts, objects) 26 | } 27 | -------------------------------------------------------------------------------- /cmd/showref.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/driusan/dgit/git" 9 | ) 10 | 11 | func ShowRef(c *git.Client, args []string) error { 12 | flags := flag.NewFlagSet("show-ref", flag.ExitOnError) 13 | flags.SetOutput(flag.CommandLine.Output()) 14 | flags.Usage = func() { 15 | flag.Usage() 16 | fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") 17 | flags.PrintDefaults() 18 | } 19 | 20 | opts := git.ShowRefOptions{} 21 | flags.BoolVar(&opts.IncludeHead, "head", false, "Include the HEAD reference") 22 | flags.BoolVar(&opts.Heads, "heads", false, "Show only heads") 23 | flags.BoolVar(&opts.Tags, "tags", false, "Show only tags") 24 | flags.BoolVar(&opts.Quiet, "quiet", false, "Do not print matching refs") 25 | flags.BoolVar(&opts.Quiet, "q", false, "alias of --q") 26 | flags.BoolVar(&opts.Verify, "verify", false, "verify the existence of an exact ref") 27 | flags.BoolVar(&opts.Dereference, "dereference", false, "dereference annotated tags") 28 | flags.BoolVar(&opts.Dereference, "d", false, "alias of -d") 29 | flags.BoolVar(&opts.Sha1Only, "hash", false, "Only show the SHA-1 hash.") 30 | flags.BoolVar(&opts.Sha1Only, "s", false, "Alias of --hash.") 31 | 32 | // These flags can be moved out of these lists and below as proper flags as they are implemented 33 | for _, sf := range []string{"abbrev"} { 34 | flags.Var(newNotimplStringValue(), sf, "Not implemented") 35 | } 36 | 37 | flags.Parse(args) 38 | refs, err := git.ShowRef(c, opts, flags.Args()) 39 | if err != nil { 40 | return err 41 | } 42 | if !opts.Quiet { 43 | for _, ref := range refs { 44 | if !opts.Sha1Only { 45 | fmt.Println(ref) 46 | } else { 47 | fmt.Println(ref.Value) 48 | } 49 | } 50 | } 51 | if len(refs) == 0 { 52 | os.Exit(1) 53 | } 54 | return nil 55 | } 56 | -------------------------------------------------------------------------------- /cmd/submodule.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | "path/filepath" 8 | 9 | "github.com/driusan/dgit/git" 10 | ) 11 | 12 | func Submodule(c *git.Client, args []string) error { 13 | flags := flag.NewFlagSet("submodule", flag.ExitOnError) 14 | flags.SetOutput(flag.CommandLine.Output()) 15 | flags.Usage = func() { 16 | flag.Usage() 17 | fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") 18 | flags.PrintDefaults() 19 | } 20 | 21 | if len(args) < 1 || args[0] != "update" { 22 | flags.Usage() 23 | os.Exit(1) 24 | } 25 | 26 | //flags.Parse(args) 27 | 28 | // Scan for any .gitmodules files and fail with an error since none of this 29 | // is supported yet. 30 | workdir := string(c.WorkDir) 31 | return filepath.Walk(workdir, func(path string, info os.FileInfo, err error) error { 32 | if filepath.Base(path) == ".gitmodules" { 33 | return fmt.Errorf("Submodules are not yet supported") 34 | } 35 | return nil 36 | }) 37 | } 38 | -------------------------------------------------------------------------------- /cmd/symbolicref.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/driusan/dgit/git" 9 | ) 10 | 11 | func SymbolicRef(c *git.Client, args []string) (git.RefSpec, error) { 12 | flags := flag.NewFlagSet("symbolic-ref", flag.ExitOnError) 13 | flags.SetOutput(flag.CommandLine.Output()) 14 | flags.Usage = func() { 15 | flag.Usage() 16 | fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") 17 | flags.PrintDefaults() 18 | } 19 | 20 | opts := git.SymbolicRefOptions{} 21 | 22 | reason := flags.String("m", "", "Reason to record in reflog for updating the reference") 23 | 24 | flags.BoolVar(&opts.Delete, "delete", false, "Delete the reference") 25 | flags.BoolVar(&opts.Delete, "d", false, "Alias of --delete") 26 | 27 | flags.BoolVar(&opts.Quiet, "quiet", false, "Do not print an error if is not a detached head") 28 | flags.BoolVar(&opts.Quiet, "q", false, "Alias of --quiet") 29 | 30 | flags.BoolVar(&opts.Short, "short", false, "Try to shorten the names of a symbolic ref") 31 | 32 | flags.Parse(args) 33 | vals := flags.Args() 34 | 35 | switch len(vals) { 36 | case 1: 37 | if opts.Delete { 38 | return "", git.SymbolicRefDelete(c, opts, git.SymbolicRef(vals[0])) 39 | } else { 40 | return git.SymbolicRefGet(c, opts, git.SymbolicRef(vals[0])) 41 | } 42 | case 2: 43 | return "", git.SymbolicRefUpdate(c, opts, git.SymbolicRef(vals[0]), git.RefSpec(vals[1]), *reason) 44 | } 45 | 46 | flags.Usage() 47 | os.Exit(2) 48 | 49 | return "", fmt.Errorf("Invalid usage") 50 | } 51 | -------------------------------------------------------------------------------- /cmd/unpackobjects.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/driusan/dgit/git" 9 | ) 10 | 11 | // Parses the arguments from git-unpack-objects as they were passed on the commandline 12 | // and calls git.CatFiles 13 | func UnpackObjects(c *git.Client, args []string) error { 14 | flags := flag.NewFlagSet("unpack-objects", flag.ExitOnError) 15 | flags.SetOutput(flag.CommandLine.Output()) 16 | flags.Usage = func() { 17 | flag.Usage() 18 | fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") 19 | flags.PrintDefaults() 20 | } 21 | options := git.UnpackObjectsOptions{} 22 | 23 | flags.BoolVar(&options.DryRun, "n", false, "Do not really unpack the objects") 24 | flags.BoolVar(&options.Quiet, "q", false, "Do not print progress information") 25 | flags.BoolVar(&options.Recover, "r", false, "Attempt to continue when dealing with a corrupt packfile") 26 | flags.BoolVar(&options.Strict, "strict", false, "Don't write objects with broken content or links") 27 | flags.UintVar(&options.MaxInputSize, "max-input-size", 0, "Do not process pack files larger than size") 28 | flags.Parse(args) 29 | 30 | _, err := git.UnpackObjects(c, options, os.Stdin) 31 | return err 32 | } 33 | -------------------------------------------------------------------------------- /cmd/updateindex_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/driusan/dgit/git" 7 | ) 8 | 9 | func sha1FromString(s string) git.Sha1 { 10 | sha1, err := git.Sha1FromString(s) 11 | if err != nil { 12 | panic(err) 13 | } 14 | return sha1 15 | } 16 | func TestUpdateIndexCacheInfoCmd(t *testing.T) { 17 | tests := []struct { 18 | input string 19 | expected git.CacheInfo 20 | expectedErr bool 21 | }{ 22 | { 23 | "103412,fbca232", 24 | git.CacheInfo{}, 25 | true, 26 | }, 27 | { 28 | "100755,c69ecb78f2115e92c1baa9887226d158fe5bfeda,foo", 29 | git.CacheInfo{ 30 | Mode: git.ModeExec, 31 | Sha1: sha1FromString("c69ecb78f2115e92c1baa9887226d158fe5bfeda"), 32 | Path: "foo", 33 | }, 34 | false, 35 | }, 36 | } 37 | for i, tc := range tests { 38 | ci, err := parseCacheInfo(tc.input) 39 | if err == nil && tc.expectedErr { 40 | t.Errorf("Case %d: Expected error, got none", i) 41 | } else if err != nil && !tc.expectedErr { 42 | t.Errorf("Case %d: Did not expect error, got %v", i, err) 43 | } 44 | 45 | if ci != tc.expected { 46 | t.Errorf("Case %d: got %v want %v", i, ci, tc.expected) 47 | } 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /cmd/writetree.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | 7 | "github.com/driusan/dgit/git" 8 | ) 9 | 10 | // WriteTree implements the git write-tree command on the Git repository 11 | // pointed to by c. 12 | func WriteTree(c *git.Client, args []string) (string, error) { 13 | flags := flag.NewFlagSet("write-tree", flag.ExitOnError) 14 | flags.SetOutput(flag.CommandLine.Output()) 15 | flags.Usage = func() { 16 | flag.Usage() 17 | fmt.Fprintf(flag.CommandLine.Output(), "\nOptions:\n\n") 18 | flags.PrintDefaults() 19 | } 20 | 21 | opts := git.WriteTreeOptions{} 22 | flags.BoolVar(&opts.MissingOk, "missing-ok", false, "allow missing objects") 23 | flags.StringVar(&opts.Prefix, "prefix", "", "write tree object for a subdirectory ") 24 | flags.Parse(args) 25 | 26 | sha1, err := git.WriteTree(c, opts) 27 | if err != nil { 28 | return "", err 29 | } 30 | return sha1.String(), nil 31 | } 32 | -------------------------------------------------------------------------------- /git/auth.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | // Denotes a username/password combo to be used to 4 | // authenticate (generally for an HTTP connection 5 | // while pushing.) 6 | type userPasswd struct { 7 | user, password string 8 | } 9 | -------------------------------------------------------------------------------- /git/branch.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | ) 7 | 8 | type BranchOptions struct { 9 | All bool 10 | Quiet bool 11 | Move bool 12 | Delete bool 13 | Force bool 14 | } 15 | 16 | func BranchList(c *Client, stdout io.Writer, opts BranchOptions, patterns []string) ([]Branch, error) { 17 | branches, err := c.GetBranches() 18 | if err != nil { 19 | return nil, err 20 | } 21 | if opts.All { 22 | rb, err := c.GetRemoteBranches() 23 | if err != nil { 24 | return nil, err 25 | } 26 | branches = append(branches, rb...) 27 | } 28 | if !opts.Quiet { 29 | head := c.GetHeadBranch() 30 | for _, b := range branches { 31 | if head == b { 32 | fmt.Println(" *", b.BranchName()) 33 | } else { 34 | fmt.Println(" ", b.BranchName()) 35 | } 36 | 37 | } 38 | } 39 | return branches, nil 40 | } 41 | -------------------------------------------------------------------------------- /git/clean.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | // Command line options which affect the behaviour of clean. 9 | type CleanOptions struct { 10 | Directory bool 11 | Force bool 12 | DryRun bool 13 | Quiet bool 14 | 15 | // Flags which affect exclusion logic 16 | ExcludePatterns []string 17 | NoStandardExclude bool 18 | OnlyExcluded bool 19 | 20 | // Not implemented 21 | Interactive bool 22 | } 23 | 24 | func Clean(c *Client, opts CleanOptions, files []File) error { 25 | lsopts := LsFilesOptions{ 26 | Others: true, 27 | Directory: opts.Directory, 28 | ExcludeStandard: !opts.NoStandardExclude, 29 | ExcludePatterns: opts.ExcludePatterns, 30 | Ignored: opts.OnlyExcluded, 31 | } 32 | paths, err := LsFiles(c, lsopts, files) 33 | if err != nil { 34 | return err 35 | } 36 | for _, entry := range paths { 37 | f, err := entry.PathName.FilePath(c) 38 | if err != nil { 39 | return err 40 | } 41 | if !opts.Quiet { 42 | fmt.Printf("Removing %v\n", f) 43 | } 44 | if opts.DryRun { 45 | continue 46 | } 47 | if opts.Directory { 48 | if err := os.RemoveAll(f.String()); err != nil { 49 | return err 50 | } 51 | } else { 52 | if err := os.Remove(f.String()); err != nil { 53 | return err 54 | } 55 | } 56 | } 57 | return nil 58 | } 59 | -------------------------------------------------------------------------------- /git/commitmessage_test.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | // Tests that the various cleanup modes for git commit messages 8 | // work as expected. 9 | func TestCommitMessageCleanup(t *testing.T) { 10 | tests := []struct { 11 | CommitMessage CommitMessage 12 | Whitespace string 13 | Strip string 14 | }{ 15 | { 16 | "I am a test", 17 | "I am a test\n", 18 | "I am a test\n", 19 | }, 20 | { 21 | "\n\nI am a test\n\n\n\n", 22 | "I am a test\n", 23 | "I am a test\n", 24 | }, 25 | { 26 | "I am a paragraph\n\n\nI had an extra newline", 27 | "I am a paragraph\n\nI had an extra newline\n", 28 | "I am a paragraph\n\nI had an extra newline\n", 29 | }, 30 | { 31 | `I am here 32 | 33 | I am another paragraph 34 | # pretend I am a status message`, 35 | `I am here 36 | 37 | I am another paragraph 38 | # pretend I am a status message 39 | `, 40 | `I am here 41 | 42 | I am another paragraph 43 | `, 44 | }, 45 | } 46 | for i, tc := range tests { 47 | if got := tc.CommitMessage.whitespace(); got != tc.Whitespace { 48 | t.Errorf("Case %d whitespace: got %v want %v", i, got, tc.Whitespace) 49 | } 50 | if got := tc.CommitMessage.strip(); got != tc.Strip { 51 | t.Errorf("Case %d strip: got %v want %v", i, got, tc.Strip) 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /git/consts.go: -------------------------------------------------------------------------------- 1 | //go:build !plan9 2 | // +build !plan9 3 | 4 | package git 5 | 6 | const ( 7 | // the command to execute for a posix compliant diff implementation. 8 | posixDiff = "diff" 9 | posixDiff3 = "diff3" 10 | 11 | posixPatch = "patch" 12 | ) 13 | -------------------------------------------------------------------------------- /git/consts_plan9.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | const ( 4 | // the command to execute for a posix compliant diff implementation. 5 | posixDiff = "/bin/ape/diff" 6 | posixDiff3 = "/bin/ape/diff3" 7 | 8 | posixPatch = "/bin/ape/patch" 9 | ) 10 | -------------------------------------------------------------------------------- /git/delta/doc.go: -------------------------------------------------------------------------------- 1 | // Delta provides functions for reading and calculating git 2 | // styles deltas. 3 | package delta 4 | -------------------------------------------------------------------------------- /git/diff.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "os/exec" 7 | "strconv" 8 | ) 9 | 10 | // Describes the options that may be specified on the command line for 11 | // "git diff". 12 | type DiffOptions struct { 13 | DiffCommonOptions 14 | 15 | Staged bool 16 | 17 | NoIndex bool 18 | } 19 | 20 | // DiffFiles implements the git diff-files command. 21 | // It compares the file system to the index. 22 | func Diff(c *Client, opt DiffOptions, paths []File) ([]HashDiff, error) { 23 | if opt.NoIndex { 24 | if len(paths) != 2 { 25 | return nil, fmt.Errorf("Must provide 2 paths for git diff --no-index") 26 | } 27 | 28 | // Just invoke the system diff command, we can't return a HashDiff 29 | // since we're not working things that are tracked by the repo. 30 | // we just directly invoke diff if --no-index is specified. 31 | diffcmd := exec.Command(posixDiff, "-U", strconv.Itoa(opt.NumContextLines), paths[0].String(), paths[1].String()) 32 | diffcmd.Stderr = os.Stderr 33 | diffcmd.Stdout = os.Stdout 34 | 35 | if err := diffcmd.Run(); err != nil { 36 | return nil, err 37 | } 38 | return nil, nil 39 | } 40 | if err := refreshIndex(c); err != nil { 41 | return nil, err 42 | } 43 | if opt.Staged { 44 | head, err := c.GetHeadCommit() 45 | if err != nil { 46 | return nil, err 47 | } 48 | index, _ := c.GitDir.ReadIndex() 49 | return DiffIndex(c, 50 | DiffIndexOptions{ 51 | DiffCommonOptions: opt.DiffCommonOptions, 52 | Cached: true, 53 | }, 54 | index, 55 | head, 56 | paths) 57 | } 58 | return DiffFiles(c, 59 | DiffFilesOptions{ 60 | DiffCommonOptions: opt.DiffCommonOptions, 61 | }, 62 | paths) 63 | } 64 | -------------------------------------------------------------------------------- /git/editor.go: -------------------------------------------------------------------------------- 1 | //go:build !plan9 2 | // +build !plan9 3 | 4 | package git 5 | 6 | import ( 7 | "fmt" 8 | "os" 9 | "os/exec" 10 | ) 11 | 12 | // Will invoke the Client's editor to edit the file f. 13 | func (c *Client) ExecEditor(f File) error { 14 | editor := os.Getenv("EDITOR") 15 | if editor == "" { 16 | fmt.Fprintf(os.Stderr, "Warning: EDITOR environment not set. Falling back on ed...\n") 17 | editor = "ed" 18 | } 19 | 20 | cmd := exec.Command(editor, f.String()) 21 | cmd.Stdin = os.Stdin 22 | cmd.Stdout = os.Stdout 23 | cmd.Stderr = os.Stderr 24 | 25 | return cmd.Run() 26 | } 27 | -------------------------------------------------------------------------------- /git/editor_plan9.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "os/exec" 7 | ) 8 | 9 | // Will invoke the Client's editor to edit the file f. 10 | func (c *Client) ExecEditor(f File) error { 11 | editor := os.Getenv("editor") 12 | if editor == "" { 13 | fmt.Fprintf(os.Stderr, "Warning: editor environment not set. Falling back on ed...\n") 14 | editor = "ed" 15 | } 16 | 17 | cmd := exec.Command(editor, f.String()) 18 | cmd.Stdin = os.Stdin 19 | cmd.Stdout = os.Stdout 20 | cmd.Stderr = os.Stderr 21 | 22 | return cmd.Run() 23 | } 24 | -------------------------------------------------------------------------------- /git/entrymode.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | // An EntryMode is like an os.FileMode, but restricted to the values 8 | // that are legal in git. 9 | type EntryMode uint32 10 | 11 | const ( 12 | ModeBlob = EntryMode(0100644) 13 | ModeExec = EntryMode(0100755) 14 | ModeSymlink = EntryMode(0120000) 15 | ModeCommit = EntryMode(0160000) 16 | ModeTree = EntryMode(0040000) 17 | ) 18 | 19 | // we sometimes see these coming from git9, although they chouldn't be valid 20 | // according to the git spec. We need to handle them to clone some repos anyways 21 | const modeGit9Tree = EntryMode(0040755) 22 | 23 | // TreeType prints the entry mode as the type that shows up in the "git ls-tree" 24 | // command. 25 | func (e EntryMode) TreeType() string { 26 | 27 | switch e { 28 | case ModeBlob, ModeExec, ModeSymlink: 29 | return "blob" 30 | case ModeCommit: 31 | return "commit" 32 | case ModeTree, modeGit9Tree: 33 | return "tree" 34 | default: 35 | panic(fmt.Sprintf("Invalid mode %o", e)) 36 | } 37 | } 38 | 39 | func ModeFromString(s string) (EntryMode, error) { 40 | switch s { 41 | case "100644": 42 | return ModeBlob, nil 43 | case "100755": 44 | return ModeExec, nil 45 | case "120000": 46 | return ModeSymlink, nil 47 | case "160000": 48 | return ModeCommit, nil 49 | case "040755": 50 | return modeGit9Tree, fmt.Errorf("Bad tree type %v", s) 51 | case "040000": 52 | return ModeTree, nil 53 | default: 54 | return 0, fmt.Errorf("Unknown mode: %v", s) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /git/errors.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | var InvalidHead error = errors.New("Invalid HEAD") 8 | var InvalidBranch error = errors.New("Invalid branch") 9 | var InvalidCommit error = errors.New("Invalid commit") 10 | var InvalidTree error = errors.New("Invalid tree") 11 | -------------------------------------------------------------------------------- /git/file_ctime_darwin.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | func (f File) CTime() (uint32, uint32) { 8 | stat, err := f.Lstat() 9 | if err != nil { 10 | return 0, 0 11 | } 12 | rawstat := stat.Sys().(*syscall.Stat_t) 13 | tspec := rawstat.Ctimespec 14 | return uint32(tspec.Sec), uint32(tspec.Nsec) 15 | } 16 | -------------------------------------------------------------------------------- /git/file_ctime_netbsd.go: -------------------------------------------------------------------------------- 1 | //go:build netbsd 2 | // +build netbsd 3 | 4 | package git 5 | 6 | import ( 7 | "syscall" 8 | ) 9 | 10 | func (f File) CTime() (uint32, uint32) { 11 | stat, err := f.Lstat() 12 | if err != nil { 13 | return 0, 0 14 | } 15 | rawstat := stat.Sys().(*syscall.Stat_t) 16 | tspec := rawstat.Ctimespec 17 | return uint32(tspec.Sec), uint32(tspec.Nsec) 18 | } 19 | -------------------------------------------------------------------------------- /git/file_ctime_other.go: -------------------------------------------------------------------------------- 1 | //go:build !dragonfly && !darwin && !linux && !openbsd && !netbsd 2 | // +build !dragonfly,!darwin,!linux,!openbsd,!netbsd 3 | 4 | package git 5 | 6 | // Ctime returns the CTime and CTimeNano parts of a time struct 7 | // for the ctime of this file. On systems where either there's no 8 | // ctime, we don't know how to get it, or or we haven't implemented 9 | // it yet, this will return 0s instead of an error so that there will 10 | // be sane behaviour on places that use it (such as index updating) 11 | // that we shouldn't be propagating a non-critical error. 12 | func (f File) CTime() (uint32, uint32) { 13 | return 0, 0 14 | } 15 | -------------------------------------------------------------------------------- /git/file_ctime_unix.go: -------------------------------------------------------------------------------- 1 | //go:build dragonfly || linux || openbsd 2 | // +build dragonfly linux openbsd 3 | 4 | package git 5 | 6 | import ( 7 | "syscall" 8 | ) 9 | 10 | func (f File) CTime() (uint32, uint32) { 11 | stat, err := f.Lstat() 12 | if err != nil { 13 | return 0, 0 14 | } 15 | rawstat := stat.Sys().(*syscall.Stat_t) 16 | tspec := rawstat.Ctim 17 | return uint32(tspec.Sec), uint32(tspec.Nsec) 18 | } 19 | -------------------------------------------------------------------------------- /git/file_inode_darwin.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | func (f File) INode() uint32 { 8 | stat, err := f.Lstat() 9 | if err != nil { 10 | return 0 11 | } 12 | rawstat := stat.Sys().(*syscall.Stat_t) 13 | return uint32(rawstat.Ino) 14 | } 15 | -------------------------------------------------------------------------------- /git/file_inode_other.go: -------------------------------------------------------------------------------- 1 | //go:build !dragonfly && !darwin && !linux && !openbsd && !netbsd 2 | // +build !dragonfly,!darwin,!linux,!openbsd,!netbsd 3 | 4 | package git 5 | 6 | func (f File) INode() uint32 { 7 | return 0 8 | } 9 | -------------------------------------------------------------------------------- /git/file_inode_unix.go: -------------------------------------------------------------------------------- 1 | //go:build dragonfly || linux || openbsd || netbsd 2 | // +build dragonfly linux openbsd netbsd 3 | 4 | package git 5 | 6 | import ( 7 | "syscall" 8 | ) 9 | 10 | func (f File) INode() uint32 { 11 | stat, err := f.Lstat() 12 | if err != nil { 13 | return 0 14 | } 15 | rawstat := stat.Sys().(*syscall.Stat_t) 16 | return uint32(rawstat.Ino) 17 | } 18 | -------------------------------------------------------------------------------- /git/file_mtime.go: -------------------------------------------------------------------------------- 1 | //go:build !plan9 2 | // +build !plan9 3 | 4 | package git 5 | 6 | func (f File) MTime() (int64, error) { 7 | stat, err := f.Lstat() 8 | if err != nil { 9 | return 0, err 10 | } 11 | base := int64(stat.ModTime().Unix()) << 32 12 | return base | int64(stat.ModTime().Nanosecond()), nil 13 | } 14 | -------------------------------------------------------------------------------- /git/file_mtime_plan9.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | func (f File) MTime() (int64, error) { 8 | stat, err := f.Stat() 9 | if err != nil { 10 | return 0, err 11 | } 12 | // Plan 9 only has 1 second precision and pads the nanoseconds 13 | // with 0, so we pretend that the qid.Version is the number 14 | // of nanoseconds. 15 | base := int64(stat.ModTime().Unix()) << 32 16 | sys := stat.Sys() 17 | if internal, ok := sys.(*syscall.Dir); ok { 18 | return base | int64(internal.Qid.Vers), nil 19 | } 20 | panic("Could not get QID.path for file") 21 | 22 | } 23 | -------------------------------------------------------------------------------- /git/foreachref.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | "strings" 7 | ) 8 | 9 | // Calls callback for each ref under c's GitDir which has prefix as a prefix. 10 | func ForEachRefCallback(c *Client, prefix string, callback func(*Client, Ref) error) error { 11 | // FIXME: Include packed refs. 12 | err := filepath.Walk( 13 | c.GitDir.File("refs").String(), 14 | func(path string, info os.FileInfo, err error) error { 15 | if info.IsDir() { 16 | return nil 17 | } 18 | refname := strings.TrimPrefix(path, c.GitDir.String()+"/") 19 | if strings.HasPrefix(refname, prefix) { 20 | r, err := parseRef(c, refname) 21 | if err != nil { 22 | return err 23 | } 24 | if err := callback(c, r); err != nil { 25 | return err 26 | } 27 | } 28 | return nil 29 | }, 30 | ) 31 | return err 32 | } 33 | -------------------------------------------------------------------------------- /git/hashobject.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "bytes" 5 | "crypto/sha1" 6 | "fmt" 7 | "io" 8 | "io/ioutil" 9 | "os" 10 | "strings" 11 | ) 12 | 13 | func HashReaderWithSize(t string, sz int64, r io.Reader) (Sha1, error) { 14 | h := sha1.New() 15 | fmt.Fprintf(h, "%s %d\000", t, sz) 16 | 17 | if sz < 0 { 18 | return Sha1{}, fmt.Errorf("Invalid size: %v", sz) 19 | } 20 | n, err := io.Copy(h, r) 21 | if err != nil { 22 | return Sha1{}, err 23 | } 24 | if n != sz { 25 | return Sha1{}, fmt.Errorf("Unexpected reader size (got %v != want %v)", n, sz) 26 | } 27 | return Sha1FromSlice(h.Sum(nil)) 28 | } 29 | 30 | // Hashes the data of r with object type t, and returns 31 | // the hash, and the data that was read from r. 32 | func HashReader(t string, r io.Reader) (Sha1, []byte, error) { 33 | // Need to read the whole reader in order to find the size 34 | data, err := ioutil.ReadAll(r) 35 | if err != nil { 36 | return Sha1{}, nil, err 37 | } 38 | 39 | h := sha1.New() 40 | fmt.Fprintf(h, "%s %d\000%s", t, len(data), data) 41 | s, err := Sha1FromSlice(h.Sum(nil)) 42 | return s, data, err 43 | } 44 | 45 | func HashSlice(t string, data []byte) (Sha1, []byte, error) { 46 | r := bytes.NewReader(data) 47 | return HashReader(t, r) 48 | } 49 | 50 | func HashFile(t, filename string) (Sha1, []byte, error) { 51 | if File(filename).IsSymlink() { 52 | l, err := os.Readlink(filename) 53 | if err != nil { 54 | return Sha1{}, nil, err 55 | } 56 | return HashReader(t, strings.NewReader(l)) 57 | } else { 58 | r, err := os.Open(filename) 59 | if err != nil { 60 | return Sha1{}, nil, err 61 | } 62 | defer r.Close() 63 | return HashReader(t, r) 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /git/init_test.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | "testing" 7 | ) 8 | 9 | func TestInitRepo(t *testing.T) { 10 | dir, err := ioutil.TempDir("", "gitinit") 11 | if err != nil { 12 | t.Fatal(err) 13 | } 14 | // We just used TempDir to get a file name. Remove it, 15 | // to ensure that Init creates it. 16 | if err := os.RemoveAll(dir); err != nil { 17 | t.Fatal(err) 18 | } 19 | defer os.RemoveAll(dir) 20 | 21 | c, err := Init(nil, InitOptions{Quiet: true}, dir) 22 | if err != nil { 23 | t.Fatal(err) 24 | } 25 | if e := GitDir(dir) + "/.git"; c.GitDir != e { 26 | t.Errorf("Unexpected GitDir in client. got %v want %v", c.GitDir, e) 27 | } 28 | head, err := c.GitDir.ReadFile("HEAD") 29 | if err != nil { 30 | t.Error(err) 31 | } 32 | if e := "ref: refs/heads/master\n"; string(head) != e { 33 | t.Errorf("Unexpected head reference. got %v want %v", string(head), e) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /git/lsremote.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | type LsRemoteOptions struct { 9 | Heads, Tags bool 10 | RefsOnly bool 11 | Quiet bool 12 | UploadPack string 13 | ExitCode bool 14 | GetURL bool 15 | SymRef bool 16 | Sort string 17 | ServerOptions []string 18 | } 19 | 20 | func LsRemote(c *Client, opts LsRemoteOptions, r Remote, patterns []string) ([]Ref, error) { 21 | if r == "" { 22 | r = "origin" 23 | if !opts.Quiet { 24 | rurl := c.GetConfig("remote.origin.url") 25 | if rurl == "" { 26 | return nil, fmt.Errorf("Can not ls-remote") 27 | } 28 | fmt.Fprintln(os.Stderr, "From", rurl) 29 | } 30 | } 31 | 32 | remoteconn, err := NewRemoteConn(c, r) 33 | if err != nil { 34 | return nil, err 35 | } 36 | if opts.UploadPack == "" { 37 | opts.UploadPack = "git-upload-pack" 38 | } 39 | remoteconn.SetService(opts.UploadPack) 40 | 41 | if err := remoteconn.OpenConn(UploadPackService); err != nil { 42 | return nil, err 43 | } 44 | defer remoteconn.Close() 45 | return remoteconn.GetRefs(opts, patterns) 46 | } 47 | -------------------------------------------------------------------------------- /git/main_test.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "flag" 5 | "io/ioutil" 6 | "log" 7 | "os" 8 | "testing" 9 | ) 10 | 11 | func TestMain(m *testing.M) { 12 | log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile) 13 | flag.Parse() 14 | if !testing.Verbose() { 15 | log.SetOutput(ioutil.Discard) 16 | } 17 | code := m.Run() 18 | os.Exit(code) 19 | } 20 | -------------------------------------------------------------------------------- /git/password_other.go: -------------------------------------------------------------------------------- 1 | //go:build !plan9 2 | // +build !plan9 3 | 4 | package git 5 | 6 | import ( 7 | "fmt" 8 | "os" 9 | 10 | "golang.org/x/crypto/ssh/terminal" 11 | ) 12 | 13 | func getUserPassword(url string) (userPasswd, error) { 14 | user := readLine("Username: ") 15 | 16 | fmt.Fprintf(os.Stderr, "Password: ") 17 | pwb, err := terminal.ReadPassword(0) 18 | return userPasswd{user, string(pwb)}, err 19 | } 20 | -------------------------------------------------------------------------------- /git/password_plan9.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "github.com/Plan9-Archive/libauth" 5 | ) 6 | 7 | func getUserPassword(url string) (userPasswd, error) { 8 | val, err := libauth.Getuserpasswd( 9 | "proto=pass service=git role=client server=%s", 10 | url, 11 | ) 12 | if err != nil { 13 | return userPasswd{}, err 14 | } 15 | return userPasswd{val.User, val.Password}, nil 16 | } 17 | -------------------------------------------------------------------------------- /git/pktline_test.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestPktLineEncode(t *testing.T) { 8 | tests := []struct { 9 | Line string 10 | Encoded PktLine 11 | }{ 12 | {Line: "foo", Encoded: PktLine("0008foo\n")}, 13 | {Line: "334a173aead888e9fb0d96eee3aa85c57cb2d8d7 3c094acaa20f8473a834cde76d044792e17c65d2\000refs/heads/AddGitPushreport-status", 14 | Encoded: PktLine("0079334a173aead888e9fb0d96eee3aa85c57cb2d8d7 3c094acaa20f8473a834cde76d044792e17c65d2\000refs/heads/AddGitPushreport-status\n"), 15 | }, 16 | } 17 | for i, test := range tests { 18 | got, err := PktLineEncode([]byte(test.Line)) 19 | if err != nil { 20 | t.Errorf("Error %v while encoding %v (TC %d)", err, test.Line, i) 21 | } 22 | if got != test.Encoded { 23 | t.Errorf("Error encoding %d: got %v want %v", i, got, test.Encoded) 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /git/progressf.go: -------------------------------------------------------------------------------- 1 | //go:build !plan9 2 | // +build !plan9 3 | 4 | package git 5 | 6 | import ( 7 | "fmt" 8 | "os" 9 | "time" 10 | ) 11 | 12 | var lastProgress int64 13 | 14 | // Print progress information to stderr 15 | func progressF(fmtS string, done bool, args ...interface{}) { 16 | if done { 17 | fmt.Fprintf(os.Stderr, "\r"+fmtS+", done\n", args...) 18 | } 19 | now := time.Now().Unix() 20 | if lastProgress > 0 && now-lastProgress < 3 { 21 | return 22 | } 23 | fmt.Fprintf(os.Stderr, "\r"+fmtS, args...) 24 | lastProgress = now 25 | } 26 | -------------------------------------------------------------------------------- /git/progressf_plan9.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "time" 7 | ) 8 | 9 | var lastProgress int64 10 | 11 | // Print progress information to stderr 12 | func progressF(fmtS string, done bool, args ...interface{}) { 13 | if done { 14 | fmt.Fprintf(os.Stderr, "\n"+fmtS+", done\n", args...) 15 | } 16 | now := time.Now().Unix() 17 | if lastProgress > 0 && now-lastProgress < 3 { 18 | return 19 | } 20 | fmt.Fprintf(os.Stderr, "\n"+fmtS, args...) 21 | lastProgress = now 22 | } 23 | -------------------------------------------------------------------------------- /git/protectfs.go: -------------------------------------------------------------------------------- 1 | //go:build !windows && !darwin 2 | // +build !windows,!darwin 3 | 4 | package git 5 | 6 | func protectHFS(c *Client) bool { 7 | return c.GetConfig("core.protectHFS") == "true" 8 | } 9 | 10 | func protectNTFS(c *Client) bool { 11 | return c.GetConfig("core.protectNTFS") == "true" 12 | } 13 | -------------------------------------------------------------------------------- /git/protectfs_darwin.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | // protectHFS defaults to true on Mac 4 | func protectHFS(c *Client) bool { 5 | return c.GetConfig("core.protectHFS") != "false" 6 | } 7 | 8 | func protectNTFS(c *Client) bool { 9 | return c.GetConfig("core.protectNTFS") == "true" 10 | } 11 | -------------------------------------------------------------------------------- /git/protectfs_windows.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | func protectHFS(c *Client) bool { 4 | return c.GetConfig("core.protectHFS") == "true" 5 | } 6 | 7 | // protectNTFS defaults to true on windows 8 | func protectNTFS(c *Client) bool { 9 | return c.GetConfig("core.protectNTFS") != "false" 10 | } 11 | -------------------------------------------------------------------------------- /git/pull.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import () 4 | 5 | type PullOptions struct { 6 | FetchOptions 7 | MergeOptions 8 | } 9 | 10 | func Pull(c *Client, opts PullOptions, repository Remote, remotebranches []string) error { 11 | err := Fetch(c, opts.FetchOptions, repository, nil) 12 | if err != nil && err.Error() != "Already up to date." { 13 | // If fetch says we have all the refs, that doesn't 14 | // mean that they're merged into the current branch 15 | // so we don't error out. 16 | return err 17 | } 18 | 19 | others := make([]Commitish, 0, len(remotebranches)) 20 | for _, name := range remotebranches { 21 | c, err := RevParseCommitish(c, &RevParseOptions{}, name) 22 | if err != nil { 23 | return err 24 | } 25 | others = append(others, c) 26 | } 27 | 28 | return Merge(c, opts.MergeOptions, others) 29 | } 30 | -------------------------------------------------------------------------------- /git/reflog.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | ) 8 | 9 | type ReflogDeleteOptions struct{} 10 | 11 | type ReflogExpireOptions struct { 12 | ReflogDeleteOptions 13 | 14 | Expire string 15 | All bool 16 | } 17 | 18 | // Returns true if a reflog exists for refname r under client. 19 | func ReflogExists(c *Client, r Refname) bool { 20 | path := filepath.Join(c.GitDir.String(), "logs", string(r)) 21 | return c.GitDir.File(File(path)).Exists() 22 | } 23 | 24 | func ReflogExpire(c *Client, opts ReflogExpireOptions, refpatterns []string) error { 25 | if opts.Expire != "now" || len(refpatterns) != 0 { 26 | return fmt.Errorf("Only reflog --expire=now --all currently supported") 27 | } 28 | if opts.All && len(refpatterns) != 0 { 29 | return fmt.Errorf("Can not combine --all with explicit refs") 30 | } 31 | 32 | // If expire is now, we just truncate applicable reflogs 33 | if opts.Expire == "now" && opts.All { 34 | // This is a hack to get fsck's test setup working. Since 35 | // we're expiring everything, we just truncate everything 36 | // in the .git/logs directory. (We can't delete them, because 37 | // the reflogs need to still exist.) 38 | // 39 | // (There's a catch-22 where the fsck tests depend on reflog, 40 | // and the reflog tests depend on fsck.) 41 | filepath.Walk(filepath.Join(c.GitDir.String(), "logs"), 42 | func(path string, info os.FileInfo, err error) error { 43 | if info.IsDir() { 44 | return nil 45 | } 46 | 47 | // Use Create to truncate the file. We know it exists 48 | // because we got here from a Walk to it, so we don't 49 | // worry about creating new files. 50 | fi, err := os.Create(path) 51 | if err != nil { 52 | return err 53 | } 54 | if err := fi.Close(); err != nil { 55 | return err 56 | } 57 | return nil 58 | }) 59 | } 60 | return nil 61 | } 62 | -------------------------------------------------------------------------------- /git/refspec_test.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestRefSpecParsing(t *testing.T) { 8 | tests := []struct { 9 | test RefSpec 10 | wantSrc Refname 11 | wantDst Refname 12 | }{ 13 | { 14 | "refs/heads/foo", 15 | "refs/heads/foo", 16 | "", 17 | }, 18 | { 19 | "+refs/heads/foo", 20 | "refs/heads/foo", 21 | "", 22 | }, 23 | { 24 | "refs/heads/foo:refs/remotes/origin/foo", 25 | "refs/heads/foo", 26 | "refs/remotes/origin/foo", 27 | }, 28 | { 29 | "+refs/heads/foo:refs/remotes/origin/foo", 30 | "refs/heads/foo", 31 | "refs/remotes/origin/foo", 32 | }, 33 | { 34 | // XXX: Determine if this is a reasonable thing to do. 35 | "refs/heads/*:refs/remotes/origin/*", 36 | "refs/heads/*", 37 | "refs/remotes/origin/*", 38 | }, 39 | } 40 | for i, tc := range tests { 41 | if got := tc.test.Src(); got != tc.wantSrc { 42 | t.Errorf("Test %d: unexpected Src for %v. got %v want %v", i, tc.test, got, tc.wantSrc) 43 | } 44 | if got := tc.test.Dst(); got != tc.wantDst { 45 | t.Errorf("Test %d: unexpected Dst for %v. got %v want %v", i, tc.test, got, tc.wantDst) 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /git/retrieve.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "io" 7 | "os" 8 | "strconv" 9 | "strings" 10 | ) 11 | 12 | type PktLine string 13 | 14 | func PktLineEncode(line []byte) (PktLine, error) { 15 | if len(line) > 65535 { 16 | return "", fmt.Errorf("Line too long to encode in PktLine format") 17 | } 18 | return PktLine(fmt.Sprintf("%.4x%s\n", len(line)+5, line)), nil 19 | } 20 | 21 | func PktLineEncodeNoNl(line []byte) (PktLine, error) { 22 | if len(line) > 65535 { 23 | return "", fmt.Errorf("Line too long to encode in PktLine format") 24 | } 25 | return PktLine(fmt.Sprintf("%.4x%s", len(line)+4, line)), nil 26 | } 27 | func (p PktLine) String() string { 28 | return string(p) 29 | } 30 | 31 | var loadLine = func(r io.Reader) string { 32 | size := make([]byte, 4) 33 | n, err := r.Read(size) 34 | if n != 4 || err != nil { 35 | return "" 36 | } 37 | val, err := strconv.ParseUint(string(size), 16, 64) 38 | if err != nil { 39 | return "" 40 | } 41 | if val == 0 { 42 | return "" 43 | } 44 | line := make([]byte, val-4) 45 | n, err = io.ReadFull(r, line) 46 | if uint64(n) != val-4 || err != nil { 47 | panic(fmt.Sprintf("Unexpected line size: %d not %d: %s", n, val, line)) 48 | } 49 | return string(line) 50 | 51 | } 52 | 53 | func readLine(prompt string) string { 54 | getInput := bufio.NewReader(os.Stdin) 55 | var val string 56 | var err error 57 | for { 58 | fmt.Fprintf(os.Stderr, prompt) 59 | val, err = getInput.ReadString('\n') 60 | if err != nil { 61 | return "" 62 | } 63 | 64 | val = strings.TrimSpace(val) 65 | if val != "" { 66 | return val 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /git/sha1_test.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestSha1Stringer(t *testing.T) { 8 | tests := []struct { 9 | Sha1 Sha1 10 | String string 11 | }{ 12 | { 13 | Sha1{0x37, 0xff, 0x15, 0xce, 0x14, 0x33, 0x8b, 0xca, 14 | 0x67, 0xe8, 0x6a, 0x73, 0x65, 0x05, 0xc5, 0x48, 0x2d, 15 | 0x83, 0x48, 0xaa, 16 | }, 17 | "37ff15ce14338bca67e86a736505c5482d8348aa", 18 | }, 19 | {Sha1{}, "0000000000000000000000000000000000000000"}, 20 | { 21 | Sha1{0x00, 0xff, 0x15, 0xce, 0x14, 0x33, 0x8b, 0xca, 22 | 0x67, 0xe8, 0x6a, 0x73, 0x65, 0x05, 0xc5, 0x48, 0x2d, 23 | 0x83, 0x48, 0xaa, 24 | }, 25 | "00ff15ce14338bca67e86a736505c5482d8348aa", 26 | }, 27 | } 28 | for i, test := range tests { 29 | if got := test.Sha1.String(); got != test.String { 30 | t.Errorf("tc %d: got %v want %v", i, got, test.String) 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /git/ssh_other.go: -------------------------------------------------------------------------------- 1 | //go:build !plan9 && !dragonfly && !openbsd && !darwin && !freebsd && !netbsd && !solaris && !linux 2 | // +build !plan9,!dragonfly,!openbsd,!darwin,!freebsd,!netbsd,!solaris,!linux 3 | 4 | package git 5 | 6 | import ( 7 | "golang.org/x/crypto/ssh" 8 | ) 9 | 10 | func getSigners() ([]ssh.Signer, error) { 11 | // By default, assume no keys 12 | return nil, nil 13 | } 14 | -------------------------------------------------------------------------------- /git/ssh_plan9.go: -------------------------------------------------------------------------------- 1 | package git 2 | 3 | import ( 4 | "crypto" 5 | _ "crypto/sha1" 6 | "io" 7 | 8 | "github.com/Plan9-Archive/libauth" 9 | "golang.org/x/crypto/ssh" 10 | ) 11 | 12 | // from mischief's scpu, get a list of signers 13 | func getSigners() ([]ssh.Signer, error) { 14 | // FIXME: Don't assume Plan 9/factotum is present, look into ~/.ssh 15 | // on other platforms. 16 | k, err := libauth.Listkeys() 17 | if err != nil { 18 | // if libauth returned an error, it just means factotum isn't 19 | // present 20 | return nil, nil 21 | } 22 | signers := make([]ssh.Signer, len(k)) 23 | for i, key := range k { 24 | skey, err := ssh.NewPublicKey(&key) 25 | if err != nil { 26 | return nil, err 27 | } 28 | // FIXME: Don't hardcode Sha1 29 | signers[i] = keySigner{skey, crypto.SHA1} 30 | } 31 | return signers, nil 32 | } 33 | 34 | // Implements ssh.PublicKeys interface (initially based on mischief's scpu, 35 | // but modified to accept more key types) 36 | // 37 | // This is necessary because we don't (necessarily) have access to the private 38 | // key (it may be in factotum) and not exposed from libauth, so we need to be 39 | // able to sign using libauth.RsaSign 40 | type keySigner struct { 41 | key ssh.PublicKey 42 | hash crypto.Hash 43 | } 44 | 45 | func (s keySigner) PublicKey() ssh.PublicKey { 46 | return s.key 47 | } 48 | 49 | func (s keySigner) Sign(rand io.Reader, data []byte) (*ssh.Signature, error) { 50 | h := s.hash.New() 51 | h.Write(data) 52 | digest := h.Sum(nil) 53 | 54 | sig, err := libauth.RsaSign(digest) 55 | if err != nil { 56 | return nil, err 57 | } 58 | return &ssh.Signature{Format: "ssh-rsa", Blob: sig}, nil 59 | } 60 | -------------------------------------------------------------------------------- /git/ssh_unix.go: -------------------------------------------------------------------------------- 1 | //go:build dragonfly || openbsd || darwin || freebsd || netbsd || solaris || linux 2 | // +build dragonfly openbsd darwin freebsd netbsd solaris linux 3 | 4 | package git 5 | 6 | import ( 7 | "golang.org/x/crypto/ssh" 8 | "io/ioutil" 9 | "os/user" 10 | ) 11 | 12 | func getSigners() ([]ssh.Signer, error) { 13 | user, err := user.Current() 14 | if err != nil { 15 | return nil, nil 16 | } 17 | f, err := ioutil.ReadFile(user.HomeDir + "/.ssh/id_rsa") 18 | if err != nil { 19 | return nil, nil 20 | } 21 | key, err := ssh.ParsePrivateKey(f) 22 | if err != nil { 23 | return nil, err 24 | } 25 | return []ssh.Signer{key}, nil 26 | } 27 | -------------------------------------------------------------------------------- /go-get-modules-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | echo "Running go get tests with Go modules enabled" 5 | 6 | # Keep existing state 7 | export ORIG_PATH=$PATH 8 | export ORIG_GIT=$(which git) 9 | export ORIG_GOPATH=$GOPATH 10 | 11 | echo "Adding dgit to the path" 12 | go build 13 | mkdir -p bin 14 | cp dgit bin/git 15 | export PATH=$(pwd)/bin:$PATH 16 | 17 | export DGIT_TRACE=/tmp/go-get-dgit-log.$$.txt 18 | 19 | # Use a fresh GOPATH 20 | mkdir /tmp/gopath.$$ 21 | export GOPATH=/tmp/gopath.$$ 22 | export GO111MODULE=on # Force Go 1.11 to use the go modules 23 | 24 | # Force Go master (>=1.14) to use git instead of a proxy. 25 | export GOPROXY="direct" 26 | 27 | mkdir -p /tmp/foo.$$ 28 | cd /tmp/foo.$$ 29 | go mod init somesite.com/foo || exit 0 30 | 31 | echo "Go get a package without semver" 32 | go get "github.com/shurcooL/vfsgen" || (echo "Go get failed"; exit 1) 33 | test -d $GOPATH/pkg/mod/github.com/shurcoo\!l || (echo "ERROR: Go get didn't work"; exit 1) 34 | 35 | test -f $DGIT_TRACE || (echo "ERROR: Dgit wasn't called for the go get test"; exit 1) 36 | rm -f $DGIT_TRACE 37 | 38 | echo "Go get a package with semver" 39 | go get "golang.org/x/text" || (echo "Go get failed"; exit 1) 40 | # Only test the parent directory, because the exact package directory includes @version 41 | test -d $GOPATH/pkg/mod/golang.org/x || (echo "ERROR: Go get didn't work"; exit 1) 42 | 43 | test -f $DGIT_TRACE 44 | rm -f $DGIT_TRACE 45 | 46 | export PATH=$ORIG_PATH 47 | unset GO111MODULE 48 | export GOPATH=$ORIG_GOPATH 49 | -------------------------------------------------------------------------------- /go-get-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | echo "Running go get tests" 5 | 6 | # Ensure that git is called, not the proxy 7 | export GOPROXY="direct" 8 | 9 | #Keep existing state 10 | export ORIG_PATH=$PATH 11 | export ORIG_GIT=$(which git) 12 | 13 | echo "Adding dgit to the path" 14 | go build 15 | 16 | # Ensure that expected "go get" behaviour is 17 | # consistent across go versions 18 | export GO111MODULE="off" 19 | 20 | mkdir -p bin 21 | cp dgit bin/git 22 | export PATH=$(pwd)/bin:$PATH 23 | 24 | export DGIT_TRACE=/tmp/go-get-dgit-log.$$.txt 25 | 26 | # Make a new $GOPATH and use it so that newer versions of 27 | # git with different default module modes don't get confused. 28 | export GOPATH=/tmp/gopath.tst 29 | export TEST_PKG=github.com/blang/semver 30 | export TEST_GIT_DIR=${GOPATH}/src/${TEST_PKG} 31 | mkdir -p $GOPATH 32 | cd $GOPATH 33 | 34 | echo "Go get a package inside $GOPATH" 35 | go get -x ${TEST_PKG} || (echo "Go get ${TEST_PKG} failed"; exit 1) 36 | test -d ${GOPATH}/src/${TEST_PKG} || (echo "ERROR: Go get didn't work"; exit 1) 37 | 38 | test -f $DGIT_TRACE || (echo "ERROR: Dgit wasn't called for the go get test"; exit 1) 39 | rm -f $DGIT_TRACE 40 | 41 | echo "Reset the package back one commit from master" 42 | $ORIG_GIT -C ${TEST_GIT_DIR} reset HEAD^1 > /dev/null 43 | $ORIG_GIT -C ${TEST_GIT_DIR} checkout . > /dev/null 44 | commitid=$($ORIG_GIT -C ${TEST_GIT_DIR} log --pretty=format:"%h" HEAD^..HEAD) 45 | 46 | echo "Run go get -u on the package" 47 | go get -x -u ${TEST_PKG} || (echo "Go get -u failed"; exit 1) 48 | test -f $DGIT_TRACE || (echo "ERROR: Dgit wasn't called for the go get -u test"; exit 1) 49 | 50 | echo "Verify that the branch is now up to date with master" 51 | commitid2=$($ORIG_GIT -C ${TEST_GIT_DIR} log --pretty=format:"%h" HEAD^..HEAD) 52 | 53 | echo COMMITS: "$commitid" "$commitid2" 54 | if [ "$commitid" == "$commitid2" ] 55 | then 56 | echo "ERROR: Pull did not pull in the latest changes" 57 | exit 1 58 | fi 59 | 60 | export PATH=$ORIG_PATH 61 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/driusan/dgit 2 | 3 | go 1.14 4 | 5 | require ( 6 | 9fans.net/go v0.0.0-20180727211846-5d4fa602e1e8 // indirect 7 | github.com/Plan9-Archive/libauth v0.0.0-20180917063427-d1ca9e94969d 8 | github.com/hashicorp/golang-lru v0.5.4 9 | golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b 10 | golang.org/x/sys v0.0.0-20180926160741-c2ed4eda69e7 // indirect 11 | ) 12 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | 9fans.net/go v0.0.0-20180727211846-5d4fa602e1e8 h1:I5as7fR6RT+wVrs+vOeEtOHJ4z2vnUnIR+cqvAiQ80s= 2 | 9fans.net/go v0.0.0-20180727211846-5d4fa602e1e8/go.mod h1:diCsxrliIURU9xsYtjCp5AbpQKqdhKmf0ujWDUSkfoY= 3 | github.com/Plan9-Archive/libauth v0.0.0-20180917063427-d1ca9e94969d h1:xH/U6K+HYxh1480TkQYRqRO8F2RJsg+R6wFiVJzdldg= 4 | github.com/Plan9-Archive/libauth v0.0.0-20180917063427-d1ca9e94969d/go.mod h1:UKp8dv9aeaZoQFWin7eQXtz89iHly1YAFZNn3MCutmQ= 5 | github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= 6 | github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= 7 | golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b h1:2b9XGzhjiYsYPnKXoEfL7klWZQIt8IfyRCz62gCqqlQ= 8 | golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 9 | golang.org/x/sys v0.0.0-20180926160741-c2ed4eda69e7 h1:bit1t3mgdR35yN0cX0G8orgLtOuyL9Wqxa1mccLB0ig= 10 | golang.org/x/sys v0.0.0-20180926160741-c2ed4eda69e7/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 11 | -------------------------------------------------------------------------------- /issues/Status-should-be-refactored/Description: -------------------------------------------------------------------------------- 1 | "dgit status" should be a wrapper around git.LsFiles(), rather than duplicating 2 | the work. 3 | 4 | It should also be done in the git/ package, not the cmd package. 5 | -------------------------------------------------------------------------------- /issues/need-git-pull-[options]-repo/Description: -------------------------------------------------------------------------------- 1 | 9legacy supports git pull. We need to too. 2 | -------------------------------------------------------------------------------- /official-git/.gitignore: -------------------------------------------------------------------------------- 1 | git 2 | -------------------------------------------------------------------------------- /official-git/fix-checkout-branch.patch: -------------------------------------------------------------------------------- 1 | diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh 2 | index 2131fb2a56..d218d5d565 100755 3 | --- a/t/t2018-checkout-branch.sh 4 | +++ b/t/t2018-checkout-branch.sh 5 | @@ -28,7 +28,7 @@ do_checkout() { 6 | 7 | git checkout $opts $exp_branch $exp_sha && 8 | 9 | - test $exp_ref = $(git rev-parse --symbolic-full-name HEAD) && 10 | + #test $exp_ref = $(git rev-parse --symbolic-full-name HEAD) && 11 | test $exp_sha = $(git rev-parse --verify HEAD) 12 | } 13 | 14 | -------------------------------------------------------------------------------- /official-git/force-official-git-pack-objects.patch: -------------------------------------------------------------------------------- 1 | diff --git a/upload-pack.c b/upload-pack.c 2 | index ca7f941780..1900c89350 100644 3 | --- a/upload-pack.c 4 | +++ b/upload-pack.c 5 | @@ -99,11 +99,13 @@ static void create_pack_file(void) 6 | int i; 7 | FILE *pipe_fd; 8 | 9 | - if (!pack_objects_hook) 10 | - pack_objects.git_cmd = 1; 11 | + if (!pack_objects_hook) { 12 | + argv_array_push(&pack_objects.args, "git.official"); 13 | + pack_objects.use_shell = 1; 14 | + } 15 | else { 16 | argv_array_push(&pack_objects.args, pack_objects_hook); 17 | - argv_array_push(&pack_objects.args, "git"); 18 | + argv_array_push(&pack_objects.args, "git.official"); 19 | pack_objects.use_shell = 1; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /official-git/git-init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | d=`dirname $0` 4 | 5 | ${d}/git init "$@" 6 | 7 | -------------------------------------------------------------------------------- /vendor/9fans.net/go/plan9/Makefile: -------------------------------------------------------------------------------- 1 | include $(GOROOT)/src/Make.inc 2 | 3 | TARG=goplan9.googlecode.com/hg/plan9 4 | GOFILES=\ 5 | bit.go\ 6 | const.go\ 7 | dir.go\ 8 | fcall.go\ 9 | 10 | include $(GOROOT)/src/Make.pkg 11 | -------------------------------------------------------------------------------- /vendor/9fans.net/go/plan9/bit.go: -------------------------------------------------------------------------------- 1 | package plan9 // import "9fans.net/go/plan9" 2 | 3 | func gbit8(b []byte) (uint8, []byte) { 4 | return uint8(b[0]), b[1:] 5 | } 6 | 7 | func gbit16(b []byte) (uint16, []byte) { 8 | return uint16(b[0]) | uint16(b[1])<<8, b[2:] 9 | } 10 | 11 | func gbit32(b []byte) (uint32, []byte) { 12 | return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24, b[4:] 13 | } 14 | 15 | func gbit64(b []byte) (uint64, []byte) { 16 | lo, b := gbit32(b) 17 | hi, b := gbit32(b) 18 | return uint64(hi)<<32 | uint64(lo), b 19 | } 20 | 21 | func gstring(b []byte) (string, []byte) { 22 | n, b := gbit16(b) 23 | return string(b[0:n]), b[n:] 24 | } 25 | 26 | func pbit8(b []byte, x uint8) []byte { 27 | n := len(b) 28 | if n+1 > cap(b) { 29 | nb := make([]byte, n, 100+2*cap(b)) 30 | copy(nb, b) 31 | b = nb 32 | } 33 | b = b[0 : n+1] 34 | b[n] = x 35 | return b 36 | } 37 | 38 | func pbit16(b []byte, x uint16) []byte { 39 | n := len(b) 40 | if n+2 > cap(b) { 41 | nb := make([]byte, n, 100+2*cap(b)) 42 | copy(nb, b) 43 | b = nb 44 | } 45 | b = b[0 : n+2] 46 | b[n] = byte(x) 47 | b[n+1] = byte(x >> 8) 48 | return b 49 | } 50 | 51 | func pbit32(b []byte, x uint32) []byte { 52 | n := len(b) 53 | if n+4 > cap(b) { 54 | nb := make([]byte, n, 100+2*cap(b)) 55 | copy(nb, b) 56 | b = nb 57 | } 58 | b = b[0 : n+4] 59 | b[n] = byte(x) 60 | b[n+1] = byte(x >> 8) 61 | b[n+2] = byte(x >> 16) 62 | b[n+3] = byte(x >> 24) 63 | return b 64 | } 65 | 66 | func pbit64(b []byte, x uint64) []byte { 67 | b = pbit32(b, uint32(x)) 68 | b = pbit32(b, uint32(x>>32)) 69 | return b 70 | } 71 | 72 | func pstring(b []byte, s string) []byte { 73 | if len(s) >= 1<<16 { 74 | panic(ProtocolError("string too long")) 75 | } 76 | b = pbit16(b, uint16(len(s))) 77 | b = append(b, []byte(s)...) 78 | return b 79 | } 80 | -------------------------------------------------------------------------------- /vendor/9fans.net/go/plan9/client/Makefile: -------------------------------------------------------------------------------- 1 | include $(GOROOT)/src/Make.inc 2 | 3 | TARG=goplan9.googlecode.com/hg/plan9/client 4 | GOFILES=\ 5 | conn.go\ 6 | dial.go\ 7 | fid.go\ 8 | fsys.go\ 9 | 10 | include $(GOROOT)/src/Make.pkg 11 | -------------------------------------------------------------------------------- /vendor/9fans.net/go/plan9/client/dial.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "os" 7 | "regexp" 8 | "strings" 9 | ) 10 | 11 | func Dial(network, addr string) (*Conn, error) { 12 | c, err := net.Dial(network, addr) 13 | if err != nil { 14 | return nil, err 15 | } 16 | return NewConn(c) 17 | } 18 | 19 | func DialService(service string) (*Conn, error) { 20 | ns := Namespace() 21 | return Dial("unix", ns+"/"+service) 22 | } 23 | 24 | func Mount(network, addr string) (*Fsys, error) { 25 | c, err := Dial(network, addr) 26 | if err != nil { 27 | return nil, err 28 | } 29 | fsys, err := c.Attach(nil, getuser(), "") 30 | if err != nil { 31 | c.Close() 32 | } 33 | return fsys, err 34 | } 35 | 36 | func MountService(service string) (*Fsys, error) { 37 | c, err := DialService(service) 38 | if err != nil { 39 | return nil, err 40 | } 41 | fsys, err := c.Attach(nil, getuser(), "") 42 | if err != nil { 43 | c.Close() 44 | } 45 | return fsys, err 46 | } 47 | 48 | var dotZero = regexp.MustCompile(`\A(.*:\d+)\.0\z`) 49 | 50 | // Namespace returns the path to the name space directory. 51 | func Namespace() string { 52 | ns := os.Getenv("NAMESPACE") 53 | if ns != "" { 54 | return ns 55 | } 56 | 57 | disp := os.Getenv("DISPLAY") 58 | if disp == "" { 59 | // No $DISPLAY? Use :0.0 for non-X11 GUI (OS X). 60 | disp = ":0.0" 61 | } 62 | 63 | // Canonicalize: xxx:0.0 => xxx:0. 64 | if m := dotZero.FindStringSubmatch(disp); m != nil { 65 | disp = m[1] 66 | } 67 | 68 | // Turn /tmp/launch/:0 into _tmp_launch_:0 (OS X 10.5). 69 | disp = strings.Replace(disp, "/", "_", -1) 70 | 71 | // NOTE: plan9port creates this directory on demand. 72 | // Maybe someday we'll need to do that. 73 | 74 | return fmt.Sprintf("/tmp/ns.%s.%s", os.Getenv("USER"), disp) 75 | } 76 | -------------------------------------------------------------------------------- /vendor/9fans.net/go/plan9/const.go: -------------------------------------------------------------------------------- 1 | package plan9 2 | 3 | const ( 4 | VERSION9P = "9P2000" 5 | MAXWELEM = 16 6 | 7 | OREAD = 0 8 | OWRITE = 1 9 | ORDWR = 2 10 | OEXEC = 3 11 | OTRUNC = 16 12 | OCEXEC = 32 13 | ORCLOSE = 64 14 | ODIRECT = 128 15 | ONONBLOCK = 256 16 | OEXCL = 0x1000 17 | OLOCK = 0x2000 18 | OAPPEND = 0x4000 19 | 20 | AEXIST = 0 21 | AEXEC = 1 22 | AWRITE = 2 23 | AREAD = 4 24 | 25 | QTDIR = 0x80 26 | QTAPPEND = 0x40 27 | QTEXCL = 0x20 28 | QTMOUNT = 0x10 29 | QTAUTH = 0x08 30 | QTTMP = 0x04 31 | QTSYMLINK = 0x02 32 | QTFILE = 0x00 33 | 34 | DMDIR = 0x80000000 35 | DMAPPEND = 0x40000000 36 | DMEXCL = 0x20000000 37 | DMMOUNT = 0x10000000 38 | DMAUTH = 0x08000000 39 | DMTMP = 0x04000000 40 | DMSYMLINK = 0x02000000 41 | DMDEVICE = 0x00800000 42 | DMNAMEDPIPE = 0x00200000 43 | DMSOCKET = 0x00100000 44 | DMSETUID = 0x00080000 45 | DMSETGID = 0x00040000 46 | DMREAD = 0x4 47 | DMWRITE = 0x2 48 | DMEXEC = 0x1 49 | 50 | NOTAG = 0xffff 51 | NOFID = 0xffffffff 52 | NOUID = 0xffffffff 53 | IOHDRSZ = 24 54 | ) 55 | -------------------------------------------------------------------------------- /vendor/github.com/Plan9-Archive/libauth/os_plan9.go: -------------------------------------------------------------------------------- 1 | package libauth 2 | 3 | import ( 4 | "io" 5 | "os" 6 | ) 7 | 8 | func openRPC() (io.ReadWriteCloser, error) { 9 | return os.OpenFile("/mnt/factotum/rpc", os.O_RDWR, 0) 10 | } 11 | 12 | func openCtl() (io.ReadWriteCloser, error) { 13 | return os.OpenFile("/mnt/factotum/ctl", os.O_RDWR, 0) 14 | } 15 | 16 | var factotum = "/boot/factotum" 17 | -------------------------------------------------------------------------------- /vendor/github.com/Plan9-Archive/libauth/os_unix.go: -------------------------------------------------------------------------------- 1 | // +build !plan9 2 | 3 | package libauth 4 | 5 | import ( 6 | "io" 7 | "os" 8 | 9 | "9fans.net/go/plan9" 10 | "9fans.net/go/plan9/client" 11 | ) 12 | 13 | func openRPC() (io.ReadWriteCloser, error) { 14 | fsys, err := client.MountService("factotum") 15 | if err != nil { 16 | return nil, err 17 | } 18 | 19 | fid, err := fsys.Open("rpc", plan9.ORDWR) 20 | if err != nil { 21 | return nil, err 22 | } 23 | 24 | return fid, nil 25 | } 26 | 27 | func openCtl() (io.ReadWriteCloser, error) { 28 | fsys, err := client.MountService("factotum") 29 | if err != nil { 30 | return nil, err 31 | } 32 | 33 | fid, err := fsys.Open("ctl", plan9.ORDWR) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | return fid, nil 39 | } 40 | 41 | var factotum = os.Getenv("PLAN9") + "/bin/factotum" 42 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/golang-lru/.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 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/golang-lru/README.md: -------------------------------------------------------------------------------- 1 | golang-lru 2 | ========== 3 | 4 | This provides the `lru` package which implements a fixed-size 5 | thread safe LRU cache. It is based on the cache in Groupcache. 6 | 7 | Documentation 8 | ============= 9 | 10 | Full docs are available on [Godoc](http://godoc.org/github.com/hashicorp/golang-lru) 11 | 12 | Example 13 | ======= 14 | 15 | Using the LRU is very simple: 16 | 17 | ```go 18 | l, _ := New(128) 19 | for i := 0; i < 256; i++ { 20 | l.Add(i, nil) 21 | } 22 | if l.Len() != 128 { 23 | panic(fmt.Sprintf("bad len: %v", l.Len())) 24 | } 25 | ``` 26 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/golang-lru/doc.go: -------------------------------------------------------------------------------- 1 | // Package lru provides three different LRU caches of varying sophistication. 2 | // 3 | // Cache is a simple LRU cache. It is based on the 4 | // LRU implementation in groupcache: 5 | // https://github.com/golang/groupcache/tree/master/lru 6 | // 7 | // TwoQueueCache tracks frequently used and recently used entries separately. 8 | // This avoids a burst of accesses from taking out frequently used entries, 9 | // at the cost of about 2x computational overhead and some extra bookkeeping. 10 | // 11 | // ARCCache is an adaptive replacement cache. It tracks recent evictions as 12 | // well as recent usage in both the frequent and recent caches. Its 13 | // computational overhead is comparable to TwoQueueCache, but the memory 14 | // overhead is linear with the size of the cache. 15 | // 16 | // ARC has been patented by IBM, so do not use it if that is problematic for 17 | // your program. 18 | // 19 | // All caches in this package take locks while operating, and are therefore 20 | // thread-safe for consumers. 21 | package lru 22 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/golang-lru/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/hashicorp/golang-lru 2 | 3 | go 1.12 4 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/golang-lru/simplelru/lru_interface.go: -------------------------------------------------------------------------------- 1 | package simplelru 2 | 3 | // LRUCache is the interface for simple LRU cache. 4 | type LRUCache interface { 5 | // Adds a value to the cache, returns true if an eviction occurred and 6 | // updates the "recently used"-ness of the key. 7 | Add(key, value interface{}) bool 8 | 9 | // Returns key's value from the cache and 10 | // updates the "recently used"-ness of the key. #value, isFound 11 | Get(key interface{}) (value interface{}, ok bool) 12 | 13 | // Checks if a key exists in cache without updating the recent-ness. 14 | Contains(key interface{}) (ok bool) 15 | 16 | // Returns key's value without updating the "recently used"-ness of the key. 17 | Peek(key interface{}) (value interface{}, ok bool) 18 | 19 | // Removes a key from the cache. 20 | Remove(key interface{}) bool 21 | 22 | // Removes the oldest entry from cache. 23 | RemoveOldest() (interface{}, interface{}, bool) 24 | 25 | // Returns the oldest entry from the cache. #key, value, isFound 26 | GetOldest() (interface{}, interface{}, bool) 27 | 28 | // Returns a slice of the keys in the cache, from oldest to newest. 29 | Keys() []interface{} 30 | 31 | // Returns the number of items in the cache. 32 | Len() int 33 | 34 | // Clears all cache entries. 35 | Purge() 36 | 37 | // Resizes cache, returning number evicted 38 | Resize(int) int 39 | } 40 | -------------------------------------------------------------------------------- /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/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/crypto/ssh/terminal/util_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 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 darwin dragonfly freebsd netbsd openbsd 6 | 7 | package terminal 8 | 9 | import "golang.org/x/sys/unix" 10 | 11 | const ioctlReadTermios = unix.TIOCGETA 12 | const ioctlWriteTermios = unix.TIOCSETA 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 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 terminal 6 | 7 | import "golang.org/x/sys/unix" 8 | 9 | const ioctlReadTermios = unix.TCGETS 10 | const ioctlWriteTermios = unix.TCSETS 11 | -------------------------------------------------------------------------------- /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/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | unix.test 3 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/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 aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build go1.9 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | type Signal = syscall.Signal 13 | type Errno = syscall.Errno 14 | type SysProcAttr = syscall.SysProcAttr 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 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 !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 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 !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for 386, Linux 11 | // 12 | 13 | // See ../runtime/sys_linux_386.s for the reason why we always use int 0x80 14 | // instead of the glibc-specific "CALL 0x10(GS)". 15 | #define INVOKE_SYSCALL INT $0x80 16 | 17 | // Just jump to package syscall's implementation for all these functions. 18 | // The runtime may know about them. 19 | 20 | TEXT ·Syscall(SB),NOSPLIT,$0-28 21 | JMP syscall·Syscall(SB) 22 | 23 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 24 | JMP syscall·Syscall6(SB) 25 | 26 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 27 | CALL runtime·entersyscall(SB) 28 | MOVL trap+0(FP), AX // syscall entry 29 | MOVL a1+4(FP), BX 30 | MOVL a2+8(FP), CX 31 | MOVL a3+12(FP), DX 32 | MOVL $0, SI 33 | MOVL $0, DI 34 | INVOKE_SYSCALL 35 | MOVL AX, r1+16(FP) 36 | MOVL DX, r2+20(FP) 37 | CALL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 47 | MOVL trap+0(FP), AX // syscall entry 48 | MOVL a1+4(FP), BX 49 | MOVL a2+8(FP), CX 50 | MOVL a3+12(FP), DX 51 | MOVL $0, SI 52 | MOVL $0, DI 53 | INVOKE_SYSCALL 54 | MOVL AX, r1+16(FP) 55 | MOVL DX, r2+20(FP) 56 | RET 57 | 58 | TEXT ·socketcall(SB),NOSPLIT,$0-36 59 | JMP syscall·socketcall(SB) 60 | 61 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 62 | JMP syscall·rawsocketcall(SB) 63 | 64 | TEXT ·seek(SB),NOSPLIT,$0-28 65 | JMP syscall·seek(SB) 66 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 23 | CALL runtime·entersyscall(SB) 24 | MOVQ a1+8(FP), DI 25 | MOVQ a2+16(FP), SI 26 | MOVQ a3+24(FP), DX 27 | MOVQ $0, R10 28 | MOVQ $0, R8 29 | MOVQ $0, R9 30 | MOVQ trap+0(FP), AX // syscall entry 31 | SYSCALL 32 | MOVQ AX, r1+32(FP) 33 | MOVQ DX, r2+40(FP) 34 | CALL runtime·exitsyscall(SB) 35 | RET 36 | 37 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 38 | JMP syscall·RawSyscall(SB) 39 | 40 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 41 | JMP syscall·RawSyscall6(SB) 42 | 43 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 44 | MOVQ a1+8(FP), DI 45 | MOVQ a2+16(FP), SI 46 | MOVQ a3+24(FP), DX 47 | MOVQ $0, R10 48 | MOVQ $0, R8 49 | MOVQ $0, R9 50 | MOVQ trap+0(FP), AX // syscall entry 51 | SYSCALL 52 | MOVQ AX, r1+32(FP) 53 | MOVQ DX, r2+40(FP) 54 | RET 55 | 56 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 57 | JMP syscall·gettimeofday(SB) 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 23 | BL runtime·entersyscall(SB) 24 | MOVW trap+0(FP), R7 25 | MOVW a1+4(FP), R0 26 | MOVW a2+8(FP), R1 27 | MOVW a3+12(FP), R2 28 | MOVW $0, R3 29 | MOVW $0, R4 30 | MOVW $0, R5 31 | SWI $0 32 | MOVW R0, r1+16(FP) 33 | MOVW $0, R0 34 | MOVW R0, r2+20(FP) 35 | BL runtime·exitsyscall(SB) 36 | RET 37 | 38 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 39 | B syscall·RawSyscall(SB) 40 | 41 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 42 | B syscall·RawSyscall6(SB) 43 | 44 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 45 | MOVW trap+0(FP), R7 // syscall entry 46 | MOVW a1+4(FP), R0 47 | MOVW a2+8(FP), R1 48 | MOVW a3+12(FP), R2 49 | SWI $0 50 | MOVW R0, r1+16(FP) 51 | MOVW $0, R0 52 | MOVW R0, r2+20(FP) 53 | RET 54 | 55 | TEXT ·seek(SB),NOSPLIT,$0-28 56 | B syscall·seek(SB) 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 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 linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 21 | BL runtime·entersyscall(SB) 22 | MOVD a1+8(FP), R0 23 | MOVD a2+16(FP), R1 24 | MOVD a3+24(FP), R2 25 | MOVD $0, R3 26 | MOVD $0, R4 27 | MOVD $0, R5 28 | MOVD trap+0(FP), R8 // syscall entry 29 | SVC 30 | MOVD R0, r1+32(FP) // r1 31 | MOVD R1, r2+40(FP) // r2 32 | BL runtime·exitsyscall(SB) 33 | RET 34 | 35 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 36 | B syscall·RawSyscall(SB) 37 | 38 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 39 | B syscall·RawSyscall6(SB) 40 | 41 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 42 | MOVD a1+8(FP), R0 43 | MOVD a2+16(FP), R1 44 | MOVD a3+24(FP), R2 45 | MOVD $0, R3 46 | MOVD $0, R4 47 | MOVD $0, R5 48 | MOVD trap+0(FP), R8 // syscall entry 49 | SVC 50 | MOVD R0, r1+32(FP) 51 | MOVD R1, r2+40(FP) 52 | RET 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 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 linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | JAL runtime·entersyscall(SB) 26 | MOVV a1+8(FP), R4 27 | MOVV a2+16(FP), R5 28 | MOVV a3+24(FP), R6 29 | MOVV R0, R7 30 | MOVV R0, R8 31 | MOVV R0, R9 32 | MOVV trap+0(FP), R2 // syscall entry 33 | SYSCALL 34 | MOVV R2, r1+32(FP) 35 | MOVV R3, r2+40(FP) 36 | JAL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | JMP syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | JMP syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVV a1+8(FP), R4 47 | MOVV a2+16(FP), R5 48 | MOVV a3+24(FP), R6 49 | MOVV R0, R7 50 | MOVV R0, R8 51 | MOVV R0, R9 52 | MOVV trap+0(FP), R2 // syscall entry 53 | SYSCALL 54 | MOVV R2, r1+32(FP) 55 | MOVV R3, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mipsx.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 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 linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 28 | JAL runtime·entersyscall(SB) 29 | MOVW a1+4(FP), R4 30 | MOVW a2+8(FP), R5 31 | MOVW a3+12(FP), R6 32 | MOVW R0, R7 33 | MOVW trap+0(FP), R2 // syscall entry 34 | SYSCALL 35 | MOVW R2, r1+16(FP) // r1 36 | MOVW R3, r2+20(FP) // r2 37 | JAL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 47 | MOVW a1+4(FP), R4 48 | MOVW a2+8(FP), R5 49 | MOVW a3+12(FP), R6 50 | MOVW trap+0(FP), R2 // syscall entry 51 | SYSCALL 52 | MOVW R2, r1+16(FP) 53 | MOVW R3, r2+20(FP) 54 | RET 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 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 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | BL runtime·entersyscall(SB) 26 | MOVD a1+8(FP), R3 27 | MOVD a2+16(FP), R4 28 | MOVD a3+24(FP), R5 29 | MOVD R0, R6 30 | MOVD R0, R7 31 | MOVD R0, R8 32 | MOVD trap+0(FP), R9 // syscall entry 33 | SYSCALL R9 34 | MOVD R3, r1+32(FP) 35 | MOVD R4, r2+40(FP) 36 | BL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | BR syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | BR syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVD a1+8(FP), R3 47 | MOVD a2+16(FP), R4 48 | MOVD a3+24(FP), R5 49 | MOVD R0, R6 50 | MOVD R0, R7 51 | MOVD R0, R8 52 | MOVD trap+0(FP), R9 // syscall entry 53 | SYSCALL R9 54 | MOVD R3, r1+32(FP) 55 | MOVD R4, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 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 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | BL runtime·entersyscall(SB) 26 | MOVD a1+8(FP), R2 27 | MOVD a2+16(FP), R3 28 | MOVD a3+24(FP), R4 29 | MOVD $0, R5 30 | MOVD $0, R6 31 | MOVD $0, R7 32 | MOVD trap+0(FP), R1 // syscall entry 33 | SYSCALL 34 | MOVD R2, r1+32(FP) 35 | MOVD R3, r2+40(FP) 36 | BL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | BR syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | BR syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVD a1+8(FP), R2 47 | MOVD a2+16(FP), R3 48 | MOVD a3+24(FP), R4 49 | MOVD $0, R5 50 | MOVD $0, R6 51 | MOVD $0, R7 52 | MOVD trap+0(FP), R1 // syscall entry 53 | SYSCALL 54 | MOVD R2, r1+32(FP) 55 | MOVD R3, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_arm.s: -------------------------------------------------------------------------------- 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 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 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.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 aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_aix_ppc.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 aix 6 | // +build ppc 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used by AIX. 10 | 11 | package unix 12 | 13 | // Major returns the major component of a Linux device number. 14 | func Major(dev uint64) uint32 { 15 | return uint32((dev >> 16) & 0xffff) 16 | } 17 | 18 | // Minor returns the minor component of a Linux device number. 19 | func Minor(dev uint64) uint32 { 20 | return uint32(dev & 0xffff) 21 | } 22 | 23 | // Mkdev returns a Linux device number generated from the given major and minor 24 | // components. 25 | func Mkdev(major, minor uint32) uint64 { 26 | return uint64(((major) << 16) | (minor)) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_aix_ppc64.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 aix 6 | // +build ppc64 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used AIX. 10 | 11 | package unix 12 | 13 | // Major returns the major component of a Linux device number. 14 | func Major(dev uint64) uint32 { 15 | return uint32((dev & 0x3fffffff00000000) >> 32) 16 | } 17 | 18 | // Minor returns the minor component of a Linux device number. 19 | func Minor(dev uint64) uint32 { 20 | return uint32((dev & 0x00000000ffffffff) >> 0) 21 | } 22 | 23 | // Mkdev returns a Linux device number generated from the given major and minor 24 | // components. 25 | func Mkdev(major, minor uint32) uint64 { 26 | var DEVNO64 uint64 27 | DEVNO64 = 0x8000000000000000 28 | return ((uint64(major) << 32) | (uint64(minor) & 0x00000000FFFFFFFF) | DEVNO64) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_darwin.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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Darwin's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a Darwin device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev >> 24) & 0xff) 13 | } 14 | 15 | // Minor returns the minor component of a Darwin device number. 16 | func Minor(dev uint64) uint32 { 17 | return uint32(dev & 0xffffff) 18 | } 19 | 20 | // Mkdev returns a Darwin device number generated from the given major and minor 21 | // components. 22 | func Mkdev(major, minor uint32) uint64 { 23 | return (uint64(major) << 24) | uint64(minor) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_dragonfly.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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Dragonfly's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a DragonFlyBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a DragonFlyBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a DragonFlyBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_freebsd.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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in FreeBSD's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a FreeBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a FreeBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a FreeBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_linux.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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used by the Linux kernel and glibc. 7 | // 8 | // The information below is extracted and adapted from bits/sysmacros.h in the 9 | // glibc sources: 10 | // 11 | // dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's 12 | // default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major 13 | // number and m is a hex digit of the minor number. This is backward compatible 14 | // with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also 15 | // backward compatible with the Linux kernel, which for some architectures uses 16 | // 32-bit dev_t, encoded as mmmM MMmm. 17 | 18 | package unix 19 | 20 | // Major returns the major component of a Linux device number. 21 | func Major(dev uint64) uint32 { 22 | major := uint32((dev & 0x00000000000fff00) >> 8) 23 | major |= uint32((dev & 0xfffff00000000000) >> 32) 24 | return major 25 | } 26 | 27 | // Minor returns the minor component of a Linux device number. 28 | func Minor(dev uint64) uint32 { 29 | minor := uint32((dev & 0x00000000000000ff) >> 0) 30 | minor |= uint32((dev & 0x00000ffffff00000) >> 12) 31 | return minor 32 | } 33 | 34 | // Mkdev returns a Linux device number generated from the given major and minor 35 | // components. 36 | func Mkdev(major, minor uint32) uint64 { 37 | dev := (uint64(major) & 0x00000fff) << 8 38 | dev |= (uint64(major) & 0xfffff000) << 32 39 | dev |= (uint64(minor) & 0x000000ff) << 0 40 | dev |= (uint64(minor) & 0xffffff00) << 12 41 | return dev 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_netbsd.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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in NetBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a NetBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x000fff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of a NetBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xfff00000) >> 12) 19 | return minor 20 | } 21 | 22 | // Mkdev returns a NetBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x000fff00 26 | dev |= (uint64(minor) << 12) & 0xfff00000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_openbsd.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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in OpenBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of an OpenBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x0000ff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of an OpenBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xffff0000) >> 8) 19 | return minor 20 | } 21 | 22 | // Mkdev returns an OpenBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x0000ff00 26 | dev |= (uint64(minor) << 8) & 0xffff0000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dirent.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 aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // ParseDirent parses up to max directory entries in buf, 12 | // appending the names to names. It returns the number of 13 | // bytes consumed from buf, the number of entries added 14 | // to names, and the new names slice. 15 | func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) { 16 | return syscall.ParseDirent(buf, max, names) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 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 ppc64 s390x mips mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 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 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.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 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | 29 | func Unsetenv(key string) error { 30 | return syscall.Unsetenv(key) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl.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 | // +build darwin dragonfly freebsd linux netbsd openbsd 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 12 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 13 | var fcntl64Syscall uintptr = SYS_FCNTL 14 | 15 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. 16 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { 17 | valptr, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(arg)) 18 | var err error 19 | if errno != 0 { 20 | err = errno 21 | } 22 | return int(valptr), err 23 | } 24 | 25 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 26 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 27 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 28 | if errno == 0 { 29 | return nil 30 | } 31 | return errno 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm linux,mips linux,mipsle 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 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 gccgo 6 | // +build !aix 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define _STRINGIFY2_(x) #x 13 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 14 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 15 | 16 | // Call syscall from C code because the gccgo support for calling from 17 | // Go to C does not support varargs functions. 18 | 19 | struct ret { 20 | uintptr_t r; 21 | uintptr_t err; 22 | }; 23 | 24 | struct ret 25 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 26 | { 27 | struct ret r; 28 | 29 | errno = 0; 30 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 31 | r.err = errno; 32 | return r; 33 | } 34 | 35 | uintptr_t 36 | gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 37 | { 38 | return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 39 | } 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.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 gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ioctl.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 aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "runtime" 10 | 11 | // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. 12 | // 13 | // To change fd's window size, the req argument should be TIOCSWINSZ. 14 | func IoctlSetWinsize(fd int, req uint, value *Winsize) error { 15 | // TODO: if we get the chance, remove the req parameter and 16 | // hardcode TIOCSWINSZ. 17 | err := ioctlSetWinsize(fd, req, value) 18 | runtime.KeepAlive(value) 19 | return err 20 | } 21 | 22 | // IoctlSetTermios performs an ioctl on fd with a *Termios. 23 | // 24 | // The req value will usually be TCSETA or TIOCSETA. 25 | func IoctlSetTermios(fd int, req uint, value *Termios) error { 26 | // TODO: if we get the chance, remove the req parameter. 27 | err := ioctlSetTermios(fd, req, value) 28 | runtime.KeepAlive(value) 29 | return err 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_darwin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for Darwin from sys/syscall.h 7 | 8 | use strict; 9 | 10 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 11 | print STDERR "GOARCH or GOOS not defined in environment\n"; 12 | exit 1; 13 | } 14 | 15 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV); 16 | 17 | print <){ 29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){ 30 | my $name = $1; 31 | my $num = $2; 32 | $name =~ y/a-z/A-Z/; 33 | print " SYS_$name = $num;" 34 | } 35 | } 36 | 37 | print <){ 30 | if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+\S+\s+(?:NO)?STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 31 | if($line =~ /^(.*)\\$/) { 32 | # Handle continuation 33 | $line = $1; 34 | $_ =~ s/^\s+//; 35 | $line .= $_; 36 | } else { 37 | # New line 38 | $line = $_; 39 | } 40 | next if $line =~ /\\$/; 41 | if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) { 42 | my $num = $1; 43 | my $proto = $6; 44 | my $compat = $8; 45 | my $name = "$7_$9"; 46 | 47 | $name = "$7_$11" if $11 ne ''; 48 | $name =~ y/a-z/A-Z/; 49 | 50 | if($compat eq '' || $compat eq '13' || $compat eq '30' || $compat eq '50') { 51 | print " $name = $num; // $proto\n"; 52 | } 53 | } 54 | } 55 | 56 | print <){ 30 | if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $3; 33 | my $name = $4; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_aix_ppc.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 aix 6 | // +build ppc 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = getrlimit64 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) = setrlimit64 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek64 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (cmsg *Cmsghdr) SetLen(length int) { 33 | cmsg.Len = uint32(length) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_aix_ppc64.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 aix 6 | // +build ppc64 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: sec, Nsec: nsec} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int64(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (cmsg *Cmsghdr) SetLen(length int) { 33 | cmsg.Len = uint32(length) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.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 amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = sec 29 | tv.Usec = usec 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint64(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint64(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.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 amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.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 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.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 amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.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 arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 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,linux 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc.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 linux,!gccgo 6 | 7 | package unix 8 | 9 | // SyscallNoError may be used instead of Syscall for syscalls that don't fail. 10 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 11 | 12 | // RawSyscallNoError may be used instead of RawSyscall for syscalls that don't 13 | // fail. 14 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc_386.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 linux,!gccgo,386 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // Underlying system call writes to newoffset via pointer. 12 | // Implemented in assembly to avoid allocation. 13 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) 14 | 15 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 16 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.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 linux,gccgo,386 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 15 | var newoffset int64 16 | offsetLow := uint32(offset & 0xffffffff) 17 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 19 | return newoffset, err 20 | } 21 | 22 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 23 | fd, _, err := Syscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 24 | return int(fd), err 25 | } 26 | 27 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 28 | fd, _, err := RawSyscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 29 | return int(fd), err 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_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 | // +build linux,gccgo,arm 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 15 | var newoffset int64 16 | offsetLow := uint32(offset & 0xffffffff) 17 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 19 | return newoffset, err 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.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 386,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.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 amd64,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 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,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.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 386,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.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 amd64,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | 35 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 36 | // of openbsd/amd64 the syscall is called sysctl instead of __sysctl. 37 | const SYS___SYSCTL = SYS_SYSCTL 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_arm.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 arm,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.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 amd64,solaris 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func (iov *Iovec) SetLen(length int) { 18 | iov.Len = uint64(length) 19 | } 20 | 21 | func (cmsg *Cmsghdr) SetLen(length int) { 22 | cmsg.Len = uint32(length) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 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 darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracearm_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(arm, arm64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build arm arm64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsArm is the registers used by arm binaries. 11 | type PtraceRegsArm struct { 12 | Uregs [18]uint32 13 | } 14 | 15 | // PtraceGetRegsArm fetches the registers used by arm binaries. 16 | func PtraceGetRegsArm(pid int, regsout *PtraceRegsArm) error { 17 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 18 | } 19 | 20 | // PtraceSetRegsArm sets the registers used by arm binaries. 21 | func PtraceSetRegsArm(pid int, regs *PtraceRegsArm) error { 22 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 23 | } 24 | 25 | // PtraceRegsArm64 is the registers used by arm64 binaries. 26 | type PtraceRegsArm64 struct { 27 | Regs [31]uint64 28 | Sp uint64 29 | Pc uint64 30 | Pstate uint64 31 | } 32 | 33 | // PtraceGetRegsArm64 fetches the registers used by arm64 binaries. 34 | func PtraceGetRegsArm64(pid int, regsout *PtraceRegsArm64) error { 35 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 36 | } 37 | 38 | // PtraceSetRegsArm64 sets the registers used by arm64 binaries. 39 | func PtraceSetRegsArm64(pid int, regs *PtraceRegsArm64) error { 40 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracemips_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(mips, mips64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build mips mips64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsMips is the registers used by mips binaries. 11 | type PtraceRegsMips struct { 12 | Regs [32]uint64 13 | Lo uint64 14 | Hi uint64 15 | Epc uint64 16 | Badvaddr uint64 17 | Status uint64 18 | Cause uint64 19 | } 20 | 21 | // PtraceGetRegsMips fetches the registers used by mips binaries. 22 | func PtraceGetRegsMips(pid int, regsout *PtraceRegsMips) error { 23 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 24 | } 25 | 26 | // PtraceSetRegsMips sets the registers used by mips binaries. 27 | func PtraceSetRegsMips(pid int, regs *PtraceRegsMips) error { 28 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 29 | } 30 | 31 | // PtraceRegsMips64 is the registers used by mips64 binaries. 32 | type PtraceRegsMips64 struct { 33 | Regs [32]uint64 34 | Lo uint64 35 | Hi uint64 36 | Epc uint64 37 | Badvaddr uint64 38 | Status uint64 39 | Cause uint64 40 | } 41 | 42 | // PtraceGetRegsMips64 fetches the registers used by mips64 binaries. 43 | func PtraceGetRegsMips64(pid int, regsout *PtraceRegsMips64) error { 44 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 45 | } 46 | 47 | // PtraceSetRegsMips64 sets the registers used by mips64 binaries. 48 | func PtraceSetRegsMips64(pid int, regs *PtraceRegsMips64) error { 49 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracemipsle_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(mipsle, mips64le). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build mipsle mips64le 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsMipsle is the registers used by mipsle binaries. 11 | type PtraceRegsMipsle struct { 12 | Regs [32]uint64 13 | Lo uint64 14 | Hi uint64 15 | Epc uint64 16 | Badvaddr uint64 17 | Status uint64 18 | Cause uint64 19 | } 20 | 21 | // PtraceGetRegsMipsle fetches the registers used by mipsle binaries. 22 | func PtraceGetRegsMipsle(pid int, regsout *PtraceRegsMipsle) error { 23 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 24 | } 25 | 26 | // PtraceSetRegsMipsle sets the registers used by mipsle binaries. 27 | func PtraceSetRegsMipsle(pid int, regs *PtraceRegsMipsle) error { 28 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 29 | } 30 | 31 | // PtraceRegsMips64le is the registers used by mips64le binaries. 32 | type PtraceRegsMips64le struct { 33 | Regs [32]uint64 34 | Lo uint64 35 | Hi uint64 36 | Epc uint64 37 | Badvaddr uint64 38 | Status uint64 39 | Cause uint64 40 | } 41 | 42 | // PtraceGetRegsMips64le fetches the registers used by mips64le binaries. 43 | func PtraceGetRegsMips64le(pid int, regsout *PtraceRegsMips64le) error { 44 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 45 | } 46 | 47 | // PtraceSetRegsMips64le sets the registers used by mips64le binaries. 48 | func PtraceSetRegsMips64le(pid int, regs *PtraceRegsMips64le) error { 49 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 50 | } 51 | -------------------------------------------------------------------------------- /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/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/modules.txt: -------------------------------------------------------------------------------- 1 | # 9fans.net/go v0.0.0-20180727211846-5d4fa602e1e8 2 | ## explicit 3 | 9fans.net/go/plan9 4 | 9fans.net/go/plan9/client 5 | # github.com/Plan9-Archive/libauth v0.0.0-20180917063427-d1ca9e94969d 6 | ## explicit 7 | github.com/Plan9-Archive/libauth 8 | # github.com/hashicorp/golang-lru v0.5.4 9 | ## explicit 10 | github.com/hashicorp/golang-lru 11 | github.com/hashicorp/golang-lru/simplelru 12 | # golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b 13 | ## explicit 14 | golang.org/x/crypto/curve25519 15 | golang.org/x/crypto/ed25519 16 | golang.org/x/crypto/ed25519/internal/edwards25519 17 | golang.org/x/crypto/internal/chacha20 18 | golang.org/x/crypto/internal/subtle 19 | golang.org/x/crypto/poly1305 20 | golang.org/x/crypto/ssh 21 | golang.org/x/crypto/ssh/terminal 22 | # golang.org/x/sys v0.0.0-20180926160741-c2ed4eda69e7 23 | ## explicit 24 | golang.org/x/sys/unix 25 | golang.org/x/sys/windows 26 | -------------------------------------------------------------------------------- /zlib/README.md: -------------------------------------------------------------------------------- 1 | This directory contains a fork of the compress/zlib algorithm from 2 | Go. 3 | 4 | It's modified so that NewReader returns a ZLibReader instead of an 5 | io.Reader, and a function is added to ZLibReader to expose the 6 | digest of the compressed block after reading it. 7 | 8 | This allows you to look back for the address of the block after 9 | reading (assuming that the underlying io.Reader is an io.ReadSeeker.) 10 | to find the end of the compressed block, even though the zlib library 11 | reads from the io.Reader greedily and might (read: does) read more than 12 | it needs to from the io.Reader given to it. 13 | --------------------------------------------------------------------------------