Colby Ranger [Tue, 8 Oct 2013 17:16:45 +0000 (10:16 -0700)]
Fix ServiceMayNotContinueException constructors for Java 1.5
IOException did not add a (String, Throwable) constructor until 1.5.
Instead use the String super constructor and initCause to initialize
the exception.
Colby Ranger [Mon, 7 Oct 2013 21:14:01 +0000 (14:14 -0700)]
Add constructors that take Throwable to ServiceMayNotContinueException.
ServiceMayNotContinueException usually wraps an underlying exception.
Add convenience constructors that take Throwable. In the case a
string is not provided, the message defaults to "internal server error",
since it may be reported to the client.
Colby Ranger [Mon, 7 Oct 2013 17:25:28 +0000 (10:25 -0700)]
Propagate IOException where possible when getting refs.
Currently, Repository.getAllRefs() and Repository.getTags() silently
ignores an IOException and instead returns an empty map. Repository
is a public API and as such cannot be changed until the next major
revision change. Where possible, update the internal jgit APIs to
use the RefDatabase directly, since it propagates the error.
Matthias Sohn [Thu, 3 Oct 2013 15:39:03 +0000 (17:39 +0200)]
Merge branch 'stable-3.1'
* stable-3.1:
Prepare post 3.1.0 builds
JGit v3.1.0.201310021548-r
Fix order of commits in rebase todo file header
Prepare post 3.1.0 RC1 builds
JGit v3.1.0.201309270735-rc1
Attempt to fix graph layout when new heads are introduced
Prepare re-signing pgm's ueberjar to avoid SecurityException
Use full branch name when getting ref in BranchTrackingStatus
Change-Id: Ida30175d0c058048cbe4b563aae7f85cd008db29 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Matthias Sohn [Tue, 24 Sep 2013 07:11:47 +0000 (09:11 +0200)]
Prepare re-signing pgm's ueberjar to avoid SecurityException
Since we now sign all build artifacts immediately after creating them
we need to re-sign the ueberjar created for jgit command line tool
because the signatures of the individual jars are invalidated when
repacking them into the ueberjar. Hence we need to exclude the
signatures of the individual jars when using maven-shade-plugin to
create the ueberjar.
Also install the shaded plugin into maven repository and exclude osgi
framework sources which were included unintentionally.
See http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg02277.html
Change-Id: Ia302e68a4b2a9399cb18025274574e31d3d3e407 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Jonathan Nieder [Tue, 24 Sep 2013 00:06:18 +0000 (17:06 -0700)]
Do not close ArchiveOutputStream on error
If we encounter an I/O error while writing an archive (for example due
to the reader of an HTTP stream closing the connection), the result is
an archive with unclosed entries, causing
TarArchiveOutputStream.finish() to throw IOException("This archives
contains unclosed entries"), hiding the IOException that caused the
early termination.
The unclosed entries are fine: the same exception that occured in the
first place will probably prevent closing the entries before finishing
this partial archive that should be discarded anyway.
It would be nicer to call TarArchiveOutputStream.finish and leave the
underlying OutputStream unclosed --- all callers close it already ---
but that would be a more invasive change so we hold off for now.
Change-Id: I328ced19aa8a1888e5353cdbb6106a85fd72d5d7 Signed-off-by: Jonathan Nieder <jrn@google.com>
Robin Stocker [Sun, 15 Sep 2013 21:26:35 +0000 (23:26 +0200)]
Use full branch name when getting ref in BranchTrackingStatus
In case there is both a tag and branch called "foo", the tag is returned
if calling getRef with the short name. By using refs/heads/foo, the
branch is returned.
Bug: 417158
Change-Id: I86b4f83955586bb24774fd621f5012499cf67909 Signed-off-by: Robin Stocker <robin@nibor.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Ignore bitmap indexes that do not match the pack checksum
If `git gc` creates a new pack with the same file name, the
pack checksum may not match that in the .bitmap. Fix the PackFile
implementaion to silently ignore invalid bitmap indexes.
Robin Stocker [Mon, 12 Aug 2013 13:13:03 +0000 (15:13 +0200)]
ResetCommand: Allow reset on unborn branch when ref not specified
In C Git 1.8.2, "git reset" now also works on an unborn branch (no HEAD
yet) if no explicit ref was specified. In that case, it is treated as a
reset to an empty tree.
This can be useful for callers because "unborn branch" no longer has to
be special-cased to "git rm --cached".
Bug: 414870
Change-Id: Ied750116f767518ae4d48823cf00752b049a8477 Signed-off-by: Robin Stocker <robin@nibor.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
OpenJDK 7 does not benefit from using an inflate stride on the input
array. The implementation of java.util.zip.Inflater supplies the
entire input byte[] to libz, with no regards for the bounds supplied.
Slicing at 512 byte increments in DfsBlock no longer has any benefit.
In OpenJDK 6 the native portion of Inflater used GetByteArrayRegion
to obtain a copy of the input buffer for libz. In this use case
supplying a small stride made sense, it avoided allocating space
for and copying data past the end of the object's compressed stream.
In OpenJDK 7 the native code uses GetPrimitiveArrayCritical,
which tries to avoid copying by freezing Java garbage collection
and accessing the byte[] contents in place. On OpenJDK 7 derived
JVMs it is likely more efficient to supply the entire DfsBlock.
Since OpenJDK 5 and 6 are deprecated and replaced by OpenJDK 7
it is reasonable to suggest any consumers running JGit with DFS
support use an OpenJDK 7 derived JVM. However, JGit still targets
local filesystem support on Java 5, so it is still not reasonble to
apply this same simplification to the internal.storage.file package.
Matthias Sohn [Fri, 30 Aug 2013 22:26:18 +0000 (00:26 +0200)]
Update build to use CBI jarsigner plugin
The dash signing plugin has been retired hence we need to update our
build to use the CBI jarsigner plugin for signing build results.
Pack test classes to enable signing them.
Also re-enable pack200 for bundle org.eclipse.jgit.
WORKAROUND: there is no easy way to run tests with maven-surefire-plugin
from signed test-jar so for a quick workaround we will have to add a
build step on Hudson so that we can run tests before signing:
- first step will do "clean, verify" to compile and run tests
- second step will do "install, deploy" with profile "eclipse-sign" and
use -DskipTests=true to skip tests since they would hit a
SecurityException when unsigned test classes are in same package as
signed classes under test
- third step will do "clean, install, deploy" on packaging reactor to
build features and p2 repository with profile "eclipse-sign" to sign
and pack200 all bundles.
TODO: Tycho doesn't suport picking up pack200 artifacts via
pomDependencies hence we need to find a way to copy them manually and
use tycho-extra's tycho-p2-extras-plugin:publish-features-and-bundles
to generate the missing p2 metadata.
Change-Id: Iec2c5ab3027a3e3f9ecc0d2f99193385177d9025 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Matthias Sohn [Thu, 22 Aug 2013 20:50:43 +0000 (22:50 +0200)]
Merge branch 'stable-3.0'
* stable-3.0:
Update reflog like C Git during rebase (non-interactive)
Make sure checkout is not deleting folders outside the workingtree
Update to Jetty 7.6.11.v20130520
Fix bugs in TreeWalk#isPathSuffix used by PathSuffixFilter
Refactor PathSuffixFilterTest to remove duplication
Check parentFile is not null
Update HEAD in cherry-picking several commits
Fix HTTP response processing for WWW-Authenticate headers
Don't skip want validation when the client sends no haves
Fix tests for OS X when the tmpdir is the default /tmp
Fix running maven http tests on OS X
Recognize CRLF when parsing the short message of a commit or tag
Update build to use Tycho 0.18
Add jgit target platform to define dependencies more precisely
Prepare 3.0.2-SNAPSHOT builds
Change-Id: Icef0cd0cce9bbccf2b2cbb3471a3f4ce0655e22c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Make sure checkout is not deleting folders outside the workingtree
There was a chance that jgit deletes symbolic links which point to the
folder on top of the working tree. Make sure not to touch these
resources.
Thanks to Cedric Darloy who reported this bug on
http://www.eclipse.org/forums/index.php/m/776910/#msg_776910 and to
Ondrej Vrabec who reported bug 412489.
Bug: 412489
Change-Id: I81735ba0394ef6794e9b2b8bdd8bd7e8b9c6460f Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Robin Stocker <robin@nibor.org>
Robin Stocker [Mon, 8 Jul 2013 08:51:52 +0000 (10:51 +0200)]
Fix bugs in TreeWalk#isPathSuffix used by PathSuffixFilter
* It didn't check the first character in the pattern due to a off-by-one
error. Spotted by James Roper.
* It returned true even when pattern was longer than current path, e.g.
it returned that ".txt" is suffix of "txt".
Bug: 411999
Change-Id: I9fbcd68a11fb57cc49956b70c387a47271a0424f Signed-off-by: Robin Stocker <robin@nibor.org>
Alex Rukhlin [Wed, 6 Mar 2013 21:35:52 +0000 (16:35 -0500)]
Fix HTTP response processing for WWW-Authenticate headers
The original code was able to process only one WWW-Authenticate
header in an HTTP response, and if this header was not one of
two expected, authentication failed regardless of that there
could be other headers in the response.
All WWW-Authenticate headers in an HTTP response have to be
browsed to find one of supported, i.e. Basic or Digest.
By that if both are present, the Digest one should be used
as more preferable.
Bug: 357719
Change-Id: Icf601a41fec63f7d40308f3c85aaa4f71a7c095b Signed-off-by: Alex Rukhlin <arukhlin@microsoft.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Robin Rosenberg [Sun, 16 Jun 2013 10:02:14 +0000 (12:02 +0200)]
Fix tests for OS X when the tmpdir is the default /tmp
/tmp is a symbolic link and some tests break when the path
gets canonicalized by JGit or Jetty. Allow Jetty to serve
symlinks by setting init parameter "aliases" to true [1].
Robin Rosenberg [Sun, 16 Jun 2013 09:28:36 +0000 (11:28 +0200)]
Fix running maven http tests on OS X
In 36144e12d8 tests were changed to use the system tmp directory as defined
by java.io.tmpdir, which was then overridden in the pom files to usea custom
directory that made som tests work, but not all.
Matthias Sohn [Fri, 31 May 2013 22:36:17 +0000 (00:36 +0200)]
Add jgit target platform to define dependencies more precisely
Avoid that the packaging build picks an older jgit version coming with
eclipse platform by using a target platform which allows to define the
dependencies more precisely.
Change-Id: I39bba3baa4517e2b5e5fe0de096e756f2904e3e9 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Lars Vogel [Thu, 25 Jul 2013 21:28:05 +0000 (23:28 +0200)]
Add missing @since tags
Change-Id: I9754e2124c0fe6ad2dbde5597c3ed10f1c3efef5 Signed-off-by: Lars Vogel <Lars.Vogel@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Colby Ranger [Thu, 8 Aug 2013 14:57:49 +0000 (07:57 -0700)]
Advertise capabilities with no refs in upload service.
With reference hiding, it is possible for a repository to appear
empty when all refs are hidden. This causes capabilities to not be
advertised either, since they are published with the first reference,
breaking fetch by SHA1 support.
Always advertise the capabilites by publishing the symbolic capabilities
reference when the repository has no references to advertise (similar to
the receive service).
Shawn Pearce [Wed, 7 Aug 2013 22:43:58 +0000 (15:43 -0700)]
Allow UploadPack requests with no options
UploadPack can be invoked with no capabilities selected by the
client if the client is an ancient version of Git that nobody in
their right mind should still be using. Or if the client is very
broken and does not want to use any of the newer features added to
the protocol since its inception.
Greg Hill [Fri, 26 Jul 2013 19:08:31 +0000 (12:08 -0700)]
Change RequestValidator parameter to ObjectId list
Instead of RevObject list, this allows a custom request validator to be called
on SHA-1's corresponding to objects that may not exist in repository storage
Change-Id: I19bb667beff0d0c144150a61d7a1dc6c9703be7f Signed-off-by: Greg Hill <greghill@google.com>
Christian Trutz [Thu, 25 Jul 2013 21:28:05 +0000 (23:28 +0200)]
Add setter for ProgressMonitor to StatusCommand
This is useful if Git.status() is a long running command.
Change-Id: I6bdbf347a688043d549c1f091fb4a264a6c7024e Signed-off-by: Christian Trutz <christian.trutz@gmail.com> Signed-off-by: Robin Stocker <robin@nibor.org>
Robin Stocker [Sat, 20 Jul 2013 14:26:05 +0000 (16:26 +0200)]
Fix NPE in openFetch on Transport without local repository
Setting the walk and other fields to null will result in NPEs when the
user e.g. calls fetch on the connection, but at least the advertised
refs can be read like that without having a local repository.
Bug: 413389
Change-Id: I39c8363e81a1c7e6cb3412ba88542ead669e69ed Signed-off-by: Robin Stocker <robin@nibor.org> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Robin Stocker [Mon, 15 Jul 2013 15:20:53 +0000 (17:20 +0200)]
Improve documentation of PathSuffixFilter
Change-Id: I1077dbb1f10c7cc687c0d1b8a8e8f763ca96977c Signed-off-by: Robin Stocker <robin@nibor.org> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Allow filtering of the status. Only files which match given paths are
inspected and only their state is reported.
Change-Id: I3c4b1b46bf297cd4ebdb4997cfa14c8752a36411 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
DirCacheCheckout had a bug when the parentdirectory of a worktree was a
symlink. DirCacheCheckout was deleting those symlinks under certain
conditions. This was fixed in I81735ba0394ef6794e9b2b8bdd8bd7e8b9c6460f
without a test because previously it was hard to setup tests containing
symlinks.
BUG: 412489
Change-Id: I2513166af519d6fc01d1eae3976ad6cff6f98530 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Make sure checkout is not deleting folders outside the workingtree
There was a chance that jgit deletes symbolic links which point to the
folder on top of the working tree. Make sure not to touch these
resources.
Thanks to Cedric Darloy who reported this bug on
http://www.eclipse.org/forums/index.php/m/776910/#msg_776910 and to
Ondrej Vrabec who reported bug 412489.
Bug: 412489
Change-Id: I81735ba0394ef6794e9b2b8bdd8bd7e8b9c6460f Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Robin Stocker <robin@nibor.org>
Robin Stocker [Mon, 8 Jul 2013 08:51:52 +0000 (10:51 +0200)]
Fix bugs in TreeWalk#isPathSuffix used by PathSuffixFilter
* It didn't check the first character in the pattern due to a off-by-one
error. Spotted by James Roper.
* It returned true even when pattern was longer than current path, e.g.
it returned that ".txt" is suffix of "txt".
Bug: 411999
Change-Id: I9fbcd68a11fb57cc49956b70c387a47271a0424f Signed-off-by: Robin Stocker <robin@nibor.org>
Make the existing concrete implementations public as well so custom
implementations may delegate to them where appropriate. Treat all custom
implementations as providing allow-tip-sha1 in want.
Dave Borowitz [Mon, 24 Jun 2013 00:02:29 +0000 (17:02 -0700)]
UploadPack: refactor want validation
Associate each RequestPolicy with an implementation of a
RequestValidator interface that contains the validation logic. The
checkWants method is only called if there are wants that were not
advertised, since clients may always request any advertised want
according to the git protocol. Calling the method only once at the
end of parsing the want list also means policy implementations can be
stateful, unlike the previous switch statement inside a loop.
For the special handling of unidirectional pipes, simply check
isBiDirectional() and delegate to other implementations if necessary.
Dave Borowitz [Tue, 18 Jun 2013 22:31:17 +0000 (15:31 -0700)]
UploadPack: configure RequestPolicy with TransportConfig
C git 1.8.2 supports setting the equivalent of RequestPolicy.TIP with
uploadpack.allowtipsha1. Parse this into TransportConfig and use it
from UploadPack. An explicitly set RequestPolicy overrides the config,
and the policy may still be upgraded on a unidirectional connection to
avoid races.
Defer figuring out the effective RequestPolicy to later in the
process. This is a minor semantic change to fix a bug: previously,
calling setRequestPolicy(ADVERTISED) _after_ calling
setBiDirectionalPipe(true) would have reintroduced the race condition
otherwise fixed by 01888db892aa9590862d886c01f3b293140db153.
Dave Borowitz [Tue, 18 Jun 2013 21:58:44 +0000 (14:58 -0700)]
Add RequestPolicy.TIP to allow fetching non-advertised ref tips
Users of UploadPack may set a custom RefFilter or AdvertisedRefsHook
that limits which refs are advertised, but clients may learn of a
SHA-1 that the server should have as a ref tip through some
alternative means. Support serving such objects from the server side
with a new RequestPolicy.
As with ADVERTISED, we need a special relaxed RequestPolicy to allow
commits reachable from the set of valid tips for unidirectional
connections.
Colby Ranger [Fri, 28 Jun 2013 17:37:56 +0000 (10:37 -0700)]
Use a bucket sort for PackReverseIndex.
Previously it took 1200ms to create a reverse index (sorted by offset).
Using a simple bucket sort algorithm, that time is reduced to 450ms.
The bucket index into the offset array is kept, in order to decrease
the binary search window.
Don't keep a copy of the offsets. Instead, use nth position
to lookup the offset in the PackIndex.