aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/index/decoder.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-01-28 18:40:43 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2017-01-28 18:40:43 +0100
commit60124e2bfd15c76738d429368b05a13f537a27d9 (patch)
tree645b152da4cad81f00c827c0f79d67fb21e150a3 /plumbing/format/index/decoder.go
parent9a9f2b1f63a98fad67a3190ef813428b68dfdd8c (diff)
downloadgo-git-60124e2bfd15c76738d429368b05a13f537a27d9.tar.gz
format/index: keep time.Time as zero, when decoded value is 0
Diffstat (limited to 'plumbing/format/index/decoder.go')
-rw-r--r--plumbing/format/index/decoder.go11
1 files changed, 9 insertions, 2 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 {