aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
Commit message (Collapse)AuthorAgeFilesLines
...
* Don't print "into HEAD" when merging refs/heads/masterRobin Stocker2011-02-011-0/+10
| | | | | | | | | | | | | | | | When MergeMessageFormatter was given a symbolic ref HEAD which points to refs/heads/master (which is the case when merging a branch in EGit), it would result in a merge message like the following: Merge branch 'a' into HEAD But it should print the following (as C Git does): Merge branch 'a' The solution is to use the leaf ref when checking for refs/heads/master. Change-Id: I28ae5713b7e8123a0176fc6d7356e469900e7e97
* PackWriter: Make thin packs more efficientShawn O. Pearce2011-02-011-0/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is no point in pushing all of the files within the edge commits into the delta search when making a thin pack. This floods the delta search window with objects that are unlikely to be useful bases for the objects that will be written out, resulting in lower data compression and higher transfer sizes. Instead observe the path of a tree or blob that is being pushed into the outgoing set, and use that path to locate up to WINDOW ancestor versions from the edge commits. Push only those objects into the edgeObjects set, reducing the number of objects seen by the search window. This allows PackWriter to only look at ancestors for the modified files, rather than all files in the project. Limiting the search to WINDOW size makes sense, because more than WINDOW edge objects will just skip through the window search as none of them need to be delta compressed. To further improve compression, sort edge objects into the front of the window list, rather than randomly throughout. This puts non-edges later in the window and gives them a better chance at finding their base, since they search backwards through the window. These changes make a significant difference in the thin-pack: Before: remote: Counting objects: 144190, done remote: Finding sources: 100% (50275/50275) remote: Getting sizes: 100% (101405/101405) remote: Compressing objects: 100% (7587/7587) Receiving objects: 100% (50275/50275), 24.67 MiB | 9.90 MiB/s, done. Resolving deltas: 100% (40339/40339), completed with 2218 local objects. real 0m30.267s After: remote: Counting objects: 61549, done remote: Finding sources: 100% (50275/50275) remote: Getting sizes: 100% (18862/18862) remote: Compressing objects: 100% (7588/7588) Receiving objects: 100% (50275/50275), 11.04 MiB | 3.51 MiB/s, done. Resolving deltas: 100% (43160/43160), completed with 5014 local objects. real 0m22.170s The resulting pack is 13.63 MiB smaller, even though it contains the same exact objects. 82,543 fewer objects had to have their sizes looked up, which saved about 8s of server CPU time. 2,796 more objects from the client were used as part of the base object set, which contributed to the smaller transfer size. Change-Id: Id01271950432c6960897495b09deab70e33993a9 Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Sigend-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* Merge "Add git-clone to the Git API"Chris Aniszczyk2011-02-011-0/+129
|\
| * Add git-clone to the Git APIChris Aniszczyk2011-01-311-0/+129
| | | | | | | | | | | | | | | | Enhance the Git API to support cloning repositories. Bug: 334763 Change-Id: Ibe1191498dceb9cbd1325aed85b4c403db19f41e Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* | Proper handling of rebase during pullMathias Kinzler2011-01-311-4/+5
|/ | | | | | | | After consulting with Christian Halstrick, it turned out that the handling of rebase during pull was implemented incorrectly. Change-Id: I40f03409e080cdfeceb21460150f5e02a016e7f4 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
* Merge changes I3a74cc84,I219f864fRobin Rosenberg2011-01-291-6/+4
|\ | | | | | | | | | | * changes: [findbugs] Do not ignore exceptional return value of createNewFile() Do not create files to be updated before checkout of DirCache entry
| * [findbugs] Do not ignore exceptional return value of createNewFile()Matthias Sohn2011-01-281-6/+4
| | | | | | | | | | | | | | Properly handle return value of java.io.File.createNewFile(). Change-Id: I3a74cc84cd126ca1a0eaccc77b2944d783ff0747 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Merge "ObjectIdSubclassMap: Support duplicate additions"Chris Aniszczyk2011-01-281-0/+221
|\ \
| * | ObjectIdSubclassMap: Support duplicate additionsShawn O. Pearce2011-01-281-0/+221
| | | | | | | | | | | | | | | | | | | | | | | | | | | The new addIfAbsent() method combines get() with add(), but does it in a single step so that the common case of get() returning null for a new object can immediately insert the object into the map. Change-Id: Ib599ab4de13ad67665ccfccf3ece52ba3222bcba Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* | | Make PullCommand work with RebaseMathias Kinzler2011-01-282-0/+265
|/ / | | | | | | | | | | | | | | | | Rebase must honor the upstream configuration branch.<branchname>.rebase Change-Id: Ic94f263d3f47b630ad75bd5412cb4741bb1109ca Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
* / RebaseCommand: detect and handle fast-forward properlyMathias Kinzler2011-01-281-2/+33
|/ | | | | | | | | | | | This bug was hidden by an incomplete test: the current Rebase implementation using the "git rebase -i" pattern does not work correctly if fast-forwarding is involved. The reason for this is that the log command does not return any commits in this case. In addition, a check for already merged commits was introduced to avoid spurious conflicts. Change-Id: Ib9898fe0f982fa08e41f1dca9452c43de715fdb6 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
* [findbugs] Do not ignore exceptional return value of mkdirMatthias Sohn2011-01-2812-60/+60
| | | | | | | | | java.io.File.mkdir() and mkdirs() report failure as an exceptional return value false. Fix the code which silently ignored this exceptional return value. Change-Id: I41244f4b9d66176e68e2c07e2329cf08492f8619 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Hard reset should not report conflict on untracked fileMatthias Sohn2011-01-271-2/+5
| | | | | | | | | | | This problem surfaced since EGit Core ResetOperationTest is failing since change I26806d21. JGit detected checkout conflict for untracked files which never were tracked by the repository. "git reset --hard" in c git also doesn't remove such untracked files. Change-Id: Icc8e1c548ecf6ed48bd2979c81eeb6f578d347bd Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Make sure not to overwrite untracked not-ignored filesChristian Halstrick2011-01-262-10/+31
| | | | | | | | | | | | | | | | | When DirCacheCheckout was checking out it was silently overwriting untracked files. This is only ok if the files are also ignored. Untracked and not ignored files should not be overwritten. This fix adds checks for this situation. Because this change in the behaviour also broke tests which expected that a checkout will overwrite untracked files (PullCommandTest) these tests have to be modified also. Bug: 333093 Change-Id: I26806d2108ceb64c51abaa877e11b584bf527fc9 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* Remove unneeded interface from test classChristian Halstrick2011-01-261-12/+0
| | | | | Change-Id: Ia876fda0d4cf91b5326d48014e88503de93a1f38 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
* Refactor IndexPack to not require local filesystemShawn O. Pearce2011-01-254-55/+109
| | | | | | | | | | | | | | | | | By moving the logic that parses a pack stream from the network (or a bundle) into a type that can be constructed by an ObjectInserter, repository implementations have a chance to inject their own logic for storing object data received into the destination repository. The API isn't completely generic yet, there are still quite a few assumptions that the PackParser subclass is storing the data onto the local filesystem as a single file. But its about the simplest split of IndexPack I can come up with without completely ripping the code apart. Change-Id: I5b167c9cc6d7a7c56d0197c62c0fd0036a83ec6c Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* Parse RevCommit bodies before calling RevFilter.include()Jesse Greenwald2011-01-251-0/+117
| | | | | | | | | | RevFilter.include()'s documentation promises the RevCommit's body is parsed before include is invoked. This wasn't always true if the commit was parsed once, had its body discarded, the RevWalk was reset() and started a new traversal. Change-Id: Ie5cafde09ae870712b165d8a97a2c9daf90b1dbd Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* Exposed the constructor of Note classSasa Zivkov2011-01-251-58/+58
| | | | | | | | | | | | | | | Additionally, defined the NoteMap.getNote method which returns a Note instance. These changes were necessary to enable implementation of the NoteMerger interface (the merge method needs to instantiate a Note) and to enable direct use of NoteMerger which expects instances of Note class as its paramters. Implementing creation of code review summary notes in Gerrit [1] will make use of both of these features. [1] https://review.source.android.com/#change,20045 Change-Id: I627aefcedcd3434deecd63fa1d3e90e303b385ac Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* Merge "File utility for creating a new empty file"Matthias Sohn2011-01-161-0/+15
|\
| * File utility for creating a new empty fileMatthias Sohn2011-01-141-0/+15
| | | | | | | | | | | | | | | | | | | | The java.io.File.createNewFile() method for creating new empty files reports failure by returning false. To ease proper checking of return values provide a utility method wrapping createNewFile() throwing IOException on failure. Change-Id: I42a3dc9d8ff70af62e84de396e6a740050afa896 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Fix API ListBranchCommand for listmode 'all'Roberto Tyley2011-01-121-0/+6
| | | | | | | | | | | | | | If remote branches are present they can not be added to the RefMap from the local branches - the two RefMaps have a different value of 'prefix' and consequently an IllegalArgumentException is thrown.
* | Merge "Using java.util.concurrent in NLSTest instead of handling threads ↵Shawn Pearce2011-01-101-30/+28
|\ \ | |/ |/| | | directly."
| * Using java.util.concurrent in NLSTest instead of handling threads directly.Sasa Zivkov2011-01-101-30/+28
| | | | | | | | | | | | | | | | | | | | A test in NLSTest was mixing the "old" and the "new" way of handling concurrency. This change makes use of the java.util.concurrent facilities to control concurrency and removes the code that was directly dealing with Thread objects. Change-Id: Ie7267776e988a48a5443f0f3fe4eb43e79eee4b1 Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
* | Merge "Config: Preserve existing case of names in sections"Shawn O. Pearce2011-01-091-2/+15
|\ \
| * | Config: Preserve existing case of names in sectionsShawn O. Pearce2011-01-061-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an application asks for the names in a section, it may want to see the existing case that was stored by the user. For example, Gerrit Code Review wants to store a configuration block like: [access "refs/heads/master"] label-Code-Review = group Developers and although the name label-Code-Review is case-insensitive, it wants to display the case as it appeared in the configuration file. When enumerating section names or variable names (both of which are case-insensitive), Config now keeps track of the string that first appeared, and presents them in file order, permitting applications to use this information. To maintain case-insensitive behavior, the contains() method of the returned Set<String> still performs a case-insensitive compare. This is a behavior change if the caller enumerates the returned Set<String> and copies it to his own Set<String>, and then performs contains() tests against that, as the strings are now the original case from the configuration block. But I don't think anyone actually does this, as the returned sets are immutable and are cached. Change-Id: Ie4e060ef7772958b2062679e462c34c506371740 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* | | Merging Git notesSasa Zivkov2011-01-092-0/+658
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Merging Git notes branches has several differences from merging "normal" branches. Although Git notes are initially stored as one flat tree the tree may fanout when the number of notes becomes too large for efficient access. In this case the first two hex digits of the note name will be used as a subdirectory name and the rest 38 hex digits as the file name under that directory. Similarly, when number of notes decreases a fanout tree may collapse back into a flat tree. The Git notes merge algorithm must take into account possibly different tree structures in different note branches and must properly match them against each other. Any conflict on a Git note is, by default, resolved by concatenating the two conflicting versions of the note. A delete-edit conflict is, by default, resolved by keeping the edit version. The note merge logic is pluggable and the caller may provide custom note merger that will perform different merging strategy. Additionally, it is possible to have non-note entries inside a notes tree. The merge algorithm must also take this fact into account and will try to merge such non-note entries. However, in case of any merge conflicts the merge operation will fail. Git notes merge algorithm is currently not trying to do content merge of non-note entries. Thanks to Shawn Pearce for patiently answering my questions related to this topic, giving hints and providing code snippets. Change-Id: I3b2335c76c766fd7ea25752e54087f9b19d69c88 Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | Fix IgnoreRule for directory-only patternsMarc Strapetz2011-01-071-0/+10
|/ / | | | | | | | | | | Patterns containing only a trailing slash have to be treated as "global" patterns. For example: "classes/" matches "classes" as well as "dir/classes" directory.
* / NoteMap implements Iterable<Note>Sasa Zivkov2011-01-051-0/+87
|/ | | | | | | | | We will need to iterate over all notes of a NoteMap, at least this will be needed for testing purposes. This change also implied making the Note class public. Change-Id: I9b0639f9843f457ee9de43504b2499a673cd0e77 Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
* Cleanup configuration of Maven JUnit runnerShawn O. Pearce2011-01-021-4/+0
| | | | | | | | | | | | | Set the plugin version in the top-level pom, not the unit test pom. This ensures the same plugin is used for all JUnit tests within the overall project. Drop the include **/*Test.java definition, as its no longer necessary with the JUnit 4 based test suite. All of the test classes now end with "Test" and include @Test annotations on the test methods. Change-Id: Ib2c180bf531e1a97e31979fcc281fa0fc5a1abb3 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Fix NLSTest and RootLocalTest for JUnit 4Shawn O. Pearce2011-01-022-19/+42
| | | | | | | | These test classes needed new @Test annotations to be found by the JUnit 4 test runner. Change-Id: I61b6a8ebd468fa2d13fad5bf9cbd8f81a6f67e41 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Merge "Implement a revert command"Shawn Pearce2011-01-022-0/+159
|\
| * Implement a revert commandRobin Rosenberg2011-01-022-0/+159
| | | | | | | | | | | | | | | | | | | | This is almost reverted cherry-pick, and the implementation is almost identical. It orders the input to merge differently to get the effect and produces a different commit message with the default author, rather than the original author. Change-Id: I39970091d9f7406ae7168b8efaab23a5e2c16bad Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
* | Require the hamcrest packaging that comes with EclipseRobin Rosenberg2011-01-011-3/+4
|/ | | | | | | | | | The other one gets installed with SWTBot, but you do not need it if you do not hack EGit. Using import-package instead of require-bundle fixes the dependency. Actually we do not need hamcrest at this time, but JUnit wants it. Change-Id: I59873618f86d02e8439d40c1f322ea8e5c4fe3fc Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
* Drop unneccessary @SuppressWarningsRobin Rosenberg2010-12-311-5/+0
| | | | | Change-Id: I3a5b877efd3a58ad463c47bb663d073baea81dda Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
* Fix TestTranslationBundleRobin Rosenberg2010-12-315-1/+1
| | | | | | | | | | | The test was never run from maven, because its name did not end in a way that was recognized by the pom. After rename it failed because it did not find its resources. Rename test class and move resources to the resources folder Change-Id: I74a7ef1373cd902e1d05ff6ea38f8648b5fc5700 Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
* Convert all JGit unit tests to JUnit 4Robin Rosenberg2010-12-31175-419/+2917
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add support for getting the system wide configurationRobin Rosenberg2010-12-311-1/+2
| | | | | | | | | | | | | These settings are stored in <prefix>/etc/gitconfig. The C Git binary is installed in <prefix>/bin, so we look for the C Git executable to find this location, first by looking at the PATH environment variable and then by attemting to launch bash as a login shell to find out. Bug: 333216 Change-Id: I1bbee9fb123a81714a34a9cc242b92beacfbb4a8 Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
* Merge "Fix FileSnapShot"Shawn Pearce2010-12-301-0/+152
|\
| * Fix FileSnapShotRobin Rosenberg2010-12-301-0/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We cannot use SystemReader to get the time, unless we do that consistently, which is harder to do and be sure we are really testing what we want. Then we need to update our lastRead variable whenever we conclude that our file is not racily clean according to lastRead. It may well be clean, but we do not know that until we check the system clock again. Finally add a test for this class. Change-Id: I1894b032b9bd359d1b5325e5472d48e372599e4c Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
* | Merge "CheckoutResult: return paths instead of Files"Shawn Pearce2010-12-291-4/+3
|\ \ | |/ |/|
| * CheckoutResult: return paths instead of FilesMathias Kinzler2010-12-211-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | As discussed in http://egit.eclipse.org/r/#change,2127 we should use paths relative the working directory instead of Files to notify the caller about conflicts and nondeleted files. Change-Id: I034c7bd846f0df78d97bc246f38d411f29713dde Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
* | Enable use of JUnit 4 with the jgit.test projectRobin Rosenberg2010-12-281-3/+4
| | | | | | | | | | | | | | | | | | Some enablement was done earlier, but we need to add the org.junit package and hamcrest to make it work. junit.textui removed, probably a mistake at some time in the past. Change-Id: I6922a2f40eb0c077a8ade5ed073ecf0e90425544
* | Fix ArrayIndexOutOfBoundsException in DirCacheIteratorShawn O. Pearce2010-12-222-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>
* Fix CheckoutCommandTestMathias Kinzler2010-12-201-3/+4
| | | | | Change-Id: Ieacae01de20d7729ef34e6e6a1523fbaf9db41a8 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
* Fix JDK 6 Usage of String.getBytes(Charset)Mathias Kinzler2010-12-201-1/+2
| | | | | Change-Id: I619b00d8a3b0770c9fd1dc3314794f915ea80604 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
* Checkout: fix handling if name does not refer to a local branchMathias Kinzler2010-12-201-1/+18
| | | | | | | | | | The CheckoutCommand does not handle names other than local branch names properly; it must detach HEAD if such a name is encountered (for example a commit ID or a remote tracking branch). Change-Id: I5d55177f4029bcc34fc2649fd564b125a2929cc4 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* Remove deprecated WriteTree from testsShawn O. Pearce2010-12-202-141/+168
| | | | | | | | | These tests doesn't need to use WriteTree anymore. There are other means of creating tree objects in the repository that aren't deprecated, so use those instead. Change-Id: I89cd8ab54c66964a5fddc0a045f1c0f1c7c49055 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Checkout: expose a CheckoutResultMathias Kinzler2010-12-201-0/+51
| | | | | | | | | | This is needed by callers to determine checkout conflicts and possible files that were not deleted during the checkout so that they can present the end user with a better Exception description and retry to delete the undeleted files later, respectively. Change-Id: I037930da7b1a4dfb24cfa3205afb51dc29e4a5b8 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
* Qualify post 0.10 buildsMatthias Sohn2010-12-172-32/+32
| | | | | Change-Id: Ifcb8fdea95286779c8aea6bf4d7647e8c1c98d63 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>