Merge pull request #3349 from steffengodskesen/tasklog-suppress-progress

tasklog: don't log progress status when stdout is not a tty
This commit is contained in:
Taylor Blau 2018-11-14 14:36:15 -08:00 committed by GitHub
commit 5a3e5e9331
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 417 additions and 24 deletions

@ -47,7 +47,9 @@ func checkoutCommand(cmd *cobra.Command, args []string) {
var totalBytes int64
var pointers []*lfs.WrappedPointer
logger := tasklog.NewLogger(os.Stdout)
logger := tasklog.NewLogger(os.Stdout,
tasklog.ForceProgress(cfg.ForceProgress()),
)
meter := tq.NewMeter()
meter.Direction = tq.Checkout
meter.Logger = meter.LoggerFromEnv(cfg.Os)

@ -230,7 +230,9 @@ func scanAll() []*lfs.WrappedPointer {
task := tasklog.NewSimpleTask()
defer task.Complete()
logger := tasklog.NewLogger(OutputWriter)
logger := tasklog.NewLogger(OutputWriter,
tasklog.ForceProgress(cfg.ForceProgress()),
)
logger.Enqueue(task)
var numObjs int64
@ -324,7 +326,9 @@ func fetchAndReportToChan(allpointers []*lfs.WrappedPointer, filter *filepathfil
}
func readyAndMissingPointers(allpointers []*lfs.WrappedPointer, filter *filepathfilter.Filter) ([]*lfs.WrappedPointer, []*lfs.WrappedPointer, *tq.Meter) {
logger := tasklog.NewLogger(os.Stdout)
logger := tasklog.NewLogger(os.Stdout,
tasklog.ForceProgress(cfg.ForceProgress()),
)
meter := buildProgressMeter(false, tq.Download)
logger.Enqueue(meter)

@ -19,7 +19,9 @@ import (
func migrateExportCommand(cmd *cobra.Command, args []string) {
ensureWorkingCopyClean(os.Stdin, os.Stderr)
l := tasklog.NewLogger(os.Stderr)
l := tasklog.NewLogger(os.Stderr,
tasklog.ForceProgress(cfg.ForceProgress()),
)
defer l.Close()
db, err := getObjectDatabase()

@ -24,7 +24,9 @@ import (
func migrateImportCommand(cmd *cobra.Command, args []string) {
ensureWorkingCopyClean(os.Stdin, os.Stderr)
l := tasklog.NewLogger(os.Stderr)
l := tasklog.NewLogger(os.Stderr,
tasklog.ForceProgress(cfg.ForceProgress()),
)
defer l.Close()
db, err := getObjectDatabase()

@ -40,7 +40,9 @@ var (
)
func migrateInfoCommand(cmd *cobra.Command, args []string) {
l := tasklog.NewLogger(os.Stderr)
l := tasklog.NewLogger(os.Stderr,
tasklog.ForceProgress(cfg.ForceProgress()),
)
db, err := getObjectDatabase()
if err != nil {

@ -57,7 +57,9 @@ func prune(fetchPruneConfig lfs.FetchPruneConfig, verifyRemote, dryRun, verbose
localObjects := make([]fs.Object, 0, 100)
retainedObjects := tools.NewStringSetWithCapacity(100)
logger := tasklog.NewLogger(OutputWriter)
logger := tasklog.NewLogger(OutputWriter,
tasklog.ForceProgress(cfg.ForceProgress()),
)
defer logger.Close()
var reachableObjects tools.StringSet

@ -38,7 +38,9 @@ func pull(filter *filepathfilter.Filter) {
}
pointers := newPointerMap()
logger := tasklog.NewLogger(os.Stdout)
logger := tasklog.NewLogger(os.Stdout,
tasklog.ForceProgress(cfg.ForceProgress()),
)
meter := tq.NewMeter()
meter.Logger = meter.LoggerFromEnv(cfg.Os)
logger.Enqueue(meter)

@ -30,8 +30,8 @@ import (
var (
Debugging = false
ErrorBuffer = &bytes.Buffer{}
ErrorWriter = io.MultiWriter(os.Stderr, ErrorBuffer)
OutputWriter = io.MultiWriter(os.Stdout, ErrorBuffer)
ErrorWriter = newMultiWriter(os.Stderr, ErrorBuffer)
OutputWriter = newMultiWriter(os.Stdout, ErrorBuffer)
ManPages = make(map[string]string, 20)
tqManifest = make(map[string]*tq.Manifest)

26
commands/multiwriter.go Normal file

@ -0,0 +1,26 @@
package commands
import (
"io"
"os"
)
type multiWriter struct {
writer io.Writer
fd uintptr
}
func newMultiWriter(f *os.File, writers ...io.Writer) *multiWriter {
return &multiWriter{
writer: io.MultiWriter(append([]io.Writer{f}, writers...)...),
fd: f.Fd(),
}
}
func (w *multiWriter) Write(p []byte) (n int, err error) {
return w.writer.Write(p)
}
func (w *multiWriter) Fd() uintptr {
return w.fd
}

@ -111,7 +111,9 @@ func newUploadContext(dryRun bool) *uploadContext {
sink = ioutil.Discard
}
ctx.logger = tasklog.NewLogger(sink)
ctx.logger = tasklog.NewLogger(sink,
tasklog.ForceProgress(cfg.ForceProgress()),
)
ctx.meter = buildProgressMeter(ctx.DryRun, tq.Upload)
ctx.logger.Enqueue(ctx.meter)
ctx.committerName, ctx.committerEmail = cfg.CurrentCommitter()

@ -308,6 +308,10 @@ func (c *Configuration) SetLockableFilesReadOnly() bool {
return c.Os.Bool("GIT_LFS_SET_LOCKABLE_READONLY", true) && c.Git.Bool("lfs.setlockablereadonly", true)
}
func (c *Configuration) ForceProgress() bool {
return c.Os.Bool("GIT_LFS_FORCE_PROGRESS", false) || c.Git.Bool("lfs.forceprogress", false)
}
// HookDir returns the location of the hooks owned by this repository. If the
// core.hooksPath configuration variable is supported, we prefer that and expand
// paths appropriately.

@ -306,6 +306,16 @@ be scoped inside the configuration for a remote.
* `total` The entire size of the file, in bytes.
* `name` The name of the file.
* `GIT_LFS_FORCE_PROGRESS`
`lfs.forceprogress`
Controls whether Git LFS will suppress progress status when the standard
output stream is not attached to a terminal. The default is `false` which
makes Git LFS detect whether stdout is a terminal and suppress progress when
it's not; you can disable this behaviour and force progress status even when
standard output stream is not a terminal by setting either variable to 1,
'yes' or 'true'.
* `GIT_LFS_SET_LOCKABLE_READONLY`
`lfs.setlockablereadonly`

@ -158,10 +158,12 @@ var (
}
}
// WithLoggerto logs updates caused by the *git/githistory.Rewriter to
// WithLoggerTo logs updates caused by the *git/githistory.Rewriter to
// the given io.Writer "sink".
WithLoggerTo = func(sink io.Writer) rewriterOption {
return WithLogger(tasklog.NewLogger(sink))
WithLoggerTo = func(sink io.Writer, forceProgress bool) rewriterOption {
return WithLogger(tasklog.NewLogger(sink,
tasklog.ForceProgress(forceProgress),
))
}
// WithLogger logs updates caused by the *git/githistory.Rewriter to the

1
go.mod

@ -8,6 +8,7 @@ require (
github.com/git-lfs/wildmatch v1.0.0
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/kr/pty v0.0.0-20150511174710-5cf931ef8f76
github.com/mattn/go-isatty v0.0.4
github.com/olekukonko/ts v0.0.0-20171002115256-78ecb04241c0
github.com/pkg/errors v0.0.0-20170505043639-c605e284fe17
github.com/rubyist/tracerx v0.0.0-20170927163412-787959303086

2
go.sum

@ -14,6 +14,8 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/kr/pty v0.0.0-20150511174710-5cf931ef8f76 h1:i5TIRQpbCg4aJMUtVHIhkQnSw++Z405Z5pzqHqeNkdU=
github.com/kr/pty v0.0.0-20150511174710-5cf931ef8f76/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/olekukonko/ts v0.0.0-20171002115256-78ecb04241c0 h1:LiZB1h0GIcudcDci2bxbqI6DXV8bF8POAnArqvRrIyw=
github.com/olekukonko/ts v0.0.0-20171002115256-78ecb04241c0/go.mod h1:F/7q8/HZz+TXjlsoZQQKVYvXTZaFH4QRa3y+j1p7MS0=
github.com/pkg/errors v0.0.0-20170505043639-c605e284fe17 h1:chPfVn+gpAM5CTpTyVU9j8J+xgRGwmoDlNDLjKnJiYo=

@ -182,7 +182,9 @@ func buildTestData(repo *t.Repo, manifest *tq.Manifest) (oidsExist, oidsMissing
oidsMissing = make([]TestObject, 0, oidCount)
// just one commit
logger := tasklog.NewLogger(os.Stdout)
logger := tasklog.NewLogger(os.Stdout,
tasklog.ForceProgress(false),
)
meter := tq.NewMeter()
meter.Logger = meter.LoggerFromEnv(repo.OSEnv())
logger.Enqueue(meter)

@ -123,12 +123,14 @@ LFS_CLIENT_KEY_FILE_ENCRYPTED="$REMOTEDIR/client.enc.key"
# the fake home dir used for the initial setup
TESTHOME="$REMOTEDIR/home"
GIT_LFS_FORCE_PROGRESS=1
GIT_CONFIG_NOSYSTEM=1
GIT_TERMINAL_PROMPT=0
GIT_SSH=lfs-ssh-echo
APPVEYOR_REPO_COMMIT_MESSAGE="test: env test should look for GIT_SSH too"
export CREDSDIR
export GIT_LFS_FORCE_PROGRESS
export GIT_CONFIG_NOSYSTEM
export GIT_SSH
export APPVEYOR_REPO_COMMIT_MESSAGE

@ -4,10 +4,12 @@ import (
"fmt"
"io"
"io/ioutil"
"os"
"strings"
"sync"
"time"
isatty "github.com/mattn/go-isatty"
"github.com/olekukonko/ts"
)
@ -25,6 +27,12 @@ type Logger struct {
// this logger is running within.
widthFn func() int
// tty is true if sink is connected to a terminal
tty bool
// forceProgress forces progress status even when stdout is not a tty
forceProgress bool
// throttle is the minimum amount of time that must pass between each
// instant data is logged.
throttle time.Duration
@ -38,9 +46,21 @@ type Logger struct {
wg *sync.WaitGroup
}
// Option is the type for
type Option func(*Logger)
// ForceProgress returns an options function that configures forced progress status
// on the logger.
func ForceProgress(v bool) Option {
return func(l *Logger) {
l.forceProgress = v
}
}
// NewLogger retuns a new *Logger instance that logs to "sink" and uses the
// current terminal width as the width of the line.
func NewLogger(sink io.Writer) *Logger {
// current terminal width as the width of the line. Will log progress status if
// stdout is a terminal or if forceProgress is true
func NewLogger(sink io.Writer, options ...Option) *Logger {
if sink == nil {
sink = ioutil.Discard
}
@ -60,11 +80,29 @@ func NewLogger(sink io.Writer) *Logger {
wg: new(sync.WaitGroup),
}
for _, option := range options {
option(l)
}
l.tty = tty(sink)
go l.consume()
return l
}
type hasFd interface {
Fd() uintptr
}
// tty returns true if the writer is connected to a tty
func tty(writer io.Writer) bool {
if v, ok := writer.(hasFd); ok {
return isatty.IsTerminal(v.Fd())
}
return false
}
// Close closes the queue and does not allow new Tasks to be `enqueue()`'d. It
// waits until the currently running Task has completed.
func (l *Logger) Close() {
@ -214,6 +252,9 @@ func (l *Logger) logTask(task Task) {
var update *Update
for update = range task.Updates() {
if !isatty.IsTerminal(os.Stdout.Fd()) && !l.forceProgress {
continue
}
if logAll || l.throttle == 0 || !update.Throttled(last.Add(l.throttle)) {
l.logLine(update.S)
last = update.At

@ -31,7 +31,7 @@ func TestLoggerLogsTasks(t *testing.T) {
close(task)
}()
l := NewLogger(&buf)
l := NewLogger(&buf, ForceProgress(true))
l.throttle = 0
l.widthFn = func() int { return 0 }
l.Enqueue(ChanTask(task))
@ -40,6 +40,25 @@ func TestLoggerLogsTasks(t *testing.T) {
assert.Equal(t, "first\rsecond\rsecond, done\n", buf.String())
}
func TestLoggerLogsSuppressesProgress(t *testing.T) {
var buf bytes.Buffer
task := make(chan *Update)
go func() {
task <- &Update{"first", time.Now(), false}
task <- &Update{"second", time.Now(), false}
close(task)
}()
l := NewLogger(&buf, ForceProgress(false))
l.throttle = 0
l.widthFn = func() int { return 0 }
l.Enqueue(ChanTask(task))
l.Close()
assert.Equal(t, "second, done\n", buf.String())
}
func TestLoggerLogsMultipleTasksInOrder(t *testing.T) {
var buf bytes.Buffer
@ -56,7 +75,7 @@ func TestLoggerLogsMultipleTasksInOrder(t *testing.T) {
close(t2)
}()
l := NewLogger(&buf)
l := NewLogger(&buf, ForceProgress(true))
l.throttle = 0
l.widthFn = func() int { return 0 }
l.Enqueue(ChanTask(t1), ChanTask(t2))
@ -75,7 +94,7 @@ func TestLoggerLogsMultipleTasksInOrder(t *testing.T) {
func TestLoggerLogsMultipleTasksWithoutBlocking(t *testing.T) {
var buf bytes.Buffer
l := NewLogger(&buf)
l := NewLogger(&buf, ForceProgress(true))
l.throttle = 0
t1, t2 := make(chan *Update), make(chan *Update)
@ -112,7 +131,7 @@ func TestLoggerThrottlesWrites(t *testing.T) {
close(t1) // t = 20+2ε ms, throttle is closed
}()
l := NewLogger(&buf)
l := NewLogger(&buf, ForceProgress(true))
l.widthFn = func() int { return 0 }
l.throttle = 15 * time.Millisecond
@ -139,7 +158,7 @@ func TestLoggerThrottlesLastWrite(t *testing.T) {
close(t1) // t = 10+2ε ms, throttle is closed
}()
l := NewLogger(&buf)
l := NewLogger(&buf, ForceProgress(true))
l.widthFn = func() int { return 0 }
l.throttle = 15 * time.Millisecond
@ -155,7 +174,7 @@ func TestLoggerThrottlesLastWrite(t *testing.T) {
func TestLoggerLogsAllDurableUpdates(t *testing.T) {
var buf bytes.Buffer
l := NewLogger(&buf)
l := NewLogger(&buf, ForceProgress(true))
l.widthFn = func() int { return 0 }
l.throttle = 15 * time.Minute
@ -182,7 +201,7 @@ func TestLoggerHandlesSilentTasks(t *testing.T) {
task := make(chan *Update)
close(task)
l := NewLogger(&buf)
l := NewLogger(&buf, ForceProgress(true))
l.Enqueue(ChanTask(task))
l.Close()

13
vendor/github.com/mattn/go-isatty/.travis.yml generated vendored Normal file

@ -0,0 +1,13 @@
language: go
go:
- tip
os:
- linux
- osx
before_install:
- go get github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/cover
script:
- $HOME/gopath/bin/goveralls -repotoken 3gHdORO5k5ziZcWMBxnd9LrMZaJs8m9x5

9
vendor/github.com/mattn/go-isatty/LICENSE generated vendored Normal file

@ -0,0 +1,9 @@
Copyright (c) Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
MIT License (Expat)
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.

50
vendor/github.com/mattn/go-isatty/README.md generated vendored Normal file

@ -0,0 +1,50 @@
# go-isatty
[![Godoc Reference](https://godoc.org/github.com/mattn/go-isatty?status.svg)](http://godoc.org/github.com/mattn/go-isatty)
[![Build Status](https://travis-ci.org/mattn/go-isatty.svg?branch=master)](https://travis-ci.org/mattn/go-isatty)
[![Coverage Status](https://coveralls.io/repos/github/mattn/go-isatty/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-isatty?branch=master)
[![Go Report Card](https://goreportcard.com/badge/mattn/go-isatty)](https://goreportcard.com/report/mattn/go-isatty)
isatty for golang
## Usage
```go
package main
import (
"fmt"
"github.com/mattn/go-isatty"
"os"
)
func main() {
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Println("Is Terminal")
} else if isatty.IsCygwinTerminal(os.Stdout.Fd()) {
fmt.Println("Is Cygwin/MSYS2 Terminal")
} else {
fmt.Println("Is Not Terminal")
}
}
```
## Installation
```
$ go get github.com/mattn/go-isatty
```
## License
MIT
## Author
Yasuhiro Matsumoto (a.k.a mattn)
## Thanks
* k-takata: base idea for IsCygwinTerminal
https://github.com/k-takata/go-iscygpty

2
vendor/github.com/mattn/go-isatty/doc.go generated vendored Normal file

@ -0,0 +1,2 @@
// Package isatty implements interface to isatty
package isatty

15
vendor/github.com/mattn/go-isatty/isatty_appengine.go generated vendored Normal file

@ -0,0 +1,15 @@
// +build appengine
package isatty
// IsTerminal returns true if the file descriptor is terminal which
// is always false on on appengine classic which is a sandboxed PaaS.
func IsTerminal(fd uintptr) bool {
return false
}
// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
// terminal. This is also always false on this environment.
func IsCygwinTerminal(fd uintptr) bool {
return false
}

18
vendor/github.com/mattn/go-isatty/isatty_bsd.go generated vendored Normal file

@ -0,0 +1,18 @@
// +build darwin freebsd openbsd netbsd dragonfly
// +build !appengine
package isatty
import (
"syscall"
"unsafe"
)
const ioctlReadTermios = syscall.TIOCGETA
// IsTerminal return true if the file descriptor is terminal.
func IsTerminal(fd uintptr) bool {
var termios syscall.Termios
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
return err == 0
}

18
vendor/github.com/mattn/go-isatty/isatty_linux.go generated vendored Normal file

@ -0,0 +1,18 @@
// +build linux
// +build !appengine,!ppc64,!ppc64le
package isatty
import (
"syscall"
"unsafe"
)
const ioctlReadTermios = syscall.TCGETS
// IsTerminal return true if the file descriptor is terminal.
func IsTerminal(fd uintptr) bool {
var termios syscall.Termios
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
return err == 0
}

@ -0,0 +1,19 @@
// +build linux
// +build ppc64 ppc64le
package isatty
import (
"unsafe"
syscall "golang.org/x/sys/unix"
)
const ioctlReadTermios = syscall.TCGETS
// IsTerminal return true if the file descriptor is terminal.
func IsTerminal(fd uintptr) bool {
var termios syscall.Termios
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
return err == 0
}

10
vendor/github.com/mattn/go-isatty/isatty_others.go generated vendored Normal file

@ -0,0 +1,10 @@
// +build !windows
// +build !appengine
package isatty
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
// terminal. This is also always false on this environment.
func IsCygwinTerminal(fd uintptr) bool {
return false
}

16
vendor/github.com/mattn/go-isatty/isatty_solaris.go generated vendored Normal file

@ -0,0 +1,16 @@
// +build solaris
// +build !appengine
package isatty
import (
"golang.org/x/sys/unix"
)
// IsTerminal returns true if the given file descriptor is a terminal.
// see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c
func IsTerminal(fd uintptr) bool {
var termio unix.Termio
err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio)
return err == nil
}

94
vendor/github.com/mattn/go-isatty/isatty_windows.go generated vendored Normal file

@ -0,0 +1,94 @@
// +build windows
// +build !appengine
package isatty
import (
"strings"
"syscall"
"unicode/utf16"
"unsafe"
)
const (
fileNameInfo uintptr = 2
fileTypePipe = 3
)
var (
kernel32 = syscall.NewLazyDLL("kernel32.dll")
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx")
procGetFileType = kernel32.NewProc("GetFileType")
)
func init() {
// Check if GetFileInformationByHandleEx is available.
if procGetFileInformationByHandleEx.Find() != nil {
procGetFileInformationByHandleEx = nil
}
}
// IsTerminal return true if the file descriptor is terminal.
func IsTerminal(fd uintptr) bool {
var st uint32
r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0)
return r != 0 && e == 0
}
// Check pipe name is used for cygwin/msys2 pty.
// Cygwin/MSYS2 PTY has a name like:
// \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master
func isCygwinPipeName(name string) bool {
token := strings.Split(name, "-")
if len(token) < 5 {
return false
}
if token[0] != `\msys` && token[0] != `\cygwin` {
return false
}
if token[1] == "" {
return false
}
if !strings.HasPrefix(token[2], "pty") {
return false
}
if token[3] != `from` && token[3] != `to` {
return false
}
if token[4] != "master" {
return false
}
return true
}
// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
// terminal.
func IsCygwinTerminal(fd uintptr) bool {
if procGetFileInformationByHandleEx == nil {
return false
}
// Cygwin/msys's pty is a pipe.
ft, _, e := syscall.Syscall(procGetFileType.Addr(), 1, fd, 0, 0)
if ft != fileTypePipe || e != 0 {
return false
}
var buf [2 + syscall.MAX_PATH]uint16
r, _, e := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(),
4, fd, fileNameInfo, uintptr(unsafe.Pointer(&buf)),
uintptr(len(buf)*2), 0, 0)
if r == 0 || e != 0 {
return false
}
l := *(*uint32)(unsafe.Pointer(&buf))
return isCygwinPipeName(string(utf16.Decode(buf[2 : 2+l/2])))
}

2
vendor/modules.txt vendored

@ -19,6 +19,8 @@ github.com/git-lfs/wildmatch
github.com/inconshreveable/mousetrap
# github.com/kr/pty v0.0.0-20150511174710-5cf931ef8f76
github.com/kr/pty
# github.com/mattn/go-isatty v0.0.4
github.com/mattn/go-isatty
# github.com/olekukonko/ts v0.0.0-20171002115256-78ecb04241c0
github.com/olekukonko/ts
# github.com/pkg/errors v0.0.0-20170505043639-c605e284fe17