@@ -797,12 +797,13 @@ static void write_promisor_file(const char *keep_name,
797
797
}
798
798
799
799
/*
800
- * Pass 1 as "only_packfile" if the pack received is the only pack in this
801
- * fetch request (that is, if there were no packfile URIs provided).
800
+ * If packfile URIs were provided, pass a non-NULL pointer to index_pack_args.
801
+ * The strings to pass as the --index-pack-arg arguments to http-fetch will be
802
+ * stored there. (It must be freed by the caller.)
802
803
*/
803
804
static int get_pack (struct fetch_pack_args * args ,
804
805
int xd [2 ], struct string_list * pack_lockfiles ,
805
- int only_packfile ,
806
+ struct strvec * index_pack_args ,
806
807
struct ref * * sought , int nr_sought )
807
808
{
808
809
struct async demux ;
@@ -845,7 +846,7 @@ static int get_pack(struct fetch_pack_args *args,
845
846
strvec_push (& cmd .args , alternate_shallow_file );
846
847
}
847
848
848
- if (do_keep || args -> from_promisor ) {
849
+ if (do_keep || args -> from_promisor || index_pack_args ) {
849
850
if (pack_lockfiles )
850
851
cmd .out = -1 ;
851
852
cmd_name = "index-pack" ;
@@ -863,7 +864,7 @@ static int get_pack(struct fetch_pack_args *args,
863
864
"--keep=fetch-pack %" PRIuMAX " on %s" ,
864
865
(uintmax_t )getpid (), hostname );
865
866
}
866
- if (only_packfile && args -> check_self_contained_and_connected )
867
+ if (! index_pack_args && args -> check_self_contained_and_connected )
867
868
strvec_push (& cmd .args , "--check-self-contained-and-connected" );
868
869
else
869
870
/*
@@ -901,7 +902,7 @@ static int get_pack(struct fetch_pack_args *args,
901
902
: transfer_fsck_objects >= 0
902
903
? transfer_fsck_objects
903
904
: 0 ) {
904
- if (args -> from_promisor || ! only_packfile )
905
+ if (args -> from_promisor || index_pack_args )
905
906
/*
906
907
* We cannot use --strict in index-pack because it
907
908
* checks both broken objects and links, but we only
@@ -913,6 +914,13 @@ static int get_pack(struct fetch_pack_args *args,
913
914
fsck_msg_types .buf );
914
915
}
915
916
917
+ if (index_pack_args ) {
918
+ int i ;
919
+
920
+ for (i = 0 ; i < cmd .args .nr ; i ++ )
921
+ strvec_push (index_pack_args , cmd .args .v [i ]);
922
+ }
923
+
916
924
cmd .in = demux .out ;
917
925
cmd .git_cmd = 1 ;
918
926
if (start_command (& cmd ))
@@ -1084,7 +1092,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
1084
1092
alternate_shallow_file = setup_temporary_shallow (si -> shallow );
1085
1093
else
1086
1094
alternate_shallow_file = NULL ;
1087
- if (get_pack (args , fd , pack_lockfiles , 1 , sought , nr_sought ))
1095
+ if (get_pack (args , fd , pack_lockfiles , NULL , sought , nr_sought ))
1088
1096
die (_ ("git fetch-pack: fetch failed." ));
1089
1097
1090
1098
all_done :
@@ -1535,6 +1543,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1535
1543
int seen_ack = 0 ;
1536
1544
struct string_list packfile_uris = STRING_LIST_INIT_DUP ;
1537
1545
int i ;
1546
+ struct strvec index_pack_args = STRVEC_INIT ;
1538
1547
1539
1548
negotiator = & negotiator_alloc ;
1540
1549
fetch_negotiator_init (r , negotiator );
@@ -1624,7 +1633,8 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1624
1633
receive_packfile_uris (& reader , & packfile_uris );
1625
1634
process_section_header (& reader , "packfile" , 0 );
1626
1635
if (get_pack (args , fd , pack_lockfiles ,
1627
- !packfile_uris .nr , sought , nr_sought ))
1636
+ packfile_uris .nr ? & index_pack_args : NULL ,
1637
+ sought , nr_sought ))
1628
1638
die (_ ("git fetch-pack: fetch failed." ));
1629
1639
do_check_stateless_delimiter (args , & reader );
1630
1640
@@ -1636,6 +1646,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1636
1646
}
1637
1647
1638
1648
for (i = 0 ; i < packfile_uris .nr ; i ++ ) {
1649
+ int j ;
1639
1650
struct child_process cmd = CHILD_PROCESS_INIT ;
1640
1651
char packname [GIT_MAX_HEXSZ + 1 ];
1641
1652
const char * uri = packfile_uris .items [i ].string +
@@ -1645,9 +1656,9 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1645
1656
strvec_pushf (& cmd .args , "--packfile=%.*s" ,
1646
1657
(int ) the_hash_algo -> hexsz ,
1647
1658
packfile_uris .items [i ].string );
1648
- strvec_push ( & cmd . args , "--index-pack-arg=index-pack" );
1649
- strvec_push (& cmd .args , "--index-pack-arg=--stdin" );
1650
- strvec_push ( & cmd . args , "--index-pack-arg=--keep" );
1659
+ for ( j = 0 ; j < index_pack_args . nr ; j ++ )
1660
+ strvec_pushf (& cmd .args , "--index-pack-arg=%s" ,
1661
+ index_pack_args . v [ j ] );
1651
1662
strvec_push (& cmd .args , uri );
1652
1663
cmd .git_cmd = 1 ;
1653
1664
cmd .no_stdin = 1 ;
@@ -1683,6 +1694,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1683
1694
packname ));
1684
1695
}
1685
1696
string_list_clear (& packfile_uris , 0 );
1697
+ strvec_clear (& index_pack_args );
1686
1698
1687
1699
if (negotiator )
1688
1700
negotiator -> release (negotiator );
0 commit comments