Merge pull request #331 from github/nut

setup nut for dependency management
This commit is contained in:
risk danger olson 2015-05-28 14:42:22 -06:00
commit 47f735098b
179 changed files with 3123 additions and 208 deletions

3
.gitignore vendored

@ -1,8 +1,5 @@
bin/
benchmark/
.vendor/pkg
servertest
.vendor/src/github.com/github/git-lfs
# only allow man/*.\d.ronn files
man/*

9
Godeps

@ -1,9 +0,0 @@
github.com/bmizerany/assert e17e99893cb6509f428e1728281c2ad60a6b31e3
github.com/cheggaaa/pb bd14546a551971ae7f460e6d6e527c5b56cd38d7
github.com/kr/pretty 088c856450c08c03eb32f7a6c221e6eefaa10e6f
github.com/kr/text 6807e777504f54ad073ecef66747de158294b639
github.com/olekukonko/ts ecf753e7c962639ab5a1fb46f7da627d4c0a04b8
github.com/spf13/cobra 864687ae689edc28688c67edef47e3d2ad651a1b
github.com/spf13/pflag 463bdc838f2b35e9307e91d480878bda5fff7232
github.com/technoweenie/go-contentaddressable 38171def3cd15e3b76eb156219b3d48704643899
github.com/rubyist/tracerx 51cd50e73e07cc41c22caec66af15313dff1aebb

21
Nut.toml Normal file

@ -0,0 +1,21 @@
[application]
name = "git-lfs"
version = "0.5.1"
authors = [
"Rick Olson <technoweenie@gmail.com>",
"Scott Barron <rubyist@github.com>",
]
[dependencies]
"github.com/cheggaaa/pb" = "bd14546a551971ae7f460e6d6e527c5b56cd38d7"
"github.com/kr/pretty" = "088c856450c08c03eb32f7a6c221e6eefaa10e6f"
"github.com/kr/pty" = "5cf931ef8f76dccd0910001d74a58a7fca84a83d"
"github.com/kr/text" = "6807e777504f54ad073ecef66747de158294b639"
"github.com/olekukonko/ts" = "ecf753e7c962639ab5a1fb46f7da627d4c0a04b8"
"github.com/rubyist/tracerx" = "51cd50e73e07cc41c22caec66af15313dff1aebb"
"github.com/spf13/cobra" = "864687ae689edc28688c67edef47e3d2ad651a1b"
"github.com/spf13/pflag" = "463bdc838f2b35e9307e91d480878bda5fff7232"
"github.com/technoweenie/assert" = "b25ea301d127043ffacf3b2545726e79b6632139"
"github.com/technoweenie/go-contentaddressable" = "38171def3cd15e3b76eb156219b3d48704643899"

@ -4,7 +4,7 @@ import (
"os"
"github.com/github/git-lfs/lfs"
"github.com/spf13/cobra"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
var (

@ -2,7 +2,7 @@ package commands
import (
"github.com/github/git-lfs/lfs"
"github.com/spf13/cobra"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
var (

@ -7,8 +7,8 @@ import (
"github.com/github/git-lfs/git"
"github.com/github/git-lfs/lfs"
"github.com/rubyist/tracerx"
"github.com/spf13/cobra"
"github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
var (

@ -2,7 +2,7 @@ package commands
import (
"github.com/github/git-lfs/lfs"
"github.com/spf13/cobra"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
var (

@ -7,7 +7,7 @@ import (
"path/filepath"
"github.com/github/git-lfs/lfs"
"github.com/spf13/cobra"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
var (

@ -3,7 +3,7 @@ package commands
import (
"github.com/github/git-lfs/git"
"github.com/github/git-lfs/lfs"
"github.com/spf13/cobra"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
var (

@ -11,7 +11,7 @@ import (
"os/exec"
"github.com/github/git-lfs/lfs"
"github.com/spf13/cobra"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
var (

@ -6,7 +6,7 @@ import (
"strings"
"github.com/github/git-lfs/lfs"
"github.com/spf13/cobra"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
var (

@ -7,8 +7,8 @@ import (
"github.com/github/git-lfs/git"
"github.com/github/git-lfs/lfs"
"github.com/rubyist/tracerx"
"github.com/spf13/cobra"
"github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
var (

@ -7,7 +7,7 @@ import (
"path/filepath"
"github.com/github/git-lfs/lfs"
"github.com/spf13/cobra"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
var (

@ -5,7 +5,7 @@ import (
"github.com/github/git-lfs/git"
"github.com/github/git-lfs/lfs"
"github.com/spf13/cobra"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
var (

@ -9,7 +9,7 @@ import (
"strings"
"github.com/github/git-lfs/lfs"
"github.com/spf13/cobra"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
var (

@ -7,7 +7,7 @@ import (
"strings"
"github.com/github/git-lfs/lfs"
"github.com/spf13/cobra"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
var (

@ -2,7 +2,7 @@ package commands
import (
"github.com/github/git-lfs/lfs"
"github.com/spf13/cobra"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
var (

@ -2,7 +2,7 @@ package commands
import (
"github.com/github/git-lfs/lfs"
"github.com/spf13/cobra"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
var (

@ -12,7 +12,7 @@ import (
"time"
"github.com/github/git-lfs/lfs"
"github.com/spf13/cobra"
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
var (

@ -8,7 +8,7 @@ import (
"os/exec"
"strings"
"github.com/rubyist/tracerx"
"github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx"
)
func LsRemote(remote, remoteRef string) (string, error) {

@ -14,7 +14,7 @@ import (
"regexp"
"strconv"
"github.com/rubyist/tracerx"
"github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx"
)
const (

@ -3,7 +3,7 @@ package lfs
import (
"testing"
"github.com/bmizerany/assert"
"github.com/github/git-lfs/vendor/_nuts/github.com/technoweenie/assert"
)
func TestEndpointDefaultsToOrigin(t *testing.T) {

@ -11,7 +11,7 @@ import (
"strings"
"time"
"github.com/rubyist/tracerx"
"github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx"
)
func DoHTTP(c *Configuration, req *http.Request) (*http.Response, error) {

@ -9,7 +9,7 @@ import (
"strings"
"github.com/github/git-lfs/git"
"github.com/rubyist/tracerx"
"github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx"
)
const Version = "0.5.1"

@ -6,9 +6,9 @@ import (
"os"
"path/filepath"
"github.com/cheggaaa/pb"
"github.com/rubyist/tracerx"
contentaddressable "github.com/technoweenie/go-contentaddressable"
"github.com/github/git-lfs/vendor/_nuts/github.com/cheggaaa/pb"
"github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx"
contentaddressable "github.com/github/git-lfs/vendor/_nuts/github.com/technoweenie/go-contentaddressable"
)
func PointerSmudge(writer io.Writer, ptr *Pointer, workingfile string, cb CopyCallback) error {

@ -6,7 +6,7 @@ import (
"strings"
"testing"
"github.com/bmizerany/assert"
"github.com/github/git-lfs/vendor/_nuts/github.com/technoweenie/assert"
)
func TestEncode(t *testing.T) {

@ -10,7 +10,7 @@ import (
"strings"
"time"
"github.com/rubyist/tracerx"
"github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx"
)
const (

@ -4,7 +4,7 @@ import (
"encoding/json"
"os/exec"
"github.com/rubyist/tracerx"
"github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx"
)
type sshAuthResponse struct {

@ -5,7 +5,7 @@ import (
"sync"
"sync/atomic"
"github.com/cheggaaa/pb"
"github.com/github/git-lfs/vendor/_nuts/github.com/cheggaaa/pb"
)
type Transferable interface {

@ -5,7 +5,7 @@ import (
"io/ioutil"
"testing"
"github.com/bmizerany/assert"
"github.com/github/git-lfs/vendor/_nuts/github.com/technoweenie/assert"
)
func TestWriterWithCallback(t *testing.T) {

@ -1,14 +1,5 @@
#!/bin/sh
script/fmt
rm -rf `pwd`/bin/*
rm -rf `pwd`/.vendor/pkg
export LOCALSRCDIR=`pwd`/.vendor/src/github.com/github/git-lfs
mkdir -p `dirname $LOCALSRCDIR`
rm -f $LOCALSRCDIR
ln -s `pwd` $LOCALSRCDIR
GOPATH="`pwd`/.vendor" \
go run script/*.go -cmd build "$@"

@ -94,15 +94,7 @@ func build(buildos, buildarch string, buildMatrix map[string]Release) error {
dir = filepath.Join(dir, "releases", buildos+"-"+buildarch, name)
}
filepath.Walk("cmd/git-lfs", func(path string, info os.FileInfo, err error) error {
if !strings.HasSuffix(path, ".go") {
return nil
}
cmd := filepath.Base(path)
cmd = cmd[0 : len(cmd)-3]
return buildCommand(path, dir, buildos, buildarch)
})
buildCommand(dir, buildos, buildarch)
if addenv {
err := os.MkdirAll(dir, 0755)
@ -121,18 +113,16 @@ func build(buildos, buildarch string, buildMatrix map[string]Release) error {
return nil
}
func buildCommand(path, dir, buildos, buildarch string) error {
func buildCommand(dir, buildos, buildarch string) error {
addenv := len(buildos) > 0 && len(buildarch) > 0
name := filepath.Base(path)
name = name[0 : len(name)-3]
bin := filepath.Join(dir, name)
bin := filepath.Join(dir, "git-lfs")
if buildos == "windows" {
bin = bin + ".exe"
}
cmd := exec.Command("go", "build", "-o", bin, path)
cmd := exec.Command("go", "build", "-o", bin, ".")
if addenv {
cmd.Env = []string{
"GOOS=" + buildos,

@ -6,7 +6,7 @@ hash goimports 2>/dev/null && {
}
# don't run gofmt in these directories
ignored=(/bin/ /docs/ /log/ /man/ /tmp/ .vendor)
ignored=(/bin/ /docs/ /log/ /man/ /tmp/ /vendor/)
for i in */ ; do
if [[ ! ${ignored[*]} =~ "/$i" ]]; then
$formatter -w -l "$@" "${i%?}"

