Commit Graph

3293 Commits

Author SHA1 Message Date
Saša Živkov c4797fe986 Let ObjectWalk.markUninteresting also mark the root tree as
uninteresting

Using the ObjectWalk and marking a commit as uninteresting didn't mark
its root tree as uninteresting. This caused the "missing tree ..."
error in Gerrit under special circumstances. For example, if the
patch-set 2 changes only the commit message then the patch-set 1
and patch-set 2 share the same root-tree:

  ps1 -> o   o <- ps2
          \ /
           o root-tree

The transported pack will contain the ps2 commit but not the root-tree
object.

When using the BaseReceivePack.setCheckReferencedObjectsAreReachable
JGit will check the reachability of all referenced objects not provided
in the transported pack. Since the ps1 was advertised it will properly
be marked as uninteresting. However, the root-tree was reachable because
the ObjectWalk.markUninteresting missed to mark it as uninteresting.
JGit was then rejecting the pack with the "missing tree ..." exception.

Gerrit-issue: https://code.google.com/p/gerrit/issues/detail?id=1582
Change-Id: Iff2de8810f14ca304e6655fc8debeb8f3e20712b
Signed-off-by: Saša Živkov <sasa.zivkov@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-08-28 18:05:59 -04:00
Yuxuan 'fishy' Wang 684a2a058a Handles repo manifest file without default remote.
Change-Id: Ic45919a0b695e8a6f4ed47cc060e0c41f1d7e7ea
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-08-27 16:29:19 -07:00
Shawn Pearce 49305cde19 Merge "ReceivePack: Accept shallow lines from Git >= 1.9" 2014-08-27 16:56:16 -04:00
Shawn Pearce 199dd4a9a9 ReceivePack: Accept shallow lines from Git >= 1.9
In Git 1.9 (5dbd767601 "support pushing from a shallow clone")
the git-core project intentionally broke the existing send-pack
protocol from shallow clients.

Shallow clients now transmit their shallow information during push,
ahead of the old-new command sequence. JGit must accept these lines
when presented.

To protect the server against clients sending partial history,
require the connectivity check when pushed to by a shallow client.

Change-Id: I46639366b0900052c376091e1688f07def44ab79
2014-08-27 12:45:17 -07:00
Robin Rosenberg 82f74e490a Merge "Strip "<", ">", and "\n" from name/email in UserConfig" 2014-08-22 09:19:49 -04:00
Robin Rosenberg 5797dbe9a7 Merge "Throw URISyntaxException for incorrect percent-encoding" 2014-08-21 17:47:51 -04:00
Robin Stocker ce312d8afb Strip "<", ">", and "\n" from name/email in UserConfig
This matches what C Git does, see "stripped" in `man git-commit-tree`.

It also fixes the bug of the user where an user.email like "<>" would
show up as "<<>>" in EGit.

