| 4009 | } |
| 4010 | |
| 4011 | int add_files_to_cache(struct repository *repo, const char *prefix, |
| 4012 | const struct pathspec *pathspec, char *ps_matched, |
| 4013 | int include_sparse, int flags, int ignored_too ) |
| 4014 | { |
| 4015 | struct odb_transaction *transaction; |
| 4016 | struct update_callback_data data; |
| 4017 | struct rev_info rev; |
| 4018 | |
| 4019 | memset(&data, 0, sizeof(data)); |
| 4020 | data.index = repo->index; |
| 4021 | data.include_sparse = include_sparse; |
| 4022 | data.flags = flags; |
| 4023 | data.repo = repo; |
| 4024 | data.ignored_too = ignored_too; |
| 4025 | data.pathspec = (struct pathspec *)pathspec; |
| 4026 | |
| 4027 | repo_init_revisions(repo, &rev, prefix); |
| 4028 | setup_revisions(0, NULL, &rev, NULL); |
| 4029 | if (pathspec) { |
| 4030 | copy_pathspec(&rev.prune_data, pathspec); |
| 4031 | rev.ps_matched = ps_matched; |
| 4032 | } |
| 4033 | rev.diffopt.output_format = DIFF_FORMAT_CALLBACK; |
| 4034 | rev.diffopt.format_callback = update_callback; |
| 4035 | rev.diffopt.format_callback_data = &data; |
| 4036 | rev.diffopt.flags.override_submodule_config = 1; |
| 4037 | rev.diffopt.detect_rename = 0; /* staging worktree changes does not need renames */ |
| 4038 | rev.max_count = 0; /* do not compare unmerged paths with stage #2 */ |
| 4039 | |
| 4040 | /* |
| 4041 | * Use an ODB transaction to optimize adding multiple objects. |
| 4042 | * This function is invoked from commands other than 'add', which |
| 4043 | * may not have their own transaction active. |
| 4044 | */ |
| 4045 | transaction = odb_transaction_begin(repo->objects); |
| 4046 | run_diff_files(&rev, DIFF_RACY_IS_MODIFIED); |
| 4047 | odb_transaction_commit(transaction); |
| 4048 | |
| 4049 | release_revisions(&rev); |
| 4050 | return !!data.add_errors; |
| 4051 | } |
no test coverage detected