1
- #define USE_THE_REPOSITORY_VARIABLE
2
-
3
1
#include "git-compat-util.h"
4
2
#include "config.h"
5
3
#include "commit.h"
@@ -44,10 +42,11 @@ int option_parse_push_signed(const struct option *opt,
44
42
die ("bad %s argument: %s" , opt -> long_name , arg );
45
43
}
46
44
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 )
48
47
{
49
48
if (negative &&
50
- !repo_has_object_file_with_flags (the_repository , oid ,
49
+ !repo_has_object_file_with_flags (r , oid ,
51
50
OBJECT_INFO_SKIP_FETCH_OBJECT |
52
51
OBJECT_INFO_QUICK ))
53
52
return ;
@@ -61,7 +60,8 @@ static void feed_object(const struct object_id *oid, FILE *fh, int negative)
61
60
/*
62
61
* Make a pack stream and spit it out into file descriptor fd
63
62
*/
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 ,
65
65
struct oid_array * negotiated ,
66
66
struct send_pack_args * args )
67
67
{
@@ -74,7 +74,7 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,
74
74
FILE * po_in ;
75
75
int rc ;
76
76
77
- trace2_region_enter ("send_pack" , "pack_objects" , the_repository );
77
+ trace2_region_enter ("send_pack" , "pack_objects" , r );
78
78
strvec_push (& po .args , "pack-objects" );
79
79
strvec_push (& po .args , "--all-progress-implied" );
80
80
strvec_push (& po .args , "--revs" );
@@ -87,7 +87,7 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,
87
87
strvec_push (& po .args , "-q" );
88
88
if (args -> progress )
89
89
strvec_push (& po .args , "--progress" );
90
- if (is_repository_shallow (the_repository ))
90
+ if (is_repository_shallow (r ))
91
91
strvec_push (& po .args , "--shallow" );
92
92
if (args -> disable_bitmaps )
93
93
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,
104
104
*/
105
105
po_in = xfdopen (po .in , "w" );
106
106
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 );
108
108
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 );
110
110
111
111
while (refs ) {
112
112
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 );
114
114
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 );
116
116
refs = refs -> next ;
117
117
}
118
118
@@ -146,10 +146,10 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,
146
146
*/
147
147
if (rc > 128 && rc != 141 )
148
148
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 );
150
150
return -1 ;
151
151
}
152
- trace2_region_leave ("send_pack" , "pack_objects" , the_repository );
152
+ trace2_region_leave ("send_pack" , "pack_objects" , r );
153
153
return 0 ;
154
154
}
155
155
@@ -164,15 +164,16 @@ static int receive_unpack_status(struct packet_reader *reader)
164
164
return 0 ;
165
165
}
166
166
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 )
168
169
{
169
170
struct ref * hint ;
170
171
int ret ;
171
172
struct ref_push_report * report = NULL ;
172
173
int new_report = 0 ;
173
174
int once = 0 ;
174
175
175
- trace2_region_enter ("send_pack" , "receive_status" , the_repository );
176
+ trace2_region_enter ("send_pack" , "receive_status" , r );
176
177
hint = NULL ;
177
178
ret = receive_unpack_status (reader );
178
179
while (1 ) {
@@ -221,10 +222,10 @@ static int receive_status(struct packet_reader *reader, struct ref *refs)
221
222
if (!strcmp (key , "refname" ))
222
223
report -> ref_name = xstrdup_or_null (val );
223
224
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 ))
225
226
report -> old_oid = oiddup (& old_oid );
226
227
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 ))
228
229
report -> new_oid = oiddup (& new_oid );
229
230
else if (!strcmp (key , "forced-update" ))
230
231
report -> forced_update = 1 ;
@@ -271,7 +272,7 @@ static int receive_status(struct packet_reader *reader, struct ref *refs)
271
272
new_report = 1 ;
272
273
}
273
274
}
274
- trace2_region_leave ("send_pack" , "receive_status" , the_repository );
275
+ trace2_region_leave ("send_pack" , "receive_status" , r );
275
276
return ret ;
276
277
}
277
278
@@ -293,9 +294,9 @@ static int advertise_shallow_grafts_cb(const struct commit_graft *graft, void *c
293
294
return 0 ;
294
295
}
295
296
296
- static void advertise_shallow_grafts_buf (struct strbuf * sb )
297
+ static void advertise_shallow_grafts_buf (struct repository * r , struct strbuf * sb )
297
298
{
298
- if (!is_repository_shallow (the_repository ))
299
+ if (!is_repository_shallow (r ))
299
300
return ;
300
301
for_each_commit_graft (advertise_shallow_grafts_cb , sb );
301
302
}
@@ -426,13 +427,14 @@ static void reject_invalid_nonce(const char *nonce, int len)
426
427
}
427
428
}
428
429
429
- static void get_commons_through_negotiation (const char * url ,
430
+ static void get_commons_through_negotiation (struct repository * r ,
431
+ const char * url ,
430
432
const struct ref * remote_refs ,
431
433
struct oid_array * commons )
432
434
{
433
435
struct child_process child = CHILD_PROCESS_INIT ;
434
436
const struct ref * ref ;
435
- int len = the_hash_algo -> hexsz + 1 ; /* hash + NL */
437
+ int len = r -> hash_algo -> hexsz + 1 ; /* hash + NL */
436
438
int nr_negotiation_tip = 0 ;
437
439
438
440
child .git_cmd = 1 ;
@@ -466,7 +468,7 @@ static void get_commons_through_negotiation(const char *url,
466
468
break ;
467
469
if (read_len != len )
468
470
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' )
470
472
die ("invalid hash" );
471
473
oid_array_append (commons , & oid );
472
474
} while (1 );
@@ -480,7 +482,8 @@ static void get_commons_through_negotiation(const char *url,
480
482
}
481
483
}
482
484
483
- int send_pack (struct send_pack_args * args ,
485
+ int send_pack (struct repository * r ,
486
+ struct send_pack_args * args ,
484
487
int fd [], struct child_process * conn ,
485
488
struct ref * remote_refs ,
486
489
struct oid_array * extra_have )
@@ -518,17 +521,17 @@ int send_pack(struct send_pack_args *args,
518
521
goto out ;
519
522
}
520
523
521
- git_config_get_bool ( "push.negotiate" , & push_negotiate );
524
+ repo_config_get_bool ( r , "push.negotiate" , & push_negotiate );
522
525
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 );
526
529
}
527
530
528
- if (!git_config_get_bool ( "push.usebitmaps" , & use_bitmaps ))
531
+ if (!repo_config_get_bool ( r , "push.usebitmaps" , & use_bitmaps ))
529
532
args -> disable_bitmaps = !use_bitmaps ;
530
533
531
- git_config_get_bool ( "transfer.advertisesid" , & advertise_sid );
534
+ repo_config_get_bool ( r , "transfer.advertisesid" , & advertise_sid );
532
535
533
536
/* Does the other end support the reporting? */
534
537
if (server_supports ("report-status-v2" ))
@@ -554,7 +557,7 @@ int send_pack(struct send_pack_args *args,
554
557
if (server_supports ("push-options" ))
555
558
push_options_supported = 1 ;
556
559
557
- if (!server_supports_hash (the_hash_algo -> name , & object_format_supported ))
560
+ if (!server_supports_hash (r -> hash_algo -> name , & object_format_supported ))
558
561
die (_ ("the receiving end does not support this repository's hash algorithm" ));
559
562
560
563
if (args -> push_cert != SEND_PACK_PUSH_CERT_NEVER ) {
@@ -596,7 +599,7 @@ int send_pack(struct send_pack_args *args,
596
599
if (use_push_options )
597
600
strbuf_addstr (& cap_buf , " push-options" );
598
601
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 );
600
603
if (agent_supported )
601
604
strbuf_addf (& cap_buf , " agent=%s" , git_user_agent_sanitized ());
602
605
if (advertise_sid )
@@ -646,7 +649,7 @@ int send_pack(struct send_pack_args *args,
646
649
}
647
650
648
651
if (!args -> dry_run )
649
- advertise_shallow_grafts_buf (& req_buf );
652
+ advertise_shallow_grafts_buf (r , & req_buf );
650
653
651
654
/*
652
655
* Finally, tell the other end!
@@ -686,7 +689,7 @@ int send_pack(struct send_pack_args *args,
686
689
}
687
690
688
691
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 ))) {
690
693
packet_buf_flush (& req_buf );
691
694
send_sideband (out , -1 , req_buf .buf , req_buf .len , LARGE_PACKET_MAX );
692
695
}
@@ -711,7 +714,7 @@ int send_pack(struct send_pack_args *args,
711
714
PACKET_READ_DIE_ON_ERR_PACKET );
712
715
713
716
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 ) {
715
718
if (args -> stateless_rpc )
716
719
close (out );
717
720
if (git_connection_is_socket (conn ))
@@ -724,7 +727,7 @@ int send_pack(struct send_pack_args *args,
724
727
* we get one).
725
728
*/
726
729
if (status_report )
727
- receive_status (& reader , remote_refs );
730
+ receive_status (r , & reader , remote_refs );
728
731
729
732
if (use_sideband ) {
730
733
close (demux .out );
@@ -743,7 +746,7 @@ int send_pack(struct send_pack_args *args,
743
746
packet_flush (out );
744
747
745
748
if (status_report && cmds_sent )
746
- ret = receive_status (& reader , remote_refs );
749
+ ret = receive_status (r , & reader , remote_refs );
747
750
else
748
751
ret = 0 ;
749
752
if (args -> stateless_rpc )
0 commit comments