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 .
Stefan Lay [Wed, 6 Nov 2013 10:16:34 +0000 (11:16 +0100)]
Interactive Rebase: Do actions if there were conflicts
If a commit was marked for edit, reword, squash or fixup, but the
interactive rebase stopped because of a conflict, the step was not done
after conflict resolution. This is done now.
Change-Id: If8e7ccc50469165744f2b8a53d180f9ba0f72330 Signed-off-by: Stefan Lay <stefan.lay@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* changes:
Use absolute paths for file:// URIs in tests
Use getPath() in FileResolverTest
Extract protocol constants to a common class
Move repeat() to utility class for tests
Remove hardcoded target/trash from test cases
Remove dependency on StatusCommandTest
Remove dependency on DiffFormatterReflowTest
Remove unnecessary import of BaseConnection in MessageWriter
Stefan Lay [Tue, 22 Oct 2013 14:01:18 +0000 (16:01 +0200)]
Add additional RebaseResult for editing commits
With the new RebaseResult.EDIT a client can now distinguish if rebase
stopped due to a conflict or because the commit was marked for edit in
an interactive rebase.
Change-Id: I40f2311cf43ed5f290dcda65a7bd85ba770a85f5 Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Tobias Pfeifer [Wed, 7 Aug 2013 12:18:23 +0000 (14:18 +0200)]
Add Squash/Fixup support for rebase interactive in RebaseCommand
The rebase command now supports squash and fixup. Both actions are not
allowed as the first step of the rebase.
In JGit, before any rebase step is performed, the next commit is
already cherry-picked. This commit keeps that behaviour. In case of
squash or fixup a soft reset to the parent is perfomed afterwards.
CQ: 7684
Bug: 396510
Change-Id: I3c4190940b4d7f19860e223d647fc78705e57203 Signed-off-by: Tobias Pfeifer <to.pfeifer@web.de> Signed-off-by: Stefan Lay <stefan.lay@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Matthias Sohn [Tue, 5 Nov 2013 08:29:13 +0000 (09:29 +0100)]
Also use MockSystemReader in GitDateParserBadlyFormattedTest
All tests should use MockSystemReader to isolate them from the
underlying platform specifics.
GitDateParserBadlyFormattedTest wasn't using MockSystemReader which
induced Bug 420772 as a side effect since GitDateParser caches
SimpleDateFormat instances without regarding their locale. This will be
fixed in another change
Bug: 420772
Change-Id: I798e55d05730a71bb0326f80aea5488541d6c1f2 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Shawn Pearce [Fri, 1 Nov 2013 14:59:57 +0000 (15:59 +0100)]
Use absolute paths for file:// URIs in tests
When run under Buck the repository paths may be relative. Request
an absolute path to construct the URI, as relative paths are not
supported in file:// style URIs.
Shawn Pearce [Fri, 1 Nov 2013 17:14:14 +0000 (11:14 -0600)]
Move repeat() to utility class for tests
Avoid depending on AutoCRLFOutputStreamTest from within another
test such as AutoCRLFInputStreamTest. Breaking the dependency up
allows the test classes to be built and executed in parallel.
Shawn Pearce [Fri, 1 Nov 2013 15:04:44 +0000 (16:04 +0100)]
Remove hardcoded target/trash from test cases
Buck does not create a target directory for the build output, this
is Maven specific and the project unit tests should not rely on it.
Instead follow the pattern used by org.eclipse.jgit.test which is to
create a temporary directory in the system temporary folder, and
configure the Maven surefire plugin to use the target directory.
Tobias Pfeifer [Mon, 5 Aug 2013 10:54:23 +0000 (12:54 +0200)]
Parse commitId and shortMessage of a commented out line in rebase todo
A rebase todo file consists of regular non-comment action lines and
comment lines. In case that a regular action line has been commented out
(i.e. prefixed with a hash '#'), the RebaseTodoLine that is representing
this line should hold the values for commitId and shortMessage even
though it's a comment line. This allows to switch between comment and
non-comment easily even after the file has been persisted and reread.
Change-Id: I56ec2ba08eaf3772e2d74d937dd496209a744d4b Signed-off-by: Tobias Pfeifer <to.pfeifer@web.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Enhance reading of git-rebase-todo formatted files
Reading and writing files formatted like the git-rebase-todo files was
hidden in the RebaseCommand. Certain constructs (like leading tabs and
spaces) have not been handled as in native git. Also the upcoming
rebase interactive feature in EGit needs reading/writing these files
independently from a RebaseCommand.
Therefore reading and writing those files has been moved to the
Repository class. RebaseCommand gets smaller because of that and doesn't
have to deal with reading/writing files.
Additional tests for empty todo-list files, or files containing comments
have been added.
Change-Id: I323f3619952fecdf28ddf50139a88e0bea34f5ba Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Also-by: Tobias Pfeifer <to.pfeifer@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Michael Nelson [Mon, 26 Aug 2013 16:35:48 +0000 (09:35 -0700)]
Support extension of TransportHttp
This allows subclasses to configure the HTTP connection (for example,
to add headers to the request).
Bug: 400724
Change-Id: I6f9d699e158a7b9d813c8fa8d273992a28994e41 Signed-off-by: Michael Nelson <michael.nelson@tasktop.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Matthias Sohn [Wed, 10 Jul 2013 22:20:09 +0000 (00:20 +0200)]
Scripts to publish jgit artifacts on Maven central
- you need an account on oss.sonatype.org and permissions for group id
org.eclipse.jgit, see [1]
- install ruby [2] if necessary
- run download.rb to download the Maven artifacts from repo.eclipse.org
- then run deploy.rb to stage the artifacts on oss.sonatype.org
- follow [3] to close the staging repository which triggers some sanity
checks on Nexus
- ask community to test artifacts from staging repository
- if tests are ok release the staging repository as described in [4]
Kaloyan Raev [Wed, 9 Oct 2013 19:40:48 +0000 (22:40 +0300)]
CLI version command falls back to Bundle-Version
If the version command cannot read the Implementation-Version of the
containing JAR fall back to read the Bundle-Version header in
MANIFEST.MF. This makes the command working also from the
org.eclipse.jgit.pgm bundle and during development in a host IDE.
Colby Ranger [Tue, 8 Oct 2013 17:16:45 +0000 (10:16 -0700)]
Fix ServiceMayNotContinueException constructors for Java 1.5
IOException did not add a (String, Throwable) constructor until 1.5.
Instead use the String super constructor and initCause to initialize
the exception.
Colby Ranger [Mon, 7 Oct 2013 21:14:01 +0000 (14:14 -0700)]
Add constructors that take Throwable to ServiceMayNotContinueException.
ServiceMayNotContinueException usually wraps an underlying exception.
Add convenience constructors that take Throwable. In the case a
string is not provided, the message defaults to "internal server error",
since it may be reported to the client.
Colby Ranger [Mon, 7 Oct 2013 17:25:28 +0000 (10:25 -0700)]
Propagate IOException where possible when getting refs.
Currently, Repository.getAllRefs() and Repository.getTags() silently
ignores an IOException and instead returns an empty map. Repository
is a public API and as such cannot be changed until the next major
revision change. Where possible, update the internal jgit APIs to
use the RefDatabase directly, since it propagates the error.
Matthias Sohn [Thu, 3 Oct 2013 15:39:03 +0000 (17:39 +0200)]
Merge branch 'stable-3.1'
* stable-3.1:
Prepare post 3.1.0 builds
JGit v3.1.0.201310021548-r
Fix order of commits in rebase todo file header
Prepare post 3.1.0 RC1 builds
JGit v3.1.0.201309270735-rc1
Attempt to fix graph layout when new heads are introduced
Prepare re-signing pgm's ueberjar to avoid SecurityException
Use full branch name when getting ref in BranchTrackingStatus
Change-Id: Ida30175d0c058048cbe4b563aae7f85cd008db29 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Matthias Sohn [Tue, 24 Sep 2013 07:11:47 +0000 (09:11 +0200)]
Prepare re-signing pgm's ueberjar to avoid SecurityException
Since we now sign all build artifacts immediately after creating them
we need to re-sign the ueberjar created for jgit command line tool
because the signatures of the individual jars are invalidated when
repacking them into the ueberjar. Hence we need to exclude the
signatures of the individual jars when using maven-shade-plugin to
create the ueberjar.
Also install the shaded plugin into maven repository and exclude osgi
framework sources which were included unintentionally.
See http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg02277.html
Change-Id: Ia302e68a4b2a9399cb18025274574e31d3d3e407 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Jonathan Nieder [Tue, 24 Sep 2013 00:35:15 +0000 (17:35 -0700)]
Revert "Close unfinished archive entries on error"
This reverts commit 75d9b31f14d6226a535a80c05cffda29e55d2ceb.
Now that we do not try to close the ArchiveOutputStream in the error
path, there is no need to artificially close partial entries from
before the error.
Change-Id: I1f1cb08ec4e9b14c79bf4621f3fa959463034b82 Signed-off-by: Jonathan Nieder <jrn@google.com>
Jonathan Nieder [Tue, 24 Sep 2013 00:06:18 +0000 (17:06 -0700)]
Do not close ArchiveOutputStream on error
If we encounter an I/O error while writing an archive (for example due
to the reader of an HTTP stream closing the connection), the result is
an archive with unclosed entries, causing
TarArchiveOutputStream.finish() to throw IOException("This archives
contains unclosed entries"), hiding the IOException that caused the
early termination.
The unclosed entries are fine: the same exception that occured in the
first place will probably prevent closing the entries before finishing
this partial archive that should be discarded anyway.
It would be nicer to call TarArchiveOutputStream.finish and leave the
underlying OutputStream unclosed --- all callers close it already ---
but that would be a more invasive change so we hold off for now.
Change-Id: I328ced19aa8a1888e5353cdbb6106a85fd72d5d7 Signed-off-by: Jonathan Nieder <jrn@google.com>
Robin Stocker [Sun, 15 Sep 2013 21:26:35 +0000 (23:26 +0200)]
Use full branch name when getting ref in BranchTrackingStatus
In case there is both a tag and branch called "foo", the tag is returned
if calling getRef with the short name. By using refs/heads/foo, the
branch is returned.
Bug: 417158
Change-Id: I86b4f83955586bb24774fd621f5012499cf67909 Signed-off-by: Robin Stocker <robin@nibor.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Ignore bitmap indexes that do not match the pack checksum
If `git gc` creates a new pack with the same file name, the
pack checksum may not match that in the .bitmap. Fix the PackFile
implementaion to silently ignore invalid bitmap indexes.