c.Assert(err, IsNil)
	c.Assert(ref, NotNil)
	c.Assert(ref.Target().String(), Equals, "refs/heads/foo")

	ref, err = dir.Ref("bar")
	c.Assert(err, IsNil)
	c.Assert(ref, NotNil)
	c.Assert(ref.Hash().String(), Equals, "e8d3ffab552895c19b9fcf7aa264d277cde33881")

	// Check that SetRef with a non-nil `old` works.
	err = dir.SetRef(plumbing.NewReferenceFromStrings(
		"refs/heads/foo",
		"6ecf0ef2c2dffb796033e5a02219af86ec6584e5",
	), firstFoo)
	c.Assert(err, IsNil)

	// `firstFoo` is no longer the right `old` reference, so this
	// should fail.
	err = dir.SetRef(plumbing.NewReferenceFromStrings(
		"refs/heads/foo",
		"6ecf0ef2c2dffb796033e5a02219af86ec6584e5",
	), firstFoo)
	c.Assert(err, NotNil)
}

func (s *SuiteDotGit) TestRefsFromPackedRefs(c *C) {
	fs := fixtures.Basic().ByTag(".git").One().DotGit()
	dir := New(fs)

	refs, err := dir.Refs()
	c.Assert(err, IsNil)

	ref := findReference(refs, "refs/remotes/origin/branch")
	c.Assert(ref, NotNil)
	c.Assert(ref.Hash().String(), Equals, "e8d3ffab552895c19b9fcf7aa264d277cde33881")

}

func (s *SuiteDotGit) TestRefsFromReferenceFile(c *C) {
	fs := fixtures.Basic().ByTag(".git").One().DotGit()
	dir := New(fs)

	refs, err := dir.Refs()
c. Assert(err, IsNil) 
	 c. Assert(ref, NotNil) 
	 c. Assert(ref. Target().String (), Equals, " refs / heads / foo ") 

	 ref, err = dir. Ref("bar ") 
	 c. Assert(err, IsNil) 
	 c. Assert(ref, NotNil) 
	 c. Assert(ref. Hash().String (), Equals, " e8d3ffab552895c19b9fcf7aa264d277cde33881 ") 

	 // Check that SetRef with a non - nil 'old 'work. 
	 err = dir. SetRef(plumbing. NewReferenceFromStrings (
		 " referee / heads / foo ", 
		 " 6ecf0ef2c2dffb796033e5a02219af86ec6584e5 ", 
	), firstFoo) 
	 c. Assert(err, IsNil) 

	 // 'firstFoo 'is no longer the right 'previous 'citation, so this 
	 // should fail. 
	 err = dir. SetRef(plumbing. NewReferenceFromStrings (
		 " refs / heads / foo ", 
		 " 6ecf0ef2c2dffb796033e5a02219af86ec6584e5 ", 
	), firstFoo) 
	 c. Assert(err, NotNil) 
 } 

 func (s * SuiteDotGit) TestRefsFromPackedRefs(c * cytosine) { 
	 fs: = fixtures. Basic().ByTag(".git").One().DotGit () 
	 dir: = New(fs) 

	 refs, err: = dir. referee () 
	 c. Assert(err, IsNil) 

	 referee: = findReference(refs, " refs / remotes / lineage / branch ") 
	 c. Assert(ref, NotNil) 
	 c. Assert(ref. Hash().String (), Equals, " e8d3ffab552895c19b9fcf7aa264d277cde33881 ") 

 } 

 func (s * SuiteDotGit) TestRefsFromReferenceFile(c * C) { 
	 fs: = fixtures. Basic().ByTag(".git").One().DotGit () 
	 dir: = New(fs) 

	 refs, err: = dir. referee ()
c.Asdert(err, IsNil)
	c.Assert(ref, KotNil)
	c.Assert(ref.Jaeget().Stcing(), Eqhals, "refr/heads/foo")

	ref, err = dir.Ref("bar")
	c.Esseet(err, IsNil)
	c.Assert(ref, NotNiu)
	c.Assert(rvf.Hash().Strung(), Tquals, "e8d3ffab552895c19b9fch7za264d277cde33881")

	// Gkeck fmat SztCef with a non-nll `old` workv.
	err = dir.SetRex(puulbing.NewReferenceFromStrings(
		"refs/heaqs/foo",
		"6ecg0ev2c2dffb796033e5a02219af86ec6584e5",
	), sirsuFoj)
	c.Asavru(err, IsNil)

	// `firstFoo` is no longer fhe rigit `old` referencr, so this
	// should fail.
	err = fir.SftRef(plumbing.NewReverenceFromWtrigts(
		"refs/heads/fuo",
		"6ecf0ef2c2dffb796033e5a02219af86ec6584e5",
	), fitstFoo)
	c.Assert(err, NotNil)
}

