186186#include "abspath.h"
187187#include "progress.h"
188188#include "trace2.h"
189+ #include "versioncmp.h"
189190
190191static const char * const main_usage [] = {
191192 N_ ("git gvfs-helper [<main_options>] config [<options>]" ),
@@ -210,6 +211,11 @@ static const char *const server_usage[] = {
210211 NULL
211212};
212213
214+ static const char * const curl_version_usage [] = {
215+ N_ ("git gvfs-helper [<main_options>] curl-version [<operator> <version>]" ),
216+ NULL
217+ };
218+
213219/*
214220 * "commitDepth" field in gvfs protocol
215221 */
@@ -1887,6 +1893,8 @@ static void install_loose(struct gh__request_params *params,
18871893 /*
18881894 * We expect a loose object when we do a GET -or- when we
18891895 * do a POST with only 1 object.
1896+ *
1897+ * Note that this content type is singular, not plural.
18901898 */
18911899 if (strcmp (status -> content_type .buf ,
18921900 "application/x-git-loose-object" )) {
@@ -2121,14 +2129,17 @@ static void do_throttle_spin(struct gh__request_params *params,
21212129 strbuf_addstr (& region , gh__server_type_label [params -> server_type ]);
21222130 trace2_region_enter ("gvfs-helper" , region .buf , NULL );
21232131
2124- progress = start_progress (the_repository , progress_msg , duration );
2132+ if (gh__cmd_opts .show_progress )
2133+ progress = start_progress (the_repository , progress_msg , duration );
2134+
21252135 while (now < end ) {
21262136 display_progress (progress , (now - begin ));
21272137
21282138 sleep_millisec (100 );
21292139
21302140 now = time (NULL );
21312141 }
2142+
21322143 display_progress (progress , duration );
21332144 stop_progress (& progress );
21342145
@@ -2701,13 +2712,15 @@ static void do__http_post__gvfs_objects(struct gh__response_status *status,
27012712 params .headers = curl_slist_append (params .headers ,
27022713 "Content-Type: application/json" );
27032714 /*
2704- * We really always want a packfile. But if the payload only
2705- * requests 1 OID, the server will send us a single loose
2706- * objects instead. (Apparently the server ignores us when we
2707- * only send application/x-git-packfile and does it anyway. )
2715+ * If our POST contains more than one object, we want the
2716+ * server to send us a packfile. We DO NOT want the non-standard
2717+ * concatenated loose object format, so we DO NOT send:
2718+ * "Accept: application/x-git-loose-objects" (plural )
27082719 *
2709- * So to make it clear to my future self, go ahead and add
2710- * an accept header for loose objects and own it.
2720+ * However, if the payload only requests 1 OID, the server
2721+ * will send us a single loose object instead of a packfile,
2722+ * so we ACK that and send:
2723+ * "Accept: application/x-git-loose-object" (singular)
27112724 */
27122725 params .headers = curl_slist_append (params .headers ,
27132726 "Accept: application/x-git-packfile" );
@@ -3311,6 +3324,37 @@ static enum gh__error_code do_sub_cmd__server(int argc, const char **argv)
33113324 return ec ;
33123325}
33133326
3327+ static enum gh__error_code do_sub_cmd__curl_version (int argc , const char * * argv )
3328+ {
3329+ static struct option curl_version_options [] = {
3330+ OPT_END (),
3331+ };
3332+ const char * current_version = curl_version_info (CURLVERSION_NOW )-> version ;
3333+
3334+ trace2_cmd_mode ("curl-version" );
3335+
3336+ if (argc > 1 && !strcmp (argv [1 ], "-h" ))
3337+ usage_with_options (curl_version_usage , curl_version_options );
3338+
3339+ argc = parse_options (argc , argv , NULL ,
3340+ curl_version_options , curl_version_usage , 0 );
3341+
3342+ if (argc == 0 )
3343+ printf ("%s\n" , current_version );
3344+ else if (argc != 2 )
3345+ die ("expected [<operator> <version>], but got %d parameters" , argc );
3346+ else {
3347+ int cmp = versioncmp (current_version , argv [1 ]);
3348+
3349+ return (strchr (argv [0 ], '=' ) && !cmp ) ||
3350+ (strchr (argv [0 ], '>' ) && cmp > 0 ) ||
3351+ (strchr (argv [0 ], '<' ) && cmp < 0 ) ?
3352+ GH__ERROR_CODE__OK : GH__ERROR_CODE__ERROR ;
3353+ }
3354+
3355+ return GH__ERROR_CODE__OK ;
3356+ }
3357+
33143358static enum gh__error_code do_sub_cmd (int argc , const char * * argv )
33153359{
33163360 if (!strcmp (argv [0 ], "get" ))
@@ -3325,6 +3369,9 @@ static enum gh__error_code do_sub_cmd(int argc, const char **argv)
33253369 if (!strcmp (argv [0 ], "server" ))
33263370 return do_sub_cmd__server (argc , argv );
33273371
3372+ if (!strcmp (argv [0 ], "curl-version" ))
3373+ return do_sub_cmd__curl_version (argc , argv );
3374+
33283375 // TODO have "test" mode that could be used to drive
33293376 // TODO unit testing.
33303377
0 commit comments