@ -1,114 +0,0 @@
#!/usr/bin/env bash
# Copied from https://github.com/pote/gpm
#
# The MIT License
#
# Copyright (c) 2013 Pablo Astigarraga
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
#
set -eu
## Functions/
usage() {
cat << EOF
SYNOPSIS
gpm leverages the power of the go get command and the underlying version
control systems used by it to set your Go dependencies to desired versions,
thus allowing easily reproducible builds in your Go projects.
A Godeps file in the root of your Go application is expected containing
the import paths of your packages and a specific tag or commit hash
from its version control system, an example Godeps file looks like this:
$ cat Godeps
# This is a comment
github.com/nu7hatch/gotrail v0.0.2
github.com/replicon/fast-archiver v1.02 #This is another comment!
github.com/nu7hatch/gotrail 2eb79d1f03ab24bacbc32b15b75769880629a865
gpm has a companion tool, called [gvp](https://github.com/pote/gvp) which
provides vendoring functionalities, it alters your GOPATH so every project
has its own isolated dependency directory, it's usage is recommended.
USAGE
$ gpm # Same as 'install'.
$ gpm install # Parses the Godeps file, installs dependencies and sets
# them to the appropriate version.
$ gpm version # Outputs version information
$ gpm help # Prints this message
EOF
}
# Iterates over Godep file dependencies and sets
# the specified version on each of them.
set_dependencies() {
deps=$(sed 's/#.*//;/^\s*$/d' < $1) || echo ""
while read package version; do
(
install_path="${GOPATH%%:*}/src/${package%%/...}"
[[ -e "$install_path/.git/index.lock" ||
-e "$install_path/.hg/store/lock" ||
-e "$install_path/.bzr/checkout/lock" ]] && wait
echo ">> Getting package "$package""
go get -u -d "$package"
echo ">> Setting $package to version $version"
cd $install_path
[ -d .hg ] && hg update -q "$version"
[ -d .git ] && git checkout -q "$version"
[ -d .bzr ] && bzr revert -q -r "$version"
[ -d .svn ] && svn update -r "$version"
) &
done < <(echo "$deps")
wait
echo ">> All Done"
}
## /Functions
case "${1:-"install"}" in
"version")
echo ">> gpm v1.2.0"
;;
"install")
deps_file="Godeps"
[[ "$#" -eq 2 ]] && [[ -n "$2" ]] && deps_file="$2"
[[ -f "$deps_file" ]] || (echo ">> $deps_file file does not exist." && exit 1)
(which go > /dev/null) ||
( echo ">> Go is currently not installed or in your PATH" && exit 1)
set_dependencies $deps_file
;;
"help")
usage
;;
*)
## Support for Plugins: if command is unknown search for a gpm-command executable.
if command -v "gpm-$1" > /dev/null
then
plugin=$1 &&
shift &&
gpm-$plugin $@ &&
exit
else
usage && exit 1
fi
;;
esac

