| 349 | } |
| 350 | |
| 351 | static const char *prepare_index(const char **argv, const char *prefix, |
| 352 | const struct commit *current_head, int is_status) |
| 353 | { |
| 354 | struct string_list partial = STRING_LIST_INIT_DUP; |
| 355 | struct pathspec pathspec; |
| 356 | int refresh_flags = REFRESH_QUIET; |
| 357 | const char *ret; |
| 358 | char *path = NULL; |
| 359 | |
| 360 | if (interactive_opts.context < -1) |
| 361 | die(_("'%s' cannot be negative"), "--unified"); |
| 362 | if (interactive_opts.interhunkcontext < -1) |
| 363 | die(_("'%s' cannot be negative"), "--inter-hunk-context"); |
| 364 | |
| 365 | if (is_status) |
| 366 | refresh_flags |= REFRESH_UNMERGED; |
| 367 | parse_pathspec(&pathspec, 0, |
| 368 | PATHSPEC_PREFER_FULL, |
| 369 | prefix, argv); |
| 370 | |
| 371 | if (pathspec_from_file) { |
| 372 | if (interactive) |
| 373 | die(_("options '%s' and '%s' cannot be used together"), "--pathspec-from-file", "--interactive/--patch"); |
| 374 | |
| 375 | if (all) |
| 376 | die(_("options '%s' and '%s' cannot be used together"), "--pathspec-from-file", "-a"); |
| 377 | |
| 378 | if (pathspec.nr) |
| 379 | die(_("'%s' and pathspec arguments cannot be used together"), "--pathspec-from-file"); |
| 380 | |
| 381 | parse_pathspec_file(&pathspec, 0, |
| 382 | PATHSPEC_PREFER_FULL, |
| 383 | prefix, pathspec_from_file, pathspec_file_nul); |
| 384 | } else if (pathspec_file_nul) { |
| 385 | die(_("the option '%s' requires '%s'"), "--pathspec-file-nul", "--pathspec-from-file"); |
| 386 | } |
| 387 | |
| 388 | if (!pathspec.nr && (also || (only && !allow_empty && |
| 389 | (!amend || (fixup_message && strcmp(fixup_prefix, "amend")))))) |
| 390 | die(_("No paths with --include/--only does not make sense.")); |
| 391 | |
| 392 | if (repo_read_index_preload(the_repository, &pathspec, 0) < 0) |
| 393 | die(_("index file corrupt")); |
| 394 | |
| 395 | if (interactive) { |
| 396 | char *old_index_env = NULL, *old_repo_index_file; |
| 397 | repo_hold_locked_index(the_repository, &index_lock, |
| 398 | LOCK_DIE_ON_ERROR); |
| 399 | |
| 400 | refresh_cache_or_die(refresh_flags); |
| 401 | |
| 402 | if (write_locked_index(the_repository->index, &index_lock, 0)) |
| 403 | die(_("unable to create temporary index")); |
| 404 | |
| 405 | old_repo_index_file = the_repository->index_file; |
| 406 | the_repository->index_file = |
| 407 | (char *)get_lock_file_path(&index_lock); |
| 408 | old_index_env = xstrdup_or_null(getenv(INDEX_ENVIRONMENT)); |
no test coverage detected