Bug: 439844
Change-Id: I567a3c620e191ce9d37d318417e63cb5d4483419
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-08-21 23:21:27 +10:00
Yi EungJun da6e729086 Throw URISyntaxException for incorrect percent-encoding
URIish.unescape() threw an ArrayIndexOutOfBoundsException if the given
url has incorrect percent-encoding (e.g. http://example.com/%gg). But an
URISyntaxException is much better to know the reason of the failure.

Change-Id: I3f40a26d43cd2eb4e32c11aba7dc2594bc1f98e2
Signed-off-by: Yi EungJun <eungjun.yi@navercorp.com>
2014-08-21 00:45:39 +09:00
Robin Stocker 30953bbb67 Merge "Fix minor spelling error in comment" 2014-08-19 10:28:46 -04:00
Robin Rosenberg a0752f71fc Fix minor spelling error in comment
Change-Id: I320b5cd526827844d4fe0cbc0f32551010e98090
2014-08-19 16:21:59 +02:00
Christian Halstrick a086582ef2 Merge "cleanup: Remove no-longer needed API compatibility warning filters" 2014-08-19 09:57:28 -04:00
Yuxuan 'fishy' Wang 66fc834530 Support remote aliases in repo manifest.
Change-Id: Icbe5761b9d8a4ae5305bfe45b2d042f214156fc8
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-08-18 11:12:08 -07:00
Yuxuan 'fishy' Wang 5a26c538b3 Support non-default remotes in project tag.
Change-Id: I3c730a1ce379d142d3ed81dda4a73f86f1f9c3eb
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-08-18 10:57:09 -07:00
Robin Stocker 8e19fea1a9 Add tests for checking out tags with CheckoutCommand
Change-Id: Ifec3ac59264c91e154b832fdd907736faf8a8412
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-08-17 19:12:04 -04:00
Robin Stocker 4bdd0037aa Add toString to Git with repository path
Useful for debugging.

Change-Id: I78b92ccbcc099370fc99a1d2fa2cf60d5f5892e6
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-08-17 17:48:05 +10:00
Shawn Pearce 9bb891e44d ResolveMerger: Use the ObjectReader to access objects
This is necessary to ensure objects accessed by the TreeWalk come from
the associated ObjectInserter when the merger is a RecursiveMerger
instance and a virtual common base was constructed but not flushed.

Change-Id: Iebe739d30fd868ebc4f61dbfb714673146a2c3ec
2014-08-15 10:27:31 -07:00
Shawn Pearce 94c4d7eee8 Cleanup use of java.util.Inflater, fixing rare infinite loops
The native implementation of inflate() can set finished to return
true at the same time as it copies the last bytes into the buffer.

Check for finished on each iteration, terminating as soon as libz
knows the stream was completely inflated.

If not finished, it is likely input is required before the next
native call could do any useful work. Most invocations are passing
in a buffer large enough to store the entire result. A partial return
from inflate() will need more input before it can continue. Checking
right away that needsInput() is true saves a native call to determine
no bytes can be inflated without more input.

This should fix a rare infinite loop condition inside of inflation
when an object ends exactly at the end of a block boundary, and
the next block contains only the 20 byte trailing SHA-1.

When the stream is finished each new attempt to inflate() returns
n == 0, as no additional bytes were output. The needsInput() test
tries to add the length of the footer block to itself, but then loops
back around an reloads the same block as the block is smaller than
a full block size. A zero length input is set to the inflater,
which triggers needsInput() condition again.

Change-Id: I95d02bfeab4bf995a254d49166b4ae62d1f21346
2014-08-14 12:36:43 -07:00
Shawn Pearce 861f5f649f Add missing @since 3.5 tag to RepoCommand.setIncludedFileReader
Change-Id: Ib5d24f8dafacc0d12c36927c2bbc3ebef2fff7b2
2014-08-13 15:28:24 -07:00
Yuxuan 'fishy' Wang 34dd64f6fe Add support to <include> tag in repo manifest xml.
Change-Id: I32d468f92e24701ea680435bf3417e3850857303
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-08-13 13:04:28 -07:00
Shawn Pearce b1bea54113 Merge "Tweak the handling of remote url in jgit repo." 2014-08-13 16:02:57 -04:00
Shawn Pearce d70419ab00 Revert "Add a method to DfsOutputStream to read as an InputStream"
This reverts commit b646578d89.

openInputStream() is never used in JGit, nor is it used by any
known working DFS implementation. The method was added as a
utility for reading back from a DfsInserter, but the final
implementation of that feature does not requrire this method.

Change-Id: I075ad95e40af49c92b554480f8993ef5658f7684
2014-08-13 10:42:43 -07:00
Dave Borowitz 8ea4319388 Add a Merger.merge method that makes flushing optional
This allows callers performing multiple separate merges to reuse a
single ObjectInserter without flushing the inserter on each iteration
(which can be slow in the DFS case).

Change-Id: Icaff7d2bc2c20c873ce5a7d9af5002da84ae1c2b
2014-08-13 10:40:04 -07:00
Dave Borowitz 0ab3f43c85 Teach mergers to use ObjectInserter.newReader()
This allows the RecursiveMerger to iteratively create new merge bases
without necessarily flushing packs to storage in the DFS case;
flushing only need happen at the end of the whole merge process.

Since Merger's walk now depends on its inserter, we need to construct
an inserter at Merger construction time.  This should not be a
significant increase in overhead since unused inserters don't use any
resources (beyond a reference to the Repository).

We also must release and recreate the walk whenever setObjectInserter
is called, which can break usages where setObjectInserter is called in
the middle of stateful operations on the walk.  No usages of this
method within JGit currently do this; the inserter is only ever set
before any stateful walk operations happen.

Change-Id: I9682a6aa4a2c37dccef8e163f132ddb791d79103
2014-08-13 10:39:57 -07:00
Yuxuan 'fishy' Wang 38a24bc799 Tweak the handling of remote url in jgit repo.
This kind of reverted 31148. URI.resolve actually can handle the absolute URL
well, the problem is only the missing "/".

Change-Id: Iee5866c005cbc1430dc20ee7db321b8b51afed30
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-08-13 10:36:56 -07:00
Dave Borowitz e1856dbf44 Add a method to ObjectInserter to read back inserted objects
In the DFS implementation, flushing an inserter writes a new pack to
the storage system and is potentially very slow, but was the only way
to ensure previously-inserted objects were available.  For some tasks,
like performing a series of three-way merges, the total size of all
inserted objects may be small enough to avoid flushing the in-memory
buffered data.

DfsOutputStream already provides a read method to read back from the
not-yet-flushed data, so use this to provide an ObjectReader in the
DFS case.

In the file-backed case, objects are written out loosely on the fly,
so the implementation can just return the existing WindowCursor.

Change-Id: I454fdfb88f4d215e31b7da2b2a069853b197b3dd
2014-08-13 10:27:12 -07:00
Shawn Pearce 63eb9042a4 DfsInserter: buffer up to streamFileThreshold from InputStream
Since 2badedcbe0 in-core merges can write up to 10 MiB
into a TemporaryBuffer.Heap strategy, where the data is stored
as a chain of byte[] blocks.

Support the inserter reading up to the streamFileThreshold (default 50
MiB) from the supplied input stream and hash the content to determine
if the merged result blob is already present in the repository.  This
allows the inserter to avoid creating duplicate objects in more cases,
reducing repository pack file churn.

Change-Id: I38967e2a0cff14c0a856cdb46a2c8fedbeb21ed5
2014-08-12 18:55:12 -07:00
Dave Borowitz fa5582f3fe Merger: clarify getBaseCommit javadoc
Change-Id: Ic52475248a545d51d3d8ac31a24f0344a1241e45
2014-08-11 14:46:45 -07:00
Dave Borowitz e06082c171 Reuse Merger's ObjectReader from ResolveMerger
The base Merger class already has a single ObjectReader instance that
it handles releasing as necessary, so creating new readers is not
necessary.

Change-Id: I990ec43af7df448c7825fc1b10e62eadaa3e0c2a
2014-08-11 14:46:31 -07:00
Robin Rosenberg 06ab442b05 Merge "Fix CheckoutCommand not setting up tracking" 2014-08-11 16:23:38 -04:00
Shawn Pearce 73a687fead Merge "Process most in-core merges without local temp files" 2014-08-11 12:42:10 -04:00
Robin Rosenberg b3cbd70684 Merge "Update tycho and signing plugins to latest versions" 2014-08-11 11:26:21 -04:00
Robin Rosenberg 2bf1368a65 Merge "Update maven plugins to latest versions" 2014-08-11 11:25:57 -04:00
Matthias Sohn 0933dbd4d5 Update tycho and signing plugins to latest versions
Change-Id: I3e8b3835b8ebbb8f0a2a9be42e6c16899cb3b993
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-08-11 10:49:30 -04:00
Matthias Sohn d0e80b2f69 Update maven plugins to latest versions
Also, remove unused findbugs exclude filter in java7 bundle since latest
findbugs plugins raises an error on this.

Change-Id: I791fc054596e7d9aa9f3cc8126eb0162539c57bf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-08-11 10:48:59 -04:00
Robin Rosenberg f9e7296829 Merge "Remove redundant semicolon" 2014-08-10 04:22:08 -04:00
Robin Rosenberg c5d62caacb Merge "We should not warn for unqualifiedFieldAcces" 2014-08-10 04:21:55 -04:00
Robin Rosenberg bca12074b2 Replace deprecated method call in Java7 FTI test
Change-Id: I3bbb6da951765d79d77aa955edeac7b5e4da5d8a
2014-08-10 03:53:20 -04:00
Robin Rosenberg fb59b36967 We should not warn for unqualifiedFieldAcces
It does not make sense and I cannot explain why it slipped through.

Change-Id: I005a54cde545ea99553c0a2d6dd8d64e6e0a7611
2014-08-10 03:52:12 -04:00
Robin Rosenberg e90fefcd50 Remove redundant semicolon
Change-Id: I15370d7807c82ee85ed7fdb05061a4baf0a77a68
2014-08-10 03:47:15 -04:00
Shawn Pearce 2badedcbe0 Process most in-core merges without local temp files
Instead of always writing to disk use TemporaryBuffer.LocalFile to
store up to 10 MiB of merge result in RAM. Most source code will
fit into this limit, avoiding local disk IO for simple merges.

Larger files will automatically spool to a temporary file that
can be cleaned up in the finally, reducing the risk of leaving
them on disk and consuming space in /tmp.

Change-Id: Ieccbd9b354d4dd3d2bc1304857325ae7a9f34ec6
2014-08-08 17:53:49 -07:00
Matthias Sohn d87a2524da Merge "ResolveMerger: push result file creation into updateIndex()" 2014-08-08 18:34:47 -04:00
Shawn Pearce 2c33c725f9 ResolveMerger: push result file creation into updateIndex()
The only caller of writeMergedFile is updateIndex, and the only
user of this path object is the code within the method. This is
a no-op change that opens the door to refactoring the way temp
files are handled for inCore merges.

Change-Id: I863a303194689a806b667e55eb958e1decf046c1
2014-08-08 15:04:57 -07:00
Shawn Pearce 678a94fc66 Update Maven JAR plugins
Seems to fix the build stalls observed under some builds of the
Java 7 JRE.

Change-Id: I94d5e927b5b2ec3971e9a70c18966368a61ec14c
2014-08-08 11:32:15 -07:00
Shawn Pearce 4bd28bc958 RecursiveMerger: do not insert virtual commits into repository
When merging common ancestors to create a single virtual common
ancestor the commit does not need to be inserted into the Git
repository. Instead just mock it out in memory as part of the
merger's RevWalk pool.

Make the author and committer stable and predictable for any
given pair of merge bases. It is not necessary for the caller's
name or email to be used as the commit will not be written out.

Change-Id: I88d5ee4de121950e1b032a5c10486c9d2c42656c
2014-08-08 11:31:24 -07:00
Yuxuan 'fishy' Wang 66ad4237be Fix non-relative remote defined in manifest xml.
Currently if the remote defined in repo manifest xml is non-relative (e.g.
"https://chromium.googlesource.com"), our code will break. This change fixed
that.

It also makes that remotes are ending with "/".

Change-Id: Icef46360b32227a9db1d9bb9e6d929c72aeaa8df
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-08-06 22:26:17 -07:00
Robin Stocker 544f65e655 Fix CheckoutCommand not setting up tracking
Instead of passing on the start point as is to CreateBranchCommand, the
resolved ObjectId was used. Given this, CreateBranchCommand did not set
up tracking.

This also fixes CreateBranchCommand with setStartPoint(null) to use HEAD
(instead of NPEing), as documented in the Javadoc.

Bug: 441153
Change-Id: I5ed82b4a4b4a32a81a7fa2854636b921bcb3d471
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-08-05 23:38:07 +10:00
Matthias Sohn d846610035 Run unit tests in parallel
Configure Maven surefire plugin to run tests concurrently using
multiple processes. By default use one process per core available
on the machine running the tests.

Running this on my MacBook Pro i7 with 8 cores 16 GB RAM SSD
I get the following results:

forkCount   "mvn clean install" on org.eclipse.jgit.test
--------------------------------------------------------
1           02:36 min
2           01:26 min
4           00:56 min
6           00:49 min
8           00:49 min
10          00:51 min

When on-access scan of McAfee virus scanner is enabled the optimum
is at half the number of cores (4 of 8) on my MacBook.

Set system property "test-fork-count" to override the default.
Either set it to an absolute number e.g. "4" or in units of
cores available on the system running the build. E.g. "0.5C" to
use 4 cores on a 8 core system or "1C" to use all 8 cores on
a 8 core system.
E.g.
$ mvn clean install -Dtest-fork-count=0.5C
to use half the number of cores processes to run tests.

Change-Id: Ifdbd1ae8153f2033922eae6ae8942c36db1f9806
Signed-off-by: Sohn <matthias.sohn@sap.com>
2014-08-04 01:05:05 +02:00
Robin Rosenberg d97558fb1c Merge "Add isRebase to API of BranchConfig" 2014-08-03 07:33:28 -04:00
Robin Rosenberg b397e7b6e0 Merge "Use bitcheck to check for presence of OPT_FULL option" 2014-08-03 04:51:12 -04:00
Robin Stocker f5494c186f Add isRebase to API of BranchConfig
Change-Id: I9819f49410e30d32c2157db0556a0dd6a0bcc5a4
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-08-03 18:38:38 +10:00