@ -1,4 +1,3 @@
#!/bin/sh
script/fmt
GOPATH="`pwd`/.vendor" \
go run script/*.go -cmd release "$@"

@ -1,2 +1,3 @@
#!/bin/sh
script/fmt
GOPATH="`pwd`/.vendor" go run cmd/git-lfs/git-lfs.go "$@"
go run ./git-lfs.go "$@"

@ -3,15 +3,8 @@
#/ script/test <subdir> # run just a package's tests
script/fmt
export LOCALSRCDIR=`pwd`/.vendor/src/github.com/github/git-lfs
mkdir -p `dirname $LOCALSRCDIR`
rm -f $LOCALSRCDIR
ln -s `pwd` $LOCALSRCDIR
GOPATH="`pwd`/.vendor"
SUITE="./${1:-"lfs"}"
suite="./${1:-"lfs"}"
if [ $# -gt 0 ]; then
shift
fi
PATH=$LOCALSRCDIR/bin:$PATH GOPATH=$GOPATH go test $SUITE "$@"
go test $suite "$@"

@ -1 +1,2 @@
GOPATH="`pwd`/.vendor" script/gpm install
#!/bin/sh
nut install

@ -33,7 +33,7 @@ github.com/rubyist/tracerx
github.com/technoweenie/go-contentaddressable
github.com/kr/pretty
github.com/github/git-lfs/git
github.com/bmizerany/assert
github.com/technoweenie/assert
=== RUN TestSuccessStatus
--- PASS: TestSuccessStatus (0.00 seconds)
PASS

@ -2,7 +2,7 @@ package main
import (
"fmt"
"github.com/cheggaaa/pb"
"github.com/github/git-lfs/vendor/_nuts/github.com/cheggaaa/pb"
"io"
"net/http"
"os"

@ -1,7 +1,7 @@
package main
import (
"github.com/cheggaaa/pb"
"github.com/github/git-lfs/vendor/_nuts/github.com/cheggaaa/pb"
"time"
)

@ -3,7 +3,7 @@
package pb
import (
"github.com/olekukonko/ts"
"github.com/github/git-lfs/vendor/_nuts/github.com/olekukonko/ts"
)
func bold(str string) string {

@ -2,7 +2,7 @@ package pretty_test
import (
"fmt"
"github.com/kr/pretty"
"github.com/github/git-lfs/vendor/_nuts/github.com/kr/pretty"
)
func Example() {

@ -7,7 +7,7 @@ import (
"strconv"
"text/tabwriter"
"github.com/kr/text"
"github.com/github/git-lfs/vendor/_nuts/github.com/kr/text"
)
const (

@ -0,0 +1,4 @@
[568].out
_go*
_test*
_obj

23
vendor/_nuts/github.com/kr/pty/License vendored Normal file

@ -0,0 +1,23 @@
Copyright (c) 2011 Keith Rarick
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall
be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -0,0 +1,36 @@
# pty
Pty is a Go package for using unix pseudo-terminals.
## Install
go get github.com/kr/pty
## Example
```go
package main
import (
"github.com/kr/pty"
"io"
"os"
"os/exec"
)
func main() {
c := exec.Command("grep", "--color=auto", "bar")
f, err := pty.Start(c)
if err != nil {
panic(err)
}
go func() {
f.Write([]byte("foo\n"))
f.Write([]byte("bar\n"))
f.Write([]byte("baz\n"))
f.Write([]byte{4}) // EOT
}()
io.Copy(os.Stdout, f)
}
```

16
vendor/_nuts/github.com/kr/pty/doc.go vendored Normal file

@ -0,0 +1,16 @@
// Package pty provides functions for working with Unix terminals.
package pty
import (
"errors"
"os"
)
// ErrUnsupported is returned if a function is not
// available on the current platform.
var ErrUnsupported = errors.New("unsupported")
// Opens a pty and its corresponding tty.
func Open() (pty, tty *os.File, err error) {
return open()
}

11
vendor/_nuts/github.com/kr/pty/ioctl.go vendored Normal file

@ -0,0 +1,11 @@
package pty
import "syscall"
func ioctl(fd, cmd, ptr uintptr) error {
_, _, e := syscall.Syscall(syscall.SYS_IOCTL, fd, cmd, ptr)
if e != 0 {
return e
}
return nil
}

@ -0,0 +1,39 @@
// +build darwin dragonfly freebsd netbsd openbsd
package pty
// from <sys/ioccom.h>
const (
_IOC_VOID uintptr = 0x20000000
_IOC_OUT uintptr = 0x40000000
_IOC_IN uintptr = 0x80000000
_IOC_IN_OUT uintptr = _IOC_OUT | _IOC_IN
_IOC_DIRMASK = _IOC_VOID | _IOC_OUT | _IOC_IN
_IOC_PARAM_SHIFT = 13
_IOC_PARAM_MASK = (1 << _IOC_PARAM_SHIFT) - 1
)
func _IOC_PARM_LEN(ioctl uintptr) uintptr {
return (ioctl >> 16) & _IOC_PARAM_MASK
}
func _IOC(inout uintptr, group byte, ioctl_num uintptr, param_len uintptr) uintptr {
return inout | (param_len&_IOC_PARAM_MASK)<<16 | uintptr(group)<<8 | ioctl_num
}
func _IO(group byte, ioctl_num uintptr) uintptr {
return _IOC(_IOC_VOID, group, ioctl_num, 0)
}
func _IOR(group byte, ioctl_num uintptr, param_len uintptr) uintptr {
return _IOC(_IOC_OUT, group, ioctl_num, param_len)
}
func _IOW(group byte, ioctl_num uintptr, param_len uintptr) uintptr {
return _IOC(_IOC_IN, group, ioctl_num, param_len)
}
func _IOWR(group byte, ioctl_num uintptr, param_len uintptr) uintptr {
return _IOC(_IOC_IN_OUT, group, ioctl_num, param_len)
}

@ -0,0 +1,19 @@
#!/usr/bin/env bash
GOOSARCH="${GOOS}_${GOARCH}"
case "$GOOSARCH" in
_* | *_ | _)
echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2
exit 1
;;
esac
GODEFS="go tool cgo -godefs"
$GODEFS types.go |gofmt > ztypes_$GOARCH.go
case $GOOS in
freebsd)
$GODEFS types_$GOOS.go |gofmt > ztypes_$GOOSARCH.go
;;
esac

@ -0,0 +1,60 @@
package pty
import (
"errors"
"os"
"syscall"
"unsafe"
)
func open() (pty, tty *os.File, err error) {
p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0)
if err != nil {
return nil, nil, err
}
sname, err := ptsname(p)
if err != nil {
return nil, nil, err
}
err = grantpt(p)
if err != nil {
return nil, nil, err
}
err = unlockpt(p)
if err != nil {
return nil, nil, err
}
t, err := os.OpenFile(sname, os.O_RDWR, 0)
if err != nil {
return nil, nil, err
}
return p, t, nil
}
func ptsname(f *os.File) (string, error) {
n := make([]byte, _IOC_PARM_LEN(syscall.TIOCPTYGNAME))
err := ioctl(f.Fd(), syscall.TIOCPTYGNAME, uintptr(unsafe.Pointer(&n[0])))
if err != nil {
return "", err
}
for i, c := range n {
if c == 0 {
return string(n[:i]), nil
}
}
return "", errors.New("TIOCPTYGNAME string not NUL-terminated")
}
func grantpt(f *os.File) error {
return ioctl(f.Fd(), syscall.TIOCPTYGRANT, 0)
}
func unlockpt(f *os.File) error {
return ioctl(f.Fd(), syscall.TIOCPTYUNLK, 0)
}

@ -0,0 +1,73 @@
package pty
import (
"errors"
"os"
"syscall"
"unsafe"
)
func posix_openpt(oflag int) (fd int, err error) {
r0, _, e1 := syscall.Syscall(syscall.SYS_POSIX_OPENPT, uintptr(oflag), 0, 0)
fd = int(r0)
if e1 != 0 {
err = e1
}
return
}
func open() (pty, tty *os.File, err error) {
fd, err := posix_openpt(syscall.O_RDWR | syscall.O_CLOEXEC)
if err != nil {
return nil, nil, err
}
p := os.NewFile(uintptr(fd), "/dev/pts")
sname, err := ptsname(p)
if err != nil {
return nil, nil, err
}
t, err := os.OpenFile("/dev/"+sname, os.O_RDWR, 0)
if err != nil {
return nil, nil, err
}
return p, t, nil
}
func isptmaster(fd uintptr) (bool, error) {
err := ioctl(fd, syscall.TIOCPTMASTER, 0)
return err == nil, err
}
var (
emptyFiodgnameArg fiodgnameArg
ioctl_FIODGNAME = _IOW('f', 120, unsafe.Sizeof(emptyFiodgnameArg))
)
func ptsname(f *os.File) (string, error) {
master, err := isptmaster(f.Fd())
if err != nil {
return "", err
}
if !master {
return "", syscall.EINVAL
}
const n = _C_SPECNAMELEN + 1
var (
buf = make([]byte, n)
arg = fiodgnameArg{Len: n, Buf: (*byte)(unsafe.Pointer(&buf[0]))}
)
err = ioctl(f.Fd(), ioctl_FIODGNAME, uintptr(unsafe.Pointer(&arg)))
if err != nil {
return "", err
}
for i, c := range buf {
if c == 0 {
return string(buf[:i]), nil
}
}
return "", errors.New("FIODGNAME string not NUL-terminated")
}

@ -0,0 +1,46 @@
package pty
import (
"os"
"strconv"
"syscall"
"unsafe"
)
func open() (pty, tty *os.File, err error) {
p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0)
if err != nil {
return nil, nil, err
}
sname, err := ptsname(p)
if err != nil {
return nil, nil, err
}
err = unlockpt(p)
if err != nil {
return nil, nil, err
}
t, err := os.OpenFile(sname, os.O_RDWR|syscall.O_NOCTTY, 0)
if err != nil {
return nil, nil, err
}
return p, t, nil
}
func ptsname(f *os.File) (string, error) {
var n _C_uint
err := ioctl(f.Fd(), syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n)))
if err != nil {
return "", err
}
return "/dev/pts/" + strconv.Itoa(int(n)), nil
}
func unlockpt(f *os.File) error {
var u _C_int
// use TIOCSPTLCK with a zero valued arg to clear the slave pty lock
return ioctl(f.Fd(), syscall.TIOCSPTLCK, uintptr(unsafe.Pointer(&u)))
}

@ -0,0 +1,11 @@
// +build !linux,!darwin,!freebsd
package pty
import (
"os"
)
func open() (pty, tty *os.File, err error) {
return nil, nil, ErrUnsupported
}

28
vendor/_nuts/github.com/kr/pty/run.go vendored Normal file

@ -0,0 +1,28 @@
package pty
import (
"os"
"os/exec"
"syscall"
)
// Start assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout,
// and c.Stderr, calls c.Start, and returns the File of the tty's
// corresponding pty.
func Start(c *exec.Cmd) (pty *os.File, err error) {
pty, tty, err := Open()
if err != nil {
return nil, err
}
defer tty.Close()
c.Stdout = tty
c.Stdin = tty
c.Stderr = tty
c.SysProcAttr = &syscall.SysProcAttr{Setctty: true, Setsid: true}
err = c.Start()
if err != nil {
pty.Close()
return nil, err
}
return pty, err
}

10
vendor/_nuts/github.com/kr/pty/types.go vendored Normal file

@ -0,0 +1,10 @@
// +build ignore
package pty
import "C"
type (
_C_int C.int
_C_uint C.uint
)

@ -0,0 +1,15 @@
// +build ignore
package pty
/*
#include <sys/param.h>
#include <sys/filio.h>
*/
import "C"
const (
_C_SPECNAMELEN = C.SPECNAMELEN /* max length of devicename */
)
type fiodgnameArg C.struct_fiodgname_arg

