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>
Axel Richard [Thu, 28 Nov 2013 13:14:32 +0000 (14:14 +0100)]
Add pgm test for checkout of existing branch with checkout conflict
Add a test that checks out an existing branch with a dirty working tree
and involves a checkout conflict. This test should pass with a message:
"error: Your local changes to the following files would be overwritten
by checkout: a".
Change-Id: I5428a04a7630d9e0101404ea1aedd796f127bd7d Signed-off-by: Axel Richard <axel.richard@obeo.fr> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
John Ross [Thu, 21 Nov 2013 19:48:42 +0000 (13:48 -0600)]
Fix broken symbolic links on Cygwin.
Bad files from symbolic links were being generated on Cygwin and
required resolution by the appropriate FS. Pass FS to getSymRef and call
FS.resolve before asking if the file is absolute.
Bug: 419494
Change-Id: I74aa7a285954cade77f41df6f813b6dafb5d6cd7 Signed-off-by: John Ross <jwross@us.ibm.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Stefan Lay [Wed, 27 Nov 2013 10:01:47 +0000 (11:01 +0100)]
Do not allow non-ff-rebase if there are uncommitted changes
With this change jgit checks for uncommitted changes before a rebase is
started. This is also done by native git. One reason is that an abort
would override such changes. The check is skipped for a non-interactive
rebase when it will result in a fast-forward. In this case there can be
only checkout conflicts but no merge conflicts, so there cannot be an
abort which overrides uncommitted changes.
Bug: 422352
Change-Id: I1e0b59b2a4d80a686b67a6729e441924362b1236 Signed-off-by: Stefan Lay <stefan.lay@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Axel Richard [Fri, 29 Nov 2013 10:06:11 +0000 (11:06 +0100)]
Manage CheckoutConflictException in pgm
Change-Id: I49f92bf7cafc80404f0bd07d62ff4b25e4db6e7c Signed-off-by: Axel Richard <axel.richard@obeo.fr> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Fix handling of file/folder conflicts during a checkout
JGit was not handling certain file/folder conflicts during a checkout
correctly. This was reported by Axel Richard in
http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg02358.html.
This commit fixes this problem.
Still JGit behaves intentionally different than native git.
If HEAD contains a tree, and workingtree, Index and Merge contain a file
with same content ... then JGit allows a conflict free checkout of
Merge. Native git always complains that it doesn't want to overwrite
local changes. But there is no need to update the working tree because
Index and Merge are already equal.
A shell script which shows how native git behaves can be found here.
https://gist.github.com/chalstrick/7694959#file-gistfile1-sh
Change-Id: Ifd6a68974d61cd4fa23bc575f3a40773db66cafc Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Shawn Pearce [Fri, 1 Nov 2013 18:13:25 +0000 (12:13 -0600)]
Break up GCTest to run in parallel
Separate some sections of the GC tests into different test classes.
Individual classes permits running in parallel under Buck, reducing
test latency if there are sufficient CPUs available.
Shawn Pearce [Fri, 1 Nov 2013 17:32:04 +0000 (11:32 -0600)]
Modify T0004_PackReaderTest to use existing pack
Instead of making a new PackFile from a resource, lookup
the existing PackFile that was already created by the base
class SampleDataRepositoryTestCase.
Shawn Pearce [Fri, 1 Nov 2013 16:49:06 +0000 (10:49 -0600)]
Support running from JARs in JGitTestUtil
Buck invokes JUnit tests from compiled JARs, not class directories.
When copying a resource back to the filesystem a jar: style URL is
obtained from the ClassLoader.
Matthias Sohn [Tue, 5 Nov 2013 15:57:06 +0000 (16:57 +0100)]
Cache SimpleDateFormat in GitDateParser per locale
Otherwise switching to another locale yields wrong results when parsing
date strings in GitDateParser. Since the MockSystemReader explicitly
uses english locale the tests need to specify the locale to be used when
parsing date strings.
Bug: 420772
Change-Id: I313ef6b1e9ef3bfb43d929ce34712ebd21f2cd9c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
The API in org.eclipse.jgit.api does allow to open repositories but it
did not allow to close them. This commit fixes this and allows
API users to close a repository without having to use lower-level
classes.
Bug: 420502
Change-Id: I866225cc8534ae5916113fa24eb1c7513fd4472e Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Colby Ranger [Wed, 13 Nov 2013 23:19:03 +0000 (15:19 -0800)]
Do not update the ref hot bit when checking isIndexLoaded
DfsPackFile.isIndexLoaded() uses the DfsBlockCache.Ref.get() method
to check if the index loaded. However, using the get() method marks
a hot bit in the cache, which can cause the index to never be unloaded
and seem hotter than it really is. Add a has() method which only
checks if the value is not null and does not update the hot bit.
Don't delete .idx file if .pack file can't be deleted
If during an garbage collection old packfiles are deleted it could
happen that on certain platforms the index file can be deleted but the
packfile can't be deleted (because someone locked the file). This led
to repositories with packfiles without corresponding index files. Those
zombie-packfiles potentially consume a lot of space on disk and it is
never tried to delete them again. Try to avoid this situation by
deleting packfiles first and don't try to delete the other files if we
can't delete the packfile. This gives us the chance to delete the
packfile during next GC.
This commit only improves the situation - there is still the chance for
orphan files during packfile deletion. We don't have an atomic delete
of multiple files .