diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-07-19 00:09:39 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-07-19 00:09:39 +0200 |
commit | 1675edbff5055189d958244b6e0ded9f5d37fe91 (patch) | |
tree | 61a73a8008e460120c7f2a6880af1d3498c8d275 | |
parent | ae80735ce2171aff4c44313b3c27eb5ddb595385 (diff) | |
download | go-git-1675edbff5055189d958244b6e0ded9f5d37fe91.tar.gz |
worktree: fix file system info in windows
-rw-r--r-- | worktree_linux.go | 1 | ||||
-rw-r--r-- | worktree_windows.go | 20 |
2 files changed, 20 insertions, 1 deletions
diff --git a/worktree_linux.go b/worktree_linux.go index 7209d7d..a33cd2f 100644 --- a/worktree_linux.go +++ b/worktree_linux.go @@ -12,7 +12,6 @@ import ( func init() { fillSystemInfo = func(e *index.Entry, sys interface{}) { if os, ok := sys.(*syscall.Stat_t); ok { - e.CreatedAt = time.Unix(int64(os.Ctim.Sec), int64(os.Ctim.Nsec)) e.Dev = uint32(os.Dev) e.Inode = uint32(os.Ino) diff --git a/worktree_windows.go b/worktree_windows.go new file mode 100644 index 0000000..d59448e --- /dev/null +++ b/worktree_windows.go @@ -0,0 +1,20 @@ +// +build windows + +package git + +import ( + "syscall" + "time" + + "gopkg.in/src-d/go-git.v4/plumbing/format/index" +) + +func init() { + fillSystemInfo = func(e *index.Entry, sys interface{}) { + if os, ok := sys.(*syscall.Win32FileAttributeData); ok { + seconds := os.CreationTime.Nanoseconds() / 1000000000 + nanoseconds := os.CreationTime.Nanoseconds() - seconds*1000000000 + e.CreatedAt = time.Unix(seconds, nanoseconds) + } + } +} |