@@ -15,8 +15,8 @@ def history_with_two_conflicting_commits(auto_update: bool = False) -> None:
1515 git config rerere.enabled true
1616 git config rerere.autoUpdate { "true" if auto_update else "false" }
1717 echo > file; git add file; git commit -m 'initial commit'
18- echo one > file; git commit -am 'commit one '
19- echo two > file; git commit -am 'commit two '
18+ echo eggs > file; git commit -am 'add eggs '
19+ echo eggs spam > file; git commit -am 'add spam '
2020 """
2121 )
2222
@@ -26,7 +26,7 @@ def history_with_two_conflicting_commits(auto_update: bool = False) -> None:
2626 [
2727 (True , None ),
2828 (False , None ),
29- (False , "custom resolution " ),
29+ (False , "only spam " ),
3030 ],
3131)
3232def test_reuse_recorded_resolution (
@@ -40,16 +40,16 @@ def test_reuse_recorded_resolution(
4040 with editor_main (("-i" , "HEAD~~" ), input = b"y\n " * 4 ) as ed :
4141 flip_last_two_commits (repo , ed )
4242 with ed .next_file () as f :
43- f .replace_dedent ("resolved two \n " )
43+ f .replace_dedent ("spam \n " )
4444 with ed .next_file () as f :
45- f .replace_dedent ("resolved one \n " )
45+ f .replace_dedent ("eggs spam \n " )
4646
4747 tree_after_resolving_conflicts = repo .get_commit ("HEAD" ).tree ()
4848 bash ("git reset --hard HEAD@{1}" )
4949
5050 # Cached case: Test auto-using, accepting or declining the recorded resolution.
5151 acceptance_input = None
52- intermediate_state = "resolved two "
52+ intermediate_state = "spam "
5353 if not auto_update :
5454 acceptance_input = b"y\n " * 2
5555 if custom_resolution is not None :
@@ -62,7 +62,7 @@ def test_reuse_recorded_resolution(
6262 with ed .next_file () as f :
6363 f .replace_dedent (custom_resolution + "\n " )
6464 with ed .next_file () as f :
65- f .replace_dedent ("resolved one \n " )
65+ f .replace_dedent ("eggs spam \n " )
6666
6767 assert tree_after_resolving_conflicts == repo .get_commit ("HEAD" ).tree ()
6868
@@ -76,15 +76,9 @@ def test_reuse_recorded_resolution(
7676 f"""\
7777 @@ -1 +1 @@
7878 -{ intermediate_state }
79- +resolved one"""
80- )
81- leftover_index = hunks (repo .git ("diff" , "-U0" , "HEAD" ))
82- assert leftover_index == dedent (
83- """\
84- @@ -1 +1 @@
85- -resolved one
86- +two"""
79+ +eggs spam"""
8780 )
81+ assert uncommitted_changes (repo ) == ""
8882
8983
9084def test_rerere_merge (repo : Repository ) -> None :
@@ -151,9 +145,11 @@ def test_replay_resolution_recorded_by_git(repo: Repository) -> None:
151145 two=$(git rev-parse HEAD)
152146 git reset --hard HEAD~~
153147 git cherry-pick "$two" 2>&1 | grep 'could not apply'
154- echo resolved two > file; git add file; GIT_EDITOR=: git cherry-pick --continue
148+ echo intermediate state > file
149+ git add file; GIT_EDITOR=: git cherry-pick --continue
155150 git cherry-pick "$one" 2>&1 | grep 'could not apply'
156- echo resolved one > file; git add file; GIT_EDITOR=: git cherry-pick --continue --no-edit
151+ echo something completely different > file
152+ git add file; GIT_EDITOR=: git cherry-pick --continue --no-edit
157153 git reset --hard "$two"
158154 """
159155 )
@@ -164,33 +160,33 @@ def test_replay_resolution_recorded_by_git(repo: Repository) -> None:
164160
165161 assert repo .git ("log" , "-p" , trim_newline = False ).decode () == dedent (
166162 """\
167- commit dc50430ecbd2d0697ee9266ba6057e0e0b511d7f
163+ commit 44fdce0cf7ae75ed5edac5f3defed83cddf3ec4a
168164 Author: Bash Author <[email protected] > 169165 Date: Thu Jul 13 21:40:00 2017 -0500
170166
171- commit one
167+ add eggs
172168
173169 diff --git a/file b/file
174- index 474b904..936bcfd 100644
170+ index 5d0f8a8..cb90548 100644
175171 --- a/file
176172 +++ b/file
177173 @@ -1 +1 @@
178- -resolved two
179- +resolved one
174+ -intermediate state
175+ +something completely different
180176
181- commit e51ab202e87f0557df78e5273dcedf51f408a468
177+ commit 1fa5135a6cce1f63dc2f5584ee68e15a4de3a99c
182178 Author: Bash Author <[email protected] > 183179 Date: Thu Jul 13 21:40:00 2017 -0500
184180
185- commit two
181+ add spam
186182
187183 diff --git a/file b/file
188- index 8b13789..474b904 100644
184+ index 8b13789..5d0f8a8 100644
189185 --- a/file
190186 +++ b/file
191187 @@ -1 +1 @@
192188 -
193- +resolved two
189+ +intermediate state
194190
195191 commit d72132e74176624d6c3e5b6b4f5ef774ff23a1b3
196192 Author: Bash Author <[email protected] > @@ -356,3 +352,7 @@ def normalize_conflict_dedent(indented_conflict: str) -> Tuple[str, str]:
356352
357353def hunks (diff : bytes ) -> str :
358354 return diff [diff .index (b"@@" ) :].decode ()
355+
356+
357+ def uncommitted_changes (repo : Repository ) -> str :
358+ return repo .git ("diff" , "-U0" , "HEAD" ).decode ()
0 commit comments