aboutsummaryrefslogtreecommitdiffstats
path: root/git-merge-resolve.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-08-03 13:36:09 -0700
committerJunio C Hamano <gitster@pobox.com>2022-08-03 13:36:09 -0700
commit966ff64a3042f879bca83e2376128cf5f39737a7 (patch)
tree9e03fa16df286180840c091d9b1de725122f09b1 /git-merge-resolve.sh
parent4e0d160bbc88c3486ff7ccae179e4730aab5dd28 (diff)
parentc23fc075c6b9601e0fe7f4c8e5399a6f0cbff13e (diff)
downloadgit-966ff64a3042f879bca83e2376128cf5f39737a7.tar.gz
Merge branch 'en/merge-restore-to-pristine'
When "git merge" finds that it cannot perform a merge, it should restore the working tree to the state before the command was initiated, but in some corner cases it didn't. * en/merge-restore-to-pristine: merge: do not exit restore_state() prematurely merge: ensure we can actually restore pre-merge state merge: make restore_state() restore staged state too merge: fix save_state() to work when there are stat-dirty files merge: do not abort early if one strategy fails to handle the merge merge: abort if index does not match HEAD for trivial merges merge-resolve: abort if index does not match HEAD merge-ort-wrappers: make printed message match the one from recursive
Diffstat (limited to 'git-merge-resolve.sh')
-rwxr-xr-xgit-merge-resolve.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/git-merge-resolve.sh b/git-merge-resolve.sh
index 343fe7bccd..77e93121bf 100755
--- a/git-merge-resolve.sh
+++ b/git-merge-resolve.sh
@@ -5,6 +5,16 @@
#
# Resolve two trees, using enhanced multi-base read-tree.
+. git-sh-setup
+
+# Abort if index does not match HEAD
+if ! git diff-index --quiet --cached HEAD --
+then
+ gettextln "Error: Your local changes to the following files would be overwritten by merge"
+ git diff-index --cached --name-only HEAD -- | sed -e 's/^/ /'
+ exit 2
+fi
+
# The first parameters up to -- are merge bases; the rest are heads.
bases= head= remotes= sep_seen=
for arg