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>
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>
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.
Shawn O. Pearce [Tue, 27 Mar 2012 19:32:16 +0000 (15:32 -0400)]
Index config section and subsection names in one pass
Instead of indexing the subsection names on each request for a given
section name, index both the section and subsection names in a single
scan through the entry list. This should improve lookup time for
reading the section names out of the configuration, especially for the
url.*.insteadof type of processing performed in RemoteConfig.
Markus Duft [Mon, 2 Apr 2012 05:27:19 +0000 (07:27 +0200)]
Don't use java.nio channel for file size determination
Java NIO has some problems (like files closing unexpectedly because the
thread was interrupted). To avoid those problems, don't use a NIO
channel to determine the size of a file, but rather ask the File itself.
We have to be prepared to handle wrong/outdated information in this case
too, as the inode of the File may change between opening and determining
file size.
Matthias Sohn [Sun, 1 Apr 2012 23:20:31 +0000 (01:20 +0200)]
Fix tests for Ant task "git-clone"
If project.init() isn't called GitCloneTaskTest fails when started from
Eclipse, according to [1] calling init() is necessary to properly
initialize the Ant project programmatically.
Always set the destination folder in order to ensure that all test
resources are created under the project's target folder and do not
pollute the project's source tree with test data.
Shawn O. Pearce [Wed, 28 Mar 2012 14:12:20 +0000 (10:12 -0400)]
Fix loading packed objects >2G
Parsing the size from a packed object header was incorrectly computing
the total inflated length when the length exceeded the range of a Java
int. The next 7 bits of size information was shifted left as an int
using a shift of 25 bits, placing the higher bits of the size into the
sign position. When this size was extended to a long to be added to
the current size accumulator the size went negative, resulting in
NegativeArraySizeException being thrown.
Fix all places where this particular pattern of code is used to read a
pack size field, or a binary delta header, as they both use the same
variable length encoding scheme.
Shawn O. Pearce [Tue, 27 Mar 2012 15:49:13 +0000 (11:49 -0400)]
Sort Config entries and use O(log N) lookup
Decrease running time for getStringList (and all other get methods) by
looking for configuration entries using binary search rather than
linear search through the configuration file.
Configuration lines are sorted by section, subsection, name in a
sorted list whenever the snapshot is rebuilt. Binary search is used to
locate an index in the middle of the values, then walk backwards to
find the first value in the range.
Given a configuration of file of 5000 distinct section/subsection/name
triplets (e.g. a Gerrit Code Review project.config configuration file
with 5000 unique access control rules), this new code is faster to
lookup each rule individually using getStringList():
old setStringList() 194 usec avg
getStringList() 196 usec avg
new setStringList() 188 usec avg
getStringList() 24 usec avg
Shawn O. Pearce [Tue, 27 Mar 2012 14:43:02 +0000 (10:43 -0400)]
Extract inner classes from Config
The Config class is getting very large. Extract two of its inner
classes into new top level types to reduce the size of Config.
Rename them slightly in the process.
Dave Borowitz [Mon, 26 Mar 2012 17:19:40 +0000 (10:19 -0700)]
Allow RepositoryResolver to throw ServiceMayNotContinueException
Implementations may want to send an error message to the user, which
doesn't really fit with any of the existing exception types.
ServiceMayNotContinueException, on the other hand, is documented as
always containing a user-visible error string, so use that.
Modify the git and HTTP transport mechanisms to properly relay this
message to the end user.
Kevin Sawicki [Wed, 21 Mar 2012 17:50:16 +0000 (10:50 -0700)]
Add command support for dropping a stashed commit
This extracts the logic for writing to the reflog from
RefDirectory into a new ReflogWriter class. This class
creates a public API for writing reflog entries similar
to ReflogReader for reading reflog entries.
The new command supports rewriting the stash's log to remove
a configured entry followed by updating the stash ref to
the value at the bottom of the newly written log.
Change-Id: Icfcbc70e838666769a742a94196eb8dc9c7efcc7 Signed-off-by: Chris Aniszczyk <zx@twitter.com>
Kevin Sawicki [Mon, 12 Mar 2012 17:00:52 +0000 (10:00 -0700)]
Compare repository format version as parsed long
This allows repositoryies with a missing repositoryformatversion
config value to be successfully opened but still throws exceptions
when the value is a non-long or greater than zero.
git-core attempts to parse this config value as a long as well
and defaults to 0 if the value is missing.
Bug: 368697
Change-Id: I4a93117afca37e591e8e0ab4d2f2eef4273f0cc9 Signed-off-by: Chris Aniszczyk <zx@twitter.com>
Shawn O. Pearce [Thu, 15 Mar 2012 14:57:56 +0000 (07:57 -0700)]
Clarify the purpose of ObjectInserter.buffer()
Recently Robin tried to increase the size of the buffer used by
ObjectInserter to fix a bug in the InputStream that handles AutoCRLF.
The purpose of this buffer is NOT to make a random InputStream work
correctly by passing it a larger buffer during read(byte[],int,int).
Clarify the Javadoc on the buffer() method to reduce the risk
someone tries to abuse it again.
While we are here, modify the method to load the field into a local
variable before returning. This should cut down 1 field load during
the common case of the buffer being already allocated.
Change-Id: Ic6898530d10fcd7e59f90397117a4a0d97e1f031 Signed-off-by: Chris Aniszczyk <zx@twitter.com>
Auto CRLF isn't special enough to be screwing around with the buffers
used for raw byte processing of the ObjectInserter API. If it needs a
buffer to process a file that is bigger than the buffer allocated by
an ObjectInserter, it needs to do its own buffer management.
Kevin Sawicki [Wed, 14 Mar 2012 00:01:42 +0000 (17:01 -0700)]
Only unstash files changed when originally stashed
Previously a DirCacheCheckout was done using a merge tree reflecting
the state of the repository when the stash was originally done.
This was wrong since unstashing after making subsequent commits
would undo changes already committed by checking out entries from
an outdated tree.
The new approach is to scan for conflicts initially using a 6-way
tree walk that contains the trees for the stashed HEAD, stashed
index, stashed working directory, current HEAD, current index, and
current working directory. Then perform a subsequent scan of the
stashed HEAD, index, and working directory trees and apply all
the stashed differences to the current index and working directory.
Bug: 372882
Change-Id: Ica65f162132c00a16964e838de66fc8b5cd0b0aa Signed-off-by: Chris Aniszczyk <zx@twitter.com>
Shawn O. Pearce [Tue, 13 Mar 2012 18:10:33 +0000 (11:10 -0700)]
Enable smart HTTP transport to place EOF at end of pack
When fetching over smart HTTP the InputStream that gets fed into
a PackParser doesn't really support EOF at the end of the pack. It
instead tries to make a new HTTP request, which fails because there
is no request body currently buffered by the client.
Make EOF work correctly on the end of an HTTP derived InputStream
for the pack by denoting no more requests are expected as the higher
level code is now consuming the pack (or side-band embedded pack).
Smart HTTP support doesn't automatically enqueue execute support onto
the end of the UnionInputStream, which allows the UnionInputStream
to correctly reflect EOF when the HTTP response is consumed.
* changes:
cleanup: Silence an unused-parameter warning
cleanup: Get rid of some unused-warnings
cleanup: Remove unused parameter in ConsoleCredentialsProvider
cleanup: Drop unused parameter on DhtPackParser
cleanup: Remove unneeded parameter to private method in RefUpdateTest
cleanup: Remove unnecessary @SuppressWarnings
Markus Duft [Mon, 12 Mar 2012 13:54:56 +0000 (14:54 +0100)]
Fix compilation error due to missing javadoc.
Another change introduced this problem. With default JGit project
settings there is a compilation problem as javadoc problems are set to
Error in the project preferences.