File tree Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 171
171
<Compile Include =" Refspec.cs" />
172
172
<Compile Include =" GitProtocolException.cs" />
173
173
<Compile Include =" Core\Compat\StreamExtensions.cs" />
174
+ <Compile Include =" ProtocolCapabilities.cs" />
174
175
</ItemGroup >
175
176
<ItemGroup >
176
177
<CodeAnalysisDictionary Include =" CustomDictionary.xml" />
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Linq ;
3
+
4
+ namespace LibGit2Sharp
5
+ {
6
+ public class ProtocolCapabilities
7
+ {
8
+ public readonly bool OfsDelta ;
9
+ public readonly bool Sideband ;
10
+ public readonly bool Sideband64k ;
11
+
12
+ private readonly string OfsDeltaStr = "ofs-delta" ;
13
+ private readonly string SidebandStr = "side-band" ;
14
+ private readonly string Sideband64kStr = "side-band-64k" ;
15
+
16
+ public ProtocolCapabilities ( string str )
17
+ {
18
+ var caps = str . Split ( ) ;
19
+
20
+ OfsDelta = caps . Contains ( OfsDeltaStr ) ;
21
+ Sideband = caps . Contains ( SidebandStr ) ;
22
+ Sideband64k = caps . Contains ( Sideband64kStr ) ;
23
+ }
24
+
25
+ public string Common
26
+ {
27
+ get {
28
+ /* Only this one for now */
29
+ return OfsDelta ? OfsDeltaStr : "" ;
30
+ }
31
+ }
32
+ }
33
+ }
34
+
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ public class Remote : IEquatable<Remote>
19
19
private Lazy < IEnumerable < string > > refnames ;
20
20
private Lazy < IEnumerable < string > > matching_refs ;
21
21
private Indexer indexer ;
22
+ private ProtocolCapabilities caps ;
22
23
23
24
/* Mostly so that the already-existing code doesn't break */
24
25
public Remote ( )
@@ -73,6 +74,9 @@ public void Connect()
73
74
if ( pkt is PktError )
74
75
throw new GitProtocolException ( ( pkt as PktError ) . Error ) ;
75
76
}
77
+
78
+ /* Figure out what capabilities we have in common */
79
+ caps = new ProtocolCapabilities ( Refs [ 0 ] . CapString ) ;
76
80
}
77
81
78
82
public IndexerStats Stats
@@ -94,11 +98,17 @@ public void Download(string path)
94
98
/* First, let's see what we want. At this point we don't send any haves */
95
99
Stream stream = new MemoryStream ( ) ;
96
100
var writer = new StreamWriter ( stream ) ;
101
+ bool first = true ;
97
102
foreach ( PktRef p in Refs ) {
98
103
if ( ! Refspec . Matches ( p . Name ) )
99
104
continue ;
100
105
101
- writer . Write ( Pkt . Line ( "want " + p . Id . Sha ) ) ;
106
+ if ( first ) {
107
+ writer . Write ( Pkt . Line ( "want " + p . Id . Sha + " " + caps . Common ) ) ;
108
+ first = false ;
109
+ } else {
110
+ writer . Write ( Pkt . Line ( "want " + p . Id . Sha ) ) ;
111
+ }
102
112
}
103
113
/* Flush after the want lines */
104
114
writer . Write ( "0000" ) ;
You can’t perform that action at this time.
0 commit comments