@@ -3,6 +3,7 @@ package git
33import (
44 "bytes"
55 "context"
6+ "fmt"
67 "io"
78 "io/ioutil"
89 "os"
@@ -55,6 +56,37 @@ func (s *RemoteSuite) TestFetchInvalidFetchOptions(c *C) {
5556 c .Assert (err , Equals , config .ErrRefSpecMalformedSeparator )
5657}
5758
59+ func (s * RemoteSuite ) TestFetchUnrelated (c * C ) {
60+ fmt .Println (fixtures .RootFolder )
61+ mem := memory .NewStorage ()
62+ r1 := newRemote (mem , & config.RemoteConfig {
63+ URLs : []string {s .GetBasicLocalRepositoryURL ()},
64+ })
65+ r2 := newRemote (mem , & config.RemoteConfig {
66+ URLs : []string {s .GetLocalRepositoryURL (fixtures .ByTag ("tags" ).One ())},
67+ })
68+
69+ // Fetch both repos into the same storage but under different remote names.
70+ s .testFetch (c , r1 , & FetchOptions {
71+ RefSpecs : []config.RefSpec {
72+ config .RefSpec ("+refs/heads/master:refs/remotes/r1/master" ),
73+ },
74+ Depth : 1 ,
75+ }, []* plumbing.Reference {
76+ plumbing .NewReferenceFromStrings ("refs/remotes/r1/master" , "6ecf0ef2c2dffb796033e5a02219af86ec6584e5" ),
77+ })
78+ s .testFetch (c , r2 , & FetchOptions {
79+ RefSpecs : []config.RefSpec {
80+ config .RefSpec ("+refs/heads/master:refs/remotes/r2/master" ),
81+ },
82+ Depth : 1 ,
83+ }, []* plumbing.Reference {
84+ plumbing .NewReferenceFromStrings ("refs/remotes/r1/master" , "6ecf0ef2c2dffb796033e5a02219af86ec6584e5" ),
85+ plumbing .NewReferenceFromStrings ("refs/remotes/r2/master" , "f7b877701fbf855b44c0a9e86f3fdce2c298b07f" ),
86+ })
87+
88+ }
89+
5890func (s * RemoteSuite ) TestFetchWildcard (c * C ) {
5991 r := newRemote (memory .NewStorage (), & config.RemoteConfig {
6092 URLs : []string {s .GetBasicLocalRepositoryURL ()},
0 commit comments