Skip to content

pr-1231/newren/fix-merge-restore-state-v2

MAINTAINER NOTE: Rebased on latest main/master. (In particular, needs
vd/sparse-stash; otherwise, the changes made here regress a
ensure-full-index testcase in t1092). Also, this fixes issues that predate
the v2.37 cycle, so this series can wait until v2.38 opens up.

Other note: If this rounds needs updates, ZheNing Hu may be the one to
respond and make any necessary updates, as per [1].

----------------------------------------------------------------------------

This is a simple series to fix restore_state() in builtin/merge.c, fixing
the issue reported by ZheNing Hu over here:
https://lore.kernel.org/git/CAOLTT8R7QmpvaFPTRs3xTpxr7eiuxF-ZWtvUUSC0-JOo9Y+SqA@mail.gmail.com/

Changes since v1:

 * Rebased
 * Included Junio's patch providing more testcases from
   https://lore.kernel.org/git/xmqqbkvtnyae.fsf@gitster.g/
 * Added three new patches to fix issues highlighted by Junio's testcases,
   in particular to (a) fix stashing with racy-dirty files present, (b) fix
   restoring staged state in restore_state(), and (c) ensure we can restore
   pre-merge state. All three were long-standing issues that we just hadn't
   noticed yet and thus are useful fixes on their own. However, my fix from
   v1 (which still remains as the final patch) does make it easier to notice
   these issues, and in particular that combined with Junio's new testcases
   unearthed those problems.

[1]
https://lore.kernel.org/git/CAOLTT8RpGGioOyaMw5tkeWXmHpOaBW9UH8JghUvBRQ50ZcDdYQ@mail.gmail.com/

Elijah Newren (5):
  merge: remove unused variable
  merge: fix save_state() to work when there are racy-dirty files
  merge: make restore_state() restore staged state too
  merge: ensure we can actually restore pre-merge state
  merge: do not exit restore_state() prematurely

Junio C Hamano (1):
  t6424: make sure a failed merge preserves local changes

 builtin/merge.c                          | 32 ++++++++++++++----------
 t/t6424-merge-unrelated-index-changes.sh | 32 ++++++++++++++++++++++--
 t/t7607-merge-state.sh                   | 25 ++++++++++++++++++
 3 files changed, 74 insertions(+), 15 deletions(-)
 create mode 100755 t/t7607-merge-state.sh

base-commit: 8ddf593a250e07d388059f7e3f471078e1d2ed5c

Submitted-As: https://lore.kernel.org/git/pull.1231.v2.git.1655621424.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.1231.git.1652977582.gitgitgadget@gmail.com
Assets 2