| 159 | } |
| 160 | |
| 161 | static int queue_diff(struct diff_options *o, const struct git_hash_algo *algop, |
| 162 | const char *name1, const char *name2, int recursing, |
| 163 | const struct pathspec *ps, |
| 164 | struct strbuf *ps_match1, struct strbuf *ps_match2) |
| 165 | { |
| 166 | int mode1 = 0, mode2 = 0; |
| 167 | enum special special1 = SPECIAL_NONE, special2 = SPECIAL_NONE; |
| 168 | |
| 169 | /* Paths can only be special if we're not recursing. */ |
| 170 | if (get_mode(name1, &mode1, recursing ? NULL : &special1) || |
| 171 | get_mode(name2, &mode2, recursing ? NULL : &special2)) |
| 172 | return -1; |
| 173 | |
| 174 | if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2)) { |
| 175 | struct diff_filespec *d1, *d2; |
| 176 | |
| 177 | if (S_ISDIR(mode1)) { |
| 178 | /* 2 is file that is created */ |
| 179 | d1 = noindex_filespec(algop, NULL, 0, SPECIAL_NONE); |
| 180 | d2 = noindex_filespec(algop, name2, mode2, special2); |
| 181 | name2 = NULL; |
| 182 | mode2 = 0; |
| 183 | } else { |
| 184 | /* 1 is file that is deleted */ |
| 185 | d1 = noindex_filespec(algop, name1, mode1, special1); |
| 186 | d2 = noindex_filespec(algop, NULL, 0, SPECIAL_NONE); |
| 187 | name1 = NULL; |
| 188 | mode1 = 0; |
| 189 | } |
| 190 | /* emit that file */ |
| 191 | diff_queue(&diff_queued_diff, d1, d2); |
| 192 | |
| 193 | /* and then let the entire directory be created or deleted */ |
| 194 | } |
| 195 | |
| 196 | if (S_ISDIR(mode1) || S_ISDIR(mode2)) { |
| 197 | struct strbuf buffer1 = STRBUF_INIT; |
| 198 | struct strbuf buffer2 = STRBUF_INIT; |
| 199 | struct string_list p1 = STRING_LIST_INIT_DUP; |
| 200 | struct string_list p2 = STRING_LIST_INIT_DUP; |
| 201 | int i1, i2, ret = 0; |
| 202 | size_t len1 = 0, len2 = 0; |
| 203 | size_t match1_len = ps_match1->len; |
| 204 | size_t match2_len = ps_match2->len; |
| 205 | |
| 206 | if (name1 && read_directory_contents(name1, &p1, ps, ps_match1)) |
| 207 | return -1; |
| 208 | if (name2 && read_directory_contents(name2, &p2, ps, ps_match2)) { |
| 209 | string_list_clear(&p1, 0); |
| 210 | return -1; |
| 211 | } |
| 212 | |
| 213 | if (name1) { |
| 214 | strbuf_addstr(&buffer1, name1); |
| 215 | strbuf_complete(&buffer1, '/'); |
| 216 | len1 = buffer1.len; |
| 217 | } |
| 218 |
no test coverage detected