Dave Borowitz [Thu, 14 Jun 2012 22:06:09 +0000 (15:06 -0700)]
Add a release() method to SubmoduleWalk
We need a way to release the underlying TreeWalk. Also, use this
method to release walks from the static factory methods on error or
when submodules are not found.
Ian Wetherbee [Thu, 7 Jun 2012 23:22:53 +0000 (16:22 -0700)]
Fix UnionInputStream.read to be more Java-like
Relax the read() method to not block until exactly "len" bytes have
been read. Instead, return when one or more bytes have been read, up
to "len", so UnionInputStream more closely resembles InputStream's
read() method.
Shawn O. Pearce [Fri, 15 Jun 2012 01:43:40 +0000 (18:43 -0700)]
Use only a single ObjectInserter in ResolveMerger
The base class supplies an ObjectInserter to its implementations
by way of the getObjectInserter method. Tracking a second inserter
instance doesn't match with the expected behavior.
Shawn O. Pearce [Thu, 14 Jun 2012 19:49:57 +0000 (12:49 -0700)]
Define ObjectInserter.Filter to wrap another ObjectInserter
Filter supports wrapping another ObjectInserter. By default all
methods are delegated to the wrapped inserter. Implementors may
override methods selectively for altered behavior.
The instance that is wrapped may be determined dynamically by code,
supporting lazy allocation of the delegate, or other patterns like
object pooling.
Shawn O. Pearce [Thu, 14 Jun 2012 19:42:39 +0000 (12:42 -0700)]
Allow applications to pass ObjectInserter to Merger
Gerrit Code Review needs to control which inserter is used by a
Merger. Allow the application to set the inserter before calling
merge, giving callers more direct control over how objects will
be created.
Matthias Sohn [Wed, 13 Jun 2012 22:20:22 +0000 (00:20 +0200)]
Merge branch 'stable-2.0'
* stable-2.0:
Prepare post v2.0.0.201206130900-r builds
JGit v2.0.0.201206130900-r
Add org.eclipse.jgit.pgm.feature to enable consumption via p2
Do not set core.autocrlf when creating repo
Change-Id: Ifdd71a6bc14d9c79f4433ebc3b53bf0042a4d4c8 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Matthias Sohn [Mon, 11 Jun 2012 22:17:55 +0000 (00:17 +0200)]
Add org.eclipse.jgit.pgm.feature to enable consumption via p2
Orion wants to consume the pgm bundle from a p2 repository in their
build. Also add corresponding source bundle and feature to provision
sources via a target platform.
Bug: 373789
Change-Id: I0016ee155553c546606b63d310666eb10bd997e1 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Robin Rosenberg [Tue, 12 Jun 2012 11:56:42 +0000 (13:56 +0200)]
Do not set core.autocrlf when creating repo
core.autorlf defaults to false, but can be set in the user or
"system" config files. Note that EGit/JGit may not know
where the "system" config file is located.
Also fix pgm's ConfigTest which depends on default repository
configuration.
Bug: 382067
Change-Id: I2c698a76e30d968e7f351b4f5a2195f0b124f62f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Dave Borowitz [Thu, 7 Jun 2012 19:08:48 +0000 (12:08 -0700)]
Expand RegexPipeline documentation
Include some behaviors that were not clear to me until I had used it a
few times.
Warn about broken behavior for capture groups that do not match. It
would be nice to support these, but even for the cases where it's
clear what the behavior should be, it would be infeasible to
implement.
For example, consider the second group of the regex "(/a)/b(/c)?"
matched against the path "/a/b". We might want getServletPath() to
return "/a/b" and getPathInfo() to return null, but this is hard to
implement: there's no easy way to say "the substring up to the point
where (/c) would have matched if it were in the string even though
it's not." And even if we could, it's not clear there is even a right
answer in the general case.
Moreover, ideally we could warn about such broken patterns at servlet
initialization time, rather than at runtime, but even answering the
question of whether there are capture groups that might not match
requires more customized regular expression parsing than we want to
embark on. Hence, the best we can do is document how it fails.
Shawn O. Pearce [Thu, 7 Jun 2012 18:37:11 +0000 (11:37 -0700)]
Merge branch 'stable-2.0'
By Robin Rosenberg (6) and others
via Gerrit Code Review @ Eclipse.org (2) and Matthias Sohn (1)
* stable-2.0:
Prepare next 2.0.0-SNAPSHOT builds
JGit v2.0.0.201206060730-rc3
Remove Jetty p2 repository from Maven build
Get rid of warnings about empty statments
Removed unused parameters from private methods
cleanup: Remove unused declarations
Make FS OS X detection work for OpenJDK
Use working tree iterator to compare file modes
Further cleanup of exceptions in Git API
Update build to use Tycho 0.15.0
Throw formal CheckoutConflictException on hard reset
Configure maven-source-plugin execution in parent POM
Support gitdir: refs in BaseRepositoryBuilder.findGitDir
Relax RevisionSyntaxException to an IllegalArgumentException
Markus Duft [Wed, 6 Jun 2012 11:14:14 +0000 (13:14 +0200)]
Make DirCacheCheckout update timestamps in the index.
This updates the timestamp of files that are not touched during
checkout. Otherwise the timestamp will always be zero, causing the
IndexDiffFilter to always calculate the checksum of file contents.
* changes:
Use BatchRefUpdate for tracking refs in FetchProcess
Batch reference updates together for storage
Expose ReceiveCommand.updateType to check for UPDATE_NONFASTFORWARD
Reject non-fast-forwards earlier in BaseReceivePack
Robin Rosenberg [Tue, 5 Jun 2012 14:52:49 +0000 (16:52 +0200)]
Further cleanup of exceptions in Git API
- Translate internal exceptions to corresponding API exception
- Do not catch GitAPI exceptions internally to an internal
exception. Just pass them to caller
- Mention thrown exceptions in javadoc
Change-Id: I9044cf86d2b0bcc8b63b7cc016e1bf0055a62053 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Matthias Sohn [Tue, 5 Jun 2012 13:45:29 +0000 (15:45 +0200)]
Update build to use Tycho 0.15.0
Also use packaging type eclipse-repository to create the p2 repository
since Tycho fixed bug 368596 which we worked around using packaging type
eclipse-update-site.
Change-Id: Id4ee884027d55cd2d43e8a6ef58a67f74ab488e4 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Kevin Sawicki [Thu, 10 May 2012 20:32:16 +0000 (13:32 -0700)]
Support gitdir: refs in BaseRepositoryBuilder.findGitDir
This allows findGitDir to be used for repositories containing
a .git file with a gitdir: ref to the repository's directory
such as submodule repositories that point to a folder under the
parent repository's .git/modules folder
Change-Id: I2f1ec7215a2208aa90511c065cadc7e816522f62 Signed-off-by: Chris Aniszczyk <zx@twitter.com>
PackWriter supports excluding objects from being written to the pack.
You may specify a PackIndex which lists all those objects which should
not go into the new pack. This feature was broken because not all
commits have been checked whether they should be excluded or not. For
other object types the exclude algorithm worked. This commit adds the
missing check.
Change-Id: Id0047098393641ccba784c58b8325175c22fcece Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Matthias Sohn [Sun, 3 Jun 2012 21:54:12 +0000 (23:54 +0200)]
Set minimum Jetty version to 7.6
This reverts commit 0c6e7d71273b2b899f35e974d5a1463ce110fa7e which
didn't work since package imports need to be different with Jetty 7.5
and 7.6. Jetty 7.6 can be installed into Eclipse SDK 3.7.2 so rather
require Jetty 7.6 instead of adding a lot of reflective code to
workaround these incompatible changes.
Change-Id: I7eb6413ecf2bc4ad7bef0c70cde45ae3fde02b2f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Matthias Sohn [Sun, 3 Jun 2012 07:30:03 +0000 (09:30 +0200)]
Fix compile error when using Jetty 7.5
Class Constraint was moved from package org.eclipse.jetty.http.security
in Jetty 7.5 to package org.eclipse.jetty.util.security in Jetty 7.6.
Hence also import package org.eclipse.jetty.security, then also Jetty
7.5, coming with Indigo, can be used to run JGit HTTP tests.
Change-Id: I26c38ec9f51b0a4fb62e1aa9f2266ada7bb2fa0c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Matthias Sohn [Sun, 3 Jun 2012 06:32:38 +0000 (08:32 +0200)]
Revert Jetty from 8.1.3.v20120416 to 7.6.0.v20120127
This reverts commit 24a0f47e32ab7cdf20c2201d7100599ea057f8a3 and
updates JGit dependencies to use the latest available Jetty 7.x
release. We can't use Jetty 8.x since it depends on Servlet API 3.0
which requires Java 6 but JGit still wants to support Java 5.
Use one of the target platforms defined in
Ibf67a6d3539fa0708a3e5dbe44fb899c56fbd8ed to work with that in Eclipse.
Change-Id: I343273d994dc7b6e0287c604e5926ff77d5b585b Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Kevin Sawicki [Thu, 10 May 2012 22:56:21 +0000 (15:56 -0700)]
Update ORIG_HEAD when resetting
Write the old object id from the RefUpdate to the
ORIG_HEAD file after the update completes.
Add two new convenience methods to Repository to read
and write the ORIG_HEAD reference similar to the methods
for reading/writing CHERRY_PICK_HEAD and MERGE_HEAD.
Robin Rosenberg [Wed, 30 May 2012 00:07:25 +0000 (02:07 +0200)]
Git API does not declare GitAPIException call() and related cleanups
All commands should throw a GitAPIException so new exceptions can be
added without breaking the builds of old code, i.e. anyone that calls
a Git API should catch GitAPIException and not just the currently known
exceptions.
Now the only checked exceptions on Git API calls are GitException and
subclasses of it. New checked exceptions that are subclasses of
GitException may be added without breaking the API.
Javadoc for GitAPIException is declared on GitCommand and
inherited to subclasses. JGitInternalException is not explicitly
documented anymore.
Unfortunately this change itself breaks the API. The intention is
that it shall be possible to add new checked subclasses of
GitAPIException without breaking the API.
Bug: 366914
EGit-Change-Id: I50380f13fc82c22d0036f47c7859cc3a77e767c5
Change-Id: I50380f13fc82c22d0036f47c7859cc3a77e767c5 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Kevin Sawicki [Fri, 11 May 2012 02:13:24 +0000 (19:13 -0700)]
Only increment mod count if packed-refs file changes
Previously if a packed-refs file was racily clean then there
was a 2.5 second window in which each call to getPackedRefs
would increment the mod count causing a RefsChangedEvent to be
fired since the FileSnapshot would report the file as modified.
If a RefsChangedListener called getRef/getRefs from the
onRefsChanged method then a StackOverflowError could occur
since the stack could be exhausted before the 2.5 second
window expired and the packed-refs file would no longer
report being modified.
Now a SHA-1 is computed of the packed-refs file and the
mod count is only incremented when the packed refs are
successfully set and the id of the new packed-refs file
does not match the id of the old packed-refs file.
Kevin Sawicki [Sun, 6 May 2012 17:17:05 +0000 (10:17 -0700)]
Retain file length and mod time when doing a mixed reset
Previously the index was cleared and updated with a new tree.
Now the commit being reset to and the index are iterated over
in a tree walk and the current index mod time and file length
are copied over to the new dir cache entry being written if
the object ids are the same.
Dariusz Luksza [Wed, 23 May 2012 00:04:04 +0000 (02:04 +0200)]
Ensure resetting on commit id
When reset command was called with tag name as parameter the resulting
HEAD was set to the tag's SHA-1 which is a bug. This patch ensures that
repository.resolve() call always returns commit id.
Change-Id: I219b898c620a75c497c8652dbf4735fd094c4d7c Signed-off-by: Dariusz Luksza <dariusz@luksza.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Shawn O. Pearce [Wed, 23 May 2012 03:13:11 +0000 (20:13 -0700)]
Use BatchRefUpdate for tracking refs in FetchProcess
If there are a lot of references to modify, using BatchRefUpdate can
save time if the underlying storage is able to combine these updates
together. This should speed up initial clone or fetch into an empty
repository, as some projects can have hundreds of release tags, or
hundreds of branch heads.
Shawn O. Pearce [Tue, 22 May 2012 23:45:06 +0000 (16:45 -0700)]
Batch reference updates together for storage
clone, fetch and push can all update multiple references in a single
command invocation. Rather than performing sequential iteration
of each reference change inside of the application code, push this
down into the reference database where the implementation can take
advantage of the batch size and optimize itself.
For the local filesystem implementation the obvious optimization
is to write a packed-refs file when the repository is completely
empty. The initial clone, fetch or push into the destination may
have hundreds of new references. Writing all of these as loose
files is not efficient. This optimization is not implemented in
this commit and is left as an exercise for the reader to supply
in a future commit to JGit.
To make the API changes simple, define the BatchRefUpdate type and
implementation using the existing sequential behavior.
Shawn O. Pearce [Tue, 22 May 2012 23:22:41 +0000 (16:22 -0700)]
Expose ReceiveCommand.updateType to check for UPDATE_NONFASTFORWARD
When a command's type is UPDATE, JGit might not yet be sure if it
is a fast-forward or not. Expose a utility method to compute the
exact type by performing the merge base test, allowing the type
to be switched to UPDATE_NONFASTFORWARD if old ObjectId is not
contained in new ObjectId.
BaseReceivePack already does this test when validating the incoming
command list, so provide a package level backdoor to set the type
and avoid needing to redo the merge test later.
Shawn O. Pearce [Tue, 22 May 2012 22:59:53 +0000 (15:59 -0700)]
Reject non-fast-forwards earlier in BaseReceivePack
If BaseReceivePack has setAllowNonFastForwards(false) configured
(such as by receive.denynonfastforwards), automatically reject
any command that attempts a non-fast-forward update before it goes
further in processing.
This matches with other checks in validateCommands(), such as the
early failure of delete attempts when isAllowDeletes() is false.
Matthias Sohn [Mon, 21 May 2012 18:51:10 +0000 (20:51 +0200)]
Fix JGit source bundle packaging
Due to Tycho bug 368596 we didn't package the correct JGit source bundle
anymore. Instead of sources it contained the binary bundle. As a
workaround fall back to use packaging type eclipse-update-site which
doesn't seem to have this problem.
Bug: 368596
Bug: 379402
Change-Id: I3192dbd00b51e6ee6596d2301050b2a6f7028e3b Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Robin Rosenberg [Mon, 21 May 2012 17:48:40 +0000 (10:48 -0700)]
Smudge index entries on first write (too), as well when reading
That happens when the index and a new file is created within the same
second and becomes a problem if we then modify the newly created file
within the same second after adding it to the index. Without smudging
JGit will, on later reads, think the file is unchanged.
The accompanying test passed with the smuding on read.
Mikael Karlsson [Fri, 18 May 2012 20:07:50 +0000 (22:07 +0200)]
Add user friendly output from jgit commit command
Instead of printing the stack trace from the JGitInternalException
thrown from CommitMessage.call(), print just the exception
message, using the Die exception.
Dave Borowitz [Thu, 3 May 2012 23:44:53 +0000 (16:44 -0700)]
Factor a base class out of ReceivePack
We are working on a publish/subscribe based git protocol, and we want to
reuse several parts of the ReceivePack-like code for reading commands
and processing a pack. In this new implementation, the connection
management will be very different, in particular, there may be multiple
packs received on a single open connection. So, hoist out as much as we
can from ReceivePack, mostly just leaving behind the single-connection
version in that class.
Matthias Sohn [Mon, 7 May 2012 21:45:24 +0000 (23:45 +0200)]
Add missing @since tags to mark API added in 2.0
Change-Id: I0a86ce0e393dfde9bb27f0b29e036e76c856396e Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Chris Aniszczyk <zx@twitter.com>
Matthias Sohn [Mon, 16 Apr 2012 15:40:43 +0000 (17:40 +0200)]
Update tycho version to 0.14.1
Tycho 0.14.1 enforces that artifactId and feature/bundle SymbolicName
must match, hence follow recommended migration practice and change
groupId of feature projects in order not to change the feature names as
this would require a feature migration.
Also migrate the p2 repository build from the deprecated packaging type
eclipse-update-site to packaging type eclipse-repository.
Change-Id: I99fc6c2bbb20efbd6514bdd9940f3535707c21bc Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Robin Rosenberg [Mon, 23 Apr 2012 20:37:50 +0000 (22:37 +0200)]
Validate paths during DirCheckout
DirCacheCheckout and CanonicalTreeParser cooperate. CanonicalTreeParser
can detect malformed, potentially malicious tree entries and sets a
flag, while DirCacheCheckout refuses to work with such paths.
Malicious tree entries are ".", "..", ".git" (case insensitive), any
name containing '/' and (on Windows '\') and also (on Windows)
any paths ending in a combination of '.' or space or containing a ':'.
We also forbid all special names like "con" etc on Windows.
Some of the test can execute on any platform by enabling partial
platform emulation.
A new runtime exception, InvalidPathException, is introduced. For
backwards compatibility it extends InvalidArgumentException.
Change-Id: I86199105814b63d4340e5de0e471d0da6b579ead Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Robin Rosenberg [Mon, 16 Apr 2012 22:18:10 +0000 (00:18 +0200)]
Enable large file support
Allow adding files with size over 2 GB. The drawback is that the tests
for huge file support adds roughly 10 minutes of execution time.
For that reason we @Ignore the test in the standard test execution.