git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] merge: make restore_state() do as its name says

From
Junio C Hamano <gitster@pobox.com>
Date
May 19, 2022, 18:32 UTC
Message-ID
<xmqqwnehnzk0.fsf@gitster.g>
In-Reply-To
<xmqq5ym1pgby.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 16 quoted lines
>> +test_expect_success 'set up custom strategy' '
>> +	test_commit --no-tag "Initial" base base &&
>> +git show-ref &&
>> +
>> +	for b in branch1 branch2 branch3
>> +	do
>> +		git checkout -b $b main &&
>> +		test_commit --no-tag "Change on $b" base $b
>> +	done &&
>> +
>> +	git checkout branch1 &&
>
> Here, perhaps we can make two additional test cases, that try with
> local change that (1) overlaps with the changes branch2 and branch3
> bring in and that (2) does not overlap.  I am worried about the case
> (2) losing the local change due to the call to reset_hard().

We do not need a new test to demonstrate the breakage in the proposed patch, I think. Here is one place I found that we already test that merging in a dirty working tree fails. We only need to make sure that we do so without losing local changes.

 t/t6424-merge-unrelated-index-changes.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git c/t/t6424-merge-unrelated-index-changes.sh w/t/t6424-merge-unrelated-index-changes.sh
index 89dd544f38..88e0b541a0 100755
--- c/t/t6424-merge-unrelated-index-changes.sh
+++ w/t/t6424-merge-unrelated-index-changes.sh
@@ -171,7 +171,8 @@ test_expect_success 'octopus, unrelated file touched' '
 	touch random_file && git add random_file &&
 
 	test_must_fail git merge C^0 D^0 &&
-	test_path_is_missing .git/MERGE_HEAD
+	test_path_is_missing .git/MERGE_HEAD &&
+	test_path_exists random_file
 '
 
 test_expect_success 'octopus, related file removed' '
