Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-10-02 21:20:00 +0300
committerJunio C Hamano <gitster@pobox.com>2023-10-02 21:20:00 +0300
commit5bb67fb7ab035ef399d019440f184aee3608f3e7 (patch)
treebd3a7acf0d30c9531630eb4f23de4fdbc1d92310 /builtin/checkout.c
parent493f4622739e9b64f24b465b21aa85870dd9dc09 (diff)
parent5bdedac3c7b0894643256304cd5f0dd29cf8eec9 (diff)
Merge branch 'jc/unresolve-removal'
"checkout --merge -- path" and "update-index --unresolve path" did not resurrect conflicted state that was resolved to remove path, but now they do. * jc/unresolve-removal: checkout: allow "checkout -m path" to unmerge removed paths checkout/restore: add basic tests for --merge checkout/restore: refuse unmerging paths unless checking out of the index update-index: remove stale fallback code for "--unresolve" update-index: use unmerge_index_entry() to support removal resolve-undo: allow resurrecting conflicted state that resolved to deletion update-index: do not read HEAD and MERGE_HEAD unconditionally
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r--builtin/checkout.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index f53612f468..f02434bc15 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -523,6 +523,15 @@ static int checkout_paths(const struct checkout_opts *opts,
"--merge", "--conflict", "--staged");
}
+ /*
+ * recreating unmerged index entries and writing out data from
+ * unmerged index entries would make no sense when checking out
+ * of a tree-ish.
+ */
+ if ((opts->merge || opts->writeout_stage) && opts->source_tree)
+ die(_("'%s', '%s', or '%s' cannot be used when checking out of a tree"),
+ "--merge", "--ours", "--theirs");
+
if (opts->patch_mode) {
enum add_p_mode patch_mode;
const char *rev = new_branch_info->name;
@@ -560,6 +569,8 @@ static int checkout_paths(const struct checkout_opts *opts,
if (opts->source_tree)
read_tree_some(opts->source_tree, &opts->pathspec);
+ if (opts->merge)
+ unmerge_index(&the_index, &opts->pathspec, CE_MATCHED);
ps_matched = xcalloc(opts->pathspec.nr, 1);
@@ -583,10 +594,6 @@ static int checkout_paths(const struct checkout_opts *opts,
}
free(ps_matched);
- /* "checkout -m path" to recreate conflicted state */
- if (opts->merge)
- unmerge_marked_index(&the_index);
-
/* Any unmerged paths? */
for (pos = 0; pos < the_index.cache_nr; pos++) {
const struct cache_entry *ce = the_index.cache[pos];