@@ -89,6 +89,7 @@ type options struct {
89
89
uploadPack bool
90
90
receivePack bool
91
91
dumbProto bool
92
+ head bool
92
93
}
93
94
94
95
type Option func (* options )
@@ -108,6 +109,14 @@ func DisableReceivePack() Option {
108
109
func WithoutDumbProto () Option {
109
110
return func (o * options ) {
110
111
o .dumbProto = false
112
+ o .head = false
113
+ }
114
+ }
115
+
116
+ func WithoutDumbProtoExceptHead () Option {
117
+ return func (o * options ) {
118
+ o .dumbProto = false
119
+ o .head = true
111
120
}
112
121
}
113
122
@@ -121,7 +130,7 @@ func New(gitRootPath, gitBinPath string, opts ...Option) (*GitHTTPXfer, error) {
121
130
gitRootPath = cwd
122
131
}
123
132
124
- ghxOpts := & options {true , true , true }
133
+ ghxOpts := & options {true , true , true , true }
125
134
126
135
for _ , opt := range opts {
127
136
opt (ghxOpts )
@@ -138,7 +147,6 @@ func New(gitRootPath, gitBinPath string, opts ...Option) (*GitHTTPXfer, error) {
138
147
ghx .Router .Add (NewRoute (http .MethodGet , getInfoRefs , ghx .getInfoRefs ))
139
148
140
149
if ghxOpts .dumbProto {
141
- ghx .Router .Add (NewRoute (http .MethodGet , getHead , ghx .getTextFile ))
142
150
ghx .Router .Add (NewRoute (http .MethodGet , getAlternates , ghx .getTextFile ))
143
151
ghx .Router .Add (NewRoute (http .MethodGet , getHTTPAlternates , ghx .getTextFile ))
144
152
ghx .Router .Add (NewRoute (http .MethodGet , getInfoPacks , ghx .getInfoPacks ))
@@ -147,6 +155,11 @@ func New(gitRootPath, gitBinPath string, opts ...Option) (*GitHTTPXfer, error) {
147
155
ghx .Router .Add (NewRoute (http .MethodGet , getPackFile , ghx .getPackFile ))
148
156
ghx .Router .Add (NewRoute (http .MethodGet , getIdxFile , ghx .getIdxFile ))
149
157
}
158
+
159
+ if ghxOpts .head {
160
+ ghx .Router .Add (NewRoute (http .MethodGet , getHead , ghx .getTextFile ))
161
+ }
162
+
150
163
return ghx , nil
151
164
}
152
165
0 commit comments