aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/git.yml9
-rw-r--r--plumbing/protocol/packp/advrefs.go8
-rw-r--r--plumbing/protocol/packp/advrefs_test.go24
-rw-r--r--plumbing/transport/internal/common/common.go7
4 files changed, 34 insertions, 14 deletions
diff --git a/.github/workflows/git.yml b/.github/workflows/git.yml
index 73a916b..f89604b 100644
--- a/.github/workflows/git.yml
+++ b/.github/workflows/git.yml
@@ -1,12 +1,12 @@
on: [push, pull_request]
-name: Git Compatibility
+name: Git Compatibility
jobs:
test:
strategy:
fail-fast: false
matrix:
git: [[master, ubuntu-latest], [v2.11.0, ubuntu-latest]]
-
+
runs-on: ${{ matrix.git[1] }}
env:
GIT_VERSION: ${{ matrix.git[0] }}
@@ -20,7 +20,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
-
+
- name: Install build dependencies
run: sudo apt-get install gettext
@@ -33,8 +33,7 @@ jobs:
git config --global user.name "GitHub Actions"
export PATH=$GIT_DIST_PATH:$PATH
-
- name: Test
env:
- GIT_EXEC_PATH: ${{ env.GIT_DIST_PATH }}
+ GIT_EXEC_PATH: ${{ github.workspace }}/${{ env.GIT_DIST_PATH }}
run: make test-coverage
diff --git a/plumbing/protocol/packp/advrefs.go b/plumbing/protocol/packp/advrefs.go
index ab286c6..1bd724c 100644
--- a/plumbing/protocol/packp/advrefs.go
+++ b/plumbing/protocol/packp/advrefs.go
@@ -201,3 +201,11 @@ func (a *AdvRefs) addSymbolicRefs(s storer.ReferenceStorer) error {
func (a *AdvRefs) supportSymrefs() bool {
return a.Capabilities.Supports(capability.SymRef)
}
+
+// IsEmpty returns true if doesn't contain any reference.
+func (a *AdvRefs) IsEmpty() bool {
+ return a.Head == nil &&
+ len(a.References) == 0 &&
+ len(a.Peeled) == 0 &&
+ len(a.Shallows) == 0
+}
diff --git a/plumbing/protocol/packp/advrefs_test.go b/plumbing/protocol/packp/advrefs_test.go
index d37f127..d163e1f 100644
--- a/plumbing/protocol/packp/advrefs_test.go
+++ b/plumbing/protocol/packp/advrefs_test.go
@@ -79,6 +79,11 @@ func (s *AdvRefSuite) TestAllReferencesBadSymref(c *C) {
c.Assert(err, NotNil)
}
+func (s *AdvRefSuite) TestIsEmpty(c *C) {
+ a := NewAdvRefs()
+ c.Assert(a.IsEmpty(), Equals, true)
+}
+
func (s *AdvRefSuite) TestNoSymRefCapabilityHeadToMaster(c *C) {
a := NewAdvRefs()
headHash := plumbing.NewHash("5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c")
@@ -156,7 +161,7 @@ type AdvRefsDecodeEncodeSuite struct{}
var _ = Suite(&AdvRefsDecodeEncodeSuite{})
-func (s *AdvRefsDecodeEncodeSuite) test(c *C, in []string, exp []string) {
+func (s *AdvRefsDecodeEncodeSuite) test(c *C, in []string, exp []string, isEmpty bool) {
var err error
var input io.Reader
{
@@ -181,6 +186,7 @@ func (s *AdvRefsDecodeEncodeSuite) test(c *C, in []string, exp []string) {
{
ar := NewAdvRefs()
c.Assert(ar.Decode(input), IsNil)
+ c.Assert(ar.IsEmpty(), Equals, isEmpty)
var buf bytes.Buffer
c.Assert(ar.Encode(&buf), IsNil)
@@ -202,7 +208,7 @@ func (s *AdvRefsDecodeEncodeSuite) TestNoHead(c *C) {
pktline.FlushString,
}
- s.test(c, input, expected)
+ s.test(c, input, expected, true)
}
func (s *AdvRefsDecodeEncodeSuite) TestNoHeadSmart(c *C) {
@@ -218,7 +224,7 @@ func (s *AdvRefsDecodeEncodeSuite) TestNoHeadSmart(c *C) {
pktline.FlushString,
}
- s.test(c, input, expected)
+ s.test(c, input, expected, true)
}
func (s *AdvRefsDecodeEncodeSuite) TestNoHeadSmartBug(c *C) {
@@ -236,7 +242,7 @@ func (s *AdvRefsDecodeEncodeSuite) TestNoHeadSmartBug(c *C) {
pktline.FlushString,
}
- s.test(c, input, expected)
+ s.test(c, input, expected, true)
}
func (s *AdvRefsDecodeEncodeSuite) TestRefs(c *C) {
@@ -256,7 +262,7 @@ func (s *AdvRefsDecodeEncodeSuite) TestRefs(c *C) {
pktline.FlushString,
}
- s.test(c, input, expected)
+ s.test(c, input, expected, false)
}
func (s *AdvRefsDecodeEncodeSuite) TestPeeled(c *C) {
@@ -280,7 +286,7 @@ func (s *AdvRefsDecodeEncodeSuite) TestPeeled(c *C) {
pktline.FlushString,
}
- s.test(c, input, expected)
+ s.test(c, input, expected, false)
}
func (s *AdvRefsDecodeEncodeSuite) TestAll(c *C) {
@@ -308,7 +314,7 @@ func (s *AdvRefsDecodeEncodeSuite) TestAll(c *C) {
pktline.FlushString,
}
- s.test(c, input, expected)
+ s.test(c, input, expected, false)
}
func (s *AdvRefsDecodeEncodeSuite) TestAllSmart(c *C) {
@@ -340,7 +346,7 @@ func (s *AdvRefsDecodeEncodeSuite) TestAllSmart(c *C) {
pktline.FlushString,
}
- s.test(c, input, expected)
+ s.test(c, input, expected, false)
}
func (s *AdvRefsDecodeEncodeSuite) TestAllSmartBug(c *C) {
@@ -372,7 +378,7 @@ func (s *AdvRefsDecodeEncodeSuite) TestAllSmartBug(c *C) {
pktline.FlushString,
}
- s.test(c, input, expected)
+ s.test(c, input, expected, false)
}
func ExampleAdvRefs_Decode() {
diff --git a/plumbing/transport/internal/common/common.go b/plumbing/transport/internal/common/common.go
index d564d25..89432e3 100644
--- a/plumbing/transport/internal/common/common.go
+++ b/plumbing/transport/internal/common/common.go
@@ -175,6 +175,13 @@ func (s *session) AdvertisedReferences() (*packp.AdvRefs, error) {
}
}
+ // Some servers like jGit, announce capabilities instead of returning an
+ // packp message with a flush. This verifies that we received a empty
+ // adv-refs, even it contains capabilities.
+ if !s.isReceivePack && ar.IsEmpty() {
+ return nil, transport.ErrEmptyRemoteRepository
+ }
+
transport.FilterUnsupportedCapabilities(ar.Capabilities)
s.advRefs = ar
return ar, nil