aboutsummaryrefslogtreecommitdiffstats
path: root/worktree.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-01-31 13:00:36 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2017-01-31 13:16:13 +0100
commit09ac55657efcc3bb40db780ce9441095aea0d64c (patch)
tree4bdb61cd002686ab3b69569d739c4fe1efb76aa9 /worktree.go
parent387683bbcf40ed48e0f1ad0884970712f9682b9e (diff)
downloadgo-git-09ac55657efcc3bb40db780ce9441095aea0d64c.tar.gz
fix worktree at non linux os
Diffstat (limited to 'worktree.go')
-rw-r--r--worktree.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/worktree.go b/worktree.go
index 69ccd05..83e3bd3 100644
--- a/worktree.go
+++ b/worktree.go
@@ -6,7 +6,6 @@ import (
"io"
"os"
"syscall"
- "time"
"srcd.works/go-git.v4/plumbing"
"srcd.works/go-git.v4/plumbing/format/index"
@@ -72,6 +71,8 @@ func (w *Worktree) checkoutFile(f *object.File, idx *index.Index) error {
return w.indexFile(f, idx)
}
+var fillSystemInfo func(e *index.Entry, os *syscall.Stat_t)
+
func (w *Worktree) indexFile(f *object.File, idx *index.Index) error {
fi, err := w.fs.Stat(f.Name)
if err != nil {
@@ -89,12 +90,8 @@ func (w *Worktree) indexFile(f *object.File, idx *index.Index) error {
// if the FileInfo.Sys() comes from os the ctime, dev, inode, uid and gid
// can be retrieved, otherwise this doesn't apply
os, ok := fi.Sys().(*syscall.Stat_t)
- if ok {
- e.CreatedAt = time.Unix(int64(os.Ctim.Sec), int64(os.Ctim.Nsec))
- e.Dev = uint32(os.Dev)
- e.Inode = uint32(os.Ino)
- e.GID = os.Gid
- e.UID = os.Uid
+ if ok && fillSystemInfo != nil {
+ fillSystemInfo(&e, os)
}
idx.Entries = append(idx.Entries, e)