git notes merge: --commit should fail if underlying notes ref has moved
commit6cfd6a9dea889707fa207ee2003010c3b56b2131
authorJohan Herland <johan@herland.net>
Tue, 9 Nov 2010 21:49:54 +0000 (9 22:49 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Nov 2010 21:22:49 +0000 (17 13:22 -0800)
treec0596682504898624057f102066fe4beddea3e5f
parent443259cf929c0041310e3c77946252cbfc3f787d
git notes merge: --commit should fail if underlying notes ref has moved

When manually resolving a notes merge, if the merging ref has moved since
the merge started, we should fail to complete the merge, and alert the user
to what's going on.

This situation may arise if you start a 'git notes merge' which results in
conflicts, and you then update the current notes ref (using for example
'git notes add/copy/amend/edit/remove/prune', 'git update-ref', etc.),
before you get around to resolving the notes conflicts and calling
'git notes merge --commit'.

We detect this situation by comparing the first parent of the partial merge
commit (which was created when the merge started) to the current value of the
merging notes ref (pointed to by the .git/NOTES_MERGE_REF symref).

If we don't fail in this situation, the notes merge commit would overwrite
the updated notes ref, thus losing the changes that happened in the meantime.

The patch includes a testcase verifying that we fail correctly in this
situation.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/notes.c
t/t3310-notes-merge-manual-resolve.sh