| 98 | } |
| 99 | |
| 100 | static int check_local_mod(struct object_id *head, int index_only) |
| 101 | { |
| 102 | /* |
| 103 | * Items in list are already sorted in the cache order, |
| 104 | * so we could do this a lot more efficiently by using |
| 105 | * tree_desc based traversal if we wanted to, but I am |
| 106 | * lazy, and who cares if removal of files is a tad |
| 107 | * slower than the theoretical maximum speed? |
| 108 | */ |
| 109 | int i, no_head; |
| 110 | int errs = 0; |
| 111 | struct string_list files_staged = STRING_LIST_INIT_NODUP; |
| 112 | struct string_list files_cached = STRING_LIST_INIT_NODUP; |
| 113 | struct string_list files_local = STRING_LIST_INIT_NODUP; |
| 114 | |
| 115 | no_head = is_null_oid(head); |
| 116 | for (i = 0; i < list.nr; i++) { |
| 117 | struct stat st; |
| 118 | int pos; |
| 119 | const struct cache_entry *ce; |
| 120 | const char *name = list.entry[i].name; |
| 121 | struct object_id oid; |
| 122 | unsigned short mode; |
| 123 | int local_changes = 0; |
| 124 | int staged_changes = 0; |
| 125 | |
| 126 | pos = index_name_pos(the_repository->index, name, strlen(name)); |
| 127 | if (pos < 0) { |
| 128 | /* |
| 129 | * Skip unmerged entries except for populated submodules |
| 130 | * that could lose history when removed. |
| 131 | */ |
| 132 | pos = get_ours_cache_pos(name, -pos - 1); |
| 133 | if (pos < 0) |
| 134 | continue; |
| 135 | |
| 136 | if (!S_ISGITLINK(the_repository->index->cache[pos]->ce_mode) || |
| 137 | is_empty_dir(name)) |
| 138 | continue; |
| 139 | } |
| 140 | ce = the_repository->index->cache[pos]; |
| 141 | |
| 142 | if (lstat(ce->name, &st) < 0) { |
| 143 | if (!is_missing_file_error(errno)) |
| 144 | warning_errno(_("failed to stat '%s'"), ce->name); |
| 145 | /* It already vanished from the working tree */ |
| 146 | continue; |
| 147 | } |
| 148 | else if (S_ISDIR(st.st_mode)) { |
| 149 | /* if a file was removed and it is now a |
| 150 | * directory, that is the same as ENOENT as |
| 151 | * far as git is concerned; we do not track |
| 152 | * directories unless they are submodules. |
| 153 | */ |
| 154 | if (!S_ISGITLINK(ce->ce_mode)) |
| 155 | continue; |
| 156 | } |
| 157 |
no test coverage detected