Previous: Junio C HamanoNext: Elijah Newren
Message 6 of 87 in “Fix merge restore state”
  1. 0/2 Fix merge restore stateElijah Newren via GitGitGadget, May 19, 2022
  2. 1/2 merge: remove unused variableElijah Newren via GitGitGadget, May 19, 2022
  3. Junio C HamanoMay 19, 2022
  4. 2/2 merge: make restore_state() do as its name saysElijah Newren via GitGitGadget, May 19, 2022
  5. Junio C HamanoMay 19, 2022
  6. Junio C HamanoMay 19, 2022
  7. Elijah NewrenJun 12, 2022
  8. ZheNing HuJun 12, 2022
  9. 0/6 Fix merge restore stateElijah Newren via GitGitGadget, Jun 19, 2022
  10. 1/6 t6424: make sure a failed merge preserves local changesJunio C Hamano via GitGitGadget, Jun 19, 2022
  11. 2/6 merge: remove unused variableElijah Newren via GitGitGadget, Jun 19, 2022
  12. Junio C HamanoJul 19, 2022
  13. 4/6 merge: make restore_state() restore staged state tooElijah Newren via GitGitGadget, Jun 19, 2022
  14. ZheNing HuJul 17, 2022
  15. Junio C HamanoJul 19, 2022
  16. Junio C HamanoJul 19, 2022
  17. Elijah NewrenJul 21, 2022
  18. 3/6 merge: fix save_state() to work when there are racy-dirty filesElijah Newren via GitGitGadget, Jun 19, 2022
  19. ZheNing HuJul 17, 2022
  20. Junio C HamanoJul 19, 2022
  21. Elijah NewrenJul 21, 2022
  22. Junio C HamanoJul 19, 2022
  23. 6/6 merge: do not exit restore_state() prematurelyElijah Newren via GitGitGadget, Jun 19, 2022
  24. ZheNing HuJul 17, 2022
  25. Junio C HamanoJul 19, 2022
  26. Eric SunshineJul 20, 2022
  27. Elijah NewrenJul 21, 2022
  28. Elijah NewrenJul 21, 2022
  29. 5/6 merge: ensure we can actually restore pre-merge stateElijah Newren via GitGitGadget, Jun 19, 2022
  30. ZheNing HuJul 17, 2022
  31. Junio C HamanoJul 19, 2022
  32. Elijah NewrenJul 21, 2022
  33. 0/7 Fix merge restore stateElijah Newren via GitGitGadget, Jul 21, 2022
  34. 1/7 merge-ort-wrappers: make printed message match the one from recursiveElijah Newren via GitGitGadget, Jul 21, 2022
  35. Junio C HamanoJul 21, 2022
  36. Elijah NewrenJul 21, 2022
  37. Junio C HamanoJul 21, 2022
  38. Elijah NewrenJul 21, 2022
  39. 2/7 merge-resolve: abort if index does not match HEADElijah Newren via GitGitGadget, Jul 21, 2022
  40. 3/7 merge: do not abort early if one strategy fails to handle the mergeElijah Newren via GitGitGadget, Jul 21, 2022
  41. Junio C HamanoJul 21, 2022
  42. Ævar Arnfjörð BjarmasonJul 25, 2022
  43. Elijah NewrenJul 26, 2022
  44. Ævar Arnfjörð BjarmasonJul 26, 2022
  45. 4/7 merge: fix save_state() to work when there are stat-dirty filesElijah Newren via GitGitGadget, Jul 21, 2022
  46. 6/7 merge: ensure we can actually restore pre-merge stateElijah Newren via GitGitGadget, Jul 21, 2022
  47. Junio C HamanoJul 21, 2022
  48. Ben HumphreysMar 2, 2023
  49. Elijah NewrenMar 2, 2023
  50. Junio C HamanoMar 2, 2023
  51. Rudy RigotMar 4, 2023
  52. Ben HumphreysMar 6, 2023
  53. 5/7 merge: make restore_state() restore staged state tooElijah Newren via GitGitGadget, Jul 21, 2022
  54. Junio C HamanoJul 21, 2022
  55. Junio C HamanoJul 21, 2022
  56. Elijah NewrenJul 21, 2022
  57. 7/7 merge: do not exit restore_state() prematurelyElijah Newren via GitGitGadget, Jul 21, 2022
  58. Junio C HamanoJul 21, 2022
  59. 0/7 Fix merge restore stateElijah Newren via GitGitGadget, Jul 22, 2022
  60. 1/7 merge-ort-wrappers: make printed message match the one from recursiveElijah Newren via GitGitGadget, Jul 22, 2022
  61. 2/7 merge-resolve: abort if index does not match HEADElijah Newren via GitGitGadget, Jul 22, 2022
  62. Ævar Arnfjörð BjarmasonJul 22, 2022
  63. Elijah NewrenJul 23, 2022
  64. Ævar Arnfjörð BjarmasonJul 23, 2022
  65. Elijah NewrenJul 26, 2022
  66. Ævar Arnfjörð BjarmasonJul 26, 2022
  67. 3/7 merge: do not abort early if one strategy fails to handle the mergeElijah Newren via GitGitGadget, Jul 22, 2022
  68. Ævar Arnfjörð BjarmasonJul 22, 2022
  69. Elijah NewrenJul 23, 2022
  70. 4/7 merge: fix save_state() to work when there are stat-dirty filesElijah Newren via GitGitGadget, Jul 22, 2022
  71. 5/7 merge: make restore_state() restore staged state tooElijah Newren via GitGitGadget, Jul 22, 2022
  72. Ævar Arnfjörð BjarmasonJul 22, 2022
  73. Elijah NewrenJul 23, 2022
  74. 6/7 merge: ensure we can actually restore pre-merge stateElijah Newren via GitGitGadget, Jul 22, 2022
  75. 7/7 merge: do not exit restore_state() prematurelyElijah Newren via GitGitGadget, Jul 22, 2022
  76. 0/8 Fix merge restore stateElijah Newren via GitGitGadget, Jul 23, 2022
  77. 2/8 merge-resolve: abort if index does not match HEADElijah Newren via GitGitGadget, Jul 23, 2022
  78. 1/8 merge-ort-wrappers: make printed message match the one from recursiveElijah Newren via GitGitGadget, Jul 23, 2022
  79. 4/8 merge: do not abort early if one strategy fails to handle the mergeElijah Newren via GitGitGadget, Jul 23, 2022
  80. 3/8 merge: abort if index does not match HEAD for trivial mergesElijah Newren via GitGitGadget, Jul 23, 2022
  81. 5/8 merge: fix save_state() to work when there are stat-dirty filesElijah Newren via GitGitGadget, Jul 23, 2022
  82. 6/8 merge: make restore_state() restore staged state tooElijah Newren via GitGitGadget, Jul 23, 2022
  83. 7/8 merge: ensure we can actually restore pre-merge stateElijah Newren via GitGitGadget, Jul 23, 2022
  84. 8/8 merge: do not exit restore_state() prematurelyElijah Newren via GitGitGadget, Jul 23, 2022
  85. Junio C HamanoJul 25, 2022
  86. Elijah NewrenJul 26, 2022
  87. ZheNing HuJul 26, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.