@@ -450,6 +450,8 @@ struct gh__request_params {
450
450
struct progress * progress ;
451
451
452
452
struct strbuf e2eid ;
453
+
454
+ struct string_list * result_list ; /* we do not own this */
453
455
};
454
456
455
457
#define GH__REQUEST_PARAMS_INIT { \
@@ -478,6 +480,7 @@ struct gh__request_params {
478
480
.progress_msg = STRBUF_INIT, \
479
481
.progress = NULL, \
480
482
.e2eid = STRBUF_INIT, \
483
+ .result_list = NULL, \
481
484
}
482
485
483
486
static void gh__request_params__release (struct gh__request_params * params )
@@ -510,6 +513,8 @@ static void gh__request_params__release(struct gh__request_params *params)
510
513
params -> progress = NULL ;
511
514
512
515
strbuf_release (& params -> e2eid );
516
+
517
+ params -> result_list = NULL ; /* we do not own this */
513
518
}
514
519
515
520
/*
@@ -1870,6 +1875,16 @@ static void install_packfile(struct gh__request_params *params,
1870
1875
goto cleanup ;
1871
1876
}
1872
1877
1878
+
1879
+ if (params -> result_list ) {
1880
+ struct strbuf result_msg = STRBUF_INIT ;
1881
+
1882
+ strbuf_addf (& result_msg , "packfile %s" ,
1883
+ params -> final_packfile_filename .buf );
1884
+ string_list_append (params -> result_list , result_msg .buf );
1885
+ strbuf_release (& result_msg );
1886
+ }
1887
+
1873
1888
cleanup :
1874
1889
child_process_clear (& ip );
1875
1890
}
@@ -1926,8 +1941,19 @@ static void install_loose(struct gh__request_params *params,
1926
1941
"could not install loose object '%s'" ,
1927
1942
params -> loose_path .buf );
1928
1943
status -> ec = GH__ERROR_CODE__COULD_NOT_INSTALL_LOOSE ;
1944
+ goto cleanup ;
1945
+ }
1946
+
1947
+ if (params -> result_list ) {
1948
+ struct strbuf result_msg = STRBUF_INIT ;
1949
+
1950
+ strbuf_addf (& result_msg , "loose %s" ,
1951
+ oid_to_hex (& params -> loose_oid ));
1952
+ string_list_append (params -> result_list , result_msg .buf );
1953
+ strbuf_release (& result_msg );
1929
1954
}
1930
1955
1956
+ cleanup :
1931
1957
strbuf_release (& tmp_path );
1932
1958
}
1933
1959
@@ -2596,7 +2622,7 @@ static void setup_gvfs_objects_progress(struct gh__request_params *params,
2596
2622
if (!gh__cmd_opts .show_progress )
2597
2623
return ;
2598
2624
2599
- if (params -> b_is_post && params -> object_count > 1 ) {
2625
+ if (params -> b_is_post ) {
2600
2626
strbuf_addf (& params -> progress_base_phase3_msg ,
2601
2627
"Receiving packfile %ld/%ld with %ld objects" ,
2602
2628
num , den , params -> object_count );
@@ -2628,6 +2654,8 @@ static void do__http_get__gvfs_object(struct gh__response_status *status,
2628
2654
2629
2655
params .object_count = 1 ;
2630
2656
2657
+ params .result_list = result_list ;
2658
+
2631
2659
params .headers = http_copy_default_headers ();
2632
2660
params .headers = curl_slist_append (params .headers ,
2633
2661
"X-TFS-FedAuthRedirect: Suppress" );
@@ -2640,16 +2668,6 @@ static void do__http_get__gvfs_object(struct gh__response_status *status,
2640
2668
2641
2669
do_req__with_fallback (component_url .buf , & params , status );
2642
2670
2643
- if (status -> ec == GH__ERROR_CODE__OK ) {
2644
- struct strbuf msg = STRBUF_INIT ;
2645
-
2646
- strbuf_addf (& msg , "loose %s" ,
2647
- oid_to_hex (& params .loose_oid ));
2648
-
2649
- string_list_append (result_list , msg .buf );
2650
- strbuf_release (& msg );
2651
- }
2652
-
2653
2671
gh__request_params__release (& params );
2654
2672
strbuf_release (& component_url );
2655
2673
}
@@ -2661,7 +2679,7 @@ static void do__http_get__gvfs_object(struct gh__response_status *status,
2661
2679
* consumed (along with the filename of the resulting packfile).
2662
2680
*
2663
2681
* However, if we only have 1 oid (remaining) in the OIDSET, the
2664
- * server will respond to our POST with a loose object rather than
2682
+ * server *MAY* respond to our POST with a loose object rather than
2665
2683
* a packfile with 1 object.
2666
2684
*
2667
2685
* Append a message to the result_list describing the result.
@@ -2692,6 +2710,8 @@ static void do__http_post__gvfs_objects(struct gh__response_status *status,
2692
2710
2693
2711
params .post_payload = & jw_req .json ;
2694
2712
2713
+ params .result_list = result_list ;
2714
+
2695
2715
params .headers = http_copy_default_headers ();
2696
2716
params .headers = curl_slist_append (params .headers ,
2697
2717
"X-TFS-FedAuthRedirect: Suppress" );
@@ -2719,20 +2739,6 @@ static void do__http_post__gvfs_objects(struct gh__response_status *status,
2719
2739
2720
2740
do_req__with_fallback ("gvfs/objects" , & params , status );
2721
2741
2722
- if (status -> ec == GH__ERROR_CODE__OK ) {
2723
- struct strbuf msg = STRBUF_INIT ;
2724
-
2725
- if (params .object_count > 1 )
2726
- strbuf_addf (& msg , "packfile %s" ,
2727
- params .final_packfile_filename .buf );
2728
- else
2729
- strbuf_addf (& msg , "loose %s" ,
2730
- oid_to_hex (& params .loose_oid ));
2731
-
2732
- string_list_append (result_list , msg .buf );
2733
- strbuf_release (& msg );
2734
- }
2735
-
2736
2742
gh__request_params__release (& params );
2737
2743
jw_release (& jw_req );
2738
2744
}
0 commit comments