RebaseCommand should ignore submodule modifications
Before a rebase happens the RebaseCommand checks that the working tree
is clean. We don't want to start a rebase on a dirty working tree. If
the working tree is dirty a rebase should not be allowed. But
RebaseCommand should ignore modifications done to submodules. E.g. if a
submodules HEAD points to <x> but the root repository has in index that
the submodule should point to <y> then this should not prohibit a
rebase. Also native git allows a rebase in this case. Since jgit's
StatusCommand has learned to ignore submodule changes this is now used
by the RebaseCommand to determine the repository state correctly.
Support for Submodule configuration submodule.<name>.ignore
For each submodule native git allows to configure which modifications to
submodules should be ignored by the status command. It is possible to
ignore "none", "all", "dirty", "untracked" [1]. This configuration is
now supported by IndexDiff. The StatusCommand offers the possibility to
specify this mode.
Andrey Loskutov [Mon, 11 Aug 2014 07:28:52 +0000 (09:28 +0200)]
Reimplementation of ignore rule parser
The current IgnoreRule/FileNameMatcher implementation scales not well
with huge repositories - it is both slow and memory expensive while
parsing glob expressions (bug 440732). Addtitionally, the "double star"
pattern (/**/) is not understood by the old parser (bug 416348).
The proposed implementation is a complete clean room rewrite of the
gitignore parser, aiming to add missing double star pattern support and
improve the performance and memory consumption.
The glob expressions from .gitignore rules are converted to Java regular
expressions (java.util.regex.Pattern). java.util.regex.Pattern code can
evaluate expression from gitignore rules considerable faster (and with
less memory consumption) as the old FileNameMatcher implementation.
Shawn Pearce [Fri, 17 Oct 2014 21:17:23 +0000 (14:17 -0700)]
Add retainOnReset(RevFlag) to RevWalk to simplify reset usage
Applications sometimes use a RevFlag instead of a Set<RevObject>
to track boolean state bits about objects being processed. However
this requires careful use of the resetRetain() methods to avoid an
accidental clearing of the RevFlag bits, effectively clearing the
Set<RevObject> the application wanted to track.
Simplify that use case by offering retainOnReset, a collection of
flags that are never cleared by the RevWalk.
Matthias Sohn [Mon, 13 Oct 2014 08:25:14 +0000 (10:25 +0200)]
Update URL of JGit Maven release repository
This repository is required to allow clirr to compare the API of the
checked out version against the API of the latest release of jgit. The
old Maven repository on the download server was replaced by Nexus a long
time back.
Change-Id: I05125407fb72531c6831ec721064b0dad278bde5 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Matthias Sohn [Thu, 25 Sep 2014 09:18:53 +0000 (11:18 +0200)]
Enable maven site generation for jgit
Generating the site:
$ mvn site:site
Local staging of the site:
$ mvn site:stage
the site is staged under ./target/staging/
If you can connect to build.eclipse.org over ssh
(ask webmaster if you are a committer and need ssh access)
you can deploy a local build of the site:
$ mvn site:deploy
The site is deployed under
http://download.eclipse.org/jgit/site/${project.version}
To select the ssh key to use for deploying over ssh add the following
section to your Maven settings.xml:
<server>
<id>jgit.website</id>
<username>username</username>
<privateKey>${user.home}/.ssh/id_rsa</privateKey>
<filePermissions>664</filePermission>
<directoryPermissions>775</directoryPermissions>
<configuration></configuration>
</server>
To deploy the site from Hudson https://hudson.eclipse.org/egit/
enable the Maven profile "build-server".
Change-Id: I7e64c8560ca75196d2232f111ffad953c14f013f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
(cherry picked from commit 6d00f0a09c67421d4ac9960c568f9c18ceb4a6a4)
When marking commits as uninteresting don't care if the tree exists
When during an ObjectWalk commits are marked as uninteresting we should
be tolerant against the situation that the commit exists in the repo but
the referenced tree is not exisiting. Since commit c4797fe98655b3d52d0a90ba44fce6e053db3b8b we are throwing
MissingObjectException in such a case. This semantic differs from native
git behaviour and may cause push operations to fail while they would
work in native git. See:
http://dev.eclipse.org/mhonarc/lists/egit-dev/msg03585.html
When marking commits as uninteresting don't care if the tree exists
When during an ObjectWalk commits are marked as uninteresting we should
be tolerant against the situation that the commit exists in the repo but
the referenced tree is not exisiting. Since commit c4797fe98655b3d52d0a90ba44fce6e053db3b8b we are throwing
MissingObjectException in such a case. This semantic differs from native
git behaviour and may cause push operations to fail while they would
work in native git. See:
http://dev.eclipse.org/mhonarc/lists/egit-dev/msg03585.html
Matthias Sohn [Fri, 26 Sep 2014 13:45:46 +0000 (15:45 +0200)]
Merge branch 'stable-3.5'
* stable-3.5:
Prepare 3.5.1-SNAPSHOT builds
JGit v3.5.0.201409260305-r
Fix PackWriterBitmapWalker handling non-existing uninteresting objects
Enable maven site generation for jgit
Generate javadocs as part of Maven site project reports
Compare API changes with clirr against 3.4.1
[cli] Use chaining credentials provider to enable .netrc
Add chaining credentials provider
[Java 8] Configure doclint to accept missing descriptions
Do not use .netrc implicitly if no CredentialsProvider was set
Prepare post 3.5.0-rc1 builds
JGit 3.5.0.201409071800-rc1
Fix the ls-remote command when there is no local repo
Change-Id: Iaa4485cac6ff9c7917380e89e12e416e0f52a557 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
When writing new packs it should be allowed to specify objects as "have"
(objects which should not be included in the pack) which do not exist in
the local repository.
This works with the traditional PackWriter, but when PackWriter was
working on a repository with bitmap indexes and used
PackWriterBitmapWalker then this feature was broken. Non-existing "have"
objects lead to MissingObjectExceptions. That broke push and Gerrit
replication. When the replication target had branches unknown to the
replication source then the source repository wanted to build pack files
where "have" included branch-tips which were unknown in the source
repository.
Bug: 427107
Change-Id: I6b6598a1ec49af68aa77ea6f1f06e827982ea4ac Also-by: Matthias Sohn <matthias.sohn@sap.com>
Matthias Sohn [Thu, 25 Sep 2014 09:18:53 +0000 (11:18 +0200)]
Enable maven site generation for jgit
Generating the site:
$ mvn site:site
Local staging of the site:
$ mvn site:stage
the site is staged under ./target/staging/
If you can connect to build.eclipse.org over ssh
(ask webmaster if you are a committer and need ssh access)
you can deploy a local build of the site:
$ mvn site:deploy
The site is deployed under
http://download.eclipse.org/jgit/site/${project.version}
To select the ssh key to use for deploying over ssh add the following
section to your Maven settings.xml:
<server>
<id>jgit.website</id>
<username>username</username>
<privateKey>${user.home}/.ssh/id_rsa</privateKey>
<filePermissions>664</filePermission>
<directoryPermissions>775</directoryPermissions>
<configuration></configuration>
</server>
To deploy the site from Hudson https://hudson.eclipse.org/egit/
enable the Maven profile "build-server".
Change-Id: I7e64c8560ca75196d2232f111ffad953c14f013f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Matthias Sohn [Wed, 17 Sep 2014 21:30:46 +0000 (23:30 +0200)]
Add chaining credentials provider
The chaining credentials provider sequentially tries to obtain
credentials from a list of credential providers and returns the
credentials from the first provider which can provide them.
Change-Id: I499f304119d7066d011dbde3556dee6facee8ab0 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
JGit should offer the possibility to do a garbage collection in
"aggressive" mode. In this mode garbage collection more aggressively
optimize the repository at the expense of taking much more time.
Technically a aggressive mode garbage collection differs from a
non-aggressive one by:
- not reusing packed objects found in old packs. Recompress every object
- the configuration pack.window is set to 250 (the default is 10)
- the configuration pack.depths is set to 250 (the default is 50)
The associated classes in org.eclipse.jgit.api and the command line
command in org.eclipse.jgit.pgm expose this new option.
The configuration parameters gc.aggressiveDepth and gc.aggressiveWindow
have been introduced to configure this feature.
Matthias Sohn [Wed, 17 Sep 2014 13:16:55 +0000 (15:16 +0200)]
Do not use .netrc implicitly if no CredentialsProvider was set
Do not silently set the NetRCCredentialsProvider if no
CredentialsProvider was set explicitly since applications may want to
have full control which provider should be used.
Bug: 444338
Change-Id: Ie096983bc1caa90443a504d302bfea8f2d26ab9e Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Matthias Sohn [Mon, 1 Sep 2014 09:27:17 +0000 (11:27 +0200)]
Prevent NPE if no CredentialsProvider is registered
If the git server requires authentication and no CredentialsProvider is
registered TransportHttp.connect() would throw an NPE since it tries to
reset the credentials provider. Instead throw a TransportException
explaining the problem.
Change-Id: Ib274e7d9c43bba301089975423de6a05ca5169f6 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Axel Richard [Fri, 29 Aug 2014 12:37:09 +0000 (14:37 +0200)]
Handle -m option for Merge command
Set the commit message to be used for the merge commit (in case one is
created)
Bug: 442886
Change-Id: Ie5ecc13822faa366f00b3daa07f74c8441cae195 Signed-off-by: Axel Richard <axel.richard@obeo.fr> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Shawn Pearce [Fri, 29 Aug 2014 19:56:17 +0000 (12:56 -0700)]
UploadPack: Always make PackWriter.Statistics available
If the packer fails, still obtain the stats and make them available
to the logger and the caller. Failures can frequently happen when
a client disconnects in the middle of a pack stream. Server admins
may still want to examine the timing metrics from counting and
compressing phases.
Saša Živkov [Tue, 5 Aug 2014 13:14:59 +0000 (15:14 +0200)]
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.
Shawn Pearce [Wed, 27 Aug 2014 17:41:59 +0000 (10:41 -0700)]
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.
Yi EungJun [Mon, 18 Aug 2014 09:46:19 +0000 (18:46 +0900)]
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>
Shawn Pearce [Fri, 15 Aug 2014 17:21:32 +0000 (10:21 -0700)]
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.
Shawn Pearce [Wed, 13 Aug 2014 23:54:22 +0000 (16:54 -0700)]
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.
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.
Dave Borowitz [Fri, 3 May 2013 18:45:36 +0000 (11:45 -0700)]
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).
Dave Borowitz [Fri, 3 May 2013 17:54:38 +0000 (10:54 -0700)]
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.
Dave Borowitz [Wed, 1 May 2013 17:20:31 +0000 (10:20 -0700)]
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.
Shawn Pearce [Tue, 12 Aug 2014 21:57:28 +0000 (14:57 -0700)]
DfsInserter: buffer up to streamFileThreshold from InputStream
Since 2badedcbe0f87c0a 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.