35
vendor/_nuts/github.com/kr/pty/util.go vendored Normal file

@ -0,0 +1,35 @@
package pty
import (
"os"
"syscall"
"unsafe"
)
// Getsize returns the number of rows (lines) and cols (positions
// in each line) in terminal t.
func Getsize(t *os.File) (rows, cols int, err error) {
var ws winsize
err = windowrect(&ws, t.Fd())
return int(ws.ws_row), int(ws.ws_col), err
}
type winsize struct {
ws_row uint16
ws_col uint16
ws_xpixel uint16
ws_ypixel uint16
}
func windowrect(ws *winsize, fd uintptr) error {
_, _, errno := syscall.Syscall(
syscall.SYS_IOCTL,
fd,
syscall.TIOCGWINSZ,
uintptr(unsafe.Pointer(ws)),
)
if errno != 0 {
return syscall.Errno(errno)
}
return nil
}

@ -0,0 +1,9 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs types.go
package pty
type (
_C_int int32
_C_uint uint32
)

@ -0,0 +1,9 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs types.go
package pty
type (
_C_int int32
_C_uint uint32
)

@ -0,0 +1,9 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs types.go
package pty
type (
_C_int int32
_C_uint uint32
)

@ -0,0 +1,11 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs types.go
// +build arm64
package pty
type (
_C_int int32
_C_uint uint32
)

