summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit/src/org
Commit message (Collapse)AuthorAgeFilesLines
* Enable and fix warnings about redundant specification of type argumentsDavid Pursehouse2017-02-203-6/+6
| | | | | | | | | | 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>
* LocalDiskRepositoryTestCase: Add clarifying comment in call to createRepositoryDavid Pursehouse2017-02-101-1/+1
| | | | | | | | | | Clarify that 'true' means 'auto close'. This makes it consistent with other calls that have a boolean argument for 'bare'. It also makes it a bit easier to see what's going on while stepping in the debugger, because it's not necessary to scroll around to find the method declaration. Change-Id: Idacd749407dcfd258af3efaaf44d129069925dd3 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* RepositoryCacheTest: avoid to close already closed repositoryMatthias Sohn2017-01-281-2/+22
| | | | | | | The tearDown() of the superclass closed the repository once more which led to a negative use count warning logged by Repository.close(). Change-Id: I331f85a540c68264a53456276c32f72b79113d61 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* LocalDiskRepositoryTestCase: Only add to toClose through access methodDavid Pursehouse2017-01-281-1/+1
| | | | | | | | | Only using the access method means we only have one place where the toClose set is modified, making it easier to debug either by adding log statements or by setting a breakpoint. Change-Id: I4f9f1774d5f2e10bcab381edfd84bb6ee0499a11 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* LocalDiskRepositoryTestCase: Prevent duplicates in list of repos to closeDavid Pursehouse2017-01-271-1/+3
| | | | | | | | | | Change the "toClose" list to a set, which will not allow duplicate entries. This reduces the number of false positive logs about corrupt use count due to the same repository being closed more than once during teardown. Change-Id: I5ab0ff8b56e7f2b2c7aab5274d957708d26f42c5 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Define MonotonicClock interface for advanced timestampsShawn Pearce2016-11-213-5/+115
| | | | | | | | | | | | | MonotonicClock can be implemented to provide more certainity about time than the standard System.currentTimeMillis() can provide. This can be used by classes such as PersonIdent and Ketch to rely on more certainity about time moving in a strictly ascending order. Gerrit Code Review can also leverage this interface through its embedding of JGit and use MonotonicClock and ProposedTimestamp to provide stronger assurance that NoteDb time is moving forward. Change-Id: I1a3cbd49a39b150a0d49b36d572da113ca83a786
* Deprecate SafeBufferedOutputStreamShawn Pearce2016-11-141-3/+3
| | | | | | | | | | | | | | | | | | | | | Java 8 fixed the silent flush during close issue by FilterOutputStream (base class of BufferedOutputStream) using try-with-resources to close the stream, getting a behavior matching what JGit's SafeBufferedOutputStream was doing: try { flush(); } finally { out.close(); } With Java 8 as the minimum required version to run JGit it is no longer necessary to override close() or have this class. Deprecate the class, and use the JRE's version of close. Change-Id: Ic0584c140010278dbe4062df2e71be5df9a797b3
* Organize importsDavid Pursehouse2016-11-141-2/+11
| | | | | Change-Id: I7c545d06b1bced678c020fab9af1382bc4416b6e Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Add a RepeatRule to help repeating flaky testsMatthias Sohn2016-08-252-0/+184
| | | | | | | | | | | | | | | | | | | | | | | | | | | | A JUnit TestRule which enables to run the same JUnit test repeatedly. This may help to identify the root cause why a flaky tests which succeed most often does fail sometimes. Add the RepeatRule to the test class containing the test to be repeated: public class MyTest { @Rule public RepeatRule repeatRule = new RepeatRule(); ... } and annotate the test to be repeated with the @Repeat(n=<repetitions>) annotation: @Test @Repeat(n = 100) public void test() { ... } then this test will be repeated 100 times. If any test execution fails test repetition will be stopped. Change-Id: I7c49ccebe1cb00bcde6b002b522d95c13fd3a35e Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Remove the deprecated TestRepository.getClock() methodTerry Parker2016-05-311-11/+0
| | | | | | | | Gitles was the holdout and TestRepository.getClock() was removed via: https://gerrit.googlesource.com/gitiles/+/f10481d8384d1695e6981b805c4e5e462e4b71ea Change-Id: I90c0fc17be4891545b097a49763b0f0c202cc004 Signed-off-by: Terry Parker <tparker@google.com>
* Replace use of deprecated method Repository.getRef()Matthias Sohn2016-05-312-4/+4
| | | | Change-Id: Iecf2b8deafc4991cc3333702fb9fa0638be7b914 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fix type parameter in javadoc in TestRepository.delete(String ref)Matthias Sohn2016-05-051-1/+1
| | | | | | Type parameter T extends AnyObjectId in signature of update(String, T) Change-Id: I9c13ddc572b8e94d5c7854f4de1f8206cb5e99ca Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* TestRepository: Add delete() methodJonathan Nieder2016-05-041-0/+34
| | | | Change-Id: Ib4841397ceab44bd38cf2f154314ac36ded73ae0
* In TestRepository, use a consistent clockTerry Parker2016-03-251-13/+12
| | | | | | | | | | | | | The default author and committer objects in TestRepository were initialized statically and did not use the MockSystemReader passed into the TestRepository ctor. Make these fields non-static and initialize them with a consistent clock. Also make the author and commiter name and email strings public for tests that want to verify against them. Change-Id: I88b444b96e22743001b32824d8e4e03c2239aa86 Signed-off-by: Terry Parker <tparker@google.com>
* Fix apply patch which did not work with non-ascii charactersXinTong Wang2016-03-031-3/+3
| | | | | | Bug: 483943 Change-Id: If28f64053d20ab1bee54245f223e952dc2fe392c Signed-off-by: XinTong Wang <xintong@ca.ibm.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Don't use deprecated LockFile constructorDavid Pursehouse2016-02-151-1/+1
| | | | | Change-Id: Ibc3e2f3372e1a65732dd6d3c71cec53fb1aa15e2 Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
* RepositoryTestCase: Open autocloseable types in try-with-resourceDavid Pursehouse2016-02-051-4/+5
| | | | | | | | ObjectInserter.Formatter and Git are autocloseable and can be opened in try-with-resource to prevent a resource leak warning. Change-Id: I48c4001aaa7d9c1e36369e9799bfbb7c3bb46d8b Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
* Remove declared IOException which is no longer thrownMatthias Sohn2016-01-201-2/+1
| | | | | | | Since 2ccea7f0 ChangeIdUtil.computeChangeId() doesn't throw IOException anymore. Change-Id: I0bf43f2346dadbbfe7e6cbcb38b5525456fbf686 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* PackWriter: Declare preparePack object sets as @NonNullShawn Pearce2016-01-121-1/+1
| | | | | | | | Require callers to pass in valid sets for both want and have collections. Offer PackWriter.NONE as a handy constant for an empty collection for the have part of preparePack instead of null. Change-Id: Ifda4450f5e488cbfefd728382b7d30797e229217
* ObjectChecker: allow some objects to skip errorsShawn Pearce2015-12-301-2/+2
| | | | | | | | | | | | | | Some ancient objects may be broken, but in a relatively harmless way. Allow the ObjectChecker caller to whitelist specific objects that are going to fail checks, but that have been reviewed by a human and decided the objects are OK enough to permit continued use of. This avoids needing to rewrite history to scrub the broken objects out. Honor the git-core fsck.skipList configuration setting when receiving a push or fetching from a remote repository. Change-Id: I62bd7c0b0848981f73dd7c752860fd02794233a6
* Add support for clean filtersChristian Halstrick2015-11-271-0/+13
| | | | | | | | | When filters are defined for certain paths in gitattributes make sure that clean filters are processed when adding new content to the object database. Change-Id: Iffd72914cec5b434ba4d0de232e285b7492db868 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Add missing @since tags and missing javadocMatthias Sohn2015-11-255-2/+32
| | | | Change-Id: I8575797127fc96abea8af56f019ca39f5897486f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Restore TestRepository.getClock(), it is used by Gerrit/GitilesTerry Parker2015-10-221-0/+11
| | | | | Change-Id: I88880f18998e33377c0c684cbd8007b5d27d76e7 Signed-off-by: Terry Parker <tparker@google.com>
* Push control of time into MockSystemReaderTerry Parker2015-10-203-25/+55
| | | | | | | | | | | LocalDiskRepositoryTestCase and TestRepository have competing ideas about time. Push them into MockSystemReader so they can cooperate. Rename getClock() methods that return Dates to getDate(). Change-Id: Ibbd9fe7f85d0064b0a19e3b675b9718a9e67c479 Signed-off-by: Terry Parker <tparker@google.com>
* Delete non empty directories before checkout a pathAndrey Loskutov2015-10-092-0/+13
| | | | | | | | | | If the checkout path is currently a non-empty directory (and was a link or a regular file before), this directory will be removed before performing checkout, but only if the checkout path is specified. Bug: 474973 Change-Id: Ifc6c61592d9b54d26c66367163acdebea369145c Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
* [performance] Cache platform name in SystemReaderAndrey Loskutov2015-09-271-0/+18
| | | | | | | | | SystemReader.isMacOs() and SystemReader.isWindows() return values are unlikely to change during the JVM lifetime (except tests). Don't read system properties each time the methods are called, just use previously calculated value. Change-Id: I495521f67a8b544e7b7247d99bbd05a42ea16d20 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
* Move `RepositoryTestCase.indexState` to parent classChris Price2015-07-102-106/+100
| | | | | | | | | | | | | | | The test helper method `indexState` in `RepositoryTestCase` is very useful for writing tests, even in cases where we need to do things like create more than one repository for a test and thus we don't want to use the built-in `db` member variable that exists in `RepositoryTestCase`. Since the method is static, we can move it up to the parent class `LocalDiskRepositoryTestCase`, where it can be used by tests that aren't a great fit for inheriting directly from `RepositoryTestCase`. Bug: 436200 Change-Id: I2b6de75c001d2d77ddb607488af246548784a67f Signed-off-by: Chris Price <chris@puppetlabs.com>
* Change `indexState` to static methodChris Price2015-07-101-1/+1
| | | | | | | | | The `indexState` method is no longer referring to any member variables from the class, so it can be made static. Bug: 436200 Change-Id: I013316de5c373417ea758ca6e17da29209fead53 Signed-off-by: Chris Price <chris@puppetlabs.com>
* Use local variable in RepositoryTestCase.indexStateChris Price2015-07-071-1/+1
| | | | | | | | | | | | | | | | | There is a signature of the test helper method `indexState`, in `RepositoryTestCase`, that accepts a `Repository` object as an argument. However, there was one line of code where this variable was not being used, and the method was instead referring to a member variable `db`. I believe this was probably just an oversight in a previous refactor, and that the correct behavior is to use the variable from the argument list. This change also has the benefit of making it possible to convert this method to a static method, since it no longer relies on any state from the class. Bug: 436200 Change-Id: Iac95b046dc5bd0b3756642e241c3637f1fad3609 Signed-off-by: Chris Price <chris@puppetlabs.com>
* Replace deprecated release() methods by close()Matthias Sohn2015-05-211-27/+29
| | | | | | | | See the discussion [1] in the Gerrit mailing list. [1] https://groups.google.com/forum/#!topic/repo-discuss/RRQT_xCqz4o Change-Id: I2c67384309c5c2e8511a7d0d4e088b4e95f819ff Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* TestRepository: Add a cherryPick methodDave Borowitz2015-03-231-0/+62
| | | | | | | | | | CherryPickCommand only works on a non-bare repository, as it must modify the working tree and index in case of a merge conflict. In tests, being able to recover from a merge conflict is less important, as the caller should be able to control the full contents of files in advance of the cherry-pick. Change-Id: Ic332e44df1308b9336e884666b08c1f6db64513d
* TestRepository: Expose a Git instanceDave Borowitz2015-03-181-0/+12
| | | | Change-Id: I2fab7dd9a24205686db4724e77c0fd0a28f2075e
* TestRepository: Allow setting explicit Change-IdDave Borowitz2015-03-121-9/+22
| | | | | | | This includes both leaving existing Change-Ids alone (as, for example Gerrit's commit-msg hook does) and programmatically setting a value. Change-Id: Iaaffb0107ae27de24df1f0e95a8d628fb8ea5364
* TestRepository: Ignore existing Change-Id in messageDave Borowitz2015-03-121-0/+4
| | | | Change-Id: I343c3065fa369ef8aab2b033ac1e392b28d10daf
* TestRepository: Support committing to unborn symrefDave Borowitz2015-03-121-2/+1
| | | | Change-Id: I6bcee635adda7c929f6fa68ef20438fe77e49184
* TestRepository: Expose some getters for CommitBuilderDave Borowitz2015-03-121-0/+16
| | | | Change-Id: Ic6d179bd2de0081633c22fb82ca68ea619cb686f
* TestRepository: Add methods to amend commits or refsDave Borowitz2015-03-121-12/+87
| | | | Change-Id: I47082416f6e281262b160ba15272258f9109abd1
* TestRepository: Add a reset method to move HEAD aroundDave Borowitz2015-03-121-0/+55
| | | | | | | | | This flushed out a number of bugs in the way DfsRefUpdate, or at least the InMemoryRepository implementation, processes symrefs. These have been fixed, to an extent, in InMemoryRepository, but other implementations may still suffer from these bugs. Change-Id: Ifd12115a0060b9ff45a88d305b72f91ca0472f9a
* TestRepository: Optionally insert Change-Id in commit messageDave Borowitz2015-03-121-1/+25
| | | | | | Copied the implementation from CommitCommand. Change-Id: Iade0e2d70bde70cfa830fe23bcc41959b011a14a
* TestRepository: Allow custom author/committer per-commitDave Borowitz2015-03-111-9/+32
| | | | Change-Id: I078fe00470ebe60f93f4a718c163dd1412fdc776
* TestRepository: Use try-with-resources where appropriateDave Borowitz2015-03-111-74/+58
| | | | Change-Id: I06f9534ab84278df37a140700fc2bed5ab667299
* Fix junit tests under windows when the platform is explicitly changedChristian Halstrick2014-12-221-0/+2
| | | | | | | | | | | | SystemReader used a chached ObjectChecker which was instantiated only once. But in case of unit tests where we can change the platform dynamically (e.g. MockSystemReader.setWindows()) this is wrong and caused DirCacheCheckoutMaliciousPathTest. testMaliciousAbsoluteCurDrivePathWindowsOnUnix() to fail. This change allows user of SystemReader to force the creation of a new ObjectChecker. MockSystemReader.setWindows() and .setUnix() make use of this feature. Change-Id: I87458d1dc63c1f5c18979f972b1c1f0d670a9ed8
* Allow explicit configuration of git directory in InitCommandChristian Halstrick2014-12-151-0/+1
| | | | | | | | | | | | | | Native git's "init" command allows to specify the location of the .git folder with the option "--separate-git-dir". This allows for example to setup repositories with a non-standard layout. E.g. .git folder under /repos/a.git and the worktree under /home/git/a. Both directories contain pointers to the other side: /repos/a.git/config contains core.worktree=/home/git/a . And /home/git/a/.git is a file containing "gitdir: /repos/a.git". This commit adds that option to InitCommand. This feature is needed to support the new submodule layout where the .git folder of the submodules is under .git/modules/<submodule>. Change-Id: I0208f643808bf8f28e2c979d6e33662607775f1f
* Fix LocalDiskRepositoryTestCase to create correct type of reposChristian Halstrick2014-12-121-1/+1
| | | | | | | | | In one place LocalDiskRepositoryTestCase was ignoring the specification whether to create a bare or non-bare repository. Fix this and fix also one test which fails now because bare repos don't write reflogs by default. Change-Id: I4bcf8cf97c5b46e2f3919809eaa121a8d0e47010 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fix RecursiveMerger's internal use of merge to find a merge baseChristian Halstrick2014-07-252-0/+9
| | | | | | | | | | | | | | | | | | When RecursiveMerger tried to determine a common base tree it was recursively tried to merge multiple common bases. But these intermediate merges which have just been done to determine a single common base for the final merge already filled some important fields (toBeCheckedOut, toBeDeleted, ...). These side effects of the intermediate merges led to wrong results of the final merge. One symptom was that after a recursive merge which should be succesful you could still see leftover files in the worktree: files which existed in the (virtual) common base but which don't exist anymore in the branches to be merged. The solution is easy: Clear the appropriate fields after common base determination and start the final merge with a clean state. Change-Id: I644ea9e1cb15360f7901bc0483cdb9286308c226 Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
* Try to fix intermittent test failure related to file timestampsRobin Rosenberg2014-07-011-3/+4
| | | | | | | | | | Improve how tests do a "touch" operation on files. Instead of doing "f.setLastModified(System.currentTimeMillis)" open a Outputstream on the file and directly close it again. This makes this method rely only on one clock - the clock of the filesystem. Bug: 436917 Change-Id: I68ef3c2878f28b12daebf2ef6a9fa0a5d6e0964d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Move SampleDataRepositoryTestCase to org.eclipse.jgit.testShawn Pearce2013-11-241-76/+0
| | | | | | | | This class requires resources which are private to another bundle. Move the class next to its resources, removing an odd cross bundle dependency. Change-Id: I30d5568b09ea5fb3bd3bb60b602f149c0867f49a
* Support running from JARs in JGitTestUtilShawn Pearce2013-11-242-5/+38
| | | | | | | | Buck invokes JUnit tests from compiled JARs, not class directories. When copying a resource back to the filesystem a jar: style URL is obtained from the ClassLoader. Change-Id: I28d702484ec13b0b309b87990da867050e4b5ec6
* Enhance RepositoryTestCase.commitFile() to work on empty repositoryMatthias Sohn2013-10-311-4/+13
| | | | | Change-Id: Ic64497f0eedf8996ba593ca52dc9a040732a5b24 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Make sure SystemReader is reset after test is runRobin Stocker2013-10-221-0/+2
| | | | | | | | Otherwise the MockSystemReader from the test setup is active for other tests. Change-Id: I7caf693bd692d06936e29efd4dc4aabb48c1c39b Signed-off-by: Robin Stocker <robin@nibor.org>