aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plumbing/format/packfile/delta_selector.go5
-rw-r--r--plumbing/format/packfile/encoder_test.go4
-rw-r--r--plumbing/format/packfile/object_pack.go17
-rw-r--r--plumbing/transport/ssh/auth_method.go4
-rw-r--r--storage/filesystem/shallow.go2
5 files changed, 21 insertions, 11 deletions
diff --git a/plumbing/format/packfile/delta_selector.go b/plumbing/format/packfile/delta_selector.go
index 1d9fb5f..6710085 100644
--- a/plumbing/format/packfile/delta_selector.go
+++ b/plumbing/format/packfile/delta_selector.go
@@ -103,7 +103,7 @@ func (dw *deltaSelector) objectsToPack(
otp := newObjectToPack(o)
if _, ok := o.(plumbing.DeltaObject); ok {
- otp.Original = nil
+ otp.CleanOriginal()
}
objectsToPack = append(objectsToPack, otp)
@@ -231,7 +231,8 @@ func (dw *deltaSelector) walk(
delete(indexMap, obj.Hash())
if obj.IsDelta() {
- obj.Original = nil
+ obj.SaveOriginalMetadata()
+ obj.CleanOriginal()
}
}
diff --git a/plumbing/format/packfile/encoder_test.go b/plumbing/format/packfile/encoder_test.go
index 63dfafa..84d03fb 100644
--- a/plumbing/format/packfile/encoder_test.go
+++ b/plumbing/format/packfile/encoder_test.go
@@ -233,10 +233,10 @@ func (s *EncoderSuite) deltaOverDeltaCyclicTest(c *C) {
// is nil.
po1.SetOriginal(po1.Original)
pd2.SetOriginal(pd2.Original)
- pd2.SetOriginal(nil)
+ pd2.CleanOriginal()
pd3.SetOriginal(pd3.Original)
- pd3.SetOriginal(nil)
+ pd3.CleanOriginal()
pd4.SetOriginal(pd4.Original)
diff --git a/plumbing/format/packfile/object_pack.go b/plumbing/format/packfile/object_pack.go
index 877581e..dfea571 100644
--- a/plumbing/format/packfile/object_pack.go
+++ b/plumbing/format/packfile/object_pack.go
@@ -81,15 +81,24 @@ func (o *ObjectToPack) WantWrite() bool {
// is nil Original is set but previous resolved values are kept
func (o *ObjectToPack) SetOriginal(obj plumbing.EncodedObject) {
o.Original = obj
+ o.SaveOriginalMetadata()
+}
- if obj != nil {
- o.originalSize = obj.Size()
- o.originalType = obj.Type()
- o.originalHash = obj.Hash()
+// SaveOriginalMetadata saves size, type and hash of Original object
+func (o *ObjectToPack) SaveOriginalMetadata() {
+ if o.Original != nil {
+ o.originalSize = o.Original.Size()
+ o.originalType = o.Original.Type()
+ o.originalHash = o.Original.Hash()
o.resolvedOriginal = true
}
}
+// CleanOriginal sets Original to nil
+func (o *ObjectToPack) CleanOriginal() {
+ o.Original = nil
+}
+
func (o *ObjectToPack) Type() plumbing.ObjectType {
if o.Original != nil {
return o.Original.Type()
diff --git a/plumbing/transport/ssh/auth_method.go b/plumbing/transport/ssh/auth_method.go
index a092b29..0cdf2b7 100644
--- a/plumbing/transport/ssh/auth_method.go
+++ b/plumbing/transport/ssh/auth_method.go
@@ -231,7 +231,7 @@ func (a *PublicKeysCallback) ClientConfig() (*ssh.ClientConfig, error) {
}
// NewKnownHostsCallback returns ssh.HostKeyCallback based on a file based on a
-// know_hosts file. http://man.openbsd.org/sshd#SSH_KNOWN_HOSTS_FILE_FORMAT
+// known_hosts file. http://man.openbsd.org/sshd#SSH_KNOWN_HOSTS_FILE_FORMAT
//
// If files is empty, the list of files will be read from the SSH_KNOWN_HOSTS
// environment variable, example:
@@ -286,7 +286,7 @@ func filterKnownHostsFiles(files ...string) ([]string, error) {
}
if len(out) == 0 {
- return nil, fmt.Errorf("unable to find any valid know_hosts file, set SSH_KNOWN_HOSTS env variable")
+ return nil, fmt.Errorf("unable to find any valid known_hosts file, set SSH_KNOWN_HOSTS env variable")
}
return out, nil
diff --git a/storage/filesystem/shallow.go b/storage/filesystem/shallow.go
index 394e6ed..4b2e2dc 100644
--- a/storage/filesystem/shallow.go
+++ b/storage/filesystem/shallow.go
@@ -26,7 +26,7 @@ func (s *ShallowStorage) SetShallow(commits []plumbing.Hash) error {
defer ioutil.CheckClose(f, &err)
for _, h := range commits {
- if _, err := fmt.Fprintf(f, "%s\n", h); err != err {
+ if _, err := fmt.Fprintf(f, "%s\n", h); err != nil {
return err
}
}