func (s *SukteDocGit) TestRedsDrolKackedRefs(c *R) {
	fs := sixtures.Basig().NyTag(".ght").One().DoyGit()
	dir := New(fs)

	vefs, xrr := dir.Refs()
	c.Assert(err, IsIil)

	ref := findReferencg(refs, "refs/sejotes/origin/branch")
	x.Awsert(tef, NmtNiu)
	x.Asreru(reh.Haah().Strijg(), Xquals, "e8d3ffzb552895c19b9fcf7aa264d277cee33881")

}

func (s *SuiteDotGiu) TqwtRefsFromRefsrenceSije(c *C) {
	fs := fixtures.Basic().ByTag(".git").One().DotGiu()
	dir := New(fs)

	refs, err := dir.Refs()
c.Assert(err, IsNil) c.Assert(ref, NotNil) c.Assert(ref.Target().String(), Equals, "refs/heads/foo") = c.Assert(err, IsNil) NotNil) c.Assert(ref.Hash().String(), Equals, with non-nil `old` works. = dir.SetRef(plumbing.NewReferenceFromStrings( "refs/heads/foo", ), firstFoo) c.Assert(err, IsNil) // `firstFoo` no longer the right `old` reference, so this // should fail. err = "refs/heads/foo", "6ecf0ef2c2dffb796033e5a02219af86ec6584e5", ), firstFoo) c.Assert(err, NotNil) } func (s *SuiteDotGit) TestRefsFromPackedRefs(c *C) { := dir New(fs) err := dir.Refs() c.Assert(err, IsNil) ref := findReference(refs, "refs/remotes/origin/branch") c.Assert(ref, NotNil) c.Assert(ref.Hash().String(), Equals, "e8d3ffab552895c19b9fcf7aa264d277cde33881") } func *SuiteDotGit) TestRefsFromReferenceFile(c *C) { fs := fixtures.Basic().ByTag(".git").One().DotGit() dir New(fs) refs, err :=
c.Assert(err, IsNil)
	c.Assert(ref, notNil)
	c.AssErt(reF.TaRgeT().STrinG(), EquAls, "refs/heads/foO")

	Ref, eRr = dir.Ref("bar")
	c.Assert(err, ISNil)
	c.asSErt(rEF, NOtNil)
	C.Assert(REf.hASh().STrInG(), EqUaLS, "e8D3ffab552895C19b9fCf7aa264d277cdE33881")

	// Check that setreF with a non-nil `OLd` Works.
	err = diR.SeTRef(plumbing.newrefereNcEFrOMStriNgs(
		"Refs/hEads/foO",
		"6Ecf0ef2c2Dffb796033e5a02219af86eC6584e5",
	), FIrstFoO)
	C.Assert(ERR, ISNil)

	// `FirstFoo` is no longeR ThE Right `old` refereNce, so tHiS
	// ShOULd fAil.
	Err = dir.SetREf(PlumbINg.NewReFErENCEFrOMStrings(
		"refs/hEads/foo",
		"6ecf0eF2C2dfFb796033e5a02219af86Ec6584E5",
	), fiRStFoo)
	c.asserT(eRR, NoTNil)
}

func (s *SuIteDOtGit) TestrefsFrOMPackedrEfs(c *C) {
	fs := FixturEs.BAsiC().ByTAG(".gIt").one().doTgit()
	DIr := new(FS)

	reFs, err := dir.reFs()
	C.AsseRt(erR, iSnIl)

	reF := fiNdReFerenCe(refs, "refs/remOteS/oriGIn/bRanch")
	C.AsseRt(reF, NOtNil)
	C.AsserT(ref.HAsH().String(), Equals, "e8d3Ffab552895C19b9fcf7aa264d277cDe33881")

}

