git/builtin
Elijah Newren e4cdfe84a0 merge: abort if index does not match HEAD for trivial merges
As noted in the last commit and the links therein (especially commit
9822175d2b ("Ensure index matches head before invoking merge machinery,
round N", 2019-08-17), we have had a very long history of problems with
failing to enforce the requirement that index matches HEAD when starting
a merge.

The "trivial merge" logic in builtin/merge.c is yet another such case
we previously missed.  Add a check for it to ensure it aborts if the
index does not match HEAD, and add a testcase where this fix is needed.

Note that the fix here would also incidentally be an alternative fix
for the testcase added in the last patch, but the fix in the last patch
is still needed when multiple merge strategies are in use, so tweak the
testcase from the previous commit so that it continues to exercise the
codepath added in the last commit.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-07-22 21:45:23 -07:00
..
add.c
am.c
annotate.c
apply.c
archive.c
bisect--helper.c
blame.c
branch.c branch: drop unused worktrees variable 2022-06-21 08:52:37 -07:00
bugreport.c
bundle.c
cat-file.c cat-file: fix a common "struct object_context" memory leak 2022-07-01 11:43:43 -07:00
check-attr.c
check-ignore.c
check-mailmap.c
check-ref-format.c check-ref-format: fix trivial memory leak 2022-07-01 11:43:42 -07:00
checkout--worker.c
checkout-index.c
checkout.c checkout: avoid "struct unpack_trees_options" leak 2022-07-01 11:43:43 -07:00
clean.c
clone.c Merge branch 'jk/clone-unborn-confusion' 2022-07-19 16:40:17 -07:00
column.c
commit-graph.c
commit-tree.c
commit.c
config.c
count-objects.c
credential-cache--daemon.c
credential-cache.c
credential-store.c
credential.c
describe.c
diff-files.c diff-files: move misplaced cleanup label 2022-07-12 07:17:28 -07:00
diff-index.c
diff-tree.c
diff.c
difftool.c
env--helper.c
fast-export.c
fast-import.c i18n: fix mismatched camelCase config variables 2022-06-17 10:38:26 -07:00
fetch-pack.c
fetch.c Merge branch 'ab/cocci-unused' 2022-07-18 13:31:57 -07:00
fmt-merge-msg.c
for-each-ref.c
for-each-repo.c
fsck.c fsck: do not dereference NULL while checking resolve-undo data 2022-07-11 16:26:33 -07:00
fsmonitor--daemon.c
gc.c gc: fix a memory leak 2022-07-01 11:43:43 -07:00
get-tar-commit-id.c
grep.c grep: add --max-count command line option 2022-06-22 13:23:29 -07:00
hash-object.c
help.c
hook.c
index-pack.c i18n: fix mismatched camelCase config variables 2022-06-17 10:38:26 -07:00
init-db.c
interpret-trailers.c
log.c
ls-files.c
ls-remote.c
ls-tree.c
mailinfo.c
mailsplit.c
merge-base.c
merge-file.c merge-file: fix memory leaks on error path 2022-07-01 11:43:43 -07:00
merge-index.c
merge-ours.c
merge-recursive.c
merge-tree.c merge-tree: add a --allow-unrelated-histories flag 2022-06-22 16:10:06 -07:00
merge.c merge: abort if index does not match HEAD for trivial merges 2022-07-22 21:45:23 -07:00
mktag.c
mktree.c mktree: do not check type of remote objects 2022-06-21 10:12:15 -07:00
multi-pack-index.c multi-pack-index: simplify handling of unknown --options 2022-07-10 14:53:48 -07:00
mv.c Merge branch 'jc/builtin-mv-move-array' 2022-07-18 13:31:53 -07:00
name-rev.c name-rev: prefix annotate-stdin with '--' in message 2022-06-20 16:20:45 -07:00
notes.c
pack-objects.c i18n: fix mismatched camelCase config variables 2022-06-17 10:38:26 -07:00
pack-redundant.c
pack-refs.c
patch-id.c
prune-packed.c
prune.c
pull.c pull: fix a "struct oid_array" memory leak 2022-07-01 11:43:43 -07:00
push.c push: fix capitalisation of the option name autoSetupMerge 2022-06-15 11:45:46 -07:00
range-diff.c
read-tree.c
rebase.c builtin/rebase: remove a redundant space in l10n string 2022-06-16 11:15:23 -07:00
receive-pack.c
reflog.c
remote-ext.c
remote-fd.c
remote.c remote: handle negative refspecs in git remote show 2022-06-17 10:03:59 -07:00
repack.c cocci: generalize "unused" rule to cover more than "strbuf" 2022-07-06 12:24:43 -07:00
replace.c
rerere.c
reset.c
rev-list.c
rev-parse.c
revert.c revert: free "struct replay_opts" members 2022-07-01 11:43:42 -07:00
rm.c
send-pack.c
shortlog.c
show-branch.c
show-index.c
show-ref.c
sparse-checkout.c
stash.c
stripspace.c
submodule--helper.c Merge branch 'ab/submodule-cleanup' 2022-07-14 15:04:00 -07:00
symbolic-ref.c
tag.c
unpack-file.c
unpack-objects.c
update-index.c
update-ref.c
update-server-info.c
upload-archive.c
upload-pack.c
var.c
verify-commit.c
verify-pack.c
verify-tag.c
worktree.c
write-tree.c