1
1
#define USE_THE_REPOSITORY_VARIABLE
2
- #define DISABLE_SIGN_COMPARE_WARNINGS
3
2
4
3
#include "builtin.h"
5
4
#include "config.h"
@@ -182,7 +181,6 @@ static int add(int argc, const char **argv, const char *prefix,
182
181
struct remote * remote ;
183
182
struct strbuf buf = STRBUF_INIT , buf2 = STRBUF_INIT ;
184
183
const char * name , * url ;
185
- int i ;
186
184
int result = 0 ;
187
185
188
186
struct option options [] = {
@@ -233,7 +231,7 @@ static int add(int argc, const char **argv, const char *prefix,
233
231
strbuf_addf (& buf , "remote.%s.fetch" , name );
234
232
if (track .nr == 0 )
235
233
string_list_append (& track , "*" );
236
- for (i = 0 ; i < track .nr ; i ++ ) {
234
+ for (size_t i = 0 ; i < track .nr ; i ++ ) {
237
235
add_branch (buf .buf , track .items [i ].string ,
238
236
name , mirror , & buf2 );
239
237
}
@@ -647,18 +645,17 @@ static int read_remote_branches(const char *refname, const char *referent UNUSED
647
645
static int migrate_file (struct remote * remote )
648
646
{
649
647
struct strbuf buf = STRBUF_INIT ;
650
- int i ;
651
648
652
649
strbuf_addf (& buf , "remote.%s.url" , remote -> name );
653
- for (i = 0 ; i < remote -> url .nr ; i ++ )
650
+ for (size_t i = 0 ; i < remote -> url .nr ; i ++ )
654
651
git_config_set_multivar (buf .buf , remote -> url .v [i ], "^$" , 0 );
655
652
strbuf_reset (& buf );
656
653
strbuf_addf (& buf , "remote.%s.push" , remote -> name );
657
- for (i = 0 ; i < remote -> push .nr ; i ++ )
654
+ for (int i = 0 ; i < remote -> push .nr ; i ++ )
658
655
git_config_set_multivar (buf .buf , remote -> push .items [i ].raw , "^$" , 0 );
659
656
strbuf_reset (& buf );
660
657
strbuf_addf (& buf , "remote.%s.fetch" , remote -> name );
661
- for (i = 0 ; i < remote -> fetch .nr ; i ++ )
658
+ for (int i = 0 ; i < remote -> fetch .nr ; i ++ )
662
659
git_config_set_multivar (buf .buf , remote -> fetch .items [i ].raw , "^$" , 0 );
663
660
#ifndef WITH_BREAKING_CHANGES
664
661
if (remote -> origin == REMOTE_REMOTES )
@@ -744,7 +741,7 @@ static int mv(int argc, const char **argv, const char *prefix,
744
741
old_remote_context = STRBUF_INIT ;
745
742
struct string_list remote_branches = STRING_LIST_INIT_DUP ;
746
743
struct rename_info rename ;
747
- int i , refs_renamed_nr = 0 , refspec_updated = 0 ;
744
+ int refs_renamed_nr = 0 , refspec_updated = 0 ;
748
745
struct progress * progress = NULL ;
749
746
int result = 0 ;
750
747
@@ -790,7 +787,7 @@ static int mv(int argc, const char **argv, const char *prefix,
790
787
strbuf_addf (& buf , "remote.%s.fetch" , rename .new_name );
791
788
git_config_set_multivar (buf .buf , NULL , NULL , CONFIG_FLAGS_MULTI_REPLACE );
792
789
strbuf_addf (& old_remote_context , ":refs/remotes/%s/" , rename .old_name );
793
- for (i = 0 ; i < oldremote -> fetch .nr ; i ++ ) {
790
+ for (int i = 0 ; i < oldremote -> fetch .nr ; i ++ ) {
794
791
char * ptr ;
795
792
796
793
strbuf_reset (& buf2 );
@@ -813,7 +810,7 @@ static int mv(int argc, const char **argv, const char *prefix,
813
810
}
814
811
815
812
read_branches ();
816
- for (i = 0 ; i < branch_list .nr ; i ++ ) {
813
+ for (size_t i = 0 ; i < branch_list .nr ; i ++ ) {
817
814
struct string_list_item * item = branch_list .items + i ;
818
815
struct branch_info * info = item -> util ;
819
816
if (info -> remote_name && !strcmp (info -> remote_name , rename .old_name )) {
@@ -846,7 +843,7 @@ static int mv(int argc, const char **argv, const char *prefix,
846
843
_ ("Renaming remote references" ),
847
844
rename .remote_branches -> nr + rename .symrefs_nr );
848
845
}
849
- for (i = 0 ; i < remote_branches .nr ; i ++ ) {
846
+ for (size_t i = 0 ; i < remote_branches .nr ; i ++ ) {
850
847
struct string_list_item * item = remote_branches .items + i ;
851
848
struct strbuf referent = STRBUF_INIT ;
852
849
@@ -859,7 +856,7 @@ static int mv(int argc, const char **argv, const char *prefix,
859
856
strbuf_release (& referent );
860
857
display_progress (progress , ++ refs_renamed_nr );
861
858
}
862
- for (i = 0 ; i < remote_branches .nr ; i ++ ) {
859
+ for (size_t i = 0 ; i < remote_branches .nr ; i ++ ) {
863
860
struct string_list_item * item = remote_branches .items + i ;
864
861
865
862
if (item -> util )
@@ -875,7 +872,7 @@ static int mv(int argc, const char **argv, const char *prefix,
875
872
die (_ ("renaming '%s' failed" ), item -> string );
876
873
display_progress (progress , ++ refs_renamed_nr );
877
874
}
878
- for (i = 0 ; i < remote_branches .nr ; i ++ ) {
875
+ for (size_t i = 0 ; i < remote_branches .nr ; i ++ ) {
879
876
struct string_list_item * item = remote_branches .items + i ;
880
877
881
878
if (!item -> util )
@@ -920,7 +917,7 @@ static int rm(int argc, const char **argv, const char *prefix,
920
917
struct string_list branches = STRING_LIST_INIT_DUP ;
921
918
struct string_list skipped = STRING_LIST_INIT_DUP ;
922
919
struct branches_for_remote cb_data ;
923
- int i , result ;
920
+ int result ;
924
921
925
922
memset (& cb_data , 0 , sizeof (cb_data ));
926
923
cb_data .branches = & branches ;
@@ -942,7 +939,7 @@ static int rm(int argc, const char **argv, const char *prefix,
942
939
for_each_remote (add_known_remote , & known_remotes );
943
940
944
941
read_branches ();
945
- for (i = 0 ; i < branch_list .nr ; i ++ ) {
942
+ for (size_t i = 0 ; i < branch_list .nr ; i ++ ) {
946
943
struct string_list_item * item = branch_list .items + i ;
947
944
struct branch_info * info = item -> util ;
948
945
if (info -> remote_name && !strcmp (info -> remote_name , remote -> name )) {
@@ -988,7 +985,7 @@ static int rm(int argc, const char **argv, const char *prefix,
988
985
"Note: Some branches outside the refs/remotes/ hierarchy were not removed;\n"
989
986
"to delete them, use:" ,
990
987
skipped .nr ));
991
- for (i = 0 ; i < skipped .nr ; i ++ )
988
+ for (size_t i = 0 ; i < skipped .nr ; i ++ )
992
989
fprintf (stderr , " git branch -d %s\n" ,
993
990
skipped .items [i ].string );
994
991
}
@@ -1166,7 +1163,6 @@ static int show_local_info_item(struct string_list_item *item, void *cb_data)
1166
1163
struct branch_info * branch_info = item -> util ;
1167
1164
struct string_list * merge = & branch_info -> merge ;
1168
1165
int width = show_info -> width + 4 ;
1169
- int i ;
1170
1166
1171
1167
if (branch_info -> rebase >= REBASE_TRUE && branch_info -> merge .nr > 1 ) {
1172
1168
error (_ ("invalid branch.%s.merge; cannot rebase onto > 1 branch" ),
@@ -1192,7 +1188,7 @@ static int show_local_info_item(struct string_list_item *item, void *cb_data)
1192
1188
} else {
1193
1189
printf_ln (_ ("merges with remote %s" ), merge -> items [0 ].string );
1194
1190
}
1195
- for (i = 1 ; i < merge -> nr ; i ++ )
1191
+ for (size_t i = 1 ; i < merge -> nr ; i ++ )
1196
1192
printf (_ ("%-*s and with remote %s\n" ), width , "" ,
1197
1193
merge -> items [i ].string );
1198
1194
@@ -1277,7 +1273,6 @@ static int get_one_entry(struct remote *remote, void *priv)
1277
1273
struct string_list * list = priv ;
1278
1274
struct strbuf remote_info_buf = STRBUF_INIT ;
1279
1275
struct strvec * url ;
1280
- int i ;
1281
1276
1282
1277
if (remote -> url .nr > 0 ) {
1283
1278
struct strbuf promisor_config = STRBUF_INIT ;
@@ -1294,8 +1289,7 @@ static int get_one_entry(struct remote *remote, void *priv)
1294
1289
} else
1295
1290
string_list_append (list , remote -> name )-> util = NULL ;
1296
1291
url = push_url_of_remote (remote );
1297
- for (i = 0 ; i < url -> nr ; i ++ )
1298
- {
1292
+ for (size_t i = 0 ; i < url -> nr ; i ++ ) {
1299
1293
strbuf_addf (& remote_info_buf , "%s (push)" , url -> v [i ]);
1300
1294
string_list_append (list , remote -> name )-> util =
1301
1295
strbuf_detach (& remote_info_buf , NULL );
@@ -1312,10 +1306,8 @@ static int show_all(void)
1312
1306
result = for_each_remote (get_one_entry , & list );
1313
1307
1314
1308
if (!result ) {
1315
- int i ;
1316
-
1317
1309
string_list_sort (& list );
1318
- for (i = 0 ; i < list .nr ; i ++ ) {
1310
+ for (size_t i = 0 ; i < list .nr ; i ++ ) {
1319
1311
struct string_list_item * item = list .items + i ;
1320
1312
if (verbose )
1321
1313
printf ("%s\t%s\n" , item -> string ,
@@ -1352,7 +1344,7 @@ static int show(int argc, const char **argv, const char *prefix,
1352
1344
query_flag = (GET_REF_STATES | GET_HEAD_NAMES | GET_PUSH_REF_STATES );
1353
1345
1354
1346
for (; argc ; argc -- , argv ++ ) {
1355
- int i ;
1347
+ size_t i ;
1356
1348
struct strvec * url ;
1357
1349
1358
1350
get_remote_ref_states (* argv , & info .states , query_flag );
@@ -1458,7 +1450,7 @@ static void report_set_head_auto(const char *remote, const char *head_name,
1458
1450
static int set_head (int argc , const char * * argv , const char * prefix ,
1459
1451
struct repository * repo UNUSED )
1460
1452
{
1461
- int i , opt_a = 0 , opt_d = 0 , result = 0 , was_detached ;
1453
+ int opt_a = 0 , opt_d = 0 , result = 0 , was_detached ;
1462
1454
struct strbuf b_head = STRBUF_INIT , b_remote_head = STRBUF_INIT ,
1463
1455
b_local_head = STRBUF_INIT ;
1464
1456
char * head_name = NULL ;
@@ -1489,7 +1481,7 @@ static int set_head(int argc, const char **argv, const char *prefix,
1489
1481
else if (states .heads .nr > 1 ) {
1490
1482
result |= error (_ ("Multiple remote HEAD branches. "
1491
1483
"Please choose one explicitly with:" ));
1492
- for (i = 0 ; i < states .heads .nr ; i ++ )
1484
+ for (size_t i = 0 ; i < states .heads .nr ; i ++ )
1493
1485
fprintf (stderr , " git remote set-head %s %s\n" ,
1494
1486
argv [0 ], states .heads .items [i ].string );
1495
1487
} else
@@ -1714,7 +1706,7 @@ static int set_branches(int argc, const char **argv, const char *prefix,
1714
1706
static int get_url (int argc , const char * * argv , const char * prefix ,
1715
1707
struct repository * repo UNUSED )
1716
1708
{
1717
- int i , push_mode = 0 , all_mode = 0 ;
1709
+ int push_mode = 0 , all_mode = 0 ;
1718
1710
const char * remotename = NULL ;
1719
1711
struct remote * remote ;
1720
1712
struct strvec * url ;
@@ -1742,7 +1734,7 @@ static int get_url(int argc, const char **argv, const char *prefix,
1742
1734
url = push_mode ? push_url_of_remote (remote ) : & remote -> url ;
1743
1735
1744
1736
if (all_mode ) {
1745
- for (i = 0 ; i < url -> nr ; i ++ )
1737
+ for (size_t i = 0 ; i < url -> nr ; i ++ )
1746
1738
printf_ln ("%s" , url -> v [i ]);
1747
1739
} else {
1748
1740
printf_ln ("%s" , url -> v [0 ]);
@@ -1754,7 +1746,7 @@ static int get_url(int argc, const char **argv, const char *prefix,
1754
1746
static int set_url (int argc , const char * * argv , const char * prefix ,
1755
1747
struct repository * repo UNUSED )
1756
1748
{
1757
- int i , push_mode = 0 , add_mode = 0 , delete_mode = 0 ;
1749
+ int push_mode = 0 , add_mode = 0 , delete_mode = 0 ;
1758
1750
int matches = 0 , negative_matches = 0 ;
1759
1751
const char * remotename = NULL ;
1760
1752
const char * newurl = NULL ;
@@ -1818,7 +1810,7 @@ static int set_url(int argc, const char **argv, const char *prefix,
1818
1810
if (regcomp (& old_regex , oldurl , REG_EXTENDED ))
1819
1811
die (_ ("Invalid old URL pattern: %s" ), oldurl );
1820
1812
1821
- for (i = 0 ; i < urlset -> nr ; i ++ )
1813
+ for (size_t i = 0 ; i < urlset -> nr ; i ++ )
1822
1814
if (!regexec (& old_regex , urlset -> v [i ], 0 , NULL , 0 ))
1823
1815
matches ++ ;
1824
1816
else
0 commit comments