summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src
Commit message (Collapse)AuthorAgeFilesLines
* Merge changes I335587ee,I4182a174David Pursehouse2017-11-103-0/+91
|\ | | | | | | | | | | * changes: Merge branch 'stable-4.9' Remove an unused import from PackParserTest
| * Merge branch 'stable-4.9'Matthias Sohn2017-11-113-0/+91
| |\ | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.9: Work around a Jsch bug: ensure the user name is set from URI Reintroduce protected method which removal broke EMF Compare Change-Id: I335587eee279f91bd36c9ba9fc149b17a6db6110 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | * Work around a Jsch bug: ensure the user name is set from URIThomas Wolf2017-11-102-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | JSch unconditionally overrides the user name given in the connection URI by the one found in ~/.ssh/config (if that does specify one for the used host). If the SSH config file has a different user name, we'll end up using the wrong name, which typically results in an authentication failure or in Eclipse/EGit asking for a password for the wrong user. Unfortunately there is no way to prevent or circumvent this Jsch behavior up front; it occurs already in the Session constructor at com.jcraft.jsch.Session() and the Session.applyConfig() method. And while there is a Session.setUserName() that would enable us to correct this, that latter method has package visibility only. So resort to reflection to invoke that setUserName() method to ensure that Jsch uses the user name from the URI, if there is one. Bug: 526778 Change-Id: Ia327099b5210a037380b2750a7fd76ff25c41a5a Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
| | * Merge "Reintroduce protected method which removal broke EMF Compare" into ↵Matthias Sohn2017-11-021-0/+56
| | |\ | | | | | | | | | | | | stable-4.9
| | | * Reintroduce protected method which removal broke EMF CompareMatthias Sohn2017-10-241-0/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far we follow OSGi semantic versioning [1] which says the following: "A change in the second (minor) part of the version signals that the change is backward compatible with consumers of the API package but not with the providers of that API. That is, when the API package goes from version 1.5 to 1.6 it is no longer compatible with a provider of that API but consumers of that API are backward compatible with that API package." The change Ib5fbf17bdaf727bc5d0e106ce88f2620d9f87a6f broke EMF Compare which subclasses ResolveMerger since we added a new parameter to the protected ResolveMerger.processEntry() method. According to the above cited OSGi semantic versioning this is ok, implementers should expect that they break on minor version changes of the API they implement. This change reintroduces the old processEntry() method in order to help avoid breakage for existing EMF Compare versions which expect breakage also for the implementer case only for major version change (in this case from JGit 4.x to 5.x). [1] http://www.osgi.org/wp-content/uploads/SemanticVersioning1.pdf See: https://dev.eclipse.org/mhonarc/lists/jgit-dev/msg03431.html Change-Id: I48ba4308dee73925fa32d6c2fd6b5fd89632c571 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | Add a setting for fsck to check connectivity onlyZhen Chen2017-11-101-1/+14
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | The object checks may take a long time and sometimes we are only interested in connectivity check. This is similar to 'git fsck --connectivity-only'. Change-Id: I654e8fdccdb16d796f920088429d188cc96734bc Signed-off-by: Zhen Chen <czhen@google.com>
* | | Merge changes I22a8874b,I68ed4abd,I740bc4bf,Icbd17d15Jonathan Nieder2017-11-106-112/+315
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | * changes: BitmapWalker: do not revisit objects in bitmap Use bitmaps for non-commit reachability checks Make PackWriterBitmapWalker public UploadPackTest: construct commits in test method
| * | | BitmapWalker: do not revisit objects in bitmapJonathan Tan2017-11-101-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, BitmapWalker walks through every object returned by the internal ObjectWalk, regardless of whether that object has already been marked in the bitmap. Set an object filter to ensure that only bitmap-unmarked objects are walked through. Change-Id: I22a8874b1e571df3c33643b365036d95f52fe7c7 Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
| * | | Use bitmaps for non-commit reachability checksJonathan Tan2017-11-101-2/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, unless RequestPolicy#ANY is used, UploadPack rejects all non-commit "want" lines unless they were advertized. This is fine, except when "uploadpack.allowreachablesha1inwant" is true (corresponding to RequestPolicy#REACHABLE_COMMIT), in which case one would expect that "want"-ing anything reachable would work. (There is no restriction that "want" lines must only contain commits - it is allowed for refs to directly point to trees and blobs, and requesting for them using "want" lines works.) This commit has been written to avoid performance regressions as much as possible. In the usual (and currently working) case where the only unadvertized things requested are commits, we do a standard RevWalk in order to avoid incurring the cost of loading bitmaps. However, if unadvertized non-commits are requested, bitmaps are used instead, and if there are no bitmaps, a WantNotValidException is thrown (as is currently done). Change-Id: I68ed4abd0e477ff415c696c7544ccaa234df7f99 Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
| * | | Make PackWriterBitmapWalker publicJonathan Tan2017-11-105-122/+273
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make PackWriterBitmapWriter class public and move it to a more central location, in preparation for its use by another class (in a subsequent commit). One of its inner static classes, AddUnseenToBitmapFilter, previously package-private, is also used directly in its former package. Therefore, AddUnseenToBitmapFilter and its sibling class have been moved to an internal package instead. Change-Id: I740bc4bfc4e4e3c857d1ee7d25fe45e90cd22a75 Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
* | | | Reject pack if delta exceeds array size limitShawn Pearce2017-11-091-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | JGit's delta handling code requires the target to be a single byte array. Any attempt to inflate a delta larger than fits in the 2GiB limit will fail with some form of array index exceptions. Check for this overflow early and abort pack parsing. Change-Id: I5bb3a71f1e4f4e0e89b8a177c7019a74ee6194da
* | | | Check non-flushed packs for existence of objectZhen Chen2017-11-071-0/+6
| | | | | | | | | | | | | | | | | | | | Change-Id: Id466909d70ec6f828c904692139891dec880305e Signed-off-by: Zhen Chen <czhen@google.com>
* | | | Merge branch 'stable-4.9'David Pursehouse2017-11-026-19/+672
|\ \ \ \ | | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.9: PackInserter: Implement newReader() Move some strings from DfsText to JGitText FileRepository: Add pack-based inserter implementation ObjectDirectory: Factor a method to close open pack handles ObjectDirectory: Remove last modified check in insertPack Change-Id: Ifc9ed6f5d8336bc978818a64eae122bceb933e5d
| * | | PackInserter: Implement newReader()Dave Borowitz2017-11-011-1/+232
| | | | | | | | | | | | | | | | Change-Id: Ib9e7f6439332eaed3d936f895a5271a7d514d3e9
| * | | Move some strings from DfsText to JGitTextDave Borowitz2017-11-013-7/+7
| | | | | | | | | | | | | | | | Change-Id: I60050e5127d12b6139d81859dba929fcfaabe504
| * | | FileRepository: Add pack-based inserter implementationDave Borowitz2017-11-012-0/+418
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Applications that use ObjectInserters to create lots of individual objects may prefer to avoid cluttering up the object directory with loose objects. Add a specialized inserter implementation that produces a single pack file no matter how many objects. This inserter is loosely based on the existing DfsInserter implementation, but is simpler since we don't need to buffer blocks in memory before writing to storage. An alternative for such applications would be to write out the loose objects and then repack just those objects later. This operation is not currently supported with the GC class, which always repacks existing packs when compacting loose objects. This in turn requires more CPU-intensive reachability checks and extra I/O to copy objects from old packs to new packs. So, the choice was between implementing a new variant of repack, or not writing loose objects in the first place. The latter approach is likely less code overall, and avoids unnecessary I/O at runtime. The current implementation does not yet support newReader() for reading back objects. Change-Id: I2074418f4e65853b7113de5eaced3a6b037d1a17
| * | | ObjectDirectory: Factor a method to close open pack handlesDave Borowitz2017-11-012-10/+16
| | | | | | | | | | | | | | | | Change-Id: I9490c4583fdf801de9c0bb09595ebb8fb4926988
| * | | ObjectDirectory: Remove last modified check in insertPackDave Borowitz2017-11-011-2/+0
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GC explicitly handles the case where a new pack has the same name as an existing pack due to it containing the exact same set of objects. In this case, the pack passed to insertPack will have the same name as an existing pack, but it will also almost certainly have a later mtime than the existing pack. The loop in insertPack tried to short-circuit when inserting a new pack, to avoid walking more of the pack list than necessary. Unfortunately, this means it will never get to the check for an identical name, resulting in a duplicate entry for the same PackFile in the pack list. Remove the short-circuit so that insertPack does not insert a duplicate entry. Change-Id: I00711b28594622ad3bd104332334e8a3592cda7f
* | | Move loggers to the top of their classSaša Živkov2017-10-302-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | There is a possibility of hitting NPE on a logger if it is not the first statically initialized member. For example, if another static initializer creates an instance of its class and the logger is used from the constructor. Change-Id: I51fa855a8883c107f2e4ef5ac039dc12a571a7ae
* | | Merge "Align PackStatistics and DfsPackDescription list length"Terry Parker2017-10-262-4/+14
|\ \ \
| * | | Align PackStatistics and DfsPackDescription list lengthMasaya Suzuki2017-10-202-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this the caller cannot tell which PackStatistics is for which pack file. Change-Id: Ifa530f8bc82459611ae694c0a0d111daec3e08f3 Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
* | | | Revert "Throw BinaryBlobException from RawParseUtils#lineMap."Han-Wen NIenhuys2017-10-242-29/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit f2e64cd895a6aa4f18ab3b876f13b7814fb98f04. The newly added throws clause breaks backward compatibility. Change-Id: Ifa76a1b95935e52640b81cd53c171eb17da175c2 Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
* | | | Fix typo in commentHan-Wen Nienhuys2017-10-241-1/+1
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Change-Id: I04912b32b55dd61ad2d2e7ccb5d688655b1dc335
* | | | Throw BinaryBlobException from RawParseUtils#lineMap.Han-Wen Nienhuys2017-10-242-13/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes detection of binaries exact for ResolveMerger and DiffFormatter: they will classify files as binary regardless of where the '\0' occurs in the text. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Change-Id: Id4342a199628d9406bfa04af1b023c27a47d4014
* | | | Avoid loading and merging binary data in ResolveMergerHan-Wen Nienhuys2017-10-241-7/+23
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Change-Id: Ide4b68872d426aa262142f224acf636c776b35d3
* | | | Introduce ObjectLoader.Filter for delegationHan-Wen Nienhuys2017-10-241-0/+38
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Change-Id: I78ada3f4023c4304b19f94fb044024f0f0b2cbbe
* | | | Introduce RawText#load.Han-Wen Nienhuys2017-10-243-53/+161
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This method creates a RawText from a blob, but avoids reading the blob if the start contains null bytes. This should reduce the amount of garbage that Gerrit produces for changes with binaries. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Change-Id: Idd202d20251f2d1653e5f1ca374fe644c2cf205f
* | | | Add missing @since tags for new API in ReceiveCommandMatthias Sohn2017-10-231-2/+8
| | | | | | | | | | | | | | | | Change-Id: I6e5d29390b71a1c123bc90ec2e3435706ea9211c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | | Merge branch 'stable-4.9'David Pursehouse2017-10-231-11/+34
|\ \ \ \ | |/ / / |/| / / | |/ / | | | | | | | | | | | | | | | * stable-4.9: Avoid bad rounding "1 year, 12 months" in date formatter Ensure that ~ in ssh config is replaced before Jsch sees it Change-Id: If6ca55f9447aaea3d7c2d36c03520d5e6dd5193e Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
| * | Avoid bad rounding "1 year, 12 months" in date formatterMichael Keppler2017-10-231-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Round first, then calculate the labels. This avoids "x years, 12 months" and instead produces "x+1 years". One test case has been added for the original example the bug was found with, and one assertion has been moved from an existing test case to the new test case, since it also triggered the bug. Bug: 525907 Change-Id: I3270af3850c4fb7bae9123a0a6582f93055c9780 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * | Ensure that ~ in ssh config is replaced before Jsch sees itThomas Wolf2017-10-181-11/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Do tilde replacement for values from the ssh config file that are file names in all cases to make sure that they are already replaced when Jsch tries to get the values. Previously, OpenSshConfig did tilde replacement only for the IdentityFile in the JGit-facing "Host" interface and left the replacement in the Jsch-facing "Config" interface to Jsch. But on Windows the JGit notion of what should be used to replace the tilde differs from Jsch's replacement. Jsch always replaces the tilde by the value of the system property "user.home", whereas JGit also considers some environment variables like %HOME%. This can lead to rather surprising failures as in the case of bug 526175 where %HOME% != user.home. Prior to commit 9d24470 (i.e.,prior to JGit 4.9.0) this problem never occurred because Jsch was completely unaware of the ssh config file and all host and IdentityFile handling happened exclusively in JGit. Bug: 526175 Change-Id: I1511699664ffea07cb58ed751cfdb79b15e3a99e Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | dfs: Switch InMemoryRepository to DfsReftableDatabaseShawn Pearce2017-10-184-210/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This ensure DfsReftableDatabase is tested by the same test suites that use/test InMemoryRepository. It also simplifies the logic of InMemoryRepository and brings its compatibility story closer to any other DFS repository that uses reftables for its reference storage. Change-Id: I881469fd77ed11a9239b477633510b8c482a19ca Signed-off-by: Minh Thai <mthai@google.com> Signed-off-by: Terry Parker <tparker@google.com>
* | | Merge changes from topic 'reftable'Terry Parker2017-10-189-27/+1127
|\ \ \ | | | | | | | | | | | | | | | | | | | | * changes: dfs: reftable backed DfsRefDatabase Support symbolic references in ReceiveCommand
| * | | dfs: reftable backed DfsRefDatabaseShawn Pearce2017-10-185-6/+864
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DfsReftableDatabase is a new alternative for DfsRefDatabase that handles more operations for the implementor by delegating through reftables. All reftable files are stored in sibling DfsObjDatabase using PackExt.REFTABLE and PackSource.INSERT. Its assumed the DfsObjDatabase periodically runs compactions and GCs using DfsPackCompactor and DfsGarbageCollector. Those passes are essential to collapsing the stack of reftables. Change-Id: Ia03196ff6fd9ae2d0623c3747cfa84357c6d0c79 Signed-off-by: Minh Thai <mthai@google.com> Signed-off-by: Terry Parker <tparker@google.com>
| * | | Support symbolic references in ReceiveCommandShawn Pearce2017-10-184-21/+263
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow creating symbolic references with link, and deleting them or switching to ObjectId with unlink. How this happens is up to the individual RefDatabase. The default implementation detaches RefUpdate if a symbolic reference is involved, supporting these command instances on RefDirectory. Unfortunately the packed-refs file does not support storing symrefs, so atomic transactions involving more than one symref command are failed early. Updating InMemoryRepository is deferred until reftable lands, as I plan to switch InMemoryRepository to use reftable for its internal storage representation. Change-Id: Ibcae068b17a2fc6d958f767f402a570ad88d9151 Signed-off-by: Minh Thai <mthai@google.com> Signed-off-by: Terry Parker <tparker@google.com>
* / | Avoid bad rounding "1 year, 12 months" in date formatterMichael Keppler2017-10-181-2/+3
|/ / | | | | | | | | | | | | | | | | | | | | | | | | Round first, then calculate the labels. This avoids "x years, 12 months" and instead produces "x+1 years". One test case has been added for the original example the bug was found with, and one assertion has been moved from an existing test case to the new test case, since it also triggered the bug. Bug: 525907 Change-Id: I3270af3850c4fb7bae9123a0a6582f93055c9780 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* / Skip unreachable garbage packs in dfs fsckZhen Chen2017-10-091-0/+5
|/ | | | | Change-Id: I8899e0faf1e4e6386dfd57340dfa4f4fdebc3cf3 Signed-off-by: Zhen Chen <czhen@google.com>
* Terminate StreamCopy threads in case of errorsTill Brychcy2017-10-071-4/+12
| | | | | | | | - fix NPE: don't invoke close() if no exception happened. Bug: 513554 Change-Id: I29f9b2ac1607ee26521e8aba334facd20e4ad79c Signed-off-by: Till Brychcy <register.eclipse@brychcy.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Use a new RevWalk for validating not advertised wantsZhen Chen2017-10-051-26/+27
| | | | | | | | | | | | | | Shadow commits in the RevWalk in the UploadPack object may cause the UNINTERESTING flag not being carried over to their parents commits since they were marked NO_PARENTS during the assumeShallow or initializeShallowCommits call. A new RevWalk needs to be created for this reason, but instead of creating a new RevWalk from Repository, we can reuse the ObjectReader in the RevWalk of UploadPack to load objects. Change-Id: Ic3fee0512d35b4f555c60e696a880f8b192e4439 Signed-off-by: Zhen Chen <czhen@google.com>
* Terminate StreamCopy threads in case of errorsDmitry Neverov2017-09-302-6/+7
| | | | | | Bug: 513554 Change-Id: I065836b8fc77ade6de92e4a809fcf770a4f793ec Signed-off-by: Dmitry Neverov <dmitry.neverov@gmail.com>
* ReflogWriter: Align auto-creation defaults with C gitDave Borowitz2017-09-303-2/+4
| | | | | | | | | | Per git-config(1), core.logAllRefUpdates auto-creates reflogs for HEAD and for refs under heads, notes, tags, and for HEAD. Add notes and remove stash from ReflogWriter#shouldAutoCreateLog. Explicitly force writing reflogs for refs/stash at call sites, now that this is supported. Change-Id: I3a46d2c2703b7c243e0ee2bbf6948279800c485c
* Support force writing reflog on a per-update basisDave Borowitz2017-09-306-14/+121
| | | | | | | | | | Even if a repository has core.logAllRefUpdates=true, ReflogWriter does not create reflog files unless the refs are under a hard-coded list of prefixes, or unless the forceWrite bit is set. Expose the forceWrite bit on a per-update basis in RefUpdate/BatchRefUpdate/ReceiveCommand, creating RefLogWriters as necessary. Change-Id: Ifc851fba00f76bf56d4134f821d0576b37810f80
* Ensure ReflogWriter only works with a RefDirectoryDave Borowitz2017-09-306-62/+63
| | | | | | | | | | | | | | | | | | | | | | | | | The ReflogWriter constructor just took a Repository and called getDirectory() on it to figure out the reflog dirs, but not all Repository instances use this storage format for reflogs, so it's incorrect to attempt to use ReflogWriter when there is not a RefDirectory directly involved. In practice, ReflogWriter was mostly only used by the implementation of RefDirectory, so enforcing this is mostly just shuffling around calls in the same internal package. The one exception is StashDropCommand, which writes to a reflog lock file directly. This was a reasonable implementation decision, because there is no general reflog interface in JGit beyond using (Batch)RefUpdate to write new entries to the reflog. So to implement "git stash drop <N>", which removes an arbitrary element from the reflog, it's fair to fall back to the RefDirectory implementation. Creating and using a more general interface is well beyond the scope of this change. That said, the old behavior of writing out the reflog file even if that's not the reflog format used by the given Repository is clearly wrong. Fail fast in this case instead. Change-Id: I9bd4b047bc3e28a5607fd346ec2400dde9151730
* HttpConfig: load user config before reading values from itThomas Wolf2017-09-261-15/+33
| | | | | | | | | | | | | Same problem as in commit c227268: openUserConfig() just creates the FileBasedConfig object, but doesn't read the file yet. An explicit load() is needed. As HttpConfig is read-only this omission did not cause any bad effects, but it simply ignored values from the user config. Most uses of HttpConfig go through the two-argument constructor, though, where HttpConfig is given an already loaded repo config. Change-Id: Ibe7c562c17d6ef37de8b661ab7f6fa0246db01a2 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Load the user config before modifying itThomas Wolf2017-09-231-4/+17
| | | | | | | | SystemReader.openUserConfig() does not load the config yet; an explicit StoredConfig.load() is needed. Bug: 374703 Change-Id: I1c397e2fb1a07ac4d9de3675d996417734ff90e9 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* SubmoduleUpdateCommand: Add fetch callbackDavid Pursehouse2017-09-201-4/+18
| | | | | | | | | | When the submodule already exists, it is fetched instead of cloned. Use the fetch callback instead of clone callback in this case. Change-Id: I170c21ab92b4117f25fdf940fe6807f214b04d39 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Fetch submodule repo before resolving commitsMichael FIG2017-09-201-1/+28
| | | | | | | | | | | | | By default, this is turned off unless cmd.setFetch(true) is given. It will default to true in a future release to mimic c-git behaviour. This is needed to prevent Eclipse from crashing with "Missing unknown [REF]" when cloning a repo with submodules. Bug: 470318 Change-Id: I8ae37c7c5bd2408cead8d57dd13e93e01e0e9dc1 Signed-off-by: Michael FIG <michael@fig.org> Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Handle SSL handshake failures in TransportHttpThomas Wolf2017-09-133-112/+266
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a https connection could not be established because the SSL handshake was unsuccessful, TransportHttp would unconditionally throw a TransportException. Other https clients like web browsers or also some SVN clients handle this more gracefully. If there's a problem with the server certificate, they inform the user and give him a possibility to connect to the server all the same. In git, this would correspond to dynamically setting http.sslVerify to false for the server. Implement this using the CredentialsProvider to inform and ask the user. We offer three choices: 1. skip SSL verification for the current git operation, or 2. skip SSL verification for the server always from now on for requests originating from the current repository, or 3. always skip SSL verification for the server from now on. For (1), we just suppress SSL verification for the current instance of TransportHttp. For (2), we store a http.<uri>.sslVerify = false setting for the original URI in the repo config. For (3), we store the http.<uri>.sslVerify setting in the git user config. Adapt the SmartClientSmartServerSslTest such that it uses this mechanism instead of setting http.sslVerify up front. Improve SimpleHttpServer to enable setting it up also with HTTPS support in anticipation of an EGit SWTbot UI test verifying that cloning via HTTPS from a server that has a certificate that doesn't validate pops up the correct dialog, and that cloning subsequently proceeds successfully if the user decides to skip SSL verification. Bug: 374703 Change-Id: Ie1abada9a3d389ad4d8d52c2d5265d2764e3fb0e Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Support http.<url>.* configsThomas Wolf2017-09-103-95/+403
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Git has a rather elaborate mechanism to specify HTTP configuration options per URL, based on pattern matching the URL against "http" subsection names.[1] The URLs used for this matching are always the original URLs; redirected URLs do not participate. * Scheme and host must match exactly case-insensitively. * An optional user name must match exactly. * Ports must match exactly after default ports have been filled in. * The path of a subsection, if any, must match a segment prefix of the path of the URL. * Matches with user name take precedence over equal-length path matches without, but longer path matches are preferred over shorter matches with user name. Implement this for JGit. Factor out the HttpConfig from TransportHttp and implement the matching and override mechanism. The set of supported settings is still the same; JGit currently supports only followRedirects, postBuffer, and sslVerify, plus the JGit-specific maxRedirects key. Add tests for path normalization and prefix matching only on segment separators, and use the new mechanism in SmartClientSmartServerSslTest to disable sslVerify selectively for only the test server URLs. Compare also bug 374703 and bug 465492. With this commit it would be possible to set sslVerify to false for only the git server using a self-signed certificate instead of having to switch it off globally via http.sslVerify. [1] https://git-scm.com/docs/git-config Change-Id: I42a3c2399cb937cd7884116a2a32fcaa7a418fcb Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Add PushConfig class with PushRecurseSubmodulesModeDavid Pursehouse2017-09-091-0/+95
| | | | | | | | This will be used later when adding for support for recursing submodules on push. Change-Id: Ie2a183e5404a32046de9f6524e6ceeec37919671 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>