@@ -458,6 +458,8 @@ struct gh__request_params {
458458 struct progress * progress ;
459459
460460 struct strbuf e2eid ;
461+
462+ struct string_list * result_list ; /* we do not own this */
461463};
462464
463465#define GH__REQUEST_PARAMS_INIT { \
@@ -486,6 +488,7 @@ struct gh__request_params {
486488 .progress_msg = STRBUF_INIT, \
487489 .progress = NULL, \
488490 .e2eid = STRBUF_INIT, \
491+ .result_list = NULL, \
489492 }
490493
491494static void gh__request_params__release (struct gh__request_params * params )
@@ -518,6 +521,8 @@ static void gh__request_params__release(struct gh__request_params *params)
518521 params -> progress = NULL ;
519522
520523 strbuf_release (& params -> e2eid );
524+
525+ params -> result_list = NULL ; /* we do not own this */
521526}
522527
523528/*
@@ -1878,6 +1883,16 @@ static void install_packfile(struct gh__request_params *params,
18781883 goto cleanup ;
18791884 }
18801885
1886+
1887+ if (params -> result_list ) {
1888+ struct strbuf result_msg = STRBUF_INIT ;
1889+
1890+ strbuf_addf (& result_msg , "packfile %s" ,
1891+ params -> final_packfile_filename .buf );
1892+ string_list_append (params -> result_list , result_msg .buf );
1893+ strbuf_release (& result_msg );
1894+ }
1895+
18811896cleanup :
18821897 child_process_clear (& ip );
18831898}
@@ -1934,8 +1949,19 @@ static void install_loose(struct gh__request_params *params,
19341949 "could not install loose object '%s'" ,
19351950 params -> loose_path .buf );
19361951 status -> ec = GH__ERROR_CODE__COULD_NOT_INSTALL_LOOSE ;
1952+ goto cleanup ;
1953+ }
1954+
1955+ if (params -> result_list ) {
1956+ struct strbuf result_msg = STRBUF_INIT ;
1957+
1958+ strbuf_addf (& result_msg , "loose %s" ,
1959+ oid_to_hex (& params -> loose_oid ));
1960+ string_list_append (params -> result_list , result_msg .buf );
1961+ strbuf_release (& result_msg );
19371962 }
19381963
1964+ cleanup :
19391965 strbuf_release (& tmp_path );
19401966}
19411967
@@ -2608,7 +2634,7 @@ static void setup_gvfs_objects_progress(struct gh__request_params *params,
26082634 if (!gh__cmd_opts .show_progress )
26092635 return ;
26102636
2611- if (params -> b_is_post && params -> object_count > 1 ) {
2637+ if (params -> b_is_post ) {
26122638 strbuf_addf (& params -> progress_base_phase3_msg ,
26132639 "Receiving packfile %ld/%ld with %ld objects" ,
26142640 num , den , params -> object_count );
@@ -2640,6 +2666,8 @@ static void do__http_get__gvfs_object(struct gh__response_status *status,
26402666
26412667 params .object_count = 1 ;
26422668
2669+ params .result_list = result_list ;
2670+
26432671 params .headers = http_copy_default_headers ();
26442672 params .headers = curl_slist_append (params .headers ,
26452673 "X-TFS-FedAuthRedirect: Suppress" );
@@ -2652,16 +2680,6 @@ static void do__http_get__gvfs_object(struct gh__response_status *status,
26522680
26532681 do_req__with_fallback (component_url .buf , & params , status );
26542682
2655- if (status -> ec == GH__ERROR_CODE__OK ) {
2656- struct strbuf msg = STRBUF_INIT ;
2657-
2658- strbuf_addf (& msg , "loose %s" ,
2659- oid_to_hex (& params .loose_oid ));
2660-
2661- string_list_append (result_list , msg .buf );
2662- strbuf_release (& msg );
2663- }
2664-
26652683 gh__request_params__release (& params );
26662684 strbuf_release (& component_url );
26672685}
@@ -2673,7 +2691,7 @@ static void do__http_get__gvfs_object(struct gh__response_status *status,
26732691 * consumed (along with the filename of the resulting packfile).
26742692 *
26752693 * However, if we only have 1 oid (remaining) in the OIDSET, the
2676- * server will respond to our POST with a loose object rather than
2694+ * server *MAY* respond to our POST with a loose object rather than
26772695 * a packfile with 1 object.
26782696 *
26792697 * Append a message to the result_list describing the result.
@@ -2704,6 +2722,8 @@ static void do__http_post__gvfs_objects(struct gh__response_status *status,
27042722
27052723 params .post_payload = & jw_req .json ;
27062724
2725+ params .result_list = result_list ;
2726+
27072727 params .headers = http_copy_default_headers ();
27082728 params .headers = curl_slist_append (params .headers ,
27092729 "X-TFS-FedAuthRedirect: Suppress" );
@@ -2731,20 +2751,6 @@ static void do__http_post__gvfs_objects(struct gh__response_status *status,
27312751
27322752 do_req__with_fallback ("gvfs/objects" , & params , status );
27332753
2734- if (status -> ec == GH__ERROR_CODE__OK ) {
2735- struct strbuf msg = STRBUF_INIT ;
2736-
2737- if (params .object_count > 1 )
2738- strbuf_addf (& msg , "packfile %s" ,
2739- params .final_packfile_filename .buf );
2740- else
2741- strbuf_addf (& msg , "loose %s" ,
2742- oid_to_hex (& params .loose_oid ));
2743-
2744- string_list_append (result_list , msg .buf );
2745- strbuf_release (& msg );
2746- }
2747-
27482754 gh__request_params__release (& params );
27492755 jw_release (& jw_req );
27502756}
0 commit comments