aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache
Commit message (Collapse)AuthorAgeFilesLines
* DirCacheBuilderTest#testBuildRejectsUnsetFileMode: Add missing fail()David Pursehouse2018-09-291-0/+1
| | | | | | | | | | | Error Prone reports: Not calling fail() when expecting an exception masks bugs See https://errorprone.info/bugpattern/MissingFail Change-Id: Ic89f9daef3c31bfbfd1f3c003cb90a373cd74847 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Deprecate Constants.CHARSET in favor of StandardCharsets.UTF_8David Pursehouse2018-09-041-3/+3
| | | | | Change-Id: I3b748620f067582afef20f144feebe40d0332be2 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Remove further unnecessary 'final' keywordsHan-Wen Nienhuys2018-05-183-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove it from * package private functions. * try blocks * for loops this was done with the following python script: $ cat f.py import sys import re import os def replaceFinal(m): return m.group(1) + "(" + m.group(2).replace('final ', '') + ")" methodDecl = re.compile(r"^([\t ]*[a-zA-Z_ ]+)\(([^)]*)\)") def subst(fn): input = open(fn) os.rename(fn, fn + "~") dest = open(fn, 'w') for l in input: l = methodDecl.sub(replaceFinal, l) dest.write(l) dest.close() for root, dirs, files in os.walk(".", topdown=False): for f in files: if not f.endswith('.java'): continue full = os.path.join(root, f) print full subst(full) Change-Id: If533a75a417594fc893e7c669d2c1f0f6caeb7ca Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
* Remove 'final' in parameter listsHan-Wen Nienhuys2018-05-153-4/+4
| | | | | Change-Id: Id924f79c8b2c720297ebc49bf9c5d4ddd6d52547 Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
* Consistently use Constants.CHARSET rather than StandardCharsets.UTF_8David Pursehouse2018-03-111-3/+3
| | | | | Change-Id: I6714fc3666e1bced22abba94ceb700477349586e Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Use StandardCharsets.UTF_8 in testsDavid Pursehouse2018-03-071-2/+3
| | | | | | | Replace hard-coded "UTF-8" string with the constant. Change-Id: Ie812add2df28e984090563ec7c6e2c0366616424 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* DirCacheCGitCompatabilityTest: Open BufferedReader in try-with-resourceDavid Pursehouse2018-03-051-10/+4
| | | | | Change-Id: I0494eb475954927743174941a7d6c06d8431f57f Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Enable and fix warnings about redundant specification of type argumentsDavid Pursehouse2017-02-202-4/+4
| | | | | | | | | | Since the introduction of generic type parameter inference in Java 7, it's not necessary to explicitly specify the type of generic parameters. Enable the warning in Eclipse, and fix all occurrences. Change-Id: I9158caf1beca5e4980b6240ac401f3868520aad0 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Enable and fix 'Should be tagged with @Override' warningDavid Pursehouse2017-02-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | Set missingOverrideAnnotation=warning in Eclipse compiler preferences which enables the warning: The method <method> of type <type> should be tagged with @Override since it actually overrides a superclass method Justification for this warning is described in: http://stackoverflow.com/a/94411/381622 Enabling this causes in excess of 1000 warnings across the entire code-base. They are very easy to fix automatically with Eclipse's "Quick Fix" tool. Fix all of them except 2 which cause compilation failure when the project is built with mvn; add TODO comments on those for further investigation. Change-Id: I5772061041fd361fe93137fd8b0ad356e748a29c Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* DirCacheBasicTest: Open ObjectInserter.Formatter in try-with-resourceDavid Pursehouse2016-02-151-3/+5
| | | | | Change-Id: Ie4b3e5ad9616bc56b6d8d2476d1e6c6319c1a0aa Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
* DirCacheBuilderIteratorTest: Open TreeWalk in try-with-resourceDavid Pursehouse2016-02-151-15/+16
| | | | | Change-Id: I94836315918924cba9a2b5be6b9ae417cb2ad215 Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
* DirCacheCGitCompatabilityTest: Open TreeWalk in try-with-resourceDavid Pursehouse2016-02-151-11/+12
| | | | | Change-Id: I81a8bd2aba7eb0a6efaea5d6f7720aa725052157 Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
* DirCacheIteratorTest: Open TreeWalk instances in try-with-resourceDavid Pursehouse2016-02-151-87/+94
| | | | | Change-Id: If23597acaebf2295b85411bf87bc0292d5dc789e Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
* Merge branch 'stable-4.2'David Pursehouse2016-01-201-0/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.2: CheckoutCommandTest: Create Git instances in try-with-resource BranchCommandTest: Create Git instances in try-with-resource CheckoutTest: Create Git instances in try-with-resource BranchTest: Create Git instances in try-with-resource URIishTest: Use @Test annotation's `expected` argument Suppress "The allocated object is never used" warning in tests Add $NON-NLS to suppress "Non-externalized string literal" warnings Don't use deprecated constructors of CmdLineException Prepare 4.2.0-SNAPSHOT builds Remove org.eclipse.jgit.updatesite project from tools/version.sh RevParse: Remove superfluous semicolon RefUpdateTest: Use try-with-resource for auto-closable types RefUpdateTest: Add null check to prevent potential NPE CommitCommand: Remove redundant null check JGit v4.2.0.201512141825-rc1 Change-Id: I2179859289b2f2e3d0b7c6d02ef7e7890c467f7b Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
| * Suppress "The allocated object is never used" warning in testsDavid Pursehouse2016-01-191-0/+3
| | | | | | | | | | Change-Id: Ibb405e0b36ce5a2cb30268a7de31ab2bd079ad80 Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
* | Paths.pathCompare: Utility to sort paths from byte[]Shawn Pearce2016-01-091-0/+17
| | | | | | | | | | | | | | | | | | Consolidate copies of this function into one location. Add some unit tests to prevent bugs that were accidentally introduced while trying to make this refactoring. Change-Id: I82f64bbb8601ca2d8316ca57ae8119df32bb5c08
* | DirCache: Do not create duplicate tree entriesShawn Pearce2015-12-291-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | If a file (e.g. "A") and a subtree file (e.g. "A/foo.c") both appear in the DirCache this cache should not be written out as a tree object. The "A" file and "A" subtree conflict with each other in the same tree and will fail fsck. Detect this condition during DirCacheBuilder and DirCacheEditor finish() so the application can be halted early before it updates a DirCache that might later write an invalid tree structure. Change-Id: I95660787e88df336297949b383f4c5fda52e75f5
* | DirCacheEditor: Replace file-with-tree and tree-with-fileShawn Pearce2015-12-291-0/+58
|/ | | | | | | | | | | If a PathEdit tries to store a file where a subtree was, or a subtree where a file was, replace the entry in the DirCache with the new name(s). This supports switching between file and tree entry types using a DirCacheEditor. Add new unit tests to cover the conditions where these can happen. Change-Id: Ie843d9388825f9e3d918a5666aa04e47cd6306e7
* DirCacheEntry: Speed up creation by avoiding string castShawn Pearce2015-11-281-2/+2
| | | | | | | | | | | | | | The checkPath function is available as a byte[] form, in fact the String form just converts to byte[] to run the algorithm. Having DirCacheEntry take a byte[] -> String -> byte[] to check if each path is valid is a huge waste of CPU time. On some systems it can double the time required to read 38,999 files from trees to the DirCache. This slows down any operation using a DirCache. Expose the byte[] form and use it for DirCacheEntry creation. Change-Id: I6db7bc793ece99ff3c356338d793c07c061aeac7
* DirCache: Refuse to read files with invalid pathsShawn Pearce2014-12-181-0/+44
| | | | | | | | | If the DirCache contains a path that is known to be invalid, refuse to read the DirCache into memory. This avoids confusing errors later if an invalid path read from the DirCache were to be passed into a new DirCacheEntry constructor. Change-Id: Ic033d81e23a5fbd554cc4dff80a232504562ffa8
* DirCache: Replace isValidPath with DirCacheCheckout.checkValidPathShawn Pearce2014-12-181-2/+6
| | | | | | | | | | | | isValidPath is an older simple form of the validation performed by checkValidPath. Use the latter as it more consistently matches git-core's validation rules. By running the same validation as fsck, callers creating an entry for the DirCache are more likely to learn early they are trying to build trees that will fail fsck. Change-Id: Ibf5ac116097156aa05c18e231bc65c0854932eb1
* Replace "a." with "a-" in unit testsShawn Pearce2014-12-187-28/+30
| | | | | | | | | | | Windows does not like naming files "a.". The trailing "." may be dropped by the filesystem, which is confusing. Even though these tests currently do not write to disk, future tests like them might. Replace "." with "-", which has the same sorting properties that were desirable about ".", but does not have the same limitations. Change-Id: Ie5b7594bf5e79828d1341883c73ddb70123d5055
* DirCache: Buffer TREE extension to $GIT_DIRShawn Pearce2014-11-251-1/+1
| | | | | | | | | | | | | | | Increase the in-memory buffer for the TREE extension to 5 MiB, and overflow to $GIT_DIR instead of /tmp. Using a larger buffer reduces the chances a repository will overflow and need to spool the extension to disk. Using $GIT_DIR allows the TREE extension contents to have the same file system protections as the final $GIT_DIR/index. Wrap the entire thing in a try/finally to ensure the temp file is deleted from disk after the block has finished using it. To avoid dangling NFS files, LocalFile.destroy() does close the local file before deleting it. Change-Id: I8f871181a4689e3ebf0cdd4fd1769333cf7546c3
* Move base test classes to the junit bundle for reuse for Java 7 testsRobin Rosenberg2013-02-047-7/+7
| | | | Change-Id: Iedb54eb9d8396bc3ae66d8754c1527fd9ca655f9
* Declare essentially static methods as staticRobin Rosenberg2012-12-272-4/+4
| | | | Change-Id: I83ca25fb569c0dbc36eb374d5437fcf2b65a6f68
* DirCacheIterator: Fix reset() and back()Robin Rosenberg2012-12-151-0/+128
| | | | | | | | | | | | | | reset() was broken and probably only worked when the position was at the beginning. More serious was that back() sometimes descended into the tree rather than skipping backward at the same level. Sometimes this would result in false conflicts, but one could suspect silent errors too. back() is called by the NamingConflictTreeWalk when looking for directory/file conflicts. Also added toString to DirCacheTree to simplify debugging. Bug: 396127 Change-Id: Iaa1b4e20e623d84c2e5ac26748f42e991080dbcd
* DirCacheEditor: Apply PathEdit for each stageRobin Stocker2012-11-161-0/+43
| | | | | | | | | | | | This behavior was defined in the Javadoc of PathEdit, but not actually implemented. It's necessary when one wants to use a PathEdit to check out a specific stage in apply. Bug: 390147 Change-Id: Iaed5cf60c554fc17e6c4d188caf4f0231da920d0 Signed-off-by: Chris Aniszczyk <zx@twitter.com>
* Suppress boxing warnings where we know they are okRobin Rosenberg2012-09-221-0/+1
| | | | | | | | | Invoke the wrapper types' valueOf via static imports. For booleans used in asserts, add a new assert in the JUnit utility package since out current version of JUnit does not have the assert(boolean, boolean) method. Change-Id: I9099bd8efbc8c133479344d51ce7dabed8958a2b
* cleanup: use assertArrayEquals for assertion on arraysRobin Rosenberg2012-09-031-2/+2
| | | | Change-Id: I1df945011f8e5f03959b693d3564fe357e707f91
* Enable DirCacheEntry's copyMetaData to not copy stage infoRobin Rosenberg2012-04-171-0/+50
| | | | | | | When there is a conflict sometimes we did not set the stage of the conflict entries properly for the STAGE_1 entry. Change-Id: I1c28ff6251fdbc95f7c40fc3e401f1b41157a9f6
* Merge "Fix DirCacheEdtor.DeleteTree for empty string argument"Christian Halstrick2011-10-051-0/+117
|\
| * Fix DirCacheEdtor.DeleteTree for empty string argumentRobin Rosenberg2011-10-011-0/+117
| | | | | | | | Change-Id: I7425da91c0752ae82484e3c29d21b57402d30c61
* | Fire IndexChangedEvent on DirCache.commit()Matthias Sohn2011-09-301-0/+72
|/ | | | | | | | | | | | | | | | | | Since we replaced GitIndex by DirCache JGit didn't fire IndexChangedEvents anymore. For EGit this still worked with a high latency since its RepositoryChangeScanner which is scheduled to run each 10 seconds fires the event in case the index changes. This scanner is meant to detect index changes induced by a different process e.g. by calling "git add" from native git. When the index is changed from within the same process we should fire the event synchronously. Compare the index checksum on write to index checksum when index was read earlier to determine if index really changed. Use IndexChangedListener interface to keep DirCache decoupled from Repository. Change-Id: Id4311f7a7859ffe8738863b3d86c83c8b5f513af Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fix DirCache,getEntriesWithin for empty string arguemntRobin Rosenberg2011-09-251-0/+7
| | | | Change-Id: I0bea130df611de3ef8c9251093b11c62b5442cd1
* Convert all JGit unit tests to JUnit 4Robin Rosenberg2010-12-319-4/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | Eclipse has some problem re-running single JUnit tests if the tests are in Junit 3 format, but the JUnit 4 launcher is used. This was quite unnecessary and the move was not completed. We still have no JUnit4 test. This completes the extermination of JUnit3. Most of the work was global searce/replace using regular expression, followed by numerous invocarions of quick-fix and organize imports and verification that we had the same number of tests before and after. - Annotations were introduced. - All references to JUnit3 classes removed - Half-good replacement for getting the test name. This was needed to make the TestRngs work. The initialization of TestRngs was also made lazily since we can not longer find out the test name in runtime in the @Before methods. - Renamed test classes to end with Test, with the exception of TestTranslateBundle, which fails from Maven - Moved JGitTestUtil to the junit support bundle Change-Id: Iddcd3da6ca927a7be773a9c63ebf8bb2147e2d13 Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Fix ArrayIndexOutOfBoundsException in DirCacheIteratorShawn O. Pearce2010-12-221-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the 'TREE' extension contains an invalid subtree that has been removed, DirCacheIterator still tried to access it due to an invalid childCnt field within the parent DirCacheTree object. This is easy for a user to do, they just need to move all files out of a subdirectory. For example, the input for the JUnit test case for this bug was built using the following C Git sequence: mkdir -p a/b touch a/b/c q git add a/b/c q git write-tree git mv a/b/c a/a After the last step, the subdirectory a/b is empty, as its only file was moved into the parent directory. Because of the earlier `git write-tree` operation, there is a 'TREE' extension present, but the a and a/b subdirectories have been marked invalid by the rename. When JGit tried to iterate over the a tree, it tried to correct childCnt to be zero as a/b no longer exists, but it failed to update childCnt. Change-Id: I7a0f78fc48a36b1a83252d354618f6807fca0426 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* DirCacheIteratorTest: Use newInCore instead of diskShawn O. Pearce2010-12-221-8/+8
| | | | | | | | | Avoid the dependency on the local filesystem by using only an in-core DirCache instance. Each test case builds up the index from scratch anyway through a DirCacheBuilder. Change-Id: I5decf6bffc3ed35bf1d3e4ad5cc095891c80b772 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Remove empty iterator from TreeWalkShawn O. Pearce2010-12-073-7/+0
| | | | | | | | | | | | | | | | | Its confusing that a new TreeWalk() needs to have reset() invoked on it before addTree(). This is a historical accident caused by how TreeWalk was abused within ObjectWalk. Drop the initial empty tree from the TreeWalk and thus remove a number of pointless reset() operations from unit tests and some of the internal JGit code. Existing application code which is still calling reset() will simply be incurring a few unnecessary field assignments, but they should consider cleaning up their code in the future. Change-Id: I434e94ffa43491019e7dff52ca420a4d2245f48b Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Extend DirCache test case to check "intent to add" flag.Marc Strapetz2010-08-311-2/+5
|
* Partial support for index file format "3".Marc Strapetz2010-08-311-0/+32
| | | | | | | | Extended flags are processed and available via DirCacheEntry's new isSkipWorkTree() and isIntentToAdd() methods. "resolve-undo" information is completely ignored since its an optional extension. Change-Id: Ie6e9c6784c9f265ca3c013c6dc0e6bd29d3b7233
* Fix concurrent read / write issue in LockFile on WindowsJens Baumgart2010-07-272-8/+12
| | | | | | | | | | LockFile.commit fails if another thread concurrently reads the base file. The problem is fixed by retrying the rename operation if it fails. Change-Id: I6bb76ea7f2e6e90e3ddc45f9dd4d69bd1b6fa1eb Bug: 308506 Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
* Move DirCache factory methods to RepositoryShawn O. Pearce2010-06-307-39/+39
| | | | | | | | | | | Instead of creating the DirCache from a static factory method, use an instance method on Repository, permitting the implementation to override the method with a completely different type of DirCache reading and writing. This would better support a repository in the cloud strategy, or even just an in-memory unit test environment. Change-Id: I6399894b12d6480c4b3ac84d10775dfd1b8d13e7 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Added MERGING_RESOLVED repository stateChristian Halstrick2010-05-081-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | The repository state tells in which state the repo is and also which actions are currently allowed. The state MERGING is telling that a commit is not possible. But this is only true in the case of unmerged paths in the index. When we are merging but have resolved all conflicts then we are in a special state: We are still merging (means the next commit should have multiple parents) but a commit is now allowed. Since the MERGING state "canCommit()" cannot be enhanced to return true/false based on the index state (MERGING is an enum value which does not have a reference to the repository its state it is representing) I had to introduce a new state MERGING_RESOLVED. This new state will report that a commit is possible. CAUTION: there might be the chance that users of jgit previously blindly did a plain commit (with only one parent) when the RepositoryState allowed them to do so. With this change these users will now be confronted with a RepositoryState which says a commit is possible but before they can commit they'll have to check the MERGE_MESSAGE and MERGE_HEAD files and use the info from these files. Change-Id: I0a885e2fe8c85049fb23722351ab89cf2c81a431 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Don't allow DirCacheEntry with mode of 0Shawn O. Pearce2010-02-037-14/+213
| | | | | | | | | | | | | | | | | | | | | | | A 0 file mode in a DirCacheEntry is not a valid mode. To C git such a value indicates the record should not be present. We already were catching this bad state and exceptioning out when writing tree objects to disk, but we did not fail when writing the dircache back to disk. This allowed JGit applications to create a dircache file which C git would not like to read. Instead of checking the mode during writes, we now check during mutation. This allows application bugs to be detected sooner and closer to the cause site. It also allows us to avoid checking most of the records which we read in from disk, as we can assume these are formatted correctly. Some of our unit tests were not setting the FileMode on their test entry, so they had to be updated to use REGULAR_FILE. Change-Id: Ie412053c390b737c0ece57b8e063e4355ee32437 Originally: http://thread.gmane.org/gmane.comp.version-control.git/128214/focus=128213 Signed-off-by: Shawn O. Pearce <spearce@spearce.org> CC: Adam W. Hawks <awhawks@writeme.com>
* Correctly skip over unrecognized optional dircache extensionsShawn O. Pearce2010-02-021-0/+29
| | | | | | | | | | | | | | | | | | | We didn't skip the correct number of bytes when we skipped over an unrecognized but optional dircache extension. We missed skipping the 8 byte header that makes up the extension's name and length. We also didn't include the skipped extension's payload as part of our index checksum, resuting in a checksum failure when the index was done reading. So ensure we always scan through a skipped section and include it in the checksum computation. Add a test case for a currently unsupported index extension, 'ZZZZ', to verify we can still read the DirCache object even though we don't know what 'ZZZZ' is supposed to mean. Bug: 301287 Change-Id: I4bdde94576fffe826d0782483fd98cab1ea628fa Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Remove RepositoryTestCase from DirCacheCGitCompatabilityTestShawn O. Pearce2010-02-021-3/+5
| | | | | | | | | This test doesn't actually depend upon the large data set we have in the RepositoryTestCase, so drop that from the dependency and use the more simple LocalDiskRepositoryTestCase instead. Change-Id: I0fd4affe1dd5ec86e8c3253db42df11d3b612e36 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Remove trailing whitespace at end of lineAlex Blewitt2009-10-311-1/+1
| | | | | | | | | As discussed on the egit-dev mailing list, we prefer not to have trailing whitespace in our source code. Correct all currently offending lines by trimming them. Change-Id: I002b1d1980071084c0bc53242c8f5900970e6845 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Initial JGit contribution to eclipse.orgGit Development Community2009-09-298-0/+1440
Per CQ 3448 this is the initial contribution of the JGit project to eclipse.org. It is derived from the historical JGit repository at commit 3a2dd9921c8a08740a9e02c421469e5b1a9e47cb. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>