1
1
#define USE_THE_REPOSITORY_VARIABLE
2
- #define DISABLE_SIGN_COMPARE_WARNINGS
3
2
4
3
#include "git-compat-util.h"
5
4
#include "abspath.h"
@@ -35,20 +34,20 @@ void add_pathspec_matches_against_index(const struct pathspec *pathspec,
35
34
char * seen ,
36
35
enum ps_skip_worktree_action sw_action )
37
36
{
38
- int num_unmatched = 0 , i ;
37
+ int num_unmatched = 0 ;
39
38
40
39
/*
41
40
* Since we are walking the index as if we were walking the directory,
42
41
* we have to mark the matched pathspec as seen; otherwise we will
43
42
* mistakenly think that the user gave a pathspec that did not match
44
43
* anything.
45
44
*/
46
- for (i = 0 ; i < pathspec -> nr ; i ++ )
45
+ for (int i = 0 ; i < pathspec -> nr ; i ++ )
47
46
if (!seen [i ])
48
47
num_unmatched ++ ;
49
48
if (!num_unmatched )
50
49
return ;
51
- for (i = 0 ; i < istate -> cache_nr ; i ++ ) {
50
+ for (unsigned int i = 0 ; i < istate -> cache_nr ; i ++ ) {
52
51
const struct cache_entry * ce = istate -> cache [i ];
53
52
if (sw_action == PS_IGNORE_SKIP_WORKTREE &&
54
53
(ce_skip_worktree (ce ) || !path_in_sparse_checkout (ce -> name , istate )))
@@ -78,7 +77,7 @@ char *find_pathspecs_matching_skip_worktree(const struct pathspec *pathspec)
78
77
{
79
78
struct index_state * istate = the_repository -> index ;
80
79
char * seen = xcalloc (pathspec -> nr , 1 );
81
- int i ;
80
+ unsigned int i ;
82
81
83
82
for (i = 0 ; i < istate -> cache_nr ; i ++ ) {
84
83
struct cache_entry * ce = istate -> cache [i ];
@@ -130,7 +129,7 @@ static void prefix_magic(struct strbuf *sb, int prefixlen,
130
129
if (element [1 ] != '(' ) {
131
130
/* Process an element in shorthand form (e.g. ":!/<match>") */
132
131
strbuf_addstr (sb , ":(" );
133
- for (int i = 0 ; i < ARRAY_SIZE (pathspec_magic ); i ++ ) {
132
+ for (unsigned int i = 0 ; i < ARRAY_SIZE (pathspec_magic ); i ++ ) {
134
133
if ((magic & pathspec_magic [i ].bit ) &&
135
134
pathspec_magic [i ].mnemonic ) {
136
135
if (sb -> buf [sb -> len - 1 ] != '(' )
@@ -341,7 +340,7 @@ static const char *parse_long_magic(unsigned *magic, int *prefix_len,
341
340
342
341
for (pos = elem + 2 ; * pos && * pos != ')' ; pos = nextat ) {
343
342
size_t len = strcspn_escaped (pos , ",)" );
344
- int i ;
343
+ unsigned int i ;
345
344
346
345
if (pos [len ] == ',' )
347
346
nextat = pos + len + 1 ; /* handle ',' */
@@ -354,7 +353,7 @@ static const char *parse_long_magic(unsigned *magic, int *prefix_len,
354
353
if (starts_with (pos , "prefix:" )) {
355
354
char * endptr ;
356
355
* prefix_len = strtol (pos + 7 , & endptr , 10 );
357
- if (endptr - pos != len )
356
+ if (( size_t )( endptr - pos ) != len )
358
357
die (_ ("invalid parameter for pathspec magic 'prefix'" ));
359
358
continue ;
360
359
}
@@ -400,7 +399,7 @@ static const char *parse_short_magic(unsigned *magic, const char *elem)
400
399
401
400
for (pos = elem + 1 ; * pos && * pos != ':' ; pos ++ ) {
402
401
char ch = * pos ;
403
- int i ;
402
+ unsigned int i ;
404
403
405
404
/* Special case alias for '!' */
406
405
if (ch == '^' ) {
@@ -564,7 +563,7 @@ static int pathspec_item_cmp(const void *a_, const void *b_)
564
563
565
564
void pathspec_magic_names (unsigned magic , struct strbuf * out )
566
565
{
567
- int i ;
566
+ unsigned int i ;
568
567
for (i = 0 ; i < ARRAY_SIZE (pathspec_magic ); i ++ ) {
569
568
const struct pathspec_magic * m = pathspec_magic + i ;
570
569
if (!(magic & m -> bit ))
@@ -803,8 +802,8 @@ int match_pathspec_attrs(struct index_state *istate,
803
802
int pathspec_needs_expanded_index (struct index_state * istate ,
804
803
const struct pathspec * pathspec )
805
804
{
806
- unsigned int i , pos ;
807
- int res = 0 ;
805
+ unsigned int pos ;
806
+ int i , res = 0 ;
808
807
char * skip_worktree_seen = NULL ;
809
808
810
809
/*
@@ -845,7 +844,8 @@ int pathspec_needs_expanded_index(struct index_state *istate,
845
844
* - not-in-cone/bar*: may need expanded index
846
845
* - **.c: may need expanded index
847
846
*/
848
- if (strspn (item .original + item .nowildcard_len , "*" ) == item .len - item .nowildcard_len &&
847
+ if (strspn (item .original + item .nowildcard_len , "*" ) ==
848
+ (unsigned int )(item .len - item .nowildcard_len ) &&
849
849
path_in_cone_mode_sparse_checkout (item .original , istate ))
850
850
continue ;
851
851
@@ -860,8 +860,10 @@ int pathspec_needs_expanded_index(struct index_state *istate,
860
860
* directory name and the sparse directory is the first
861
861
* component of the pathspec, need to expand the index.
862
862
*/
863
- if (item .nowildcard_len > ce_namelen (ce ) &&
864
- !strncmp (item .original , ce -> name , ce_namelen (ce ))) {
863
+ if ((unsigned int )item .nowildcard_len >
864
+ ce_namelen (ce ) &&
865
+ !strncmp (item .original , ce -> name ,
866
+ ce_namelen (ce ))) {
865
867
res = 1 ;
866
868
break ;
867
869
}
0 commit comments