#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "advice.h"
#include "branch.h"
#include "cache-tree.h"
#include "checkout.h"
#include "commit.h"
#include "config.h"
#include "diff.h"
#include "dir.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "hook.h"
#include "merge-ll.h"
#include "lockfile.h"
#include "mem-pool.h"
#include "merge-recursive.h"
#include "object-name.h"
#include "object-store-ll.h"
#include "parse-options.h"
#include "path.h"
#include "preload-index.h"
#include "read-cache.h"
#include "refs.h"
#include "remote.h"
#include "repo-settings.h"
#include "resolve-undo.h"
#include "revision.h"
#include "setup.h"
#include "submodule.h"
#include "symlinks.h"
#include "trace2.h"
#include "tree.h"
#include "tree-walk.h"
#include "unpack-trees.h"
#include "wt-status.h"
#include "xdiff-interface.h"
#include "entry.h"
#include "parallel-checkout.h"
#include "add-interactive.h"
static const char * const checkout_usage[] = …;
static const char * const switch_branch_usage[] = …;
static const char * const restore_usage[] = …;
struct checkout_opts { … };
#define CHECKOUT_OPTS_INIT …
struct branch_info { … };
static void branch_info_release(struct branch_info *info)
{ … }
static int post_checkout_hook(struct commit *old_commit, struct commit *new_commit,
int changed)
{ … }
static int update_some(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, void *context UNUSED)
{ … }
static int read_tree_some(struct tree *tree, const struct pathspec *pathspec)
{ … }
static int skip_same_name(const struct cache_entry *ce, int pos)
{ … }
static int check_stage(int stage, const struct cache_entry *ce, int pos,
int overlay_mode)
{ … }
static int check_stages(unsigned stages, const struct cache_entry *ce, int pos)
{ … }
static int checkout_stage(int stage, const struct cache_entry *ce, int pos,
const struct checkout *state, int *nr_checkouts,
int overlay_mode)
{ … }
static int checkout_merged(int pos, const struct checkout *state,
int *nr_checkouts, struct mem_pool *ce_mem_pool,
int conflict_style)
{ … }
static void mark_ce_for_checkout_overlay(struct cache_entry *ce,
char *ps_matched,
const struct checkout_opts *opts)
{ … }
static void mark_ce_for_checkout_no_overlay(struct cache_entry *ce,
char *ps_matched,
const struct checkout_opts *opts)
{ … }
static int checkout_worktree(const struct checkout_opts *opts,
const struct branch_info *info)
{ … }
static int checkout_paths(const struct checkout_opts *opts,
const struct branch_info *new_branch_info)
{ … }
static void show_local_changes(struct object *head,
const struct diff_options *opts)
{ … }
static void describe_detached_head(const char *msg, struct commit *commit)
{ … }
static int reset_tree(struct tree *tree, const struct checkout_opts *o,
int worktree, int *writeout_error,
struct branch_info *info)
{ … }
static void setup_branch_path(struct branch_info *branch)
{ … }
static void init_topts(struct unpack_trees_options *topts, int merge,
int show_progress, int overwrite_ignore,
struct commit *old_commit)
{ … }
static int merge_working_tree(const struct checkout_opts *opts,
struct branch_info *old_branch_info,
struct branch_info *new_branch_info,
int *writeout_error)
{ … }
static void report_tracking(struct branch_info *new_branch_info)
{ … }
static void update_refs_for_switch(const struct checkout_opts *opts,
struct branch_info *old_branch_info,
struct branch_info *new_branch_info)
{ … }
static int add_pending_uninteresting_ref(const char *refname, const char *referent UNUSED,
const struct object_id *oid,
int flags UNUSED, void *cb_data)
{ … }
static void describe_one_orphan(struct strbuf *sb, struct commit *commit)
{ … }
#define ORPHAN_CUTOFF …
static void suggest_reattach(struct commit *commit, struct rev_info *revs)
{ … }
static void orphaned_commit_warning(struct commit *old_commit, struct commit *new_commit)
{ … }
static int switch_branches(const struct checkout_opts *opts,
struct branch_info *new_branch_info)
{ … }
static int git_checkout_config(const char *var, const char *value,
const struct config_context *ctx, void *cb)
{ … }
static void setup_new_branch_info_and_source_tree(
struct branch_info *new_branch_info,
struct checkout_opts *opts,
struct object_id *rev,
const char *arg)
{ … }
static char *parse_remote_branch(const char *arg,
struct object_id *rev,
int could_be_checkout_paths)
{ … }
static int parse_branchname_arg(int argc, const char **argv,
int dwim_new_local_branch_ok,
struct branch_info *new_branch_info,
struct checkout_opts *opts,
struct object_id *rev)
{ … }
static int switch_unborn_to_new_branch(const struct checkout_opts *opts)
{ … }
static void die_expecting_a_branch(const struct branch_info *branch_info)
{ … }
static void die_if_some_operation_in_progress(void)
{ … }
static void die_if_switching_to_a_branch_in_use(struct checkout_opts *opts,
const char *full_ref)
{ … }
static int checkout_branch(struct checkout_opts *opts,
struct branch_info *new_branch_info)
{ … }
static int parse_opt_conflict(const struct option *o, const char *arg, int unset)
{ … }
static struct option *add_common_options(struct checkout_opts *opts,
struct option *prevopts)
{ … }
static struct option *add_common_switch_branch_options(
struct checkout_opts *opts, struct option *prevopts)
{ … }
static struct option *add_checkout_path_options(struct checkout_opts *opts,
struct option *prevopts)
{ … }
static char cb_option = …;
static int checkout_main(int argc, const char **argv, const char *prefix,
struct checkout_opts *opts, struct option *options,
const char * const usagestr[])
{ … }
int cmd_checkout(int argc,
const char **argv,
const char *prefix,
struct repository *repo UNUSED)
{ … }
int cmd_switch(int argc,
const char **argv,
const char *prefix,
struct repository *repo UNUSED)
{ … }
int cmd_restore(int argc,
const char **argv,
const char *prefix,
struct repository *repo UNUSED)
{ … }