@@ -441,6 +441,8 @@ struct gh__request_params {
441
441
struct progress * progress ;
442
442
443
443
struct strbuf e2eid ;
444
+
445
+ struct string_list * result_list ; /* we do not own this */
444
446
};
445
447
446
448
#define GH__REQUEST_PARAMS_INIT { \
@@ -469,6 +471,7 @@ struct gh__request_params {
469
471
.progress_msg = STRBUF_INIT, \
470
472
.progress = NULL, \
471
473
.e2eid = STRBUF_INIT, \
474
+ .result_list = NULL, \
472
475
}
473
476
474
477
static void gh__request_params__release (struct gh__request_params * params )
@@ -501,6 +504,8 @@ static void gh__request_params__release(struct gh__request_params *params)
501
504
params -> progress = NULL ;
502
505
503
506
strbuf_release (& params -> e2eid );
507
+
508
+ params -> result_list = NULL ; /* we do not own this */
504
509
}
505
510
506
511
/*
@@ -1858,6 +1863,16 @@ static void install_packfile(struct gh__request_params *params,
1858
1863
goto cleanup ;
1859
1864
}
1860
1865
1866
+
1867
+ if (params -> result_list ) {
1868
+ struct strbuf result_msg = STRBUF_INIT ;
1869
+
1870
+ strbuf_addf (& result_msg , "packfile %s" ,
1871
+ params -> final_packfile_filename .buf );
1872
+ string_list_append (params -> result_list , result_msg .buf );
1873
+ strbuf_release (& result_msg );
1874
+ }
1875
+
1861
1876
cleanup :
1862
1877
child_process_clear (& ip );
1863
1878
}
@@ -1873,6 +1888,8 @@ static void install_loose(struct gh__request_params *params,
1873
1888
/*
1874
1889
* We expect a loose object when we do a GET -or- when we
1875
1890
* do a POST with only 1 object.
1891
+ *
1892
+ * Note that this content type is singular, not plural.
1876
1893
*/
1877
1894
if (strcmp (status -> content_type .buf ,
1878
1895
"application/x-git-loose-object" )) {
@@ -1912,8 +1929,19 @@ static void install_loose(struct gh__request_params *params,
1912
1929
"could not install loose object '%s'" ,
1913
1930
params -> loose_path .buf );
1914
1931
status -> ec = GH__ERROR_CODE__COULD_NOT_INSTALL_LOOSE ;
1932
+ goto cleanup ;
1933
+ }
1934
+
1935
+ if (params -> result_list ) {
1936
+ struct strbuf result_msg = STRBUF_INIT ;
1937
+
1938
+ strbuf_addf (& result_msg , "loose %s" ,
1939
+ oid_to_hex (& params -> loose_oid ));
1940
+ string_list_append (params -> result_list , result_msg .buf );
1941
+ strbuf_release (& result_msg );
1915
1942
}
1916
1943
1944
+ cleanup :
1917
1945
strbuf_release (& tmp_path );
1918
1946
}
1919
1947
@@ -2107,14 +2135,17 @@ static void do_throttle_spin(struct gh__request_params *params,
2107
2135
strbuf_addstr (& region , gh__server_type_label [params -> server_type ]);
2108
2136
trace2_region_enter ("gvfs-helper" , region .buf , NULL );
2109
2137
2110
- progress = start_progress (progress_msg , duration );
2138
+ if (gh__cmd_opts .show_progress )
2139
+ progress = start_progress (progress_msg , duration );
2140
+
2111
2141
while (now < end ) {
2112
2142
display_progress (progress , (now - begin ));
2113
2143
2114
2144
sleep_millisec (100 );
2115
2145
2116
2146
now = time (NULL );
2117
2147
}
2148
+
2118
2149
display_progress (progress , duration );
2119
2150
stop_progress (& progress );
2120
2151
@@ -2529,7 +2560,7 @@ static void setup_gvfs_objects_progress(struct gh__request_params *params,
2529
2560
if (!gh__cmd_opts .show_progress )
2530
2561
return ;
2531
2562
2532
- if (params -> b_is_post && params -> object_count > 1 ) {
2563
+ if (params -> b_is_post ) {
2533
2564
strbuf_addf (& params -> progress_base_phase3_msg ,
2534
2565
"Receiving packfile %ld/%ld with %ld objects" ,
2535
2566
num , den , params -> object_count );
@@ -2561,6 +2592,8 @@ static void do__http_get__gvfs_object(struct gh__response_status *status,
2561
2592
2562
2593
params .object_count = 1 ;
2563
2594
2595
+ params .result_list = result_list ;
2596
+
2564
2597
params .headers = http_copy_default_headers ();
2565
2598
params .headers = curl_slist_append (params .headers ,
2566
2599
"X-TFS-FedAuthRedirect: Suppress" );
@@ -2573,16 +2606,6 @@ static void do__http_get__gvfs_object(struct gh__response_status *status,
2573
2606
2574
2607
do_req__with_fallback (component_url .buf , & params , status );
2575
2608
2576
- if (status -> ec == GH__ERROR_CODE__OK ) {
2577
- struct strbuf msg = STRBUF_INIT ;
2578
-
2579
- strbuf_addf (& msg , "loose %s" ,
2580
- oid_to_hex (& params .loose_oid ));
2581
-
2582
- string_list_append (result_list , msg .buf );
2583
- strbuf_release (& msg );
2584
- }
2585
-
2586
2609
gh__request_params__release (& params );
2587
2610
strbuf_release (& component_url );
2588
2611
}
@@ -2594,7 +2617,7 @@ static void do__http_get__gvfs_object(struct gh__response_status *status,
2594
2617
* consumed (along with the filename of the resulting packfile).
2595
2618
*
2596
2619
* However, if we only have 1 oid (remaining) in the OIDSET, the
2597
- * server will respond to our POST with a loose object rather than
2620
+ * server *MAY* respond to our POST with a loose object rather than
2598
2621
* a packfile with 1 object.
2599
2622
*
2600
2623
* Append a message to the result_list describing the result.
@@ -2625,6 +2648,8 @@ static void do__http_post__gvfs_objects(struct gh__response_status *status,
2625
2648
2626
2649
params .post_payload = & jw_req .json ;
2627
2650
2651
+ params .result_list = result_list ;
2652
+
2628
2653
params .headers = http_copy_default_headers ();
2629
2654
params .headers = curl_slist_append (params .headers ,
2630
2655
"X-TFS-FedAuthRedirect: Suppress" );
@@ -2633,13 +2658,15 @@ static void do__http_post__gvfs_objects(struct gh__response_status *status,
2633
2658
params .headers = curl_slist_append (params .headers ,
2634
2659
"Content-Type: application/json" );
2635
2660
/*
2636
- * We really always want a packfile. But if the payload only
2637
- * requests 1 OID, the server will send us a single loose
2638
- * objects instead. (Apparently the server ignores us when we
2639
- * only send application/x-git-packfile and does it anyway. )
2661
+ * If our POST contains more than one object, we want the
2662
+ * server to send us a packfile. We DO NOT want the non-standard
2663
+ * concatenated loose object format, so we DO NOT send:
2664
+ * "Accept: application/x-git-loose-objects" (plural )
2640
2665
*
2641
- * So to make it clear to my future self, go ahead and add
2642
- * an accept header for loose objects and own it.
2666
+ * However, if the payload only requests 1 OID, the server
2667
+ * will send us a single loose object instead of a packfile,
2668
+ * so we ACK that and send:
2669
+ * "Accept: application/x-git-loose-object" (singular)
2643
2670
*/
2644
2671
params .headers = curl_slist_append (params .headers ,
2645
2672
"Accept: application/x-git-packfile" );
@@ -2650,20 +2677,6 @@ static void do__http_post__gvfs_objects(struct gh__response_status *status,
2650
2677
2651
2678
do_req__with_fallback ("gvfs/objects" , & params , status );
2652
2679
2653
- if (status -> ec == GH__ERROR_CODE__OK ) {
2654
- struct strbuf msg = STRBUF_INIT ;
2655
-
2656
- if (params .object_count > 1 )
2657
- strbuf_addf (& msg , "packfile %s" ,
2658
- params .final_packfile_filename .buf );
2659
- else
2660
- strbuf_addf (& msg , "loose %s" ,
2661
- oid_to_hex (& params .loose_oid ));
2662
-
2663
- string_list_append (result_list , msg .buf );
2664
- strbuf_release (& msg );
2665
- }
2666
-
2667
2680
gh__request_params__release (& params );
2668
2681
jw_release (& jw_req );
2669
2682
}
0 commit comments