26
i = dir->nr;
27
while (--i >= 0) {
28
struct dir_entry *entry = *src++;
29
- int how = match_pathspec(pathspec, entry->name, entry->len,
30
- prefix, seen);
31
- /*
32
- * ignored entries can be added with exact match,
33
- * but not with glob nor recursive.
34
- */
35
- if (!how ||
36
- (entry->ignored_entry && how != MATCHED_EXACTLY)) {
37
- free(entry);
38
- continue;
39
- }
40
- *dst++ = entry;
29
+ if (match_pathspec(pathspec, entry->name, entry->len,
30
+ prefix, seen))
31
+ *dst++ = entry;
32
}
33
dir->nr = dst - dir->entries;
34
38
if (seen[i])
39
continue;
40
50
- /* Existing file? We must have ignored it */
41
match = pathspec[i];
52
- if (!match[0] || !lstat(match, &st))
42
+ if (!match[0])
43
continue;
44
+
45
+ /* Existing file? We must have ignored it */
46
+ if (!lstat(match, &st)) {
47
+ struct dir_entry *ent;
48
+
49
+ ent = dir_add_name(dir, match, strlen(match));
50
+ ent->ignored = 1;
51
+ if (S_ISDIR(st.st_mode))
52
+ ent->ignored_dir = 1;
53
+ continue;
54
+ }
55
die("pathspec '%s' did not match any files", match);
56
}
57
}
63
64
/* Set up the default git porcelain excludes */
65
memset(dir, 0, sizeof(*dir));
65
- if (pathspec)
66
- dir->show_both = 1;
66
dir->exclude_per_dir = ".gitignore";
67
path = git_path("info/exclude");
68
if (!access(path, R_OK))
153
if (show_only) {
154
const char *sep = "", *eof = "";
155
for (i = 0; i < dir.nr; i++) {
157
- if (!ignored_too && dir.entries[i]->ignored_entry)
156
+ if (!ignored_too && dir.entries[i]->ignored)
157
continue;
158
printf("%s%s", sep, dir.entries[i]->name);
159
sep = " ";
167
die("index file corrupt");
168
169
if (!ignored_too) {
171
- int has_ignored = -1;
172
- for (i = 0; has_ignored < 0 && i < dir.nr; i++)
173
- if (dir.entries[i]->ignored_entry)
174
- has_ignored = i;
175
- if (0 <= has_ignored) {
170
+ int has_ignored = 0;
171
+ for (i = 0; i < dir.nr; i++)
172
+ if (dir.entries[i]->ignored)
173
+ has_ignored = 1;
174
+ if (has_ignored) {
175
fprintf(stderr, ignore_warning);
177
- for (i = has_ignored; i < dir.nr; i++) {
178
- if (!dir.entries[i]->ignored_entry)
176
+ for (i = 0; i < dir.nr; i++) {
177
+ if (!dir.entries[i]->ignored)
178
continue;
180
- fprintf(stderr, "%s\n", dir.entries[i]->name);
179
+ fprintf(stderr, "%s", dir.entries[i]->name);
180
+ if (dir.entries[i]->ignored_dir)
181
+ fprintf(stderr, " (directory)");
182
+ fputc('\n', stderr);
183
}
184
fprintf(stderr,
185
"Use -f if you really want to add them.\n");