@@ -71,7 +71,7 @@ fn test_bisect_run() -> TestResult {
7171 create_commit ( & work_dir, "f" , & [ "e" ] ) ;
7272
7373 std:: fs:: write ( & bisection_script, [ "fail" ] . join ( "\0 " ) ) ?;
74- insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , & bisector_path] ) , @"
74+ insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , "--trust-endpoints" , & bisector_path] ) , @"
7575 Bisecting: 5 revisions left to test after this (roughly 3 steps)
7676 Now evaluating: royxmykx dffaa0d4 c | c
7777 fake-bisector testing commit dffaa0d4daccf6cee70bac3498fae3b3fd5d6b5b
@@ -111,7 +111,7 @@ fn test_bisect_run() -> TestResult {
111111 // Try with legacy command argument
112112 std:: fs:: write ( & bisection_script, [ "fail" ] . join ( "\0 " ) ) ?;
113113 // Testing only stderr to avoid a variable op id in the stdout.
114- insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , "--command" , & bisector_path] ) . success( ) . stderr, @"
114+ insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , "--trust-endpoints" , "-- command", & bisector_path] ) . success( ) . stderr, @"
115115 Warning: `--command` is deprecated; use positional arguments instead: `jj bisect run --range=... -- $FAKE_BISECTOR_PATH`
116116 Working copy (@) now at: nkmrtpmo 1601f7b4 (empty) (no description set)
117117 Parent commit (@-) : royxmykx dffaa0d4 c | c
@@ -136,6 +136,169 @@ fn test_bisect_run() -> TestResult {
136136 Ok ( ( ) )
137137}
138138
139+ #[ test]
140+ // like test_bisect::test_bisect_nonlinear
141+ // bisecting over commits 0,1,2,3,4,5,6 with 5 being the first bad commit
142+ // this fails because 6 should also be bad!
143+ fn test_bisect_run_nonlinear_no_merge ( ) -> TestResult {
144+ let mut test_env = TestEnvironment :: default ( ) ;
145+ let bisector_path = fake_bisector_path ( ) ;
146+ test_env. set_up_fake_bisector ( ) ;
147+ test_env. run_jj_in ( "." , [ "git" , "init" , "repo" ] ) . success ( ) ;
148+ let work_dir = test_env. work_dir ( "repo" ) ;
149+
150+ // h
151+ // |\
152+ // f g
153+ // | |
154+ // d e
155+ // | |
156+ // b c
157+ // |/
158+ // a
159+
160+ create_commit ( & work_dir, "a" , & [ ] ) ;
161+ create_commit ( & work_dir, "b" , & [ "a" ] ) ;
162+ create_commit ( & work_dir, "c" , & [ "a" ] ) ;
163+ create_commit ( & work_dir, "d" , & [ "b" ] ) ;
164+ create_commit ( & work_dir, "e" , & [ "c" ] ) ;
165+ create_commit ( & work_dir, "f" , & [ "d" ] ) ;
166+ create_commit ( & work_dir, "g" , & [ "e" ] ) ;
167+ create_commit ( & work_dir, "h" , & [ "f" , "g" ] ) ;
168+
169+ // rather than complicating fake_bisector, we try and --find-good
170+ insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=ancestors(parents(h))" , "--find-good" , "--" , & bisector_path, "--require-file=f" ] ) , @"
171+ Pre-bisection check: ensuring this commit is good:
172+ kmkuslsw 3548fddf f | f
173+ fake-bisector testing commit 3548fddfc5b69ba4c5b78a19c1cc6d39e52e5a22
174+ Pre-bisection check: ensuring this commit is good:
175+ lylxulpl 97949f0f g | g
176+ fake-bisector testing commit 97949f0f52afedfc72ef44d63d21266bbfc42774
177+ Cannot bisect: this commit was expected to be good, but was found to be bad (exit status: 1) instead.
178+ Search complete. To discard any revisions created during search, run:
179+ jj op restore 7d0937f0feb3
180+ [EOF]
181+ ------- stderr -------
182+ Working copy (@) now at: xznxytkn 08be40de (empty) (no description set)
183+ Parent commit (@-) : kmkuslsw 3548fddf f | f
184+ Added 0 files, modified 0 files, removed 4 files
185+ Working copy (@) now at: smwtzssm fc3a931c (empty) (no description set)
186+ Parent commit (@-) : lylxulpl 97949f0f g | g
187+ Added 3 files, modified 0 files, removed 3 files
188+ Error: Bisection preconditions failed
189+ [EOF]
190+ [exit status: 1]
191+ " ) ;
192+ insta:: assert_snapshot!( get_log_output( & work_dir) , @"
193+ @ smwtzssmuxzk fc3a931c8da8 '' files:
194+ │ ○ nkmrtpmomlro b47137c13576 'h' files: h
195+ ╭─┤
196+ ○ │ lylxulplsnyw 97949f0f52af 'g' files: g
197+ ○ │ znkkpsqqskkl efcb3d331401 'e' files: e
198+ ○ │ royxmykxtrkr 991a7501d660 'c' files: c
199+ │ ○ kmkuslswpqwq 3548fddfc5b6 'f' files: f
200+ │ ○ vruxwmqvtpmx 01a5f35e756c 'd' files: d
201+ │ ○ zsuskulnrvyr 123b4d91f6e5 'b' files: b
202+ ├─╯
203+ ○ rlvkpnrzqnoo 7d980be7a1d4 'a' files: a
204+ ◆ zzzzzzzzzzzz 000000000000 '' files:
205+ [EOF]
206+ " ) ;
207+ Ok ( ( ) )
208+ }
209+ // like test_bisect_run_nonlinear_with_merge, but we include the merge commit.
210+ // that makes it okay for commit f to be the first bad one.
211+ #[ test]
212+ fn test_bisect_run_nonlinear_with_merge ( ) -> TestResult {
213+ let mut test_env = TestEnvironment :: default ( ) ;
214+ let bisector_path = fake_bisector_path ( ) ;
215+ test_env. set_up_fake_bisector ( ) ;
216+ test_env. run_jj_in ( "." , [ "git" , "init" , "repo" ] ) . success ( ) ;
217+ let work_dir = test_env. work_dir ( "repo" ) ;
218+
219+ // h
220+ // |\
221+ // f g
222+ // | |
223+ // d e
224+ // | |
225+ // b c
226+ // |/
227+ // a
228+
229+ create_commit ( & work_dir, "a" , & [ ] ) ;
230+ create_commit ( & work_dir, "b" , & [ "a" ] ) ;
231+ create_commit ( & work_dir, "c" , & [ "a" ] ) ;
232+ create_commit ( & work_dir, "d" , & [ "b" ] ) ;
233+ create_commit ( & work_dir, "e" , & [ "c" ] ) ;
234+ create_commit ( & work_dir, "f" , & [ "d" ] ) ;
235+ create_commit ( & work_dir, "g" , & [ "e" ] ) ;
236+ create_commit ( & work_dir, "h" , & [ "f" , "g" ] ) ;
237+
238+ insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , "--find-good" , "--" , & bisector_path, "--require-file=f" ] ) , @"
239+ Pre-bisection check: ensuring this commit is good:
240+ nkmrtpmo b47137c1 h | h
241+ fake-bisector testing commit b47137c135761c932a7d0c1619d6121868eb7df9
242+ Bisecting: 8 revisions left to test after this (roughly 4 steps)
243+ Now evaluating: royxmykx 991a7501 c | c
244+ fake-bisector testing commit 991a7501d660abb6a80e8b00f77c651d76d845d7
245+ The revision is bad.
246+
247+ Bisecting: 5 revisions left to test after this (roughly 3 steps)
248+ Now evaluating: znkkpsqq efcb3d33 e | e
249+ fake-bisector testing commit efcb3d33140196e8aa5157e4c865e9a4c513f8bb
250+ The revision is bad.
251+
252+ Bisecting: 4 revisions left to test after this (roughly 3 steps)
253+ Now evaluating: vruxwmqv 01a5f35e d | d
254+ fake-bisector testing commit 01a5f35e756cec7f8543120aeedcce0d086a2504
255+ The revision is bad.
256+
257+ Bisecting: 2 revisions left to test after this (roughly 2 steps)
258+ Now evaluating: kmkuslsw 3548fddf f | f
259+ fake-bisector testing commit 3548fddfc5b69ba4c5b78a19c1cc6d39e52e5a22
260+ The revision is good.
261+
262+ Search complete. To discard any revisions created during search, run:
263+ jj op restore 7d0937f0feb3
264+ The first good revision is: kmkuslsw 3548fddf f | f
265+ [EOF]
266+ ------- stderr -------
267+ Working copy (@) now at: xznxytkn 8d14f10f (empty) (no description set)
268+ Parent commit (@-) : nkmrtpmo b47137c1 h | h
269+ Working copy (@) now at: smwtzssm 38d94e5b (empty) (no description set)
270+ Parent commit (@-) : royxmykx 991a7501 c | c
271+ Added 0 files, modified 0 files, removed 6 files
272+ Working copy (@) now at: zlusorwl 00dc6326 (empty) (no description set)
273+ Parent commit (@-) : znkkpsqq efcb3d33 e | e
274+ Added 1 files, modified 0 files, removed 0 files
275+ Working copy (@) now at: ukzzzykq 6e876421 (empty) (no description set)
276+ Parent commit (@-) : vruxwmqv 01a5f35e d | d
277+ Added 2 files, modified 0 files, removed 2 files
278+ Working copy (@) now at: lqoxyrsk 4967f850 (empty) (no description set)
279+ Parent commit (@-) : kmkuslsw 3548fddf f | f
280+ Added 1 files, modified 0 files, removed 0 files
281+ [EOF]
282+ " ) ;
283+
284+ insta:: assert_snapshot!( get_log_output( & work_dir) , @"
285+ @ lqoxyrskwpry 4967f85032d5 '' files:
286+ │ ○ nkmrtpmomlro b47137c13576 'h' files: h
287+ ╭─┤
288+ │ ○ lylxulplsnyw 97949f0f52af 'g' files: g
289+ │ ○ znkkpsqqskkl efcb3d331401 'e' files: e
290+ │ ○ royxmykxtrkr 991a7501d660 'c' files: c
291+ ○ │ kmkuslswpqwq 3548fddfc5b6 'f' files: f
292+ ○ │ vruxwmqvtpmx 01a5f35e756c 'd' files: d
293+ ○ │ zsuskulnrvyr 123b4d91f6e5 'b' files: b
294+ ├─╯
295+ ○ rlvkpnrzqnoo 7d980be7a1d4 'a' files: a
296+ ◆ zzzzzzzzzzzz 000000000000 '' files:
297+ [EOF]
298+ " ) ;
299+ Ok ( ( ) )
300+ }
301+
139302#[ test]
140303fn test_bisect_run_find_first_good ( ) {
141304 let mut test_env = TestEnvironment :: default ( ) ;
@@ -151,7 +314,7 @@ fn test_bisect_run_find_first_good() {
151314 create_commit ( & work_dir, "e" , & [ "d" ] ) ;
152315 create_commit ( & work_dir, "f" , & [ "e" ] ) ;
153316
154- insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , "--find-good" , & bisector_path] ) , @"
317+ insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , "--find-good" , "--trust-endpoints" , & bisector_path] ) , @"
155318 Bisecting: 5 revisions left to test after this (roughly 3 steps)
156319 Now evaluating: royxmykx dffaa0d4 c | c
157320 fake-bisector testing commit dffaa0d4daccf6cee70bac3498fae3b3fd5d6b5b
@@ -202,7 +365,13 @@ fn test_bisect_run_missing_bisector() {
202365 create_commit ( & work_dir, "e" , & [ "d" ] ) ;
203366 create_commit ( & work_dir, "f" , & [ "e" ] ) ;
204367
205- let output = work_dir. run_jj ( [ "bisect" , "run" , "--range=.." , "nonexistent" ] ) ;
368+ let output = work_dir. run_jj ( [
369+ "bisect" ,
370+ "run" ,
371+ "--range=.." ,
372+ "--trust-endpoints" ,
373+ "nonexistent" ,
374+ ] ) ;
206375 if cfg ! ( unix) {
207376 insta:: assert_snapshot!( output, @r"
208377 Bisecting: 5 revisions left to test after this (roughly 3 steps)
@@ -249,7 +418,7 @@ fn test_bisect_run_with_args() {
249418 create_commit ( & work_dir, "e" , & [ "d" ] ) ;
250419 create_commit ( & work_dir, "f" , & [ "e" ] ) ;
251420
252- insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , "--find-good" , "--" , & bisector_path, "--require-file=c" ] ) , @"
421+ insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , "--find-good" , "--trust-endpoints" , "-- ", & bisector_path, "--require-file=c" ] ) , @"
253422 Bisecting: 5 revisions left to test after this (roughly 3 steps)
254423 Now evaluating: royxmykx dffaa0d4 c | c
255424 fake-bisector testing commit dffaa0d4daccf6cee70bac3498fae3b3fd5d6b5b
@@ -312,7 +481,7 @@ fn test_bisect_run_crash() -> TestResult {
312481
313482 // bisector crash is equivalent to a failure
314483 std:: fs:: write ( & bisection_script, [ "crash" ] . join ( "\0 " ) ) ?;
315- insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , & bisector_path] ) , @"
484+ insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , "--trust-endpoints" , & bisector_path] ) , @"
316485 Bisecting: 5 revisions left to test after this (roughly 3 steps)
317486 Now evaluating: royxmykx dffaa0d4 c | c
318487 fake-bisector testing commit dffaa0d4daccf6cee70bac3498fae3b3fd5d6b5b
@@ -353,7 +522,7 @@ fn test_bisect_run_abort() -> TestResult {
353522
354523 // stop immediately on failure
355524 std:: fs:: write ( & bisection_script, [ "abort" ] . join ( "\0 " ) ) ?;
356- insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , & bisector_path] ) , @"
525+ insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , "--trust-endpoints" , & bisector_path] ) , @"
357526 Bisecting: 2 revisions left to test after this (roughly 2 steps)
358527 Now evaluating: rlvkpnrz 7d980be7 a | a
359528 fake-bisector testing commit 7d980be7a1d499e4d316ab4c01242885032f7eaf
@@ -386,7 +555,7 @@ fn test_bisect_run_skip() -> TestResult {
386555 create_commit ( & work_dir, "b" , & [ "a" ] ) ;
387556
388557 std:: fs:: write ( & bisection_script, [ "skip" ] . join ( "\0 " ) ) ?;
389- insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , & bisector_path] ) , @"
558+ insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , "--trust-endpoints" , & bisector_path] ) , @"
390559 Bisecting: 1 revisions left to test after this (roughly 1 steps)
391560 Now evaluating: rlvkpnrz 7d980be7 a | a
392561 fake-bisector testing commit 7d980be7a1d499e4d316ab4c01242885032f7eaf
@@ -422,7 +591,7 @@ fn test_bisect_run_multiple_results() {
422591 create_commit ( & work_dir, "c" , & [ "a" ] ) ;
423592 create_commit ( & work_dir, "d" , & [ "c" ] ) ;
424593
425- insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=a|b|c|d" , & bisector_path] ) , @"
594+ insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=a|b|c|d" , "--trust-endpoints" , & bisector_path] ) , @"
426595 Bisecting: 2 revisions left to test after this (roughly 2 steps)
427596 Now evaluating: rlvkpnrz 7d980be7 a | a
428597 fake-bisector testing commit 7d980be7a1d499e4d316ab4c01242885032f7eaf
@@ -468,7 +637,7 @@ fn test_bisect_run_write_file() -> TestResult {
468637 & bisection_script,
469638 [ "write new-file\n some contents" , "fail" ] . join ( "\0 " ) ,
470639 ) ?;
471- insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , & bisector_path] ) , @"
640+ insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , "--trust-endpoints" , & bisector_path] ) , @"
472641 Bisecting: 4 revisions left to test after this (roughly 3 steps)
473642 Now evaluating: zsuskuln 123b4d91 b | b
474643 fake-bisector testing commit 123b4d91f6e5e39bfed39bae3bacf9380dc79078
@@ -534,7 +703,7 @@ fn test_bisect_run_jj_command() -> TestResult {
534703 create_commit ( & work_dir, "e" , & [ "d" ] ) ;
535704
536705 std:: fs:: write ( & bisection_script, [ "jj new -mtesting" , "fail" ] . join ( "\0 " ) ) ?;
537- insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , & bisector_path] ) , @"
706+ insta:: assert_snapshot!( work_dir. run_jj( [ "bisect" , "run" , "--range=.." , "--trust-endpoints" , & bisector_path] ) , @"
538707 Bisecting: 4 revisions left to test after this (roughly 3 steps)
539708 Now evaluating: zsuskuln 123b4d91 b | b
540709 fake-bisector testing commit 123b4d91f6e5e39bfed39bae3bacf9380dc79078
0 commit comments