diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-01-30 16:24:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-30 16:24:07 +0100 |
commit | a24e40af0aa2d9d512051269993a1b08c0496d12 (patch) | |
tree | 65936a6a365263c93e4b57c3b67aad6a13489e68 /plumbing/format | |
parent | a48bc6e17ef6298f93ec21cdf1a5e387640673b6 (diff) | |
parent | 35378e7db9288e8244f2634a1b47981606731cef (diff) | |
download | go-git-a24e40af0aa2d9d512051269993a1b08c0496d12.tar.gz |
Merge pull request #229 from mcuadros/worktree
Worktree and new Repository Contructors
Diffstat (limited to 'plumbing/format')
-rw-r--r-- | plumbing/format/index/decoder.go | 11 | ||||
-rw-r--r-- | plumbing/format/index/decoder_test.go | 7 |
2 files changed, 12 insertions, 6 deletions
diff --git a/plumbing/format/index/decoder.go b/plumbing/format/index/decoder.go index 9069c9e..aba5fe8 100644 --- a/plumbing/format/index/decoder.go +++ b/plumbing/format/index/decoder.go @@ -112,8 +112,15 @@ func (d *Decoder) readEntry(idx *Index) (*Entry, error) { } read := entryHeaderLength - e.CreatedAt = time.Unix(int64(sec), int64(nsec)) - e.ModifiedAt = time.Unix(int64(msec), int64(mnsec)) + + if sec != 0 || nsec != 0 { + e.CreatedAt = time.Unix(int64(sec), int64(nsec)) + } + + if msec != 0 || mnsec != 0 { + e.ModifiedAt = time.Unix(int64(msec), int64(mnsec)) + } + e.Stage = Stage(flags>>12) & 0x3 if flags&entryExtended != 0 { diff --git a/plumbing/format/index/decoder_test.go b/plumbing/format/index/decoder_test.go index 4614701..47a8186 100644 --- a/plumbing/format/index/decoder_test.go +++ b/plumbing/format/index/decoder_test.go @@ -41,6 +41,7 @@ func (s *IndexSuite) TestDecodeEntries(c *C) { c.Assert(idx.Entries, HasLen, 9) e := idx.Entries[0] + c.Assert(e.CreatedAt.Unix(), Equals, int64(1480626693)) c.Assert(e.CreatedAt.Nanosecond(), Equals, 498593596) c.Assert(e.ModifiedAt.Unix(), Equals, int64(1480626693)) @@ -111,10 +112,8 @@ func (s *IndexSuite) TestDecodeMergeConflict(c *C) { // stagged files for i, e := range idx.Entries[4:7] { c.Assert(e.Stage, Equals, expected[i].Stage) - c.Assert(e.CreatedAt.Unix(), Equals, int64(0)) - c.Assert(e.CreatedAt.Nanosecond(), Equals, 0) - c.Assert(e.ModifiedAt.Unix(), Equals, int64(0)) - c.Assert(e.ModifiedAt.Nanosecond(), Equals, 0) + c.Assert(e.CreatedAt.IsZero(), Equals, true) + c.Assert(e.ModifiedAt.IsZero(), Equals, true) c.Assert(e.Dev, Equals, uint32(0)) c.Assert(e.Inode, Equals, uint32(0)) c.Assert(e.UID, Equals, uint32(0)) |