Skip to content

Commit 412b970

Browse files
committed
test_rerere: Test conflicting state between commits, not after
When reordering commits and there is a conflict, changing the final state is not what the user is asking for (that's adding, not reordering, changes). As far as the correct final state is known, git-revise should rather spare the user the work of recreating it. Before changing git-revise to do the right thing without asking, the test must do its thing without doing the forbidden.
1 parent a5780dd commit 412b970

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

tests/test_rerere.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,40 +49,40 @@ def test_reuse_recorded_resolution(
4949

5050
# Cached case: Test auto-using, accepting or declining the recorded resolution.
5151
acceptance_input = None
52-
state_after_the_second_commit = "resolved one"
52+
intermediate_state = "resolved two"
5353
if not auto_update:
5454
acceptance_input = b"y\n" * 2
5555
if custom_resolution is not None:
56-
# Choose the second commit to get the custom resolution.
57-
acceptance_input = b"y\nn\n" + b"y\n" * 2
58-
state_after_the_second_commit = custom_resolution
56+
acceptance_input = b"n\n" + b"y\n" * 4
57+
intermediate_state = custom_resolution
5958

6059
with editor_main(("-i", "HEAD~~"), input=acceptance_input) as ed:
6160
flip_last_two_commits(repo, ed)
6261
if custom_resolution is not None:
6362
with ed.next_file() as f:
6463
f.replace_dedent(custom_resolution + "\n")
64+
with ed.next_file() as f:
65+
f.replace_dedent("resolved one\n")
6566

66-
if custom_resolution is None:
67-
assert tree_after_resolving_conflicts == repo.get_commit("HEAD").tree()
67+
assert tree_after_resolving_conflicts == repo.get_commit("HEAD").tree()
6868

6969
assert hunks(repo.git("show", "-U0", "HEAD~")) == dedent(
70-
"""\
70+
f"""\
7171
@@ -1 +1 @@
7272
-
73-
+resolved two"""
73+
+{intermediate_state}"""
7474
)
7575
assert hunks(repo.git("show", "-U0", "HEAD")) == dedent(
7676
f"""\
7777
@@ -1 +1 @@
78-
-resolved two
79-
+{state_after_the_second_commit}"""
78+
-{intermediate_state}
79+
+resolved one"""
8080
)
8181
leftover_index = hunks(repo.git("diff", "-U0", "HEAD"))
8282
assert leftover_index == dedent(
83-
f"""\
83+
"""\
8484
@@ -1 +1 @@
85-
-{state_after_the_second_commit}
85+
-resolved one
8686
+two"""
8787
)
8888

0 commit comments

Comments
 (0)