Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

packp: AdvRefs is not encoded correctly when missing Head pointer #152

Closed
smola opened this issue Nov 30, 2016 · 3 comments
Closed

packp: AdvRefs is not encoded correctly when missing Head pointer #152

smola opened this issue Nov 30, 2016 · 3 comments
Labels

Comments

@smola
Copy link
Collaborator

smola commented Nov 30, 2016

From https://github.com/git/git/blob/master/Documentation/technical/pack-protocol.txt

If HEAD is a valid ref, HEAD MUST appear as the first advertised
ref.  If HEAD is not a valid ref, HEAD MUST NOT appear in the
advertisement list at all, but other refs may still appear.

So HEAD, if present, should be the first reference. Otherwise, the first reference is encoded as usual.

This is different from our current implementation, which encodes a zero hash instead:

func (s *AdvRefsEncodeSuite) TestRefs(c *C) {
	references := map[string]plumbing.Hash{
		"refs/heads/master":      plumbing.NewHash("a6930aaee06755d1bdcfd943fbf614e4d92bb0c7"),
		"refs/tags/v2.6.12-tree": plumbing.NewHash("1111111111111111111111111111111111111111"),
		"refs/tags/v2.7.13-tree": plumbing.NewHash("3333333333333333333333333333333333333333"),
		"refs/tags/v2.6.13-tree": plumbing.NewHash("2222222222222222222222222222222222222222"),
		"refs/tags/v2.6.11-tree": plumbing.NewHash("5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c"),
	}
	ar := &AdvRefs{
		References: references,
	}

	expected := pktlines(c,
		"0000000000000000000000000000000000000000 capabilities^{}\x00\n",
		"a6930aaee06755d1bdcfd943fbf614e4d92bb0c7 refs/heads/master\n",
		"5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11-tree\n",
		"1111111111111111111111111111111111111111 refs/tags/v2.6.12-tree\n",
		"2222222222222222222222222222222222222222 refs/tags/v2.6.13-tree\n",
		"3333333333333333333333333333333333333333 refs/tags/v2.7.13-tree\n",
		pktline.FlushString,
	)

	testEncode(c, ar, expected)
}
@smola smola added the bug label Nov 30, 2016
@mcuadros
Copy link
Contributor

@smola still happening?

@mcarmonaa
Copy link
Contributor

PR #552 solves it

@orirawlings
Copy link
Contributor

Can this be closed?

gsalingu-ovhus pushed a commit to gsalingu-ovhus/go-git that referenced this issue Mar 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants