1- #define USE_THE_REPOSITORY_VARIABLE
2-
31#include "git-compat-util.h"
42#include "config.h"
53#include "commit.h"
@@ -44,10 +42,11 @@ int option_parse_push_signed(const struct option *opt,
4442 die ("bad %s argument: %s" , opt -> long_name , arg );
4543}
4644
47- static void feed_object (const struct object_id * oid , FILE * fh , int negative )
45+ static void feed_object (struct repository * r ,
46+ const struct object_id * oid , FILE * fh , int negative )
4847{
4948 if (negative &&
50- !repo_has_object_file_with_flags (the_repository , oid ,
49+ !repo_has_object_file_with_flags (r , oid ,
5150 OBJECT_INFO_SKIP_FETCH_OBJECT |
5251 OBJECT_INFO_QUICK ))
5352 return ;
@@ -61,7 +60,8 @@ static void feed_object(const struct object_id *oid, FILE *fh, int negative)
6160/*
6261 * Make a pack stream and spit it out into file descriptor fd
6362 */
64- static int pack_objects (int fd , struct ref * refs , struct oid_array * advertised ,
63+ static int pack_objects (struct repository * r ,
64+ int fd , struct ref * refs , struct oid_array * advertised ,
6565 struct oid_array * negotiated ,
6666 struct send_pack_args * args )
6767{
@@ -74,7 +74,7 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,
7474 FILE * po_in ;
7575 int rc ;
7676
77- trace2_region_enter ("send_pack" , "pack_objects" , the_repository );
77+ trace2_region_enter ("send_pack" , "pack_objects" , r );
7878 strvec_push (& po .args , "pack-objects" );
7979 strvec_push (& po .args , "--all-progress-implied" );
8080 strvec_push (& po .args , "--revs" );
@@ -87,7 +87,7 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,
8787 strvec_push (& po .args , "-q" );
8888 if (args -> progress )
8989 strvec_push (& po .args , "--progress" );
90- if (is_repository_shallow (the_repository ))
90+ if (is_repository_shallow (r ))
9191 strvec_push (& po .args , "--shallow" );
9292 if (args -> disable_bitmaps )
9393 strvec_push (& po .args , "--no-use-bitmap-index" );
@@ -104,15 +104,15 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,
104104 */
105105 po_in = xfdopen (po .in , "w" );
106106 for (size_t i = 0 ; i < advertised -> nr ; i ++ )
107- feed_object (& advertised -> oid [i ], po_in , 1 );
107+ feed_object (r , & advertised -> oid [i ], po_in , 1 );
108108 for (size_t i = 0 ; i < negotiated -> nr ; i ++ )
109- feed_object (& negotiated -> oid [i ], po_in , 1 );
109+ feed_object (r , & negotiated -> oid [i ], po_in , 1 );
110110
111111 while (refs ) {
112112 if (!is_null_oid (& refs -> old_oid ))
113- feed_object (& refs -> old_oid , po_in , 1 );
113+ feed_object (r , & refs -> old_oid , po_in , 1 );
114114 if (!is_null_oid (& refs -> new_oid ))
115- feed_object (& refs -> new_oid , po_in , 0 );
115+ feed_object (r , & refs -> new_oid , po_in , 0 );
116116 refs = refs -> next ;
117117 }
118118
@@ -146,10 +146,10 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,
146146 */
147147 if (rc > 128 && rc != 141 )
148148 error ("pack-objects died of signal %d" , rc - 128 );
149- trace2_region_leave ("send_pack" , "pack_objects" , the_repository );
149+ trace2_region_leave ("send_pack" , "pack_objects" , r );
150150 return -1 ;
151151 }
152- trace2_region_leave ("send_pack" , "pack_objects" , the_repository );
152+ trace2_region_leave ("send_pack" , "pack_objects" , r );
153153 return 0 ;
154154}
155155
@@ -164,15 +164,16 @@ static int receive_unpack_status(struct packet_reader *reader)
164164 return 0 ;
165165}
166166
167- static int receive_status (struct packet_reader * reader , struct ref * refs )
167+ static int receive_status (struct repository * r ,
168+ struct packet_reader * reader , struct ref * refs )
168169{
169170 struct ref * hint ;
170171 int ret ;
171172 struct ref_push_report * report = NULL ;
172173 int new_report = 0 ;
173174 int once = 0 ;
174175
175- trace2_region_enter ("send_pack" , "receive_status" , the_repository );
176+ trace2_region_enter ("send_pack" , "receive_status" , r );
176177 hint = NULL ;
177178 ret = receive_unpack_status (reader );
178179 while (1 ) {
@@ -221,10 +222,10 @@ static int receive_status(struct packet_reader *reader, struct ref *refs)
221222 if (!strcmp (key , "refname" ))
222223 report -> ref_name = xstrdup_or_null (val );
223224 else if (!strcmp (key , "old-oid" ) && val &&
224- !parse_oid_hex (val , & old_oid , & val ))
225+ !parse_oid_hex_algop (val , & old_oid , & val , r -> hash_algo ))
225226 report -> old_oid = oiddup (& old_oid );
226227 else if (!strcmp (key , "new-oid" ) && val &&
227- !parse_oid_hex (val , & new_oid , & val ))
228+ !parse_oid_hex_algop (val , & new_oid , & val , r -> hash_algo ))
228229 report -> new_oid = oiddup (& new_oid );
229230 else if (!strcmp (key , "forced-update" ))
230231 report -> forced_update = 1 ;
@@ -271,7 +272,7 @@ static int receive_status(struct packet_reader *reader, struct ref *refs)
271272 new_report = 1 ;
272273 }
273274 }
274- trace2_region_leave ("send_pack" , "receive_status" , the_repository );
275+ trace2_region_leave ("send_pack" , "receive_status" , r );
275276 return ret ;
276277}
277278
@@ -293,9 +294,9 @@ static int advertise_shallow_grafts_cb(const struct commit_graft *graft, void *c
293294 return 0 ;
294295}
295296
296- static void advertise_shallow_grafts_buf (struct strbuf * sb )
297+ static void advertise_shallow_grafts_buf (struct repository * r , struct strbuf * sb )
297298{
298- if (!is_repository_shallow (the_repository ))
299+ if (!is_repository_shallow (r ))
299300 return ;
300301 for_each_commit_graft (advertise_shallow_grafts_cb , sb );
301302}
@@ -426,13 +427,14 @@ static void reject_invalid_nonce(const char *nonce, int len)
426427 }
427428}
428429
429- static void get_commons_through_negotiation (const char * url ,
430+ static void get_commons_through_negotiation (struct repository * r ,
431+ const char * url ,
430432 const struct ref * remote_refs ,
431433 struct oid_array * commons )
432434{
433435 struct child_process child = CHILD_PROCESS_INIT ;
434436 const struct ref * ref ;
435- int len = the_hash_algo -> hexsz + 1 ; /* hash + NL */
437+ int len = r -> hash_algo -> hexsz + 1 ; /* hash + NL */
436438 int nr_negotiation_tip = 0 ;
437439
438440 child .git_cmd = 1 ;
@@ -466,7 +468,7 @@ static void get_commons_through_negotiation(const char *url,
466468 break ;
467469 if (read_len != len )
468470 die ("invalid length read %d" , read_len );
469- if (parse_oid_hex (hex_hash , & oid , & end ) || * end != '\n' )
471+ if (parse_oid_hex_algop (hex_hash , & oid , & end , r -> hash_algo ) || * end != '\n' )
470472 die ("invalid hash" );
471473 oid_array_append (commons , & oid );
472474 } while (1 );
@@ -480,7 +482,8 @@ static void get_commons_through_negotiation(const char *url,
480482 }
481483}
482484
483- int send_pack (struct send_pack_args * args ,
485+ int send_pack (struct repository * r ,
486+ struct send_pack_args * args ,
484487 int fd [], struct child_process * conn ,
485488 struct ref * remote_refs ,
486489 struct oid_array * extra_have )
@@ -518,17 +521,17 @@ int send_pack(struct send_pack_args *args,
518521 goto out ;
519522 }
520523
521- git_config_get_bool ( "push.negotiate" , & push_negotiate );
524+ repo_config_get_bool ( r , "push.negotiate" , & push_negotiate );
522525 if (push_negotiate ) {
523- trace2_region_enter ("send_pack" , "push_negotiate" , the_repository );
524- get_commons_through_negotiation (args -> url , remote_refs , & commons );
525- trace2_region_leave ("send_pack" , "push_negotiate" , the_repository );
526+ trace2_region_enter ("send_pack" , "push_negotiate" , r );
527+ get_commons_through_negotiation (r , args -> url , remote_refs , & commons );
528+ trace2_region_leave ("send_pack" , "push_negotiate" , r );
526529 }
527530
528- if (!git_config_get_bool ( "push.usebitmaps" , & use_bitmaps ))
531+ if (!repo_config_get_bool ( r , "push.usebitmaps" , & use_bitmaps ))
529532 args -> disable_bitmaps = !use_bitmaps ;
530533
531- git_config_get_bool ( "transfer.advertisesid" , & advertise_sid );
534+ repo_config_get_bool ( r , "transfer.advertisesid" , & advertise_sid );
532535
533536 /* Does the other end support the reporting? */
534537 if (server_supports ("report-status-v2" ))
@@ -554,7 +557,7 @@ int send_pack(struct send_pack_args *args,
554557 if (server_supports ("push-options" ))
555558 push_options_supported = 1 ;
556559
557- if (!server_supports_hash (the_hash_algo -> name , & object_format_supported ))
560+ if (!server_supports_hash (r -> hash_algo -> name , & object_format_supported ))
558561 die (_ ("the receiving end does not support this repository's hash algorithm" ));
559562
560563 if (args -> push_cert != SEND_PACK_PUSH_CERT_NEVER ) {
@@ -596,7 +599,7 @@ int send_pack(struct send_pack_args *args,
596599 if (use_push_options )
597600 strbuf_addstr (& cap_buf , " push-options" );
598601 if (object_format_supported )
599- strbuf_addf (& cap_buf , " object-format=%s" , the_hash_algo -> name );
602+ strbuf_addf (& cap_buf , " object-format=%s" , r -> hash_algo -> name );
600603 if (agent_supported )
601604 strbuf_addf (& cap_buf , " agent=%s" , git_user_agent_sanitized ());
602605 if (advertise_sid )
@@ -646,7 +649,7 @@ int send_pack(struct send_pack_args *args,
646649 }
647650
648651 if (!args -> dry_run )
649- advertise_shallow_grafts_buf (& req_buf );
652+ advertise_shallow_grafts_buf (r , & req_buf );
650653
651654 /*
652655 * Finally, tell the other end!
@@ -686,7 +689,7 @@ int send_pack(struct send_pack_args *args,
686689 }
687690
688691 if (args -> stateless_rpc ) {
689- if (!args -> dry_run && (cmds_sent || is_repository_shallow (the_repository ))) {
692+ if (!args -> dry_run && (cmds_sent || is_repository_shallow (r ))) {
690693 packet_buf_flush (& req_buf );
691694 send_sideband (out , -1 , req_buf .buf , req_buf .len , LARGE_PACKET_MAX );
692695 }
@@ -711,7 +714,7 @@ int send_pack(struct send_pack_args *args,
711714 PACKET_READ_DIE_ON_ERR_PACKET );
712715
713716 if (need_pack_data && cmds_sent ) {
714- if (pack_objects (out , remote_refs , extra_have , & commons , args ) < 0 ) {
717+ if (pack_objects (r , out , remote_refs , extra_have , & commons , args ) < 0 ) {
715718 if (args -> stateless_rpc )
716719 close (out );
717720 if (git_connection_is_socket (conn ))
@@ -724,7 +727,7 @@ int send_pack(struct send_pack_args *args,
724727 * we get one).
725728 */
726729 if (status_report )
727- receive_status (& reader , remote_refs );
730+ receive_status (r , & reader , remote_refs );
728731
729732 if (use_sideband ) {
730733 close (demux .out );
@@ -743,7 +746,7 @@ int send_pack(struct send_pack_args *args,
743746 packet_flush (out );
744747
745748 if (status_report && cmds_sent )
746- ret = receive_status (& reader , remote_refs );
749+ ret = receive_status (r , & reader , remote_refs );
747750 else
748751 ret = 0 ;
749752 if (args -> stateless_rpc )
0 commit comments