diff options
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r-- | builtin/checkout.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c index 81f07c3ef2..5d583d6c96 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -37,6 +37,7 @@ struct checkout_opts { int overwrite_ignore; int ignore_skipworktree; int ignore_other_worktrees; + int no_index; int show_progress; const char *new_branch; @@ -268,6 +269,9 @@ static int checkout_paths(const struct checkout_opts *opts, die(_("Cannot update paths and switch to branch '%s' at the same time."), opts->new_branch); + if (opts->no_index && !opts->source_tree) + die(_("'--working-tree-only' requires a tree-ish")); + if (opts->patch_mode) return run_add_interactive(revision, "--patch=checkout", &opts->pathspec); @@ -370,7 +374,9 @@ static int checkout_paths(const struct checkout_opts *opts, } } - if (write_locked_index(&the_index, lock_file, COMMIT_LOCK)) + if (opts->no_index) + ; /* discard the in-core index */ + else if (write_locked_index(&the_index, lock_file, COMMIT_LOCK)) die(_("unable to write new index file")); read_ref_full("HEAD", 0, rev.hash, NULL); @@ -1164,6 +1170,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) OPT_BOOL(0, "ignore-other-worktrees", &opts.ignore_other_worktrees, N_("do not check if another worktree is holding the given ref")), OPT_BOOL(0, "progress", &opts.show_progress, N_("force progress reporting")), + OPT_BOOL(0, "working-tree-only", &opts.no_index, N_("checkout to working tree only without touching the index")), OPT_END(), }; |