1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.api;
12
13 import static java.nio.charset.StandardCharsets.UTF_8;
14 import static org.junit.Assert.assertEquals;
15 import static org.junit.Assert.assertNotNull;
16 import static org.junit.Assert.assertTrue;
17
18 import java.io.File;
19 import java.io.IOException;
20
21 import org.eclipse.jgit.api.errors.JGitInternalException;
22 import org.eclipse.jgit.junit.RepositoryTestCase;
23 import org.eclipse.jgit.lib.Constants;
24 import org.eclipse.jgit.lib.ObjectId;
25 import org.eclipse.jgit.lib.Repository;
26 import org.eclipse.jgit.revwalk.RevWalk;
27 import org.eclipse.jgit.treewalk.TreeWalk;
28 import org.junit.Test;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92 public class CommitOnlyTest extends RepositoryTestCase {
93 private static final String F1 = "f1.txt";
94
95 private static final String F2 = "f2.txt";
96
97 private static final String F3 = "f3.txt";
98
99 private static final String MSG = "commit";
100
101 private static int A = 0;
102
103 private static int B = 1;
104
105 private static int C = 2;
106
107 private static int D = 3;
108
109 private static int E = 4;
110
111 @Test
112 public void testOnlyOption_f1_1_a() throws Exception {
113 final Git git = new Git(db);
114 prepare_f3(git, A);
115 prepare_f1_1(git);
116 executeAndCheck_f1_1(git, A);
117 }
118
119 @Test
120 public void testOnlyOption_f1_1_b() throws Exception {
121 final Git git = new Git(db);
122 prepare_f3(git, B);
123 prepare_f1_1(git);
124 executeAndCheck_f1_1(git, B);
125 }
126
127 @Test
128 public void testOnlyOption_f1_1_c() throws Exception {
129 final Git git = new Git(db);
130 prepare_f3(git, C);
131 prepare_f1_1(git);
132 executeAndCheck_f1_1(git, C);
133 }
134
135 @Test
136 public void testOnlyOption_f1_1_d() throws Exception {
137 final Git git = new Git(db);
138 prepare_f3(git, D);
139 prepare_f1_1(git);
140 executeAndCheck_f1_1(git, D);
141 }
142
143 @Test
144 public void testOnlyOption_f1_1_e() throws Exception {
145 final Git git = new Git(db);
146 prepare_f3(git, E);
147 prepare_f1_1(git);
148 executeAndCheck_f1_1(git, E);
149 }
150
151 @Test
152 public void testOnlyOption_f1_1_f2_14_a() throws Exception {
153 final Git git = new Git(db);
154 prepare_f3_f2_14(git, A);
155 prepare_f1_1(git);
156 executeAndCheck_f1_1_f2_f14(git, A);
157 }
158
159 @Test
160 public void testOnlyOption_f1_1_f2_14_b() throws Exception {
161 final Git git = new Git(db);
162 prepare_f3_f2_14(git, B);
163 prepare_f1_1(git);
164 executeAndCheck_f1_1_f2_f14(git, B);
165 }
166
167 @Test
168 public void testOnlyOption_f1_1_f2_14_c() throws Exception {
169 final Git git = new Git(db);
170 prepare_f3_f2_14(git, C);
171 prepare_f1_1(git);
172 executeAndCheck_f1_1_f2_f14(git, C);
173 }
174
175 @Test
176 public void testOnlyOption_f1_1_f2_14_d() throws Exception {
177 final Git git = new Git(db);
178 prepare_f3_f2_14(git, D);
179 prepare_f1_1(git);
180 executeAndCheck_f1_1_f2_f14(git, D);
181 }
182
183 @Test
184 public void testOnlyOption_f1_1_f2_14_e() throws Exception {
185 final Git git = new Git(db);
186 prepare_f3_f2_14(git, E);
187 prepare_f1_1(git);
188 executeAndCheck_f1_1_f2_f14(git, E);
189 }
190
191 @Test
192 public void testOnlyOption_f1_2_a() throws Exception {
193 final Git git = new Git(db);
194 prepare_f3(git, A);
195 prepare_f1_2(git);
196 executeAndCheck_f1_2(git, A);
197 }
198
199 @Test
200 public void testOnlyOption_f1_2_b() throws Exception {
201 final Git git = new Git(db);
202 prepare_f3(git, B);
203 prepare_f1_2(git);
204 executeAndCheck_f1_2(git, B);
205 }
206
207 @Test
208 public void testOnlyOption_f1_2_c() throws Exception {
209 final Git git = new Git(db);
210 prepare_f3(git, C);
211 prepare_f1_2(git);
212 executeAndCheck_f1_2(git, C);
213 }
214
215 @Test
216 public void testOnlyOption_f1_2_d() throws Exception {
217 final Git git = new Git(db);
218 prepare_f3(git, D);
219 prepare_f1_2(git);
220 executeAndCheck_f1_2(git, D);
221 }
222
223 @Test
224 public void testOnlyOption_f1_2_e() throws Exception {
225 final Git git = new Git(db);
226 prepare_f3(git, E);
227 prepare_f1_2(git);
228 executeAndCheck_f1_2(git, E);
229 }
230
231 @Test
232 public void testOnlyOption_f1_2_f2_14_a() throws Exception {
233 final Git git = new Git(db);
234 prepare_f3_f2_14(git, A);
235 prepare_f1_2(git);
236 executeAndCheck_f1_2_f2_f14(git, A);
237 }
238
239 @Test
240 public void testOnlyOption_f1_2_f2_14_b() throws Exception {
241 final Git git = new Git(db);
242 prepare_f3_f2_14(git, B);
243 prepare_f1_2(git);
244 executeAndCheck_f1_2_f2_f14(git, B);
245 }
246
247 @Test
248 public void testOnlyOption_f1_2_f2_14_c() throws Exception {
249 final Git git = new Git(db);
250 prepare_f3_f2_14(git, C);
251 prepare_f1_2(git);
252 executeAndCheck_f1_2_f2_f14(git, C);
253 }
254
255 @Test
256 public void testOnlyOption_f1_2_f2_14_d() throws Exception {
257 final Git git = new Git(db);
258 prepare_f3_f2_14(git, D);
259 prepare_f1_2(git);
260 executeAndCheck_f1_2_f2_f14(git, D);
261 }
262
263 @Test
264 public void testOnlyOption_f1_2_f2_14_e() throws Exception {
265 final Git git = new Git(db);
266 prepare_f3_f2_14(git, E);
267 prepare_f1_2(git);
268 executeAndCheck_f1_2_f2_f14(git, E);
269 }
270
271 @Test
272 public void testOnlyOption_f1_3_a() throws Exception {
273 final Git git = new Git(db);
274 prepare_f3(git, A);
275 prepare_f1_3(git);
276 executeAndCheck_f1_3(git, A);
277 }
278
279 @Test
280 public void testOnlyOption_f1_3_b() throws Exception {
281 final Git git = new Git(db);
282 prepare_f3(git, B);
283 prepare_f1_3(git);
284 executeAndCheck_f1_3(git, B);
285 }
286
287 @Test
288 public void testOnlyOption_f1_3_c() throws Exception {
289 final Git git = new Git(db);
290 prepare_f3(git, C);
291 prepare_f1_3(git);
292 executeAndCheck_f1_3(git, C);
293 }
294
295 @Test
296 public void testOnlyOption_f1_3_d() throws Exception {
297 final Git git = new Git(db);
298 prepare_f3(git, D);
299 prepare_f1_3(git);
300 executeAndCheck_f1_3(git, D);
301 }
302
303 @Test
304 public void testOnlyOption_f1_3_e() throws Exception {
305 final Git git = new Git(db);
306 prepare_f3(git, E);
307 prepare_f1_3(git);
308 executeAndCheck_f1_3(git, E);
309 }
310
311 @Test
312 public void testOnlyOption_f1_4_a() throws Exception {
313 final Git git = new Git(db);
314 prepare_f3(git, A);
315 prepare_f1_4(git);
316 executeAndCheck_f1_4(git, A);
317 }
318
319 @Test
320 public void testOnlyOption_f1_4_b() throws Exception {
321 final Git git = new Git(db);
322 prepare_f3(git, B);
323 prepare_f1_4(git);
324 executeAndCheck_f1_4(git, B);
325 }
326
327 @Test
328 public void testOnlyOption_f1_4_c() throws Exception {
329 final Git git = new Git(db);
330 prepare_f3(git, C);
331 prepare_f1_4(git);
332 executeAndCheck_f1_4(git, C);
333 }
334
335 @Test
336 public void testOnlyOption_f1_4_d() throws Exception {
337 final Git git = new Git(db);
338 prepare_f3(git, D);
339 prepare_f1_4(git);
340 executeAndCheck_f1_4(git, D);
341 }
342
343 @Test
344 public void testOnlyOption_f1_4_e() throws Exception {
345 final Git git = new Git(db);
346 prepare_f3(git, E);
347 prepare_f1_4(git);
348 executeAndCheck_f1_4(git, E);
349 }
350
351 @Test
352 public void testOnlyOption_f1_5_a() throws Exception {
353 final Git git = new Git(db);
354 prepare_f3(git, A);
355 prepare_f1_5(git);
356 executeAndCheck_f1_5(git, A);
357 }
358
359 @Test
360 public void testOnlyOption_f1_5_b() throws Exception {
361 final Git git = new Git(db);
362 prepare_f3(git, B);
363 prepare_f1_5(git);
364 executeAndCheck_f1_5(git, B);
365 }
366
367 @Test
368 public void testOnlyOption_f1_5_c() throws Exception {
369 final Git git = new Git(db);
370 prepare_f3(git, C);
371 prepare_f1_5(git);
372 executeAndCheck_f1_5(git, C);
373 }
374
375 @Test
376 public void testOnlyOption_f1_5_d() throws Exception {
377 final Git git = new Git(db);
378 prepare_f3(git, D);
379 prepare_f1_5(git);
380 executeAndCheck_f1_5(git, D);
381 }
382
383 @Test
384 public void testOnlyOption_f1_5_e() throws Exception {
385 final Git git = new Git(db);
386 prepare_f3(git, E);
387 prepare_f1_5(git);
388 executeAndCheck_f1_5(git, E);
389 }
390
391 @Test
392 public void testOnlyOption_f1_6_a() throws Exception {
393 final Git git = new Git(db);
394 prepare_f3(git, A);
395 prepare_f1_6(git);
396 executeAndCheck_f1_6(git, A);
397 }
398
399 @Test
400 public void testOnlyOption_f1_6_b() throws Exception {
401 final Git git = new Git(db);
402 prepare_f3(git, B);
403 prepare_f1_6(git);
404 executeAndCheck_f1_6(git, B);
405 }
406
407 @Test
408 public void testOnlyOption_f1_6_c() throws Exception {
409 final Git git = new Git(db);
410 prepare_f3(git, C);
411 prepare_f1_6(git);
412 executeAndCheck_f1_6(git, C);
413 }
414
415 @Test
416 public void testOnlyOption_f1_6_d() throws Exception {
417 final Git git = new Git(db);
418 prepare_f3(git, D);
419 prepare_f1_6(git);
420 executeAndCheck_f1_6(git, D);
421 }
422
423 @Test
424 public void testOnlyOption_f1_6_e() throws Exception {
425 final Git git = new Git(db);
426 prepare_f3(git, E);
427 prepare_f1_6(git);
428 executeAndCheck_f1_6(git, E);
429 }
430
431 @Test
432 public void testOnlyOption_f1_6_f2_14_a() throws Exception {
433 final Git git = new Git(db);
434 prepare_f3_f2_14(git, A);
435 prepare_f1_6(git);
436 executeAndCheck_f1_6_f2_14(git, A);
437 }
438
439 @Test
440 public void testOnlyOption_f1_6_f2_14_b() throws Exception {
441 final Git git = new Git(db);
442 prepare_f3_f2_14(git, B);
443 prepare_f1_6(git);
444 executeAndCheck_f1_6_f2_14(git, B);
445 }
446
447 @Test
448 public void testOnlyOption_f1_6_f2_14_c() throws Exception {
449 final Git git = new Git(db);
450 prepare_f3_f2_14(git, C);
451 prepare_f1_6(git);
452 executeAndCheck_f1_6_f2_14(git, C);
453 }
454
455 @Test
456 public void testOnlyOption_f1_6_f2_14_d() throws Exception {
457 final Git git = new Git(db);
458 prepare_f3_f2_14(git, D);
459 prepare_f1_6(git);
460 executeAndCheck_f1_6_f2_14(git, D);
461 }
462
463 @Test
464 public void testOnlyOption_f1_6_f2_14_e() throws Exception {
465 final Git git = new Git(db);
466 prepare_f3_f2_14(git, E);
467 prepare_f1_6(git);
468 executeAndCheck_f1_6_f2_14(git, E);
469 }
470
471 @Test
472 public void testOnlyOption_f1_7_a() throws Exception {
473 final Git git = new Git(db);
474 prepare_f3(git, A);
475 prepare_f1_7(git);
476 executeAndCheck_f1_7(git, A);
477 }
478
479 @Test
480 public void testOnlyOption_f1_7_b() throws Exception {
481 final Git git = new Git(db);
482 prepare_f3(git, B);
483 prepare_f1_7(git);
484 executeAndCheck_f1_7(git, B);
485 }
486
487 @Test
488 public void testOnlyOption_f1_7_c() throws Exception {
489 final Git git = new Git(db);
490 prepare_f3(git, C);
491 prepare_f1_7(git);
492 executeAndCheck_f1_7(git, C);
493 }
494
495 @Test
496 public void testOnlyOption_f1_7_d() throws Exception {
497 final Git git = new Git(db);
498 prepare_f3(git, D);
499 prepare_f1_7(git);
500 executeAndCheck_f1_7(git, D);
501 }
502
503 @Test
504 public void testOnlyOption_f1_7_e() throws Exception {
505 final Git git = new Git(db);
506 prepare_f3(git, E);
507 prepare_f1_7(git);
508 executeAndCheck_f1_7(git, E);
509 }
510
511 @Test
512 public void testOnlyOption_f1_7_f2_14_a() throws Exception {
513 final Git git = new Git(db);
514 prepare_f3_f2_14(git, A);
515 prepare_f1_7(git);
516 executeAndCheck_f1_7_f2_14(git, A);
517 }
518
519 @Test
520 public void testOnlyOption_f1_7_f2_14_b() throws Exception {
521 final Git git = new Git(db);
522 prepare_f3_f2_14(git, B);
523 prepare_f1_7(git);
524 executeAndCheck_f1_7_f2_14(git, B);
525 }
526
527 @Test
528 public void testOnlyOption_f1_7_f2_14_c() throws Exception {
529 final Git git = new Git(db);
530 prepare_f3_f2_14(git, C);
531 prepare_f1_7(git);
532 executeAndCheck_f1_7_f2_14(git, C);
533 }
534
535 @Test
536 public void testOnlyOption_f1_7_f2_14_d() throws Exception {
537 final Git git = new Git(db);
538 prepare_f3_f2_14(git, D);
539 prepare_f1_7(git);
540 executeAndCheck_f1_7_f2_14(git, D);
541 }
542
543 @Test
544 public void testOnlyOption_f1_7_f2_14_e() throws Exception {
545 final Git git = new Git(db);
546 prepare_f3_f2_14(git, E);
547 prepare_f1_7(git);
548 executeAndCheck_f1_7_f2_14(git, E);
549 }
550
551 @Test
552 public void testOnlyOption_f1_8_a() throws Exception {
553 final Git git = new Git(db);
554 prepare_f3(git, A);
555 prepare_f1_8(git);
556 executeAndCheck_f1_8(git, A);
557 }
558
559 @Test
560 public void testOnlyOption_f1_8_b() throws Exception {
561 final Git git = new Git(db);
562 prepare_f3(git, B);
563 prepare_f1_8(git);
564 executeAndCheck_f1_8(git, B);
565 }
566
567 @Test
568 public void testOnlyOption_f1_8_c() throws Exception {
569 final Git git = new Git(db);
570 prepare_f3(git, C);
571 prepare_f1_8(git);
572 executeAndCheck_f1_8(git, C);
573 }
574
575 @Test
576 public void testOnlyOption_f1_8_d() throws Exception {
577 final Git git = new Git(db);
578 prepare_f3(git, D);
579 prepare_f1_8(git);
580 executeAndCheck_f1_8(git, D);
581 }
582
583 @Test
584 public void testOnlyOption_f1_8_e() throws Exception {
585 final Git git = new Git(db);
586 prepare_f3(git, E);
587 prepare_f1_8(git);
588 executeAndCheck_f1_8(git, E);
589 }
590
591 @Test
592 public void testOnlyOption_f1_9_a() throws Exception {
593 final Git git = new Git(db);
594 prepare_f3(git, A);
595 prepare_f1_9(git);
596 executeAndCheck_f1_9(git, A);
597 }
598
599 @Test
600 public void testOnlyOption_f1_9_b() throws Exception {
601 final Git git = new Git(db);
602 prepare_f3(git, B);
603 prepare_f1_9(git);
604 executeAndCheck_f1_9(git, B);
605 }
606
607 @Test
608 public void testOnlyOption_f1_9_c() throws Exception {
609 final Git git = new Git(db);
610 prepare_f3(git, C);
611 prepare_f1_9(git);
612 executeAndCheck_f1_9(git, C);
613 }
614
615 @Test
616 public void testOnlyOption_f1_9_d() throws Exception {
617 final Git git = new Git(db);
618 prepare_f3(git, D);
619 prepare_f1_9(git);
620 executeAndCheck_f1_9(git, D);
621 }
622
623 @Test
624 public void testOnlyOption_f1_9_e() throws Exception {
625 final Git git = new Git(db);
626 prepare_f3(git, E);
627 prepare_f1_9(git);
628 executeAndCheck_f1_9(git, E);
629 }
630
631 @Test
632 public void testOnlyOption_f1_10_a() throws Exception {
633 final Git git = new Git(db);
634 prepare_f3(git, A);
635 prepare_f1_10(git);
636 executeAndCheck_f1_10(git, A);
637 }
638
639 @Test
640 public void testOnlyOption_f1_10_b() throws Exception {
641 final Git git = new Git(db);
642 prepare_f3(git, B);
643 prepare_f1_10(git);
644 executeAndCheck_f1_10(git, B);
645 }
646
647 @Test
648 public void testOnlyOption_f1_10_c() throws Exception {
649 final Git git = new Git(db);
650 prepare_f3(git, C);
651 prepare_f1_10(git);
652 executeAndCheck_f1_10(git, C);
653 }
654
655 @Test
656 public void testOnlyOption_f1_10_d() throws Exception {
657 final Git git = new Git(db);
658 prepare_f3(git, D);
659 prepare_f1_10(git);
660 executeAndCheck_f1_10(git, D);
661 }
662
663 @Test
664 public void testOnlyOption_f1_10_e() throws Exception {
665 final Git git = new Git(db);
666 prepare_f3(git, E);
667 prepare_f1_10(git);
668 executeAndCheck_f1_10(git, E);
669 }
670
671 @Test
672 public void testOnlyOption_f1_11_a() throws Exception {
673 final Git git = new Git(db);
674 prepare_f3(git, A);
675 prepare_f1_11(git);
676 executeAndCheck_f1_11(git, A);
677 }
678
679 @Test
680 public void testOnlyOption_f1_11_b() throws Exception {
681 final Git git = new Git(db);
682 prepare_f3(git, B);
683 prepare_f1_11(git);
684 executeAndCheck_f1_11(git, B);
685 }
686
687 @Test
688 public void testOnlyOption_f1_11_c() throws Exception {
689 final Git git = new Git(db);
690 prepare_f3(git, C);
691 prepare_f1_11(git);
692 executeAndCheck_f1_11(git, C);
693 }
694
695 @Test
696 public void testOnlyOption_f1_11_d() throws Exception {
697 final Git git = new Git(db);
698 prepare_f3(git, D);
699 prepare_f1_11(git);
700 executeAndCheck_f1_11(git, D);
701 }
702
703 @Test
704 public void testOnlyOption_f1_11_e() throws Exception {
705 final Git git = new Git(db);
706 prepare_f3(git, E);
707 prepare_f1_11(git);
708 executeAndCheck_f1_11(git, E);
709 }
710
711 @Test
712 public void testOnlyOption_f1_12_a() throws Exception {
713 final Git git = new Git(db);
714 prepare_f3(git, A);
715 prepare_f1_12(git);
716 executeAndCheck_f1_12(git, A);
717 }
718
719 @Test
720 public void testOnlyOption_f1_12_b() throws Exception {
721 final Git git = new Git(db);
722 prepare_f3(git, B);
723 prepare_f1_12(git);
724 executeAndCheck_f1_12(git, B);
725 }
726
727 @Test
728 public void testOnlyOption_f1_12_c() throws Exception {
729 final Git git = new Git(db);
730 prepare_f3(git, C);
731 prepare_f1_12(git);
732 executeAndCheck_f1_12(git, C);
733 }
734
735 @Test
736 public void testOnlyOption_f1_12_d() throws Exception {
737 final Git git = new Git(db);
738 prepare_f3(git, D);
739 prepare_f1_12(git);
740 executeAndCheck_f1_12(git, D);
741 }
742
743 @Test
744 public void testOnlyOption_f1_12_e() throws Exception {
745 final Git git = new Git(db);
746 prepare_f3(git, E);
747 prepare_f1_12(git);
748 executeAndCheck_f1_12(git, E);
749 }
750
751 @Test
752 public void testOnlyOption_f1_12_f2_14_a() throws Exception {
753 final Git git = new Git(db);
754 prepare_f3_f2_14(git, A);
755 prepare_f1_12(git);
756 executeAndCheck_f1_12_f2_14(git, A);
757 }
758
759 @Test
760 public void testOnlyOption_f1_12_f2_14_b() throws Exception {
761 final Git git = new Git(db);
762 prepare_f3_f2_14(git, B);
763 prepare_f1_12(git);
764 executeAndCheck_f1_12_f2_14(git, B);
765 }
766
767 @Test
768 public void testOnlyOption_f1_12_f2_14_c() throws Exception {
769 final Git git = new Git(db);
770 prepare_f3_f2_14(git, C);
771 prepare_f1_12(git);
772 executeAndCheck_f1_12_f2_14(git, C);
773 }
774
775 @Test
776 public void testOnlyOption_f1_12_f2_14_d() throws Exception {
777 final Git git = new Git(db);
778 prepare_f3_f2_14(git, D);
779 prepare_f1_12(git);
780 executeAndCheck_f1_12_f2_14(git, D);
781 }
782
783 @Test
784 public void testOnlyOption_f1_12_f2_14_e() throws Exception {
785 final Git git = new Git(db);
786 prepare_f3_f2_14(git, E);
787 prepare_f1_12(git);
788 executeAndCheck_f1_12_f2_14(git, E);
789 }
790
791 @Test
792 public void testOnlyOption_f1_13_a() throws Exception {
793 final Git git = new Git(db);
794 prepare_f3(git, A);
795 prepare_f1_13(git);
796 executeAndCheck_f1_13(git, A);
797 }
798
799 @Test
800 public void testOnlyOption_f1_13_b() throws Exception {
801 final Git git = new Git(db);
802 prepare_f3(git, B);
803 prepare_f1_13(git);
804 executeAndCheck_f1_13(git, B);
805 }
806
807 @Test
808 public void testOnlyOption_f1_13_c() throws Exception {
809 final Git git = new Git(db);
810 prepare_f3(git, C);
811 prepare_f1_13(git);
812 executeAndCheck_f1_13(git, C);
813 }
814
815 @Test
816 public void testOnlyOption_f1_13_d() throws Exception {
817 final Git git = new Git(db);
818 prepare_f3(git, D);
819 prepare_f1_13(git);
820 executeAndCheck_f1_13(git, D);
821 }
822
823 @Test
824 public void testOnlyOption_f1_13_e() throws Exception {
825 final Git git = new Git(db);
826 prepare_f3(git, E);
827 prepare_f1_13(git);
828 executeAndCheck_f1_13(git, E);
829 }
830
831 @Test
832 public void testOnlyOption_f1_14_a() throws Exception {
833 final Git git = new Git(db);
834 prepare_f3(git, A);
835 prepare_f1_14(git);
836 executeAndCheck_f1_14(git, A);
837 }
838
839 @Test
840 public void testOnlyOption_f1_14_b() throws Exception {
841 final Git git = new Git(db);
842 prepare_f3(git, B);
843 prepare_f1_14(git);
844 executeAndCheck_f1_14(git, B);
845 }
846
847 @Test
848 public void testOnlyOption_f1_14_c() throws Exception {
849 final Git git = new Git(db);
850 prepare_f3(git, C);
851 prepare_f1_14(git);
852 executeAndCheck_f1_14(git, C);
853 }
854
855 @Test
856 public void testOnlyOption_f1_14_d() throws Exception {
857 final Git git = new Git(db);
858 prepare_f3(git, D);
859 prepare_f1_14(git);
860 executeAndCheck_f1_14(git, D);
861 }
862
863 @Test
864 public void testOnlyOption_f1_14_e() throws Exception {
865 final Git git = new Git(db);
866 prepare_f3(git, E);
867 prepare_f1_14(git);
868 executeAndCheck_f1_14(git, E);
869 }
870
871 @Test
872 public void testOnlyOptionWithDirectory() throws Exception {
873 final Git git = new Git(db);
874
875
876 final File f1 = writeTrashFile("d1/d2/f1.txt", "c1");
877 writeTrashFile("d1/d2/f2.txt", "c2");
878 final File f3 = writeTrashFile("d1/f3.txt", "c3");
879 writeTrashFile("d1/f4.txt", "c4");
880 final File f5 = writeTrashFile("d3/d4/f5.txt", "c5");
881 writeTrashFile("d3/d4/f6.txt", "c6");
882 final File f7 = writeTrashFile("d3/f7.txt", "c7");
883 writeTrashFile("d3/f8.txt", "c8");
884 final File f9 = writeTrashFile("d5/f9.txt", "c9");
885 writeTrashFile("d5/f10.txt", "c10");
886 final File f11 = writeTrashFile("d6/f11.txt", "c11");
887 writeTrashFile("d6/f12.txt", "c12");
888
889
890 git.add().addFilepattern(".").call();
891
892
893 write(f1, "c1'");
894 write(f3, "c3'");
895 write(f5, "c5'");
896 write(f7, "c7'");
897 write(f9, "c9'");
898 write(f11, "c11'");
899
900
901 git.commit().setOnly("d1").setOnly("d3/d4/").setOnly("d5")
902 .setOnly("d6/f11.txt").setMessage(MSG).call();
903
904 assertEquals("c1'", getHead(git, "d1/d2/f1.txt"));
905 assertEquals("c2", getHead(git, "d1/d2/f2.txt"));
906 assertEquals("c3'", getHead(git, "d1/f3.txt"));
907 assertEquals("c4", getHead(git, "d1/f4.txt"));
908 assertEquals("c5'", getHead(git, "d3/d4/f5.txt"));
909 assertEquals("c6", getHead(git, "d3/d4/f6.txt"));
910 assertEquals("", getHead(git, "d3/f7.txt"));
911 assertEquals("", getHead(git, "d3/f8.txt"));
912 assertEquals("c9'", getHead(git, "d5/f9.txt"));
913 assertEquals("c10", getHead(git, "d5/f10.txt"));
914 assertEquals("c11'", getHead(git, "d6/f11.txt"));
915 assertEquals("", getHead(git, "d6/f12.txt"));
916 assertEquals("[d1/d2/f1.txt, mode:100644, content:c1']"
917 + "[d1/d2/f2.txt, mode:100644, content:c2]"
918 + "[d1/f3.txt, mode:100644, content:c3']"
919 + "[d1/f4.txt, mode:100644, content:c4]"
920 + "[d3/d4/f5.txt, mode:100644, content:c5']"
921 + "[d3/d4/f6.txt, mode:100644, content:c6]"
922 + "[d3/f7.txt, mode:100644, content:c7]"
923 + "[d3/f8.txt, mode:100644, content:c8]"
924 + "[d5/f10.txt, mode:100644, content:c10]"
925 + "[d5/f9.txt, mode:100644, content:c9']"
926 + "[d6/f11.txt, mode:100644, content:c11']"
927 + "[d6/f12.txt, mode:100644, content:c12]", indexState(CONTENT));
928 }
929
930 @SuppressWarnings("unused")
931 private File prepare_f1_1(final Git git) throws IOException {
932 return writeTrashFile(F1, "c1");
933 }
934
935 private File prepare_f1_2(final Git git) throws Exception {
936 final File f1 = prepare_f1_4(git);
937 f1.delete();
938 return f1;
939 }
940
941 private File prepare_f1_3(final Git git) throws Exception {
942 final File f1 = prepare_f1_7(git);
943 git.rm().addFilepattern(F1).call();
944 return f1;
945 }
946
947 private File prepare_f1_4(final Git git) throws Exception {
948 final File f1 = prepare_f1_1(git);
949 git.add().addFilepattern(F1).call();
950 return f1;
951 }
952
953 private File prepare_f1_5(final Git git) throws Exception {
954 final File f1 = prepare_f1_7(git);
955 f1.delete();
956 return f1;
957 }
958
959 private File prepare_f1_6(final Git git) throws Exception {
960 final File f1 = prepare_f1_3(git);
961 write(f1, "c1");
962 return f1;
963 }
964
965 private File prepare_f1_7(final Git git) throws Exception {
966 final File f1 = prepare_f1_4(git);
967 git.commit().setOnly(F1).setMessage(MSG).call();
968 return f1;
969 }
970
971 private File prepare_f1_8(final Git git) throws Exception {
972 final File f1 = prepare_f1_4(git);
973 write(f1, "c1'");
974 return f1;
975 }
976
977 private File prepare_f1_9(final Git git) throws Exception {
978 final File f1 = prepare_f1_3(git);
979 write(f1, "c1'");
980 return f1;
981 }
982
983 private File prepare_f1_10(final Git git) throws Exception {
984 final File f1 = prepare_f1_9(git);
985 git.add().addFilepattern(F1).call();
986 f1.delete();
987 return f1;
988 }
989
990 private File prepare_f1_11(final Git git) throws Exception {
991 final File f1 = prepare_f1_7(git);
992 write(f1, "c1'");
993 return f1;
994 }
995
996 private File prepare_f1_12(final Git git) throws Exception {
997 final File f1 = prepare_f1_13(git);
998 write(f1, "c1");
999 return f1;
1000 }
1001
1002 private File prepare_f1_13(final Git git) throws Exception {
1003 final File f1 = prepare_f1_11(git);
1004 git.add().addFilepattern(F1).call();
1005 return f1;
1006 }
1007
1008 private File prepare_f1_14(final Git git) throws Exception {
1009 final File f1 = prepare_f1_13(git);
1010 write(f1, "c1''");
1011 return f1;
1012 }
1013
1014 private void executeAndCheck_f1_1(final Git git, final int state)
1015 throws Exception {
1016 JGitInternalException exception = null;
1017 try {
1018 git.commit().setOnly(F1).setMessage(MSG).call();
1019 } catch (JGitInternalException e) {
1020 exception = e;
1021 }
1022 assertNotNull(exception);
1023 assertTrue(exception.getMessage().contains(F1));
1024
1025 assertEquals(expected_f3_head(state), getHead(git, F3));
1026 assertEquals(expected_f3_idx(state), indexState(CONTENT));
1027 }
1028
1029 private void executeAndCheck_f1_1_f2_f14(final Git git, final int state)
1030 throws Exception {
1031 JGitInternalException exception = null;
1032 try {
1033 git.commit().setOnly(F1).setOnly(F2).setMessage(MSG).call();
1034 } catch (JGitInternalException e) {
1035 exception = e;
1036 }
1037 assertNotNull(exception);
1038 assertTrue(exception.getMessage().contains(F1));
1039
1040 assertEquals("c2", getHead(git, F2));
1041 assertEquals(expected_f3_head(state), getHead(git, F3));
1042 assertEquals("[f2.txt, mode:100644, content:c2']"
1043 + expected_f3_idx(state), indexState(CONTENT));
1044 }
1045
1046 private void executeAndCheck_f1_2(final Git git, final int state)
1047 throws Exception {
1048 JGitInternalException exception = null;
1049 try {
1050 git.commit().setOnly(F1).setMessage(MSG).call();
1051 } catch (JGitInternalException e) {
1052 exception = e;
1053 }
1054 assertNotNull(exception);
1055 assertTrue(exception.getMessage().contains("No changes"));
1056
1057 assertEquals(expected_f3_head(state), getHead(git, F3));
1058 assertEquals("[f1.txt, mode:100644, content:c1]"
1059 + expected_f3_idx(state), indexState(CONTENT));
1060 }
1061
1062 private void executeAndCheck_f1_2_f2_f14(final Git git, final int state)
1063 throws Exception {
1064 git.commit().setOnly(F1).setOnly(F2).setMessage(MSG).call();
1065
1066 assertEquals("", getHead(git, F1));
1067 assertEquals("c2''", getHead(git, F2));
1068 assertEquals(expected_f3_head(state), getHead(git, F3));
1069 assertEquals("[f2.txt, mode:100644, content:c2'']"
1070 + expected_f3_idx(state), indexState(CONTENT));
1071 }
1072
1073 private void executeAndCheck_f1_3(final Git git, final int state)
1074 throws Exception {
1075 git.commit().setOnly(F1).setMessage(MSG).call();
1076
1077 assertEquals("", getHead(git, F1));
1078 assertEquals(expected_f3_head(state), getHead(git, F3));
1079 assertEquals(expected_f3_idx(state), indexState(CONTENT));
1080 }
1081
1082 private void executeAndCheck_f1_4(final Git git, final int state)
1083 throws Exception {
1084 git.commit().setOnly(F1).setMessage(MSG).call();
1085
1086 assertEquals("c1", getHead(git, F1));
1087 assertEquals(expected_f3_head(state), getHead(git, F3));
1088 assertEquals("[f1.txt, mode:100644, content:c1]"
1089 + expected_f3_idx(state), indexState(CONTENT));
1090 }
1091
1092 private void executeAndCheck_f1_5(final Git git, final int state)
1093 throws Exception {
1094 executeAndCheck_f1_3(git, state);
1095 }
1096
1097 private void executeAndCheck_f1_6(final Git git, final int state)
1098 throws Exception {
1099 JGitInternalException exception = null;
1100 try {
1101 git.commit().setOnly(F1).setMessage(MSG).call();
1102 } catch (JGitInternalException e) {
1103 exception = e;
1104 }
1105 assertNotNull(exception);
1106 assertTrue(exception.getMessage().contains("No changes"));
1107
1108 assertEquals(expected_f3_head(state), getHead(git, F3));
1109 assertEquals(expected_f3_idx(state), indexState(CONTENT));
1110 }
1111
1112 private void executeAndCheck_f1_6_f2_14(final Git git, final int state)
1113 throws Exception {
1114 git.commit().setOnly(F1).setOnly(F2).setMessage(MSG).call();
1115
1116 assertEquals("c1", getHead(git, F1));
1117 assertEquals("c2''", getHead(git, F2));
1118 assertEquals(expected_f3_head(state), getHead(git, F3));
1119 assertEquals("[f1.txt, mode:100644, content:c1]"
1120 + "[f2.txt, mode:100644, content:c2'']"
1121 + expected_f3_idx(state), indexState(CONTENT));
1122 }
1123
1124 private void executeAndCheck_f1_7(final Git git, final int state)
1125 throws Exception {
1126 executeAndCheck_f1_2(git, state);
1127 }
1128
1129 private void executeAndCheck_f1_7_f2_14(final Git git, final int state)
1130 throws Exception {
1131 executeAndCheck_f1_6_f2_14(git, state);
1132 }
1133
1134 private void executeAndCheck_f1_8(final Git git, final int state)
1135 throws Exception {
1136 git.commit().setOnly(F1).setMessage(MSG).call();
1137
1138 assertEquals("c1'", getHead(git, F1));
1139 assertEquals(expected_f3_head(state), getHead(git, F3));
1140 assertEquals("[f1.txt, mode:100644, content:c1']"
1141 + expected_f3_idx(state), indexState(CONTENT));
1142 }
1143
1144 private void executeAndCheck_f1_9(final Git git, final int state)
1145 throws Exception {
1146 executeAndCheck_f1_8(git, state);
1147 }
1148
1149 private void executeAndCheck_f1_10(final Git git, final int state)
1150 throws Exception {
1151 executeAndCheck_f1_3(git, state);
1152 }
1153
1154 private void executeAndCheck_f1_11(final Git git, final int state)
1155 throws Exception {
1156 executeAndCheck_f1_8(git, state);
1157 }
1158
1159 private void executeAndCheck_f1_12(final Git git, final int state)
1160 throws Exception {
1161 JGitInternalException exception = null;
1162 try {
1163 git.commit().setOnly(F1).setMessage(MSG).call();
1164 } catch (JGitInternalException e) {
1165 exception = e;
1166 }
1167 assertNotNull(exception);
1168 assertTrue(exception.getMessage().contains("No changes"));
1169
1170 assertEquals(expected_f3_head(state), getHead(git, F3));
1171 assertEquals("[f1.txt, mode:100644, content:c1']"
1172 + expected_f3_idx(state), indexState(CONTENT));
1173 }
1174
1175 private void executeAndCheck_f1_12_f2_14(final Git git, final int state)
1176 throws Exception {
1177 executeAndCheck_f1_6_f2_14(git, state);
1178 }
1179
1180 private void executeAndCheck_f1_13(final Git git, final int state)
1181 throws Exception {
1182 executeAndCheck_f1_8(git, state);
1183 }
1184
1185 private void executeAndCheck_f1_14(final Git git, final int state)
1186 throws Exception {
1187 git.commit().setOnly(F1).setMessage(MSG).call();
1188
1189 assertEquals("c1''", getHead(git, F1));
1190 assertEquals(expected_f3_head(state), getHead(git, F3));
1191 assertEquals("[f1.txt, mode:100644, content:c1'']"
1192 + expected_f3_idx(state), indexState(CONTENT));
1193 }
1194
1195 private void prepare_f3(final Git git, final int state) throws Exception {
1196 prepare_f3_f2_14(git, state, false);
1197 }
1198
1199 private void prepare_f3_f2_14(final Git git, final int state)
1200 throws Exception {
1201 prepare_f3_f2_14(git, state, true);
1202 }
1203
1204 private void prepare_f3_f2_14(final Git git, final int state,
1205 final boolean include_f2) throws Exception {
1206 File f2 = null;
1207 if (include_f2) {
1208 f2 = writeTrashFile(F2, "c2");
1209 git.add().addFilepattern(F2).call();
1210 git.commit().setMessage(MSG).call();
1211 }
1212
1213 if (state >= 1) {
1214 writeTrashFile(F3, "c3");
1215 git.add().addFilepattern(F3).call();
1216 }
1217 if (state >= 2)
1218 git.commit().setMessage(MSG).call();
1219 if (state >= 3)
1220 git.rm().addFilepattern(F3).call();
1221 if (state == 4) {
1222 writeTrashFile(F3, "c3'");
1223 git.add().addFilepattern(F3).call();
1224 }
1225
1226 if (include_f2) {
1227 write(f2, "c2'");
1228 git.add().addFilepattern(F2).call();
1229 write(f2, "c2''");
1230 }
1231 }
1232
1233 private static String expected_f3_head(final int state) {
1234 switch (state) {
1235 case 0:
1236 case 1:
1237 return "";
1238 case 2:
1239 case 3:
1240 case 4:
1241 return "c3";
1242 }
1243 return null;
1244 }
1245
1246 private static String expected_f3_idx(final int state) {
1247 switch (state) {
1248 case 0:
1249 case 3:
1250 return "";
1251 case 1:
1252 case 2:
1253 return "[f3.txt, mode:100644, content:c3]";
1254 case 4:
1255 return "[f3.txt, mode:100644, content:c3']";
1256 }
1257 return null;
1258 }
1259
1260 static private String getHead(Git git, String path)
1261 throws Exception {
1262 try {
1263 final Repository repo = git.getRepository();
1264 final ObjectId headId = repo.resolve(Constants.HEAD + "^{commit}");
1265 if (headId == null) {
1266 return "";
1267 }
1268 try (RevWalk rw = new RevWalk(repo)) {
1269 final TreeWalk tw = TreeWalk.forPath(repo, path,
1270 rw.parseTree(headId));
1271 if (tw == null) {
1272 return "";
1273 }
1274 return new String(tw.getObjectReader().open(tw.getObjectId(0))
1275 .getBytes(), UTF_8);
1276 }
1277 } catch (Exception e) {
1278 return "";
1279 }
1280 }
1281 }