| 340 | } |
| 341 | |
| 342 | static int add_files(struct repository *repo, struct dir_struct *dir, int flags) |
| 343 | { |
| 344 | int i, exit_status = 0; |
| 345 | struct string_list matched_sparse_paths = STRING_LIST_INIT_NODUP; |
| 346 | |
| 347 | if (dir->ignored_nr) { |
| 348 | fprintf(stderr, _(ignore_error)); |
| 349 | for (i = 0; i < dir->ignored_nr; i++) |
| 350 | fprintf(stderr, "%s\n", dir->ignored[i]->name); |
| 351 | advise_if_enabled(ADVICE_ADD_IGNORED_FILE, |
| 352 | _("Use -f if you really want to add them.")); |
| 353 | exit_status = 1; |
| 354 | } |
| 355 | |
| 356 | for (i = 0; i < dir->nr; i++) { |
| 357 | if (!include_sparse && |
| 358 | !path_in_sparse_checkout(dir->entries[i]->name, repo->index)) { |
| 359 | string_list_append(&matched_sparse_paths, |
| 360 | dir->entries[i]->name); |
| 361 | continue; |
| 362 | } |
| 363 | if (add_file_to_index(repo->index, dir->entries[i]->name, flags)) { |
| 364 | if (!ignore_add_errors) |
| 365 | die(_("adding files failed")); |
| 366 | exit_status = 1; |
| 367 | } else { |
| 368 | check_embedded_repo(dir->entries[i]->name); |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | if (matched_sparse_paths.nr) { |
| 373 | advise_on_updating_sparse_paths(&matched_sparse_paths); |
| 374 | exit_status = 1; |
| 375 | } |
| 376 | |
| 377 | string_list_clear(&matched_sparse_paths, 0); |
| 378 | |
| 379 | return exit_status; |
| 380 | } |
| 381 | |
| 382 | int cmd_add(int argc, |
| 383 | const char **argv, |
no test coverage detected