MCPcopy Create free account
hub / github.com/git/git / checkout_paths

Function checkout_paths

builtin/checkout.c:517–719  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

515}
516
517static int checkout_paths(const struct checkout_opts *opts,
518 const struct branch_info *new_branch_info)
519{
520 int pos;
521 static char *ps_matched;
522 struct object_id rev;
523 struct commit *head;
524 int errs = 0;
525 struct lock_file lock_file = LOCK_INIT;
526 int checkout_index;
527
528 trace2_cmd_mode(opts->patch_mode ? "patch" : "path");
529
530 if (opts->track != BRANCH_TRACK_UNSPECIFIED)
531 die(_("'%s' cannot be used with updating paths"), "--track");
532
533 if (opts->new_branch_log)
534 die(_("'%s' cannot be used with updating paths"), "-l");
535
536 if (opts->ignore_unmerged && opts->patch_mode)
537 die(_("'%s' cannot be used with updating paths"),
538 opts->ignore_unmerged_opt);
539
540 if (opts->force_detach)
541 die(_("'%s' cannot be used with updating paths"), "--detach");
542
543 if (opts->merge && opts->patch_mode)
544 die(_("options '%s' and '%s' cannot be used together"), "--merge", "--patch");
545
546 if (opts->ignore_unmerged && opts->merge)
547 die(_("options '%s' and '%s' cannot be used together"),
548 opts->ignore_unmerged_opt, "-m");
549
550 if (opts->new_branch)
551 die(_("Cannot update paths and switch to branch '%s' at the same time."),
552 opts->new_branch);
553
554 if (!opts->checkout_worktree && !opts->checkout_index)
555 die(_("neither '%s' or '%s' is specified"),
556 "--staged", "--worktree");
557
558 if (!opts->checkout_worktree && !opts->from_treeish)
559 die(_("'%s' must be used when '%s' is not specified"),
560 "--worktree", "--source");
561
562 /*
563 * Reject --staged option to the restore command when combined with
564 * merge-related options. Use the accept_ref flag to distinguish it
565 * from the checkout command, which does not accept --staged anyway.
566 *
567 * `restore --ours|--theirs --worktree --staged` could mean resolving
568 * conflicted paths to one side in both the worktree and the index,
569 * but does not currently.
570 *
571 * `restore --merge|--conflict=<style>` already recreates conflicts
572 * in both the worktree and the index, so adding --staged would be
573 * meaningless.
574 */

Callers 1

checkout_mainFunction · 0.85

Calls 15

oid_to_hex_rFunction · 0.85
run_add_pFunction · 0.85
repo_hold_locked_indexFunction · 0.85
repo_read_index_preloadFunction · 0.85
errorFunction · 0.85
read_tree_someFunction · 0.85
unmerge_indexFunction · 0.85
xcallocFunction · 0.85
report_path_errorFunction · 0.85
warningFunction · 0.85

Tested by

no test coverage detected