Similar to commit c8c562a, if a user is resolving conflicts, they may think it wise to stash their current work tree and git pull to see if there are additional changes on the remote. The stash will fail to save if the index contains unmerged entries, but if the conflicts are resolved, the stash will succeed, and both MERGE_HEAD and MERGE_MSG will be removed. This is probably a mistake, and we should warn the user and refuse to stash. Signed-off-by: Dave Olszewski <cxreg@xxxxxxxxx> --- git-stash.sh | 5 +++++ t/t3903-stash.sh | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 0 deletions(-) diff --git a/git-stash.sh b/git-stash.sh index aa47e54..1a70f8d 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -172,6 +172,11 @@ save_stash () { test -f "$GIT_DIR/logs/$ref_stash" || clear_stash || die "Cannot initialize stash" + if test -f "$GIT_DIR/MERGE_HEAD" + then + die "You have not concluded your merge. (MERGE_HEAD exists)"; + fi + create_stash "$stash_msg" # Make sure the reflog for stash is kept. diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 476e5ec..9915f4f 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -228,4 +228,23 @@ test_expect_success 'stash --invalid-option' ' test bar,bar2 = $(cat file),$(cat file2) ' +test_expect_success 'stash during merge' ' + git branch other && + git checkout master && + echo conflict > conflict && + git add conflict && + git commit -m "conflict" && + git checkout other && + echo other content > conflict && + git add conflict && + git commit -m "other branch conflict" && + git checkout master && + test_must_fail git merge other && + test_must_fail git stash && + git add . && + git status && + test_must_fail git stash && + git reset --hard +' + test_done -- 1.7.0.2.200.ga611.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html