Skip to content

Commit ad93507

Browse files
committed
test-gvfs-prococol, t5799: tests for gvfs-helper
Create t/helper/test-gvfs-protocol.c and t/t5799-gvfs-helper.sh to test gvfs-helper. Create t/helper/test-gvfs-protocol.c as a stand-alone web server that speaks the GVFS Protocol [1] and serves loose objects and packfiles to clients. It is borrows heavily from the code in daemon.c. It includes a "mayhem" mode to cause various network and HTTP errors to test the retry/recovery ability of gvfs-helper. Create t/t5799-gvfs-helper.sh to test gvfs-helper. [1] https://github.com/microsoft/VFSForGit/blob/master/Protocol.md Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
1 parent 468727a commit ad93507

File tree

4 files changed

+2735
-7
lines changed

4 files changed

+2735
-7
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,7 @@ else
13611361
endif
13621362

13631363
PROGRAM_OBJS += gvfs-helper.o
1364+
TEST_PROGRAMS_NEED_X += test-gvfs-protocol
13641365

13651366
REMOTE_CURL_PRIMARY = git-remote-http$X
13661367
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X

gvfs-helper.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,6 +1871,8 @@ static void install_loose(struct gh__request_params *params,
18711871
/*
18721872
* We expect a loose object when we do a GET -or- when we
18731873
* do a POST with only 1 object.
1874+
*
1875+
* Note that this content type is singular, not plural.
18741876
*/
18751877
if (strcmp(status->content_type.buf,
18761878
"application/x-git-loose-object")) {
@@ -2105,14 +2107,17 @@ static void do_throttle_spin(struct gh__request_params *params,
21052107
strbuf_addstr(&region, gh__server_type_label[params->server_type]);
21062108
trace2_region_enter("gvfs-helper", region.buf, NULL);
21072109

2108-
progress = start_progress(progress_msg, duration);
2110+
if (gh__cmd_opts.show_progress)
2111+
progress = start_progress(progress_msg, duration);
2112+
21092113
while (now < end) {
21102114
display_progress(progress, (now - begin));
21112115

21122116
sleep_millisec(100);
21132117

21142118
now = time(NULL);
21152119
}
2120+
21162121
display_progress(progress, duration);
21172122
stop_progress(&progress);
21182123

@@ -2631,13 +2636,15 @@ static void do__http_post__gvfs_objects(struct gh__response_status *status,
26312636
params.headers = curl_slist_append(params.headers,
26322637
"Content-Type: application/json");
26332638
/*
2634-
* We really always want a packfile. But if the payload only
2635-
* requests 1 OID, the server will send us a single loose
2636-
* objects instead. (Apparently the server ignores us when we
2637-
* only send application/x-git-packfile and does it anyway.)
2639+
* If our POST contains more than one object, we want the
2640+
* server to send us a packfile. We DO NOT want the non-standard
2641+
* concatenated loose object format, so we DO NOT send:
2642+
* "Accept: application/x-git-loose-objects" (plural)
26382643
*
2639-
* So to make it clear to my future self, go ahead and add
2640-
* an accept header for loose objects and own it.
2644+
* However, if the payload only requests 1 OID, the server
2645+
* will send us a single loose object instead of a packfile,
2646+
* so we ACK that and send:
2647+
* "Accept: application/x-git-loose-object" (singular)
26412648
*/
26422649
params.headers = curl_slist_append(params.headers,
26432650
"Accept: application/x-git-packfile");

0 commit comments

Comments
 (0)