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