#include "builtin.h"
#include "config.h"
#include "checkout.h"
#include "lockfile.h"
#include "parse-options.h"
#include "refs.h"
#include "object-store.h"
#include "commit.h"
#include "tree.h"
#include "tree-walk.h"
#include "cache-tree.h"
#include "unpack-trees.h"
#include "dir.h"
#include "run-command.h"
#include "merge-recursive.h"
#include "branch.h"
#include "diff.h"
#include "revision.h"
#include "remote.h"
#include "blob.h"
#include "xdiff-interface.h"
#include "ll-merge.h"
#include "resolve-undo.h"
#include "submodule-config.h"
#include "submodule.h"
#include "advice.h"
static int checkout_optimize_new_branch;
static const char * const checkout_usage[] = {
N_("git checkout [<options>] <branch>"),
N_("git checkout [<options>] [<branch>] -- <file>..."),
NULL,
};
struct checkout_opts {
int patch_mode;
int quiet;
int merge;
int force;
int force_detach;
int writeout_stage;
int overwrite_ignore;
int ignore_skipworktree;
int ignore_other_worktrees;
int show_progress;
/*
* If new checkout options are added, skip_merge_working_tree
* should be updated accordingly.
*/
const char *new_branch;
const char *new_branch_force;
const char *new_orphan_branch;
int new_branch_log;
enum branch_track track;
struct diff_options diff_options;
int branch_exists;
const char *prefix;
struct pathspec pathspec;
struct tree *source_tree;
};
static int post_checkout_hook(struct commit *old_commit, struct commit *new_commit,
int changed)
{
return run_hook_le(NULL, "post-checkout",
oid_to_hex(old_commit ? &old_commit->object.oid : &null_oid),
oid_to_hex(new_commit ? &new_commit->object.oid : &null_oid),
changed ? "1" : "0", NULL);
/* "new_commit" can be NULL when checking out from the index before
a commit exists. */
}
static int update_some(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, int stage, void *context)
{
int len;
|