Matthias Sohn [Wed, 5 Mar 2014 07:46:11 +0000 (08:46 +0100)]
Update com.jcraft.jsch to 0.1.50 also in pom dependencies
We updated the target platforms in 3.3 following the version shipped
by the release train but missed to update it in pom dependencies.
This wasn't harmful as there were no API changes between 0.1.46 and
0.1.50.
Change-Id: Ie8ac2ea447fa93d6643b9817f58767ab7f0b1aa4 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
While fixing an NPE, I introduced another one in a deprecated isModified
method. It cannot avoid NPE's entirely, which is the reason the method
is deprecated
Saša Živkov [Mon, 24 Feb 2014 16:03:40 +0000 (17:03 +0100)]
Add getPackFile to ReceivePack to make PostReceiveHook more usable
Having access to the pack file that was created by the ReceivePack
may be useful for post receive hooks. For example, a hook may want
to check the size of the received pack and the created index.
Change-Id: I4d51758e4565d32c9f8892242947eb72644b847d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Matthias Sohn [Mon, 24 Feb 2014 00:19:00 +0000 (01:19 +0100)]
Package httpclient and httpcore in o.e.j.http.apache.feature
When adding the new feature o.e.j.http.apache.feature in
I4adfecd56d84ee24a50cadb1700c8be56e4172a3 in order to make the
httpclient based implementation optional I missed to also move the
apache libraries.
Change-Id: I7285458a70aee3dd6faf739b68a0b5783b8da01d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Matthias Sohn [Thu, 20 Feb 2014 21:07:48 +0000 (22:07 +0100)]
Move Apache httpclient based HTTP support to a separate bundle
This move avoids that all consumers of org.eclipse.jgit depend on Apache
httpclient. Also add another feature to make this optional for OSGi
consumers as well.
Change-Id: I5ef5e00c53678b9e1d7cfd54bbca3ff6f1c1c967 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Shawn Pearce [Fri, 14 Feb 2014 17:53:48 +0000 (09:53 -0800)]
Fix diff header on renamed or copied files
When git-core renames or copies a file and the mode differs the
header shows the mode change first, then the rename or copy data:
diff --git a/COPYING b/LICENSE
old mode 100644
new mode 100755
similarity index 92%
rename from COPYING
rename to LICENSE
index d645695..54863be
--- a/COPYING
+++ b/LICENSE
@@ -56,20 +56,6 @@
JGit relies on this ordering inside of FileHeader. Parsing "new file
mode NNN" after "copy from/to" or "rename from/to" resets the change
type to be ADD, losing the COPIED or RENAMED status and old path.
This fixes a 4 year old bug in Gerrit Code Review that prevents
opening a file for review if the file was copied from another file,
modified in this change, and the mode was updated (e.g. execute
bit was added).
Change-Id: If4c9ecd61ef0ca8e3e1ea857301f7b5c948efb96
[ms: added test case] Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Add an implementation for HttpConnection using Apache HttpClient
This change implements the http connection abstraction with the help of
org.apache.http.client.HttpClient. The default implementation used by
JGit is still the JDK HttpURLConnection. But now JGit users have the
possibility to switch completely to org.apache.httpclient. The reason
for this is that in certain (e.g. cloud) environments you are forced to
use the org.apache classes.
Change-Id: I0b357f23243ed13a014c79ba179fa327dfe318b2 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Previously all HTTP communication was done with the help of
java.net.HttpUrlConnection. In order to make JGit usable in environments
where the direct usage of such connections is not allowed but where the
environment provides other means to get network connections an
abstraction for connections is introduced. The idea is that new
implementations of this interface will be introduced which will not use
java.net.HttpUrlConnection but use e.g.
org.apache.client.http.HttpClient to provide network connections.
One example: certain cloud infrastructures don't allow that components
in the cloud communicate directly with HttpUrlConnection. Instead they
provide services where a component can ask for a connection (given a
symbolic name for the destination) and where the infrastructure returns
a preconfigured org.apache.http.client.HttpClient. In order to allow
JGit to be running in such environments we need the abstraction
introduced in this commit.
Change-Id: I3b06629f90a118bd284e55bb3f6465fe7d10463d Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Shawn Pearce [Fri, 14 Feb 2014 17:48:50 +0000 (09:48 -0800)]
Remove dead isBinary method from DiffFormatter
This method always returns false and is private so it cannot be
overridden at runtime by a subclass. Drop the method and the branch
that can never be taken.
Konrad Kügler [Sat, 18 Jan 2014 12:00:08 +0000 (13:00 +0100)]
Use branch.<x>.mergeoptions and merge.ff as defaults for merging
Read options that control squashing, whether or not to commit the merge
and regarding fast forwarding from the configuration and use them if no
explicit values for these options have been provided to MergeCommand.
Change-Id: Ifdaed4b5e4adc142657c03c8e78b709a99eeddbd Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
When the caller specifies to JGit in advance that a ref-update is a
non-fast-forward update, and that those are permitted, we should never
need to call the potentially expensive isMergedInto() check. Re-checking
that the older commit is /not/ reachable from the newer is superfluous.
Roberto Tyley [Wed, 29 Jan 2014 00:01:53 +0000 (00:01 +0000)]
Initialise ReceiveCommand status to NOT_ATTEMPTED for all constructors
Formerly the 4-arg constructor did not do this, which was unfortunate
as that constructor's the only way for an external user of JGit to set
the /type/ of the ref-update - which you might want to do to indicate
that the update is expected to be a UPDATE_NONFASTFORWARD, and thus does
not require expensive isMergedInto() calculations:
Change-Id: Ida79d335218e1c9f5c6e2ce03386ac8a1c0b212e Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Axel Richard [Tue, 3 Dec 2013 09:25:05 +0000 (10:25 +0100)]
Add some tests cases on files modes for symbolic links
Test that the file mode of a file is the one expected before and after a
checkout. Tests between symlink and file, symlink and folder, symlink
and missing.
Change-Id: If65a85a5667e25103eb9fd328a8723e29de04a1f Signed-off-by: Axel Richard <axel.richard@obeo.fr> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Robin Rosenberg [Wed, 10 Jul 2013 22:17:23 +0000 (00:17 +0200)]
Add special case to WorkingTreeIterator for matching unnormalized symlinks
If there is an unnormalized symbolic link in the index, lie that it
matches a normalized link in the working tree. This does not make the
case completely invisible everywhere though, but it helps to some
degree.
Change-Id: I599fb71648c41fa2310049d0e0040b3c9f09386b Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Robin Rosenberg [Thu, 23 Jan 2014 05:07:12 +0000 (06:07 +0100)]
Use fileAttributes to get more attributes in one go
On Windows the length reported by FileAttributes is the size
of the target file (a bug, I guess) rather than the link,
so we read the linke and look at the length of the link instead.
Bug: 353771
Change-Id: I834b06d0447f84379612b8c9190fa77093617595 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Robin Stocker [Tue, 14 Jan 2014 15:56:01 +0000 (16:56 +0100)]
Fix RevWalkUtils.findBranchesReachableFrom not finding some branches
The "cut off" optimization causes it to not include branches that
contain the specified commit but happen to share commits with a branch
that does not contain the commit.
An example:
-B foo
\
-A---C master
findBranchesReachableFrom for commit A with both branches as input may
not return master (depending on the order of the input). The reason is
that A is not contained in foo, and therefore the old code would put B
in the cutOff set. When then walking the master commits and B is
checked, it is found in the cutOff set and the walk is aborted, causing
master not to be returned even though it should.
Bug: 425674
Change-Id: I2c0c406ce5fcc9a03538b483473af930d4895d30 Signed-off-by: Robin Stocker <robin@nibor.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Robin Rosenberg [Fri, 4 Jan 2013 23:34:03 +0000 (00:34 +0100)]
Add symlink support to JGit
The change includes comparing symbolic links between disk and index,
adding symbolic links to the index, creating/modifying links on
checkout. The behavior is controlled by the core.symlinks setting, just
as C Git does. When a new repository is created core.symlinks will be
set depending on the capabilities of the operating system and Java
runtime.
If core.symlinks is set to true, the assumption is that symlinks are
supported, which may result in runtime errors if this turns out not to
be the case.
Measuring the cost of jgit status on a repository with ~70000 files,
of which ~30000 are tracked reveals a penalty of about 10% for using
the Java7 (really NIO2) support module.
Bug: 354367
Change-Id: I12f0fdd9d26212324a586896ef7eb1f6ff89c39c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Shawn Pearce [Fri, 31 Jan 2014 00:25:49 +0000 (16:25 -0800)]
Fix MissingObjectException race in ObjectDirectory
Johannes Carlsson identified a race condition[1] that can lead to
spurious MissingObjectExceptions at read time. If two threads are
active inside of ObjectDirectory looking for a packed object and the
packList is currently the empty NO_PACKS list, thread A will find
no object and eventually consider tryAgain1(). If thread A is put
to sleep and this point and thread B also does not find the object,
loads the packs, when thread A wakes up its tryAgain1 would return
false and the thread never considers the packs.
Rework the internal API of ObjectDirectory to keep a handle on the
exact PackList that was iterated by thread A, allowing it to always
retry walking through the packs if the new PackList is different.
This had some ripple effect into the CachedObjectDirectory and
the shared FileObjectDatabase interface. The new code should be
slightly easier to follow, especially from the perspective of the
CachedObjectDirectory trying to minimize the number of open system
calls it makes to files matching "$GIT_DIR/objects/??/?x{38}".
Shawn Pearce [Wed, 29 Jan 2014 00:29:15 +0000 (16:29 -0800)]
Fix serving fetch of existing shallow client
In certain cases a JGit server updating an existing shallow client
selected a common ancestor that was behind the shallow edge of
the client. This allowed the server to assume the client had some
objects it did not have and allowed creation of pack deltas the
client could never inflate.
Any commit the client has advertised as shallow must be treated
by UploadPack server as though it has no parents. With no parents
the walker cannot visit graph history the client does not have,
and PackWriter cannot consider delta base candidates the client
is lacking.
Jonathan Nieder [Tue, 14 Jan 2014 14:43:20 +0000 (15:43 +0100)]
Update commons-compress to 1.6
Includes various fixes, including
o Writing TAR PAX headers failed if the generated entry name ended
with a "/".
Issue: COMPRESS-203.
which has been happening in the wild (java.io.IOException: request to
write '120' bytes exceeds size in header of '0' bytes for entry
'./PaxHeaders.X/hostsidetests/appsecurity/test-apps/AppAccessData/[...]/').
TODO: update orbit repository URL when new Orbit R-build is available,
see bug 425660
Change-Id: I92a87543a6ace9a06a70a29534399608cee6adb1 Signed-off-by: Jonathan Nieder <jrn@google.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Jonathan Nieder [Sat, 2 Nov 2013 03:28:58 +0000 (20:28 -0700)]
archive: Use an empty directory for submodules
When encountering a submodule entry, "jgit archive" tries to write its
content verbatim as an entry to the archive, which fails with a
JGitInternalException wrapping a MissingObjectException because the
submodule repository commits are typically not part of the
superproject.
When a subproject is available (for example because it has been
checked out as a subdirectory of a superproject worktree), it would be
nice to recurse into it and make one archive recording the state of
the entire project. Unfortunately sometimes the subproject is not
available or it can be hard to find (e.g., it can be on another
server). Even when some subprojects are available, "jgit archive"
should not produce different output for the same tree depending on
which subprojects it has easy access to, so there is no obvious good
default behavior that recurses without relying on access to all
subprojects.
Instead, replace each submodule entry with a placeholder empty
directory. "git archive" does the same.
Change-Id: I1295086037b77fc948b3f93c21d47341e25483e5 Signed-off-by: Jonathan Nieder <jrn@google.com>
Jonathan Nieder [Fri, 27 Dec 2013 16:55:39 +0000 (08:55 -0800)]
archive: Include entries for directories
Entries for directories are optional and mostly wasted space in most
archive formats (except as a place to hang ownership and filesystem
permissions), but "git archive" includes them. Follow suit.
This will make it easier in a later change to include empty
directories as placeholders for missing submodules.
Change-Id: I1810c686bcc9eb4d73498e4d3e763e18787b088a Signed-off-by: Jonathan Nieder <jrn@google.com>
Matthias Sohn [Thu, 19 Dec 2013 14:46:08 +0000 (15:46 +0100)]
Merge branch 'stable-3.2'
* stable-3.2:
Prepare post 3.2.0 builds
JGit v3.2.0.201312181205-r
Revert "Fix for core.autocrlf=input resulting in modified file..."
Fix for core.autocrlf=input resulting in modified file and unsmudge
Change-Id: I6650642c3511f5a41d673e561fec8204208d428d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
We found this fix uncovers problems with unsmudged DirCacheEntry's. This
surfaced because egit's ui test CreatePatchActionTest failed since jgit
computes a wrong status. JGit doesn't detect modified content in now
unsmudged entries. Hence revert this change until these problems are
fixed.
Change-Id: Ia04277ce316d35fc5b0d82c93d2078b856af24bb Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Jonathan Nieder [Tue, 17 Dec 2013 19:22:46 +0000 (11:22 -0800)]
archive: Prepend a specified prefix to all entry filenames
Common practice when distributing tarballs is to prefix all entries
with a single directory name so when the tarball is extracted it all
falls neatly into a single directory. Add a setPrefix() method to
ArchiveCommand to support this.
Change-Id: I16b2832ef98c30977f6b77b646728b83d93c196f Signed-off-by: Jonathan Nieder <jrn@google.com>
Matthias Sohn [Fri, 13 Dec 2013 11:55:50 +0000 (12:55 +0100)]
Merge branch 'stable-3.2'
* stable-3.2:
Canonicalize worktree path in BaseRepositoryBuilder if set via config
Add missing @since tags for new public methods in Config
Don't use API exception in RebaseTodoLine
Fix aborting rebase with detached head
Add recursive variant of Config.getNames() methods
Prepare post 3.2.0-m3 builds
JGit v3.2.0.201311130903-m3
Change-Id: Iad6e284e0fe2c7950f156372b334e47ebd82f3f7 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Robin Stocker [Mon, 9 Dec 2013 23:13:08 +0000 (00:13 +0100)]
Canonicalize worktree path in BaseRepositoryBuilder if set via config
This is the case for submodules in .git/modules, which typically have a
worktree config of "../../../dir". This can confuse callers, which e.g.
try to call Repository.stripWorkDir with it.
Bug: 423644
Change-Id: I0c00953f73f9316a66d0fc10eab52d8779c88f00 Signed-off-by: Robin Stocker <robin@nibor.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This came up while testing the proposed buck build for jgit. With buck
we can introduce smaller modules to allow for more concurrency during
build and to better control inner structure of jgit. Trying to put the
porcelain API into a different module than lower level implementation
classes failed since RebaseTodoLine used a porcelain API exception
causing a dependency cycle on the proposed modules. Using an exception
defined on the same abstraction level fixes this problem.
Change-Id: I26a5353e1a8fc23e67d8ce61309bd964f7665bcb Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Matthias Sohn [Sun, 1 Dec 2013 00:19:35 +0000 (01:19 +0100)]
Add recursive variant of Config.getNames() methods
These methods allow to find all configuration entry names for a given
section or section/subsection searching recursively through all base
configurations of the given configuration.
These methods are needed to calculate the names for the effective
configuration of a git repository which combines the configuration entry
names found in the repository, global and system configuration files
Bug: 396659
Change-Id: Ie3731b5e877f8686aadad3f1a46b2e583ad3b7c6 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Matthias Sohn [Wed, 4 Dec 2013 23:14:08 +0000 (00:14 +0100)]
Merge branch 'master' into stable-3.2
* master:
Implement rebase.autostash
CLI status should support --porcelain
More helpful InvalidPathException messages (include reason)
Fix IgnoreRule#isMatch returning wrong result due to missing reset
Fix exception on conflicts with recursive merge
Add pgm test for checkout of existing branch with checkout conflict
Fix broken symbolic links on Cygwin.
Do not allow non-ff-rebase if there are uncommitted changes
Manage CheckoutConflictException in pgm
Fix handling of file/folder conflicts during a checkout
Mention null return in Javadoc of Config#getString
Fix applying stash on other commit
Use static factory methods instead of overloaded constructors
Break up GCTest to run in parallel
Modify T0004_PackReaderTest to use existing pack
Move SampleDataRepositoryTestCase to org.eclipse.jgit.test
Support running from JARs in JGitTestUtil
Cache SimpleDateFormat in GitDateParser per locale
Fix FIXUP error for blank lines in interactive rebase
Fix parsing Rebase todo lines when commit message is missing
Add close() method to API
Update Jetty to 7.6.14.v20131031
Document that path parameters should use '/' as separator
Improve Javadoc for typeHint parameter
Do not update the ref hot bit when checking isIndexLoaded
Don't delete .idx file if .pack file can't be deleted
Change-Id: I02abfc09000d0fe9bdf4331c65bec7046f586179 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Robin Stocker [Sat, 10 Aug 2013 15:37:20 +0000 (17:37 +0200)]
More helpful InvalidPathException messages (include reason)
Instead of just a generic "Invalid path: $path", add a reason for the
cases where it's not obvious what the problem is (e.g. "aux" being
reserved on Windows).
Bug: 413915
Change-Id: Ia6436bd2560e4f049c92d9aac907cb87348605e0 Signed-off-by: Robin Stocker <robin@nibor.org>
Robin Stocker [Wed, 16 Oct 2013 21:51:24 +0000 (23:51 +0200)]
Fix exception on conflicts with recursive merge
When there are conflicts with a recursive merge, the conflicting paths
are stored in unmergedPaths (field in ResolveMerger). Later, when the
MergeResult is constructed in MergeCommand, getBaseCommit is called,
which computes the merge base a second time.
In case of RecursiveMerger, getBaseCommit merges the multiple merge
bases into one. It does this not by creating a new ResolveMerger but
instead calling mergeTrees. The problem with mergeTrees is that at the
end, it checks if unmergedPaths is non-empty and returns false in that
case.
Because unmergedPaths was already non-empty because of the real merge,
it thinks that there were conflicts when computing the merge base again,
when there really were none.
This can be fixed by storing the base commit when computing it and then
returning that instead of computing it a second time.
Note that another possible fix would be to just use a new ResolveMerger
for merging the merge bases instead. This would also remove the need to
remember the old value of dircache, inCore and workingTreeIterator (see
RecursiveMerger#getBaseCommit).
Bug: 419641
Change-Id: Ib2ebf4e177498c22a9098aa225e3cfcf16bbd958 Signed-off-by: Robin Stocker <robin@nibor.org>