aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-09-04 11:58:30 +0200
committerGitHub <noreply@github.com>2018-09-04 11:58:30 +0200
commit8e76874ae2a3f5029269af76a86f0ee294699df9 (patch)
tree47358d2a3004c293589334c8b341997e7b9ca936
parent7f42492cdeffaf2127e4050b1456f1f0b13f9bbd (diff)
parentba3ee05efbdeb11364d585ec4dfa84fe07e64430 (diff)
downloadgo-git-8e76874ae2a3f5029269af76a86f0ee294699df9.tar.gz
Merge pull request #939 from keybase/taruti/cherrypick-for-upstream-clamp-object-timestamp
Clamp object timestamps before unix epoch to unix epoch
-rw-r--r--plumbing/object/object.go6
-rw-r--r--plumbing/object/tag_test.go2
2 files changed, 6 insertions, 2 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
}
diff --git a/plumbing/object/tag_test.go b/plumbing/object/tag_test.go
index 9900093..e7dd06e 100644
--- a/plumbing/object/tag_test.go
+++ b/plumbing/object/tag_test.go
@@ -265,7 +265,7 @@ func (s *TagSuite) TestStringNonCommit(c *C) {
c.Assert(tag.String(), Equals,
"tag TAG TWO\n"+
"Tagger: <>\n"+
- "Date: Mon Jan 01 00:00:00 0001 +0000\n"+
+ "Date: Thu Jan 01 00:00:00 1970 +0000\n"+
"\n"+
"tag two\n")
}