diff options
author | Taru Karttunen <taruti@taruti.net> | 2018-08-29 12:43:23 +0000 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2018-08-29 13:44:35 +0000 |
commit | ba3ee05efbdeb11364d585ec4dfa84fe07e64430 (patch) | |
tree | c324dbc27e41c6db87386ccb643bf0b482784a6d /plumbing/object/object.go | |
parent | 1cef577576855d92ca4a3b23e205d08b3dac9027 (diff) | |
download | go-git-ba3ee05efbdeb11364d585ec4dfa84fe07e64430.tar.gz |
plumbing: object: Clamp object timestamps before unix epoch to unix epoch
Signed-off-by: Taru Karttunen <taruti@taruti.net>
Diffstat (limited to 'plumbing/object/object.go')
-rw-r--r-- | plumbing/object/object.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/plumbing/object/object.go b/plumbing/object/object.go index 4b59aba..e960e50 100644 --- a/plumbing/object/object.go +++ b/plumbing/object/object.go @@ -152,7 +152,11 @@ func (s *Signature) decodeTimeAndTimeZone(b []byte) { } func (s *Signature) encodeTimeAndTimeZone(w io.Writer) error { - _, err := fmt.Fprintf(w, "%d %s", s.When.Unix(), s.When.Format("-0700")) + u := s.When.Unix() + if u < 0 { + u = 0 + } + _, err := fmt.Fprintf(w, "%d %s", u, s.When.Format("-0700")) return err } |