The implementation of Remote.List() lists does not preserve the reference order as found in the remote repo.
To reproduce this behavior, try running https://github.com/src-d/go-git/blob/master/_examples/ls-remote/main.go against a repo several times and watch the order of references change between calls. This is different from the behavior of git ls-remote <repoURL> whose order is deterministic.
The reason appears to be the use of maps to store and iterate over references
The implementation of
Remote.List()
lists does not preserve the reference order as found in the remote repo.To reproduce this behavior, try running https://github.com/src-d/go-git/blob/master/_examples/ls-remote/main.go against a repo several times and watch the order of references change between calls. This is different from the behavior of
git ls-remote <repoURL>
whose order is deterministic.The reason appears to be the use of maps to store and iterate over references
https://github.com/src-d/go-git/blob/aac20cc0e86f9f563bc74c42e9b9c598dfe271da/storage/memory/storage.go#L242
In Go, the iteration order of maps is non-deterministic.