1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897
|
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
index 3f0bc04..8cdc066 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
@@ -43,8 +43,6 @@
*/
package org.eclipse.jgit.api;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -248,8 +246,8 @@ public void testCheckoutOfDirectoryShouldBeRecursive() throws Exception {
write(b, "modified");
git.checkout().addPath("dir").call();
- assertThat(read(a), is("A"));
- assertThat(read(b), is("B"));
+ assertEquals(read(a), "A");
+ assertEquals(read(b), "B");
}
@Test
@@ -263,8 +261,8 @@ public void testCheckoutAllPaths() throws Exception {
write(b, "modified");
git.checkout().setAllPaths(true).call();
- assertThat(read(a), is("A"));
- assertThat(read(b), is("B"));
+ assertEquals(read(a), "A");
+ assertEquals(read(b), "B");
}
@Test
@@ -279,7 +277,7 @@ public void testCheckoutWithStartPoint() throws Exception {
git.checkout().setCreateBranch(true).setName("a")
.setStartPoint(first.getId().getName()).call();
- assertThat(read(a), is("A"));
+ assertEquals(read(a), "A");
}
@Test
@@ -296,8 +294,8 @@ public void testCheckoutWithStartPointOnlyCertainFiles() throws Exception {
git.checkout().setCreateBranch(true).setName("a")
.setStartPoint(first.getId().getName()).addPath("a.txt").call();
- assertThat(read(a), is("A"));
- assertThat(read(b), is("other"));
+ assertEquals(read(a), "A");
+ assertEquals(read(b), "other");
}
@Test
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java
deleted file mode 100644
index fb9cc2c..0000000
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java
+++ /dev/null
@@ -1,405 +0,0 @@
-/*
- * Copyright (C) 2011, Robin Rosenberg <robin.rosenberg@dewire.com>
- * and other copyright owners as documented in the project's IP log.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v1.0 which accompanies this
- * distribution, is reproduced below, and is available at
- * http://www.eclipse.org/org/documents/edl-v10.php
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of the Eclipse Foundation, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-package org.eclipse.jgit.lib;
-
-import static org.hamcrest.Matchers.startsWith;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.api.errors.GitAPIException;
-import org.eclipse.jgit.dircache.InvalidPathException;
-import org.eclipse.jgit.junit.MockSystemReader;
-import org.eclipse.jgit.revwalk.RevWalk;
-import org.eclipse.jgit.util.SystemReader;
-import org.junit.Test;
-
-public class DirCacheCheckoutMaliciousPathTest extends RepositoryTestCase {
- protected ObjectId theHead;
- protected ObjectId theMerge;
-
- @Test
- public void testMaliciousAbsolutePathIsOk() throws Exception {
- testMaliciousPathGoodFirstCheckout("ok");
- }
-
- @Test
- public void testMaliciousAbsolutePathIsOkSecondCheckout() throws Exception {
- testMaliciousPathGoodSecondCheckout("ok");
- }
-
- @Test
- public void testMaliciousAbsolutePathIsOkTwoLevels() throws Exception {
- testMaliciousPathGoodSecondCheckout("a", "ok");
- }
-
- @Test
- public void testMaliciousAbsolutePath() throws Exception {
- testMaliciousPathBadFirstCheckout("/tmp/x");
- }
-
- @Test
- public void testMaliciousAbsolutePathSecondCheckout() throws Exception {
- testMaliciousPathBadSecondCheckout("/tmp/x");
- }
-
- @Test
- public void testMaliciousAbsolutePathTwoLevelsFirstBad() throws Exception {
- testMaliciousPathBadFirstCheckout("/tmp/x", "y");
- }
-
- @Test
- public void testMaliciousAbsolutePathTwoLevelsSecondBad() throws Exception {
- testMaliciousPathBadFirstCheckout("y", "/tmp/x");
- }
-
- @Test
- public void testMaliciousAbsoluteCurDrivePathWindows() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows();
- testMaliciousPathBadFirstCheckout("\\somepath");
- }
-
- @Test
- public void testMaliciousAbsoluteCurDrivePathWindowsOnUnix()
- throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setUnix();
- testMaliciousPathGoodFirstCheckout("\\somepath");
- }
-
- @Test
- public void testMaliciousAbsoluteUNCPathWindows1() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows();
- testMaliciousPathBadFirstCheckout("\\\\somepath");
- }
-
- @Test
- public void testMaliciousAbsoluteUNCPathWindows1OnUnix() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setUnix();
- testMaliciousPathGoodFirstCheckout("\\\\somepath");
- }
-
- @Test
- public void testMaliciousAbsoluteUNCPathWindows2() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows();
- testMaliciousPathBadFirstCheckout("\\/somepath");
- }
-
- @Test
- public void testMaliciousAbsoluteUNCPathWindows2OnUnix() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setUnix();
- testMaliciousPathBadFirstCheckout("\\/somepath");
- }
-
- @Test
- public void testMaliciousAbsoluteWindowsPath1() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows();
- testMaliciousPathBadFirstCheckout("c:\\temp\\x");
- }
-
- @Test
- public void testMaliciousAbsoluteWindowsPath1OnUnix() throws Exception {
- if (File.separatorChar == '\\')
- return; // cannot emulate Unix on Windows for this test
- ((MockSystemReader) SystemReader.getInstance()).setUnix();
- testMaliciousPathGoodFirstCheckout("c:\\temp\\x");
- }
-
- @Test
- public void testMaliciousAbsoluteWindowsPath2() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setCurrentPlatform();
- testMaliciousPathBadFirstCheckout("c:/temp/x");
- }
-
- @Test
- public void testMaliciousGitPath1() throws Exception {
- testMaliciousPathBadFirstCheckout(".git/konfig");
- }
-
- @Test
- public void testMaliciousGitPath2() throws Exception {
- testMaliciousPathBadFirstCheckout(".git", "konfig");
- }
-
- @Test
- public void testMaliciousGitPath1Case() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows(); // or OS X
- testMaliciousPathBadFirstCheckout(".Git/konfig");
- }
-
- @Test
- public void testMaliciousGitPath2Case() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows(); // or OS X
- testMaliciousPathBadFirstCheckout(".gIt", "konfig");
- }
-
- @Test
- public void testMaliciousGitPath3Case() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows(); // or OS X
- testMaliciousPathBadFirstCheckout(".giT", "konfig");
- }
-
- @Test
- public void testMaliciousGitPathEndSpaceWindows() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows();
- testMaliciousPathBadFirstCheckout(".git ", "konfig");
- }
-
- @Test
- public void testMaliciousGitPathEndSpaceUnixOk() throws Exception {
- if (File.separatorChar == '\\')
- return; // cannot emulate Unix on Windows for this test
- ((MockSystemReader) SystemReader.getInstance()).setUnix();
- testMaliciousPathGoodFirstCheckout(".git ", "konfig");
- }
-
- @Test
- public void testMaliciousGitPathEndDotWindows1() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows();
- testMaliciousPathBadFirstCheckout(".git.", "konfig");
- }
-
- @Test
- public void testMaliciousGitPathEndDotWindows2() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows();
- testMaliciousPathBadFirstCheckout(".f.");
- }
-
- @Test
- public void testMaliciousGitPathEndDotWindows3() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows();
- testMaliciousPathGoodFirstCheckout(".f");
- }
-
- @Test
- public void testMaliciousGitPathEndDotUnixOk() throws Exception {
- if (File.separatorChar == '\\')
- return; // cannot emulate Unix on Windows for this test
- ((MockSystemReader) SystemReader.getInstance()).setUnix();
- testMaliciousPathGoodFirstCheckout(".git.", "konfig");
- }
-
- @Test
- public void testMaliciousPathDotDot() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setCurrentPlatform();
- testMaliciousPathBadFirstCheckout("..", "no");
- }
-
- @Test
- public void testMaliciousPathDot() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setCurrentPlatform();
- testMaliciousPathBadFirstCheckout(".", "no");
- }
-
- @Test
- public void testMaliciousPathEmpty() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setCurrentPlatform();
- testMaliciousPathBadFirstCheckout("", "no");
- }
-
- @Test
- public void testMaliciousWindowsADS() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows();
- testMaliciousPathBadFirstCheckout("some:path");
- }
-
- @Test
- public void testMaliciousWindowsADSOnUnix() throws Exception {
- if (File.separatorChar == '\\')
- return; // cannot emulate Unix on Windows for this test
- ((MockSystemReader) SystemReader.getInstance()).setUnix();
- testMaliciousPathGoodFirstCheckout("some:path");
- }
-
- @Test
- public void testForbiddenNamesOnWindowsEgCon() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows();
- testMaliciousPathBadFirstCheckout("con");
- }
-
- @Test
- public void testForbiddenNamesOnWindowsEgConDotSuffix() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows();
- testMaliciousPathBadFirstCheckout("con.txt");
- }
-
- @Test
- public void testForbiddenNamesOnWindowsEgLpt1() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows();
- testMaliciousPathBadFirstCheckout("lpt1");
- }
-
- @Test
- public void testForbiddenNamesOnWindowsEgLpt1DotSuffix() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows();
- testMaliciousPathBadFirstCheckout("lpt1.txt");
- }
-
- @Test
- public void testForbiddenNamesOnWindowsEgDotCon() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows();
- testMaliciousPathGoodFirstCheckout(".con");
- }
-
- @Test
- public void testForbiddenNamesOnWindowsEgLpr() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows();
- testMaliciousPathGoodFirstCheckout("lpt"); // good name
- }
-
- @Test
- public void testForbiddenNamesOnWindowsEgCon1() throws Exception {
- ((MockSystemReader) SystemReader.getInstance()).setWindows();
- testMaliciousPathGoodFirstCheckout("con1"); // good name
- }
-
- @Test
- public void testForbiddenWindowsNamesOnUnixEgCon() throws Exception {
- if (File.separatorChar == '\\')
- return; // cannot emulate Unix on Windows for this test
- testMaliciousPathGoodFirstCheckout("con");
- }
-
- @Test
- public void testForbiddenWindowsNamesOnUnixEgLpt1() throws Exception {
- if (File.separatorChar == '\\')
- return; // cannot emulate Unix on Windows for this test
- testMaliciousPathGoodFirstCheckout("lpt1");
- }
-
- private void testMaliciousPathBadFirstCheckout(String... paths)
- throws Exception {
- testMaliciousPath(false, false, paths);
- }
-
- private void testMaliciousPathBadSecondCheckout(String... paths) throws Exception {
- testMaliciousPath(false, true, paths);
- }
-
- private void testMaliciousPathGoodFirstCheckout(String... paths)
- throws Exception {
- testMaliciousPath(true, false, paths);
- }
-
- private void testMaliciousPathGoodSecondCheckout(String... paths) throws Exception {
- testMaliciousPath(true, true, paths);
- }
-
- /**
- * Create a bad tree and tries to check it out
- *
- * @param good
- * true if we expect this to pass
- * @param secondCheckout
- * perform the actual test on the second checkout
- * @param path
- * to the blob, one or more levels
- * @throws GitAPIException
- * @throws IOException
- */
- private void testMaliciousPath(boolean good, boolean secondCheckout,
- String... path) throws GitAPIException, IOException {
- Git git = new Git(db);
- ObjectInserter newObjectInserter;
- newObjectInserter = git.getRepository().newObjectInserter();
- ObjectId blobId = newObjectInserter.insert(Constants.OBJ_BLOB,
- "data".getBytes());
- newObjectInserter = git.getRepository().newObjectInserter();
- FileMode mode = FileMode.REGULAR_FILE;
- ObjectId insertId = blobId;
- for (int i = path.length - 1; i >= 0; --i) {
- TreeFormatter treeFormatter = new TreeFormatter();
- treeFormatter.append("goodpath", mode, insertId);
- insertId = newObjectInserter.insert(treeFormatter);
- mode = FileMode.TREE;
- }
- newObjectInserter = git.getRepository().newObjectInserter();
- CommitBuilder commitBuilder = new CommitBuilder();
- commitBuilder.setAuthor(author);
- commitBuilder.setCommitter(committer);
- commitBuilder.setMessage("foo#1");
- commitBuilder.setTreeId(insertId);
- ObjectId firstCommitId = newObjectInserter.insert(commitBuilder);
-
- newObjectInserter = git.getRepository().newObjectInserter();
- mode = FileMode.REGULAR_FILE;
- insertId = blobId;
- for (int i = path.length - 1; i >= 0; --i) {
- TreeFormatter treeFormatter = new TreeFormatter();
- treeFormatter.append(path[i], mode, insertId);
- insertId = newObjectInserter.insert(treeFormatter);
- mode = FileMode.TREE;
- }
-
- // Create another commit
- commitBuilder = new CommitBuilder();
- commitBuilder.setAuthor(author);
- commitBuilder.setCommitter(committer);
- commitBuilder.setMessage("foo#2");
- commitBuilder.setTreeId(insertId);
- commitBuilder.setParentId(firstCommitId);
- ObjectId commitId = newObjectInserter.insert(commitBuilder);
-
- RevWalk revWalk = new RevWalk(git.getRepository());
- if (!secondCheckout)
- git.checkout().setStartPoint(revWalk.parseCommit(firstCommitId))
- .setName("refs/heads/master").setCreateBranch(true).call();
- try {
- if (secondCheckout) {
- git.checkout().setStartPoint(revWalk.parseCommit(commitId))
- .setName("refs/heads/master").setCreateBranch(true)
- .call();
- } else {
- git.branchCreate().setName("refs/heads/next")
- .setStartPoint(commitId.name()).call();
- git.checkout().setName("refs/heads/next")
- .call();
- }
- if (!good)
- fail("Checkout of Tree " + Arrays.asList(path) + " should fail");
- } catch (InvalidPathException e) {
- if (good)
- throw e;
- assertThat(e.getMessage(), startsWith("Invalid path: "));
- }
- }
-
-}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/RootLocaleTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/RootLocaleTest.java
deleted file mode 100644
index 4e694b6..0000000
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/RootLocaleTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com>
- * and other copyright owners as documented in the project's IP log.
- *
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Distribution License v1.0 which
- * accompanies this distribution, is reproduced below, and is
- * available at http://www.eclipse.org/org/documents/edl-v10.php
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- *
- * - Neither the name of the Eclipse Foundation, Inc. nor the
- * names of its contributors may be used to endorse or promote
- * products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.eclipse.jgit.nls;
-
-import org.eclipse.jgit.awtui.UIText;
-import org.eclipse.jgit.console.ConsoleText;
-import org.eclipse.jgit.internal.JGitText;
-import org.eclipse.jgit.iplog.IpLogText;
-import org.eclipse.jgit.pgm.CLIText;
-import org.junit.Before;
-import org.junit.Test;
-
-public class RootLocaleTest {
- @Before
- public void setUp() {
- NLS.setLocale(NLS.ROOT_LOCALE);
- }
-
- @Test
- public void testJGitText() {
- NLS.getBundleFor(JGitText.class);
- }
-
- @Test
- public void testConsoleText() {
- NLS.getBundleFor(ConsoleText.class);
- }
-
- @Test
- public void testCLIText() {
- NLS.getBundleFor(CLIText.class);
- }
-
- @Test
- public void testUIText() {
- NLS.getBundleFor(UIText.class);
- }
-
- @Test
- public void testIpLogText() {
- NLS.getBundleFor(IpLogText.class);
- }
-}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java
index 484039e..fb36482 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java
@@ -60,110 +60,95 @@
*/
public class MergeResult {
- /**
- * The status the merge resulted in.
- */
- public enum MergeStatus {
- /** */
- FAST_FORWARD {
- @Override
+ public static abstract class MergeStatus {
+ public static MergeStatus FAST_FORWARD = new FAST_FORWARD_Class ();
+ public static MergeStatus FAST_FORWARD_SQUASHED = new FAST_FORWARD_SQUASHED_Class ();
+ public static MergeStatus ALREADY_UP_TO_DATE = new ALREADY_UP_TO_DATE_Class ();
+ public static MergeStatus FAILED = new FAILED_Class ();
+ public static MergeStatus MERGED = new MERGED_Class ();
+ public static MergeStatus MERGED_SQUASHED = new MERGED_SQUASHED_Class ();
+ public static MergeStatus CONFLICTING = new CONFLICTING_Class ();
+ public static MergeStatus NOT_SUPPORTED = new NOT_SUPPORTED_Class ();
+
+ static class FAST_FORWARD_Class extends MergeStatus {
public String toString() {
return "Fast-forward";
}
- @Override
public boolean isSuccessful() {
return true;
}
- },
- /**
- * @since 2.0
- */
- FAST_FORWARD_SQUASHED {
- @Override
- public String toString() {
+ }
+
+ static class FAST_FORWARD_SQUASHED_Class extends MergeStatus {
+ public String toString () {
return "Fast-forward-squashed";
}
- @Override
- public boolean isSuccessful() {
+ public boolean isSuccessful () {
return true;
}
- },
- /** */
- ALREADY_UP_TO_DATE {
- @Override
+ }
+
+ static class ALREADY_UP_TO_DATE_Class extends MergeStatus {
public String toString() {
return "Already-up-to-date";
}
- @Override
public boolean isSuccessful() {
return true;
}
- },
- /** */
- FAILED {
- @Override
+ }
+
+ static class FAILED_Class extends MergeStatus {
public String toString() {
return "Failed";
}
- @Override
public boolean isSuccessful() {
return false;
}
- },
- /** */
- MERGED {
- @Override
+ }
+
+ static class MERGED_Class extends MergeStatus {
public String toString() {
return "Merged";
}
- @Override
public boolean isSuccessful() {
return true;
}
- },
- /**
- * @since 2.0
- */
- MERGED_SQUASHED {
- @Override
+ }
+
+ static class MERGED_SQUASHED_Class extends MergeStatus {
public String toString() {
return "Merged-squashed";
}
- @Override
public boolean isSuccessful() {
return true;
}
- },
- /** */
- CONFLICTING {
- @Override
+ }
+
+ static class CONFLICTING_Class extends MergeStatus {
public String toString() {
return "Conflicting";
}
- @Override
public boolean isSuccessful() {
return false;
}
- },
- /** */
- NOT_SUPPORTED {
- @Override
+ }
+
+ static class NOT_SUPPORTED_Class extends MergeStatus {
public String toString() {
return "Not-yet-supported";
}
- @Override
public boolean isSuccessful() {
return false;
}
- };
+ }
/**
* @return whether the status indicates a successful result
@@ -363,7 +348,10 @@ public void addConflict(String path, org.eclipse.jgit.merge.MergeResult<?> lowLe
}
}
int currentConflict = -1;
- int[][] ret=new int[nrOfConflicts][mergedCommits.length+1];
+ int[][] ret = new int[nrOfConflicts][];
+ for (int n = 0; n < nrOfConflicts; n++)
+ ret[n] = new int[mergedCommits.length + 1];
+
for (MergeChunk mergeChunk : lowLevelResult) {
// to store the end of this chunk (end of the last conflicting range)
int endOfChunk = 0;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
index 6f87349..5c3a9f6 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
@@ -85,6 +85,7 @@
import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;
+import org.eclipse.jgit.lib.RepositoryState;
import org.eclipse.jgit.lib.RefUpdate.Result;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -719,33 +720,30 @@ private RevCommit tryFastForward(String headName, RevCommit oldCommit,
}
private void checkParameters() throws WrongRepositoryStateException {
+ RepositoryState s = repo.getRepositoryState();
if (this.operation != Operation.BEGIN) {
// these operations are only possible while in a rebasing state
- switch (repo.getRepositoryState()) {
- case REBASING_INTERACTIVE:
- case REBASING:
- case REBASING_REBASING:
- case REBASING_MERGE:
- break;
- default:
+ if (s != RepositoryState.REBASING_INTERACTIVE &&
+ s != RepositoryState.REBASING &&
+ s != RepositoryState.REBASING_REBASING &&
+ s != RepositoryState.REBASING_MERGE)
throw new WrongRepositoryStateException(MessageFormat.format(
JGitText.get().wrongRepositoryState, repo
.getRepositoryState().name()));
- }
- } else
- switch (repo.getRepositoryState()) {
- case SAFE:
+ } else {
+ if (s == RepositoryState.SAFE) {
if (this.upstreamCommit == null)
throw new JGitInternalException(MessageFormat
.format(JGitText.get().missingRequiredParameter,
"upstream"));
return;
- default:
+ } else {
throw new WrongRepositoryStateException(MessageFormat.format(
JGitText.get().wrongRepositoryState, repo
.getRepositoryState().name()));
}
+ }
}
private void createFile(File parentDir, String name, String content)
@@ -988,10 +986,10 @@ public RebaseCommand setProgressMonitor(ProgressMonitor monitor) {
return this;
}
- static enum Action {
- PICK("pick"); // later add SQUASH, EDIT, etc.
+ static class Action {
+ public static Action PICK = new Action ("pick"); // later add SQUASH, EDIT, etc.
- private final String token;
+ public final String token;
private Action(String token) {
this.token = token;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseResult.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseResult.java
index a09f8c2..d05fa4e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseResult.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseResult.java
@@ -52,80 +52,58 @@
* The result of a {@link RebaseCommand} execution
*/
public class RebaseResult {
- /**
- * The overall status
- */
- public enum Status {
- /**
- * Rebase was successful, HEAD points to the new commit
- */
- OK {
- @Override
+
+ public static abstract class Status {
+ public static Status OK = new OK_Class ();
+ public static Status ABORTED = new ABORTED_Class ();
+ public static Status STOPPED = new STOPPED_Class ();
+ public static Status FAILED = new FAILED_Class ();
+ public static Status UP_TO_DATE = new UP_TO_DATE_Class ();
+ public static Status FAST_FORWARD = new FAST_FORWARD_Class ();
+ public static Status NOTHING_TO_COMMIT = new NOTHING_TO_COMMIT_Class ();
+
+ static class OK_Class extends Status {
public boolean isSuccessful() {
return true;
}
- },
- /**
- * Aborted; the original HEAD was restored
- */
- ABORTED {
- @Override
+ }
+
+ static class ABORTED_Class extends Status {
public boolean isSuccessful() {
return false;
}
- },
- /**
- * Stopped due to a conflict; must either abort or resolve or skip
- */
- STOPPED {
- @Override
+ }
+
+ static class STOPPED_Class extends Status {
public boolean isSuccessful() {
return false;
}
- },
- /**
- * Failed; the original HEAD was restored
- */
- FAILED {
- @Override
+ }
+
+ static class FAILED_Class extends Status {
public boolean isSuccessful() {
return false;
}
- },
- /**
- * Already up-to-date
- */
- UP_TO_DATE {
- @Override
+ }
+
+ static class UP_TO_DATE_Class extends Status {
public boolean isSuccessful() {
return true;
}
- },
- /**
- * Fast-forward, HEAD points to the new commit
- */
- FAST_FORWARD {
- @Override
+ }
+
+ static class FAST_FORWARD_Class extends Status {
public boolean isSuccessful() {
return true;
}
- },
-
- /**
- * Continue with nothing left to commit (possibly want skip).
- *
- * @since 2.0
- */
- NOTHING_TO_COMMIT {
- @Override
+ }
+
+ static class NOTHING_TO_COMMIT_Class extends Status {
public boolean isSuccessful() {
return false;
}
- };
+ }
- /**
- * @return whether the status indicates a successful result
- */
public abstract boolean isSuccessful();
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffEntry.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffEntry.java
index 5084e9d..5c43d86 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffEntry.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffEntry.java
@@ -80,7 +80,7 @@
RENAME,
/** Copy an existing file to a new location, keeping the original */
- COPY;
+ COPY
}
/** Specify the old or new side for more generalized access. */
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java
index f0c7cda..ac0812d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java
@@ -76,7 +76,7 @@
REPLACE,
/** Sequence A and B have zero length, describing nothing. */
- EMPTY;
+ EMPTY
}
int beginA;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/BaseDirCacheEditor.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/BaseDirCacheEditor.java
index 70f80ae..a6806c3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/BaseDirCacheEditor.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/BaseDirCacheEditor.java
@@ -52,7 +52,7 @@
* The different update strategies extend this class to provide their own unique
* services to applications.
*/
-abstract class BaseDirCacheEditor {
+public abstract class BaseDirCacheEditor {
/** The cache instance this editor updates during {@link #finish()}. */
protected DirCache cache;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdOwnerMap.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdOwnerMap.java
index c9b483f..4b871d5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdOwnerMap.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdOwnerMap.java
@@ -227,15 +227,15 @@ public boolean isEmpty() {
private int tblIdx;
- private V next;
+ private V nextv;
public boolean hasNext() {
return found < size;
}
public V next() {
- if (next != null)
- return found(next);
+ if (nextv != null)
+ return foundv(nextv);
for (;;) {
V[] table = directory[dirIdx];
@@ -249,15 +249,15 @@ public V next() {
while (tblIdx < table.length) {
V v = table[tblIdx++];
if (v != null)
- return found(v);
+ return foundv(v);
}
}
}
@SuppressWarnings("unchecked")
- private V found(V v) {
+ private V foundv(V v) {
found++;
- next = (V) v.next;
+ nextv = (V) v.next;
return v;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Ref.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Ref.java
index f119c44..d961602 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Ref.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Ref.java
@@ -57,20 +57,20 @@
*/
public interface Ref {
/** Location where a {@link Ref} is stored. */
- public static enum Storage {
+ public static class Storage {
/**
* The ref does not exist yet, updating it may create it.
* <p>
* Creation is likely to choose {@link #LOOSE} storage.
*/
- NEW(true, false),
+ public static Storage NEW = new Storage(true, false);
/**
* The ref is stored in a file by itself.
* <p>
* Updating this ref affects only this ref.
*/
- LOOSE(true, false),
+ public static Storage LOOSE = new Storage(true, false);
/**
* The ref is stored in the <code>packed-refs</code> file, with others.
@@ -78,7 +78,7 @@
* Updating this ref requires rewriting the file, with perhaps many
* other refs being included at the same time.
*/
- PACKED(false, true),
+ public static Storage PACKED = new Storage(false, true);
/**
* The ref is both {@link #LOOSE} and {@link #PACKED}.
@@ -86,7 +86,7 @@
* Updating this ref requires only updating the loose file, but deletion
* requires updating both the loose file and the packed refs file.
*/
- LOOSE_PACKED(true, true),
+ public static Storage LOOSE_PACKED = new Storage(true, true);
/**
* The ref came from a network advertisement and storage is unknown.
@@ -95,7 +95,7 @@
* side, as Git-aware code consolidate the remote refs and reported them
* to this process.
*/
- NETWORK(false, false);
+ public static Storage NETWORK = new Storage(false, false);
private final boolean loose;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
index 911b1f6..5727433 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
@@ -775,7 +775,6 @@ private RevCommit resolveReflog(RevWalk rw, Ref ref, String time)
throw new RevisionSyntaxException(MessageFormat.format(
JGitText.get().invalidReflogRevision, time));
}
- assert number >= 0;
ReflogReader reader = new ReflogReader(this, ref.getName());
ReflogEntry entry = reader.getReverseEntry(number);
if (entry == null)
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryState.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryState.java
index 7e3ba51..4a7034d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryState.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryState.java
@@ -54,246 +54,202 @@
* The granularity and set of states are somewhat arbitrary. The methods
* on the state are the only supported means of deciding what to do.
*/
-public enum RepositoryState {
+public abstract class RepositoryState {
/** Has no work tree and cannot be used for normal editing. */
- BARE {
- @Override
- public boolean canCheckout() { return false; }
+ public static RepositoryState BARE = new BARE_Class ();
- @Override
+ static class BARE_Class extends RepositoryState {
+ public boolean canCheckout() { return false; }
public boolean canResetHead() { return false; }
-
- @Override
public boolean canCommit() { return false; }
-
- @Override
public boolean canAmend() { return false; }
-
- @Override
public String getDescription() { return "Bare"; }
- },
+ public String name() {
+ return "BARE";
+ }
+ }
/**
* A safe state for working normally
* */
- SAFE {
- @Override
- public boolean canCheckout() { return true; }
+ public static RepositoryState SAFE = new SAFE_Class ();
- @Override
+ static class SAFE_Class extends RepositoryState {
+ public boolean canCheckout() { return true; }
public boolean canResetHead() { return true; }
-
- @Override
public boolean canCommit() { return true; }
-
- @Override
public boolean canAmend() { return true; }
-
- @Override
public String getDescription() { return JGitText.get().repositoryState_normal; }
- },
+ public String name() {
+ return "SAFE";
+ }
+ }
/** An unfinished merge. Must resolve or reset before continuing normally
*/
- MERGING {
- @Override
- public boolean canCheckout() { return false; }
+ public static RepositoryState MERGING = new MERGING_Class ();
- @Override
+ static class MERGING_Class extends RepositoryState {
+ public boolean canCheckout() { return false; }
public boolean canResetHead() { return true; }
-
- @Override
public boolean canCommit() { return false; }
-
- @Override
public boolean canAmend() { return false; }
-
- @Override
public String getDescription() { return JGitText.get().repositoryState_conflicts; }
- },
+ public String name() {
+ return "MERGING";
+ }
+ }
/**
* An merge where all conflicts have been resolved. The index does not
* contain any unmerged paths.
*/
- MERGING_RESOLVED {
- @Override
- public boolean canCheckout() { return true; }
+ public static RepositoryState MERGING_RESOLVED = new MERGING_RESOLVED_Class ();
- @Override
+ static class MERGING_RESOLVED_Class extends RepositoryState {
+ public boolean canCheckout() { return true; }
public boolean canResetHead() { return true; }
-
- @Override
public boolean canCommit() { return true; }
-
- @Override
public boolean canAmend() { return false; }
-
- @Override
public String getDescription() { return JGitText.get().repositoryState_merged; }
- },
+ public String name() {
+ return "MERGING_RESOLVED";
+ }
+ }
/** An unfinished cherry-pick. Must resolve or reset before continuing normally
*/
- CHERRY_PICKING {
- @Override
+ public static RepositoryState CHERRY_PICKING = new CHERRY_PICKING_Class ();
+
+ static class CHERRY_PICKING_Class extends RepositoryState {
public boolean canCheckout() { return false; }
-
- @Override
public boolean canResetHead() { return true; }
-
- @Override
public boolean canCommit() { return false; }
-
- @Override
public boolean canAmend() { return false; }
-
- @Override
public String getDescription() { return JGitText.get().repositoryState_conflicts; }
- },
+ public String name() {
+ return "CHERRY_PICKING";
+ }
+ }
/**
* A cherry-pick where all conflicts have been resolved. The index does not
* contain any unmerged paths.
*/
- CHERRY_PICKING_RESOLVED {
- @Override
+ public static RepositoryState CHERRY_PICKING_RESOLVED = new CHERRY_PICKING_RESOLVED_Class ();
+
+ static class CHERRY_PICKING_RESOLVED_Class extends RepositoryState {
public boolean canCheckout() { return true; }
-
- @Override
public boolean canResetHead() { return true; }
-
- @Override
public boolean canCommit() { return true; }
-
- @Override
public boolean canAmend() { return false; }
-
- @Override
public String getDescription() { return JGitText.get().repositoryState_merged; }
- },
+ public String name() {
+ return "CHERRY_PICKING_RESOLVED";
+ }
+ }
/**
* An unfinished rebase or am. Must resolve, skip or abort before normal work can take place
*/
- REBASING {
- @Override
- public boolean canCheckout() { return false; }
+ public static RepositoryState REBASING = new REBASING_Class ();
- @Override
+ static class REBASING_Class extends RepositoryState {
+ public boolean canCheckout() { return false; }
public boolean canResetHead() { return false; }
-
- @Override
public boolean canCommit() { return true; }
-
- @Override
public boolean canAmend() { return true; }
-
- @Override
public String getDescription() { return JGitText.get().repositoryState_rebaseOrApplyMailbox; }
- },
+ public String name() {
+ return "REBASING";
+ }
+ }
/**
* An unfinished rebase. Must resolve, skip or abort before normal work can take place
*/
- REBASING_REBASING {
- @Override
- public boolean canCheckout() { return false; }
+ public static RepositoryState REBASING_REBASING = new REBASING_REBASING_Class ();
- @Override
+ static class REBASING_REBASING_Class extends RepositoryState {
+ public boolean canCheckout() { return false; }
public boolean canResetHead() { return false; }
-
- @Override
public boolean canCommit() { return true; }
-
- @Override
public boolean canAmend() { return true; }
-
- @Override
public String getDescription() { return JGitText.get().repositoryState_rebase; }
- },
+ public String name() {
+ return "REBASING_REBASING";
+ }
+ }
/**
* An unfinished apply. Must resolve, skip or abort before normal work can take place
*/
- APPLY {
- @Override
- public boolean canCheckout() { return false; }
+ public static RepositoryState APPLY = new APPLY_Class ();
- @Override
+ static class APPLY_Class extends RepositoryState {
+ public boolean canCheckout() { return false; }
public boolean canResetHead() { return false; }
-
- @Override
public boolean canCommit() { return true; }
-
- @Override
public boolean canAmend() { return true; }
-
- @Override
public String getDescription() { return JGitText.get().repositoryState_applyMailbox; }
- },
+ public String name() {
+ return "APPLY";
+ }
+ }
/**
* An unfinished rebase with merge. Must resolve, skip or abort before normal work can take place
*/
- REBASING_MERGE {
- @Override
- public boolean canCheckout() { return false; }
+ public static RepositoryState REBASING_MERGE = new REBASING_MERGE_Class ();
- @Override
+ static class REBASING_MERGE_Class extends RepositoryState {
+ public boolean canCheckout() { return false; }
public boolean canResetHead() { return false; }
-
- @Override
public boolean canCommit() { return true; }
-
- @Override
public boolean canAmend() { return true; }
-
- @Override
public String getDescription() { return JGitText.get().repositoryState_rebaseWithMerge; }
- },
+ public String name() {
+ return "REBASING_MERGE";
+ }
+ }
/**
* An unfinished interactive rebase. Must resolve, skip or abort before normal work can take place
*/
- REBASING_INTERACTIVE {
- @Override
- public boolean canCheckout() { return false; }
+ public static RepositoryState REBASING_INTERACTIVE = new REBASING_INTERACTIVE_Class ();
- @Override
+ static class REBASING_INTERACTIVE_Class extends RepositoryState {
+ public boolean canCheckout() { return false; }
public boolean canResetHead() { return false; }
-
- @Override
public boolean canCommit() { return true; }
-
- @Override
public boolean canAmend() { return true; }
-
- @Override
public String getDescription() { return JGitText.get().repositoryState_rebaseInteractive; }
- },
+ public String name() {
+ return "REBASING_INTERACTIVE";
+ }
+ }
/**
* Bisecting being done. Normal work may continue but is discouraged
*/
- BISECTING {
+ public static RepositoryState BISECTING = new BISECTING_Class ();
+
+ static class BISECTING_Class extends RepositoryState {
/* Changing head is a normal operation when bisecting */
- @Override
public boolean canCheckout() { return true; }
/* Do not reset, checkout instead */
- @Override
public boolean canResetHead() { return false; }
/* Commit during bisect is useful */
- @Override
public boolean canCommit() { return true; }
- @Override
public boolean canAmend() { return false; }
- @Override
public String getDescription() { return JGitText.get().repositoryState_bisecting; }
+ public String name() {
+ return "BISECTING";
+ }
};
/**
@@ -320,4 +276,6 @@
* @return a human readable description of the state.
*/
public abstract String getDescription();
+
+ public abstract String name();
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ThreadSafeProgressMonitor.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ThreadSafeProgressMonitor.java
index 9e8e256..b774b1b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ThreadSafeProgressMonitor.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ThreadSafeProgressMonitor.java
@@ -127,7 +127,7 @@ public void endWorker() {
* ThreadSafeProgressMonior.
*/
public void pollForUpdates() {
- assert isMainThread();
+ //assert isMainThread();
doUpdates();
}
@@ -142,7 +142,7 @@ public void pollForUpdates() {
* completion of workers.
*/
public void waitForCompletion() throws InterruptedException {
- assert isMainThread();
+ //assert isMainThread();
while (0 < workers.get()) {
doUpdates();
process.acquire();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
index 1782bb2..7ca4267 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
@@ -104,7 +104,7 @@
private NameConflictTreeWalk tw;
- private String commitNames[];
+ private String[] commitNames;
private static final int T_BASE = 0;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/patch/BinaryHunk.java b/org.eclipse.jgit/src/org/eclipse/jgit/patch/BinaryHunk.java
index 340b674..3dd89c1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/patch/BinaryHunk.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/patch/BinaryHunk.java
@@ -61,7 +61,7 @@
LITERAL_DEFLATED,
/** A Git pack-style delta is stored, deflated. */
- DELTA_DEFLATED;
+ DELTA_DEFLATED
}
private final FileHeader file;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/AbstractRevQueue.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/AbstractRevQueue.java
index 843c2af..b533a3b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/AbstractRevQueue.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/AbstractRevQueue.java
@@ -43,7 +43,7 @@
package org.eclipse.jgit.revwalk;
-abstract class AbstractRevQueue extends Generator {
+public abstract class AbstractRevQueue extends Generator {
static final AbstractRevQueue EMPTY_QUEUE = new AlwaysEmptyQueue();
/** Current output flags set for this generator instance. */
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BlockRevQueue.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BlockRevQueue.java
index 30d140a..8dd8d72 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BlockRevQueue.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BlockRevQueue.java
@@ -48,7 +48,7 @@
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
-abstract class BlockRevQueue extends AbstractRevQueue {
+public abstract class BlockRevQueue extends AbstractRevQueue {
protected BlockFreeList free;
/** Create an empty revision queue. */
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/Generator.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/Generator.java
index a95303b..c67652f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/Generator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/Generator.java
@@ -59,7 +59,7 @@
* @see PendingGenerator
* @see StartGenerator
*/
-abstract class Generator {
+public abstract class Generator {
/** Commits are sorted by commit date and time, descending. */
static final int SORT_COMMIT_TIME_DESC = 1 << 0;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileObjectDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileObjectDatabase.java
index f28facb..f8283f2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileObjectDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileObjectDatabase.java
@@ -60,7 +60,7 @@
import org.eclipse.jgit.storage.pack.PackWriter;
import org.eclipse.jgit.util.FS;
-abstract class FileObjectDatabase extends ObjectDatabase {
+public abstract class FileObjectDatabase extends ObjectDatabase {
static enum InsertLooseObjectResult {
INSERTED, EXISTS_PACKED, EXISTS_LOOSE, FAILURE;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackReverseIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackReverseIndex.java
index 990106b..20aafab 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackReverseIndex.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackReverseIndex.java
@@ -68,18 +68,18 @@
/**
* (offset31, truly) Offsets accommodating in 31 bits.
*/
- private final int offsets32[];
+ private final int[] offsets32;
/**
* Offsets not accommodating in 31 bits.
*/
- private final long offsets64[];
+ private final long[] offsets64;
/** Position of the corresponding {@link #offsets32} in {@link #index}. */
- private final int nth32[];
+ private final int[] nth32;
/** Position of the corresponding {@link #offsets64} in {@link #index}. */
- private final int nth64[];
+ private final int[] nth64;
/**
* Create reverse index from straight/forward pack index, by indexing all
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java
index 99ec75c..1ff8bca 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java
@@ -189,7 +189,7 @@ public void remove() {
}
@SuppressWarnings("unchecked")
- private final BlockList<ObjectToPack> objectsLists[] = new BlockList[Constants.OBJ_TAG + 1];
+ private final BlockList<ObjectToPack>[] objectsLists = new BlockList[Constants.OBJ_TAG + 1];
{
objectsLists[Constants.OBJ_COMMIT] = new BlockList<ObjectToPack>();
objectsLists[Constants.OBJ_TREE] = new BlockList<ObjectToPack>();
@@ -229,7 +229,7 @@ public void remove() {
private List<ObjectToPack> sortedByName;
- private byte packcsum[];
+ private byte[] packcsum;
private boolean deltaBaseAsOffset;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java
index c7cee1e..d16e1c0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java
@@ -76,7 +76,7 @@
* @see BasePackFetchConnection
* @see BasePackPushConnection
*/
-abstract class BasePackConnection extends BaseConnection {
+public abstract class BasePackConnection extends BaseConnection {
/** The repository this transport fetches into, or pushes out of. */
protected final Repository local;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java
index 582b75a..f02608a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java
@@ -180,8 +180,12 @@
*/
public static final String OPTION_NO_DONE = "no-done";
- static enum MultiAck {
- OFF, CONTINUE, DETAILED;
+ static class MultiAck {
+ public static final int OFF = 0;
+
+ public static final int CONTINUE = 1;
+
+ public static final int DETAILED = 2;
}
private final RevWalk walk;
@@ -201,7 +205,7 @@
/** Marks a commit listed in the advertised refs. */
final RevFlag ADVERTISED;
- private MultiAck multiAck = MultiAck.OFF;
+ private int multiAck = MultiAck.OFF;
private boolean thinPack;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java
index 4c7ffec..493d059 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java
@@ -87,7 +87,7 @@
UPDATE_NONFASTFORWARD,
/** Delete an existing ref; the ref should already exist. */
- DELETE;
+ DELETE
}
/** Result of the update command. */
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteConfig.java
index f75ac70..90ddadc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteConfig.java
@@ -127,6 +127,8 @@
private String name;
+ private String oldName;
+
private List<URIish> uris;
private List<URIish> pushURIs;
@@ -163,6 +165,7 @@
public RemoteConfig(final Config rc, final String remoteName)
throws URISyntaxException {
name = remoteName;
+ oldName = remoteName;
String[] vlst;
String val;
@@ -240,6 +243,11 @@ public void update(final Config rc) {
set(rc, KEY_TAGOPT, getTagOpt().option(), TagOpt.AUTO_FOLLOW.option());
set(rc, KEY_MIRROR, mirror, DEFAULT_MIRROR);
set(rc, KEY_TIMEOUT, timeout, 0);
+
+ if (!oldName.equals(name)) {
+ rc.unsetSection(SECTION, oldName);
+ oldName = name;
+ }
}
private void set(final Config rc, final String key,
@@ -309,6 +317,16 @@ public String getName() {
}
/**
+ * Set the local name this remote configuration is recognized as.
+ *
+ * @param newName
+ * the new name of this remote.
+ */
+ public void setName(String newName) {
+ name = newName;
+ }
+
+ /**
* Get all configured URIs under this remote.
*
* @return the set of URIs known to this remote.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TagOpt.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TagOpt.java
index 3b25870..9b7b7ac 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TagOpt.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TagOpt.java
@@ -49,7 +49,7 @@
import org.eclipse.jgit.internal.JGitText;
/** Specification of annotated tag behavior during fetch. */
-public enum TagOpt {
+public class TagOpt {
/**
* Automatically follow tags if we fetch the thing they point at.
* <p>
@@ -59,7 +59,7 @@
* prove that we already have (or will have when the fetch completes) the
* object the annotated tag peels (dereferences) to.
*/
- AUTO_FOLLOW(""),
+ public static TagOpt AUTO_FOLLOW = new TagOpt ("");
/**
* Never fetch tags, even if we have the thing it points at.
@@ -69,7 +69,7 @@
* publishes annotated tags, but you are not interested in the tags and only
* want their branches.
*/
- NO_TAGS("--no-tags"),
+ public static TagOpt NO_TAGS = new TagOpt("--no-tags");
/**
* Always fetch tags, even if we do not have the thing it points at.
@@ -78,7 +78,7 @@
* hundreds of megabytes of objects to be fetched if the receiving
* repository does not yet have the necessary dependencies.
*/
- FETCH_TAGS("--tags");
+ public static TagOpt FETCH_TAGS = new TagOpt("--tags");
private final String option;
@@ -111,4 +111,8 @@ public static TagOpt fromOption(final String o) {
}
throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidTagOption, o));
}
+
+ private static TagOpt[] values() {
+ return new TagOpt[] { AUTO_FOLLOW, NO_TAGS, FETCH_TAGS };
+ }
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
index c2cda54..95069a3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
@@ -252,7 +252,7 @@ public String getLine() {
private RequestPolicy requestPolicy = RequestPolicy.ADVERTISED;
- private MultiAck multiAck = MultiAck.OFF;
+ private int multiAck = MultiAck.OFF;
private boolean noDone;
@@ -875,14 +875,14 @@ private ObjectId processHaveLines(List<ObjectId> peerHas, ObjectId last)
// If both sides have the same object; let the client know.
//
switch (multiAck) {
- case OFF:
+ case MultiAck.OFF:
if (commonBase.size() == 1)
pckOut.writeString("ACK " + obj.name() + "\n");
break;
- case CONTINUE:
+ case MultiAck.CONTINUE:
pckOut.writeString("ACK " + obj.name() + " continue\n");
break;
- case DETAILED:
+ case MultiAck.DETAILED:
pckOut.writeString("ACK " + obj.name() + " common\n");
break;
}
@@ -924,12 +924,12 @@ private ObjectId processHaveLines(List<ObjectId> peerHas, ObjectId last)
didOkToGiveUp = true;
if (okToGiveUp()) {
switch (multiAck) {
- case OFF:
+ case MultiAck.OFF:
break;
- case CONTINUE:
+ case MultiAck.CONTINUE:
pckOut.writeString("ACK " + id.name() + " continue\n");
break;
- case DETAILED:
+ case MultiAck.DETAILED:
pckOut.writeString("ACK " + id.name() + " ready\n");
sentReady = true;
break;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java
index 315d909..98cedfa 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java
@@ -146,7 +146,7 @@ public AbstractTreeIterator createSubtreeIterator(final ObjectReader reader)
/**
* Wrapper for a standard Java IO file
*/
- static public class FileEntry extends Entry {
+ static class FileEntry extends Entry {
final File file;
private final FileMode mode;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
index 9ee5f8b..648d597 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
@@ -135,6 +135,12 @@
private int contentIdOffset;
/**
+ * Cached value of isEntryIgnored(). 0 if not ignored, 1 if ignored, -1 if
+ * the value is not yet cached.
+ */
+ private int ignoreStatus = -1;
+
+ /**
* Create a new iterator with no parent.
*
* @param options
@@ -569,6 +575,8 @@ public boolean isEntryIgnored() throws IOException {
* a relevant ignore rule file exists but cannot be read.
*/
protected boolean isEntryIgnored(final int pLen) throws IOException {
+ if (ignoreStatus != -1)
+ return ignoreStatus == 1;
IgnoreNode rules = getIgnoreNode();
if (rules != null) {
// The ignore code wants path to start with a '/' if possible.
@@ -581,15 +589,20 @@ protected boolean isEntryIgnored(final int pLen) throws IOException {
String p = TreeWalk.pathOf(path, pOff, pLen);
switch (rules.isIgnored(p, FileMode.TREE.equals(mode))) {
case IGNORED:
+ ignoreStatus = 1;
return true;
case NOT_IGNORED:
+ ignoreStatus = 0;
return false;
case CHECK_PARENT:
break;
}
}
- if (parent instanceof WorkingTreeIterator)
- return ((WorkingTreeIterator) parent).isEntryIgnored(pLen);
+ if (parent instanceof WorkingTreeIterator) {
+ ignoreStatus = ((WorkingTreeIterator) parent).isEntryIgnored(pLen) ? 1 : 0;
+ return ignoreStatus == 1;
+ }
+ ignoreStatus = 0;
return false;
}
@@ -757,8 +770,10 @@ public MetadataDiff compareMetadata(DirCacheEntry entry) {
// only. Otherwise we compare the timestamp at millisecond precision.
long cacheLastModified = entry.getLastModified();
long fileLastModified = getEntryLastModified();
- if (cacheLastModified % 1000 == 0)
+ if (cacheLastModified % 1000 == 0 || fileLastModified % 1000 == 0) {
+ cacheLastModified = cacheLastModified - cacheLastModified % 1000;
fileLastModified = fileLastModified - fileLastModified % 1000;
+ }
if (fileLastModified != cacheLastModified)
return MetadataDiff.DIFFER_BY_TIMESTAMP;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/TreeFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/TreeFilter.java
index acc1ae6..686d65a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/TreeFilter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/TreeFilter.java
@@ -129,17 +129,15 @@ public String toString() {
public static final TreeFilter ANY_DIFF = new AnyDiffFilter();
private static final class AnyDiffFilter extends TreeFilter {
- private static final int baseTree = 0;
-
@Override
public boolean include(final TreeWalk walker) {
final int n = walker.getTreeCount();
if (n == 1) // Assume they meant difference to empty tree.
return true;
- final int m = walker.getRawMode(baseTree);
+ final int m = walker.getRawMode(0);
for (int i = 1; i < n; i++)
- if (walker.getRawMode(i) != m || !walker.idEqual(i, baseTree))
+ if (walker.getRawMode(i) != m || !walker.idEqual(i, 0))
return true;
return false;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/GitDateParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/GitDateParser.java
index f1743d4..b76ecc6 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/GitDateParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/GitDateParser.java
@@ -97,17 +97,30 @@ private static SimpleDateFormat getDateFormat(ParseableSimpleDateFormat f) {
// like "yesterday" or "1 week ago") which this parser can parse but which
// are not listed here because they are parsed without the help of a
// SimpleDateFormat.
- enum ParseableSimpleDateFormat {
- ISO("yyyy-MM-dd HH:mm:ss Z"), //
- RFC("EEE, dd MMM yyyy HH:mm:ss Z"), //
- SHORT("yyyy-MM-dd"), //
- SHORT_WITH_DOTS_REVERSE("dd.MM.yyyy"), //
- SHORT_WITH_DOTS("yyyy.MM.dd"), //
- SHORT_WITH_SLASH("MM/dd/yyyy"), //
- DEFAULT("EEE MMM dd HH:mm:ss yyyy Z"), //
- LOCAL("EEE MMM dd HH:mm:ss yyyy");
-
- String formatStr;
+ public static class ParseableSimpleDateFormat {
+ public static ParseableSimpleDateFormat ISO = new ParseableSimpleDateFormat ("yyyy-MM-dd HH:mm:ss Z"); //
+ public static ParseableSimpleDateFormat RFC = new ParseableSimpleDateFormat ("EEE, dd MMM yyyy HH:mm:ss Z"); //
+ public static ParseableSimpleDateFormat SHORT = new ParseableSimpleDateFormat ("yyyy-MM-dd"); //
+ public static ParseableSimpleDateFormat SHORT_WITH_DOTS_REVERSE = new ParseableSimpleDateFormat("dd.MM.yyyy"); //
+ public static ParseableSimpleDateFormat SHORT_WITH_DOTS = new ParseableSimpleDateFormat("yyyy.MM.dd"); //
+ public static ParseableSimpleDateFormat SHORT_WITH_SLASH = new ParseableSimpleDateFormat("MM/dd/yyyy"); //
+ public static ParseableSimpleDateFormat DEFAULT = new ParseableSimpleDateFormat ("EEE MMM dd HH:mm:ss yyyy Z"); //
+ public static ParseableSimpleDateFormat LOCAL = new ParseableSimpleDateFormat("EEE MMM dd HH:mm:ss yyyy");
+ public static ParseableSimpleDateFormat[] values ()
+ {
+ return new ParseableSimpleDateFormat[] {
+ ISO,
+ RFC,
+ SHORT,
+ SHORT_WITH_DOTS_REVERSE,
+ SHORT_WITH_DOTS,
+ SHORT_WITH_SLASH,
+ DEFAULT,
+ LOCAL
+ };
+ }
+
+ public String formatStr;
private ParseableSimpleDateFormat(String formatStr) {
this.formatStr = formatStr;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
index e9d9953..196e0e7 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
@@ -112,7 +112,6 @@ public String getHostname() {
// we do nothing
hostname = "localhost";
}
- assert hostname != null;
}
return hostname;
}
|