@ -0,0 +1,13 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs types_freebsd.go
package pty
const (
_C_SPECNAMELEN = 0x3f
)
type fiodgnameArg struct {
Len int32
Buf *byte
}

@ -0,0 +1,14 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs types_freebsd.go
package pty
const (
_C_SPECNAMELEN = 0x3f
)
type fiodgnameArg struct {
Len int32
Pad_cgo_0 [4]byte
Buf *byte
}

@ -0,0 +1,13 @@
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs types_freebsd.go
package pty
const (
_C_SPECNAMELEN = 0x3f
)
type fiodgnameArg struct {
Len int32
Buf *byte
}

@ -0,0 +1,11 @@
// +build ppc64
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs types.go
package pty
type (
_C_int int32
_C_uint uint32
)

@ -0,0 +1,11 @@
// +build ppc64le
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs types.go
package pty
type (
_C_int int32
_C_uint uint32
)

@ -0,0 +1,11 @@
// +build s390x
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs types.go
package pty
type (
_C_int int32
_C_uint uint32
)

@ -10,8 +10,8 @@
package main
import (
"github.com/kr/pty"
"github.com/kr/text/colwriter"
"github.com/github/git-lfs/vendor/_nuts/github.com/kr/pty"
"github.com/github/git-lfs/vendor/_nuts/github.com/kr/text/colwriter"
"io"
"log"
"os"

Some files were not shown because too many files have changed in this diff Show More