summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
Commit message (Collapse)AuthorAgeFilesLines
* AbbreviationTest: Open FileOutputStream in try-with-resourceDavid Pursehouse2018-03-031-1/+4
| | | | | Change-Id: Id1d48da466251f9e4186f4674afba4b5901a4388 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Enable warning for resources not managed by try-with-resourceDavid Pursehouse2018-03-031-1/+1
| | | | | Change-Id: Iefe97de6bdb62af558f1b0e77c9205a9186f9b4c Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* LFS: support merge/rebase/cherry-pick/diff/compare with LFS filesMarkus Duft2018-03-032-8/+4
| | | | | | | | | | | | Respect merge=lfs and diff=lfs attributes where required to replace (in memory) the content of LFS pointers with the actual blob content from the LFS storage (and vice versa when staging/merging). Does not implement general support for merge/diff attributes for any other use case apart from LFS. Change-Id: Ibad8875de1e0bee8fe3a1dffb1add93111534cae Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* MergeGitAttributeTest: Open FileInputStream in try-with-resourceDavid Pursehouse2018-02-261-27/+17
| | | | | Change-Id: Iec85eea044c46a199b5b6f6bdbb3191d817dd441 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* PullCommandWithRebaseTest: Open File{Input|Output}Stream in try-with-resourceDavid Pursehouse2018-02-261-13/+2
| | | | | Change-Id: I1ff707ab7bab676603907f4c0bb1bc495503055b Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* RecursiveMergerTest: Open FileOutputStream in try-with-resourceDavid Pursehouse2018-02-261-33/+28
| | | | | Change-Id: I158333d6393fb807bc21fba23fec7ad474384471 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* PullCommandTest: Use try-with-resources for File{Input,Output}StreamDavid Pursehouse2018-02-261-13/+2
| | | | | Change-Id: I09242eb289655c7554aefa9e0817d9b881db656b Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Add ObjectIdSerializerDavid Pursehouse2018-02-251-0/+88
| | | | | | | | | | | | | | | This is based on the ObjectIdSerialization class written by Shawn Pearce for the Gerrit Code Review project in 2009 [1]. As mentioned in the commit message there, it should be part of core JGit. This implementation is slightly different to Shawn's version. Rather than having separate methods for null/non-null ids, single methods are implemented with @Nullable annotations. [1] https://gerrit-review.googlesource.com/c/gerrit/+/9792 Change-Id: I7599cf8bd1ecd546e2252783d6d672eb76804060 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* CheckoutCommandTest: Fix name of created temp fileDavid Pursehouse2018-02-251-1/+1
| | | | | Change-Id: I29048f83aee3848679bbc6ded09dd3dd4a2ea35b Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* IgnoreNodeTest: Suppress deprecation warnings in testEmptyIgnoreNodeDavid Pursehouse2018-02-251-0/+1
| | | | | Change-Id: I930c9408cc702af911419f2a7b3d03f652a2d4e3 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Fix processing of gitignore negationsMarc Strapetz2018-02-232-1/+296
| | | | | | | | | | Processing of negated rules, like !bin/ was not working correctly: they were interpreted too broad, resulting in unexpected untracked files which should actually be ignored Bug: 409664 Change-Id: I0a422fd6607941461bf2175c9105a0311612efa0 Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
* PathMatcher: fix handling of **/Marc Strapetz2018-02-223-1/+104
| | | | | | | **/ should match only directories, but not files Change-Id: I885c83e5912cac5bff338ba657faf6bb9ec94064 Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
* Merge changes Id616611e,Ib6509e81,I52f5d3f2David Pursehouse2018-02-221-33/+154
|\ | | | | | | | | | | | | * changes: RepoCommand: generate relative submodule URLs from absolute URLs. RepoCommand: don't record new commit if tree did not change RepoCommand: persist unreadable submodules in .gitmodules
| * RepoCommand: generate relative submodule URLs from absolute URLs.Han-Wen Nienhuys2018-02-211-0/+58
| | | | | | | | | | | | | | | | If a manifest file specifies an absolute URL on the same host on which the superproject resides, rewrite the URLs to be relative. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Change-Id: Id616611e5195998fb665c8e7806539a3a02e219a
| * RepoCommand: don't record new commit if tree did not changeHan-Wen Nienhuys2018-02-191-2/+54
| | | | | | | | | | Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Change-Id: Ib6509e816684256d723558d5e8f3c37de58a2ff8
| * RepoCommand: persist unreadable submodules in .gitmodulesHan-Wen Nienhuys2018-02-191-33/+44
| | | | | | | | | | | | | | | | | | | | | | | | In cases where a manifest file mixes different remotes, a Gerrit server process may not have access to all remotes, and won't be able to produce a full submodule tree. Preserving this information in .gitmodules will let downstream clients reconstruct the full tree. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Change-Id: I52f5d3f288e771dca0af2b4dd3f3fa0f940dcf15
* | CGitIgnoreTest: also test untracked filesMarc Strapetz2018-02-211-5/+30
|/ | | | | Change-Id: I21a4ebd63eaaa85aa2e68f99ef58c141189bdab4 Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
* Merge "Merge branch 'stable-4.10'"Matthias Sohn2018-02-142-0/+287
|\
| * Merge branch 'stable-4.10'Matthias Sohn2018-02-142-0/+287
| |\ | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.10: Fix ssh host name handling for Jsch Jsch overrides the port in the URI with the one in ~/.ssh/config Change-Id: I860fc61ceb12ae792b1ee7421046ecd32373b9f8 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | * Merge branch 'stable-4.9' into stable-4.10Matthias Sohn2018-02-142-0/+287
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.9: Fix ssh host name handling for Jsch Jsch overrides the port in the URI with the one in ~/.ssh/config Change-Id: Iff9076f65e767bbe8df016337b631bdaeb40ad98 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | | * Fix ssh host name handling for JschThomas Wolf2018-02-141-1/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we give Jsch access to the ssh config file, we must _not_ resolve the host name from the alias. Instead we must give the alias (i.e., the host name as is in the URI) to Jsch, so that it finds the same ssh config entry. Otherwise if the hostname in the URI, which is taken as an alias in ssh config ("Host" line), is unequal to the "Hostname" line, and there happens to be another ssh config entry with that translated host name as alias, Jsch will pick up that second entry, and we end up with a strange mixture of both. Add tests for this case. Bug: 531118 Change-Id: I249d8c073b0190ed110a69dca5b9be2a749822c3 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
| | | * Jsch overrides the port in the URI with the one in ~/.ssh/configThomas Wolf2018-02-142-0/+220
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Jsch unconditionally overwrites the port from the ssh config file (if a port is specified there), even if the URI explicitly does give a different port. Fix this, and add tests. Change-Id: I7b014543c7ece26270e366db39d7647f82d64f0d Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | | InitCommand: Don't leave Repository open after Git is closedDavid Pursehouse2018-02-141-36/+41
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The InitCommand returns a Git that is instantiated with the newly created Repository, but the Repository is not closed with the Git resulting in resource leaks. Create the Git with `closeRepo` set to true, such that the Repository is also closed when the Git is closed. Adjust the tests to use try-with-resource on the Git instance. Change-Id: Ib26e7428c7d8840956d1edb09e53b93e23e6fe5a Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | | URIish: add a test for equals and hashcode methodsMatthias Sohn2018-02-131-0/+28
| | | | | | | | | | | | Change-Id: I5727ac1757dca0d63631401bcb074ee8f58ce082 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | Add a minimum negotiation feature for fetchTerry Parker2018-02-121-3/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Android an Chrome have several repos with >300k refs. We sometimes see negotiations of >100k rounds. This change provides a "minimal negotiation" feature on the client side that limits how many "have" lines the client sends. The client extracts the current SHA-1 values for the refs in its wants set, and terminates negotiation early when all of those values have been sent as haves. If a new branch is being fetched then that set will be empty and the client will terminate after current default minimum of two rounds. This feature is gated behind a "fetch.useminimalnegotiation" configuration flag, which defaults to false. Change-Id: Ib12b095cac76a59da6e8f72773c4129e3b32ff2b Signed-off-by: Terry Parker <tparker@google.com>
* | | MergedReftable to skip shadowed refs in same reftableMinh Thai2018-02-091-0/+21
| | | | | | | | | | | | | | | | | | | | | This would allow compact and GC process to clean up duplicate ref names in the reftables. Change-Id: I2b9df0bf72dba63cc3525e374982e60559a776c2 Signed-off-by: Minh Thai <mthai@google.com>
* | | Fix CleanCommand not to throw FileNotFoundExceptionsChristian Halstrick2018-02-081-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When CleanCommand is collecting the files and folders to be deleted it may happen that the list of directories contains obsolete entries. E.g. a folder and its parent folder may be in the list. Only the parent folder would be sufficient. This was a reason for hitting FileNotFoundExceptions when finally trying to delete the files and folders. Improve CleanCommand to ignore files to be deleted which are already gone. Bug: 514434 Change-Id: I10caa01bfb9cec5967dfdaea50c6e4a713eeeabd Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | GC: Remove empty references foldersHector Caballero2018-02-071-0/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After packaging references, the folders containing these references are not deleted. In a busy repository, this causes operations to slow down as traversing the references tree becomes longer. Delete empty reference folders after the loose references have been packed. To avoid deleting a folder that was just created by another concurrent operation, only delete folders that were not modified in the last 30 seconds. Signed-off-by: Hector Oswaldo Caballero <hector.caballero@ericsson.com> Change-Id: Ie79447d6121271cf5e25171be377ea396c7028e0
* | | Basic submodule merge handlingDavid Turner2018-02-042-2/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This doesn't handle the really hard thing, which is merging spurious conflicts inside .gitmodules files. That's OK: git.git doesn't either. Users can resolve the conflict themselves and then commit the merge. Previously, jgit would crash when attempting to merge conflicting submodule changes. Even if there was no conflict, after a merge which adds submodules, the repository would have been missing empty directories for newly-added submodules. This patch fixes the crash, and adds the empty directories where necessary. It ensures that the index is in a conflicted state when submodule changes conflict. Reported-by: Alexey Korobkov Bug: 494551 Change-Id: I79db6798c2bdcc1159b5b2589b02da198dc906a1 Signed-off-by: David Turner <dturner@twosigma.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | Fix index blob for merges with CRLF translationsThomas Wolf2018-02-021-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit fc7d407 corrected line endings for working tree files resulting from merges when CRLF translations are to be done. However, that also resulted in the file content being put as-is into the index, which is wrong. The index must contain the file content with reverse CRLF translations applied. With core.autocrlf=true, the working tree file should have CR-LF, but the index blob must still contain only LF. Fix this oversight and apply the inverse translation when updating the index, similar to what is done in AddCommand. Bug: 499615 Change-Id: I3a33931318bdb580b2390f3450f91ea8f258a6a4 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | Fix version of slf4j in manifest filesDavid Pursehouse2018-02-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Consistently require 1.7.0. We ship 1.7.2 with our p2 repository but there is no need to require 1.7.2 since it should be API compatible with 1.7.0. Change-Id: I8467bb14316cb24daa79e89275332107d2716190 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | Honor CRLF settings when writing merge resultsThomas Wolf2018-02-021-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Merges are performed using the raw text as stored in the git repository. When we write the merge result, we must apply the correct CRLF settings. Otherwise the line endings in the result will be wrong. Bug: 499615 Change-Id: I37a9b987e9404c97645d2720cd1c7c04c076a96b Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | Minor improvements in git config file inclusionsThomas Wolf2018-01-281-2/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Section and key names in git config files are case-insensitive. * If an include directive is invalid, include the line in the exception message. * If inclusion of the included file fails, put the file name into the exception message so that the user knows in which file the problem is. Change-Id: If920943af7ff93f5321b3d315dfec5222091256c Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | Merge branch 'stable-4.10'Matthias Sohn2018-01-131-1/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.10: Revert handling of ssh IdentityFile to pre-4.9 behavior Prepare 4.10.1-SNAPSHOT builds JGit v4.10.0.201712302008-r Change-Id: I13797f064de919c257feb8e96da226d7b1faaf7a Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * | Merge branch 'stable-4.9' into stable-4.10Matthias Sohn2018-01-131-1/+2
| |\| | | | | | | | | | | | | | | | | | | * stable-4.9: Revert handling of ssh IdentityFile to pre-4.9 behavior Change-Id: I7cd2f0fe93be5193d6de2a376a023bdece5d84a9
| | * Revert handling of ssh IdentityFile to pre-4.9 behaviorThomas Wolf2018-01-121-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Jsch caches keys (aka identities) specified in ~/.ssh/config via IndentityFile only for the current Jsch Session. This results in multiple password prompts for successive sessions. Do the handling of IdentityFile exclusively in JGit, as it was before 4.9. JGit uses different Jsch instances per host and caches the IdentityFile there, allowing it to be re-used in different sessions for the same host. * Add comments to explain this. * Move the JschBugFixingConfig from OpenSshConfig to JschConfigSessionFactory to have all these Jsch work-arounds in one place. * Make that config hide the IdentityFile config from Jsch to avoid that Jsch overrides the JGit behavior. Bug: 529173 Change-Id: Ib36c34a2921ba736adeb64de71323c2b91151613 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
| * | Prepare 4.10.1-SNAPSHOT buildsMatthias Sohn2017-12-312-47/+47
| | | | | | | | | | | | | | | Change-Id: I139fb660c4630d9d073eabf37ff26ea3a823bcbd Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * | JGit v4.10.0.201712302008-rv4.10.0.201712302008-rMatthias Sohn2017-12-312-2/+2
| | | | | | | | | | | | | | | Change-Id: I9cc3a839d906acd01829df1de64cfafca8a6d008 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | PackInserterTest#newLargeBlob: Factor Random instance out to class memberDavid Pursehouse2018-01-111-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of instantiating a new Random on each invocation of newLargeBlob, create it once and reuse it. This fixes a warning raised by Spotbugs about the Random object being created and only used once. Change-Id: I5b8e6ccbbc92641811537808aed9eae2034c1133 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | | Prepare 4.11.0-SNAPSHOT buildsMatthias Sohn2017-12-312-47/+47
|/ / | | | | | | | | Change-Id: I5d5e2befcf530d93457d44684bd9e4fc2392e5eb Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Add a command to deinitialize submodulesDavid Turner2017-12-271-0/+251
| | | | | | | | | | Change-Id: Iaaefc2cbafbf083d6ab158b1c378ec69cc76d282 Signed-off-by: David Turner <dturner@twosigma.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | URIish: support for empty portsMarc Strapetz2017-12-231-7/+16
| | | | | | | | | | | | | | | | Properly parse URLs like "ssh://host:/path" Bug: 519187 Change-Id: I0054868e30509e4ba919444be16c2a20f741545a Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
* | Add header Automatic-Module-Name for Java 9Karsten Thoms2017-12-231-0/+1
| | | | | | | | | | | | Bug: 529075 Change-Id: I4532ce2c80eb91531d46026676502d636ccda706 Signed-off-by: Karsten Thoms <karsten.thoms@itemis.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Merge branch 'stable-4.9'Matthias Sohn2017-12-233-0/+68
|\| | | | | | | | | | | | | | | * stable-4.9: Strings#convertGlob: fix escaping of patterns like [\[]. Change-Id: I18d55537002b3153db35f8a6b60f2f5317d17248 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * Strings#convertGlob: fix escaping of patterns like [\[].Dmitry Pavlenko2017-12-213-0/+68
| | | | | | | | | | | | | | | | | | | | Originally the patterns were escaped twice leading to wrong matching results. Bug: 528886 Change-Id: I26e201b4b0ef51cac08f940b76f381260fa925ca Signed-off-by: Dmitry Pavlenko <pavlenko@tmatesoft.com> Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | ConfigTest: Add some additional comment parsing testsDave Borowitz2017-12-211-0/+5
| | | | | | | | Change-Id: I0f1df93bd1ceeb847771ea6484f9de539e8c177b
* | Config: Drop backslash in invalid escape sequences in subsectionsDave Borowitz2017-12-211-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are ignored by C git when parsing: $ git config -f - --list <<EOF [foo "x\0y"] bar = baz [foo "x\qy"] bar = baz [foo "x\by"] bar = baz [foo "x\ny"] bar = baz [foo "x\ty"] bar = baz EOF foo.x0y.bar=baz foo.xqy.bar=baz foo.xby.bar=baz foo.xny.bar=baz foo.xty.bar=baz This behavior is different from value parsing, where an invalid escape sequence is an error (which JGit already does as well): $ git config -f - --list <<EOF [foo] bar = x\qy EOF fatal: bad config line 2 in standard input Change-Id: Ifd40129b37d9a62df3d886d8d7e22f766f54e9d1
* | Config: Match C git behavior more closely in escaping valuesDave Borowitz2017-12-212-7/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So this happened: $ git config -f foo.config foo.a 'x"y' $ git config -f foo.config foo.b x\\y $ git config -f foo.config foo.c $'x\ny' $ git config -f foo.config foo.d $'x\ty' $ git config -f foo.config foo.e $'x\by' $ cat foo.config [foo] a = x\"y b = x\\y c = x\ny d = x\ty e = y That last line is my shell interpreting the backspace byte: $ python -c 'print repr(open("foo.config").read())' '[foo]\n\ta = x\\"y\n\tb = x\\\\y\n\tc = x\\ny\n\td = x\\ty\n\te = x\x08y\n' Change-Id: I1b059e1afb544c39ddb587c07bf79a06e99d0a09
* | Fix remaining javadoc errors raised by doclintMatthias Sohn2017-12-216-22/+23
| | | | | | | | | | | | | | For now ignore doclint "missing" warnings. Change-Id: I0e5af7a757f4d92ffeeb113f30576a35414d6781 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Merge branch 'stable-4.9'Dave Borowitz2017-12-201-3/+49
|\| | | | | | | | | | | | | | | * stable-4.9: PackInserter: Ensure objects are written at the end of the pack ObjectInserter: Add warning about mixing read-back with writes Change-Id: I308e7c1c6b72e8d4d9b5d0f4f51e9815fc92d7d7