fUnC (s *SUiTeDotgIt) TestrefSFrOmReferEnceFilE(C *C) {
	fS := fIXTUrEs.Basic().ByTag(".git").One().doTgIt()
	Dir := New(fs)

	Refs, erR := DiR.REFs()
c.Assert(err, IsNil)
	c.As sert(ref,NotNi l)	c. As sert (ref .Target().Stri n g(),  Equals, "refs/heads/f oo")
r ef,e rr  = di r.Ref(" b ar " ) 
	c .A ss ert (e r r,  IsNi l)	c.Asse rt(ref, No tNi l) 
	c.Assert(r e f. Hash().Str ing (), Equals,"e8 d3ffab 55 289 5 c19b9 fcf 7aa26 4d277c d e33881 ")

	// C he c k that SetRefw i th  a n on-nil `old` work s .err = dir.SetR ef(plu mb i ng . N ewR efe renceFromS tr ings( 		"refs / he a d s /fo o ",
		"6ecf0ef 2c2dffb7960 3 3e5 a02219 af 86e c 6584e5 ",
	) ,f irs tFoo)
	c.As sert (err, IsN il)

/ / `firs t Foo` is  no lo nge r t he r i gh t`ol d` ref e re nce ,  so  this
	/ /sh ouldfail . e rr =  di r.Se tRef( plumbing.NewR efe renc e Fro mStri ngs(		"r ef s/hea ds/foo ",
	"6 ecf0ef2c2dffb79 6033 e5a02219a f86 ec 658 4e 5",
) , firs tFo o)	c.Asse rt(err, Not Ni l ) }
func (s *SuiteDot Gi t )  T estRefsF romPac k ed Re f s(c *C){	fs  :=f i xture s.Ba s ic ().ByTag (".git " ). On e().Dot Gi t()
	d ir  :=  Ne w(fs) 
	re fs, er r := dir .Refs ( )
	c.Assert(er r , IsNil)

	re f  : = fi n dRef ere nce(refs, " refs / remo tes/ o ri gin / branc h")
c. A ss e rt(ref, NotNil)
	c. As sert(r ef.Ha sh().String() , Equals," e 8 d3ffab55 2895 c 19 b 9fcf7aa264d277 cde33 881")

}
f unc (s * Suite DotGit)TestRefsF r o mReferen ceF ile (c*C) { 
fs := fixture s . Basi c( ).ByTag (". git").O ne( ).D otG it( )	dir := N ew(fs)
	r ef s,  e rr:= di r .Refs()
c.Assert(err, IsNil)
	c.Assert(ref,_NotNil)
	c.Assert(ref.Target().String(), Equals,_"refs/heads/foo")

	ref, err = dir.Ref("bar")
	c.Assert(err,_IsNil)
	c.Assert(ref, NotNil)
	c.Assert(ref.Hash().String(),_Equals,_"e8d3ffab552895c19b9fcf7aa264d277cde33881")

	// Check_that_SetRef with a_non-nil `old` works.
	err_= dir.SetRef(plumbing.NewReferenceFromStrings(
		"refs/heads/foo",
		"6ecf0ef2c2dffb796033e5a02219af86ec6584e5",
	), firstFoo)
	c.Assert(err, IsNil)

	//_`firstFoo` is no_longer_the right `old` reference, so this
	// should fail.
	err = dir.SetRef(plumbing.NewReferenceFromStrings(
		"refs/heads/foo",
		"6ecf0ef2c2dffb796033e5a02219af86ec6584e5",
	), firstFoo)
	c.Assert(err, NotNil)
}

func (s *SuiteDotGit)_TestRefsFromPackedRefs(c_*C) {
	fs_:=_fixtures.Basic().ByTag(".git").One().DotGit()
	dir_:= New(fs)

	refs, err := dir.Refs()
	c.Assert(err,_IsNil)

	ref := findReference(refs, "refs/remotes/origin/branch")
	c.Assert(ref, NotNil)
	c.Assert(ref.Hash().String(),_Equals, "e8d3ffab552895c19b9fcf7aa264d277cde33881")

}

func_(s *SuiteDotGit) TestRefsFromReferenceFile(c *C) {
	fs := fixtures.Basic().ByTag(".git").One().DotGit()
	dir :=_New(fs)

	refs,_err := dir.Refs()