Commit Graph

937 Commits

Author SHA1 Message Date
Matthias Sohn 658401c8ef Merge branch 'stable-3.0'
* stable-3.0:
  Prepare post 3.0.0-rc2 builds
  JGit v3.0.0.201305281830-rc2
  Support refspecs with wildcard in middle (not only at end)
  Fix multiple bugs in RawSubStringPattern used by MessageRevFilter
  Handle short branch/tag name for setBranch in CloneCommand
  Add missing Bundle-Localization header
  Apply tree filter marks when pairing DiffEntry for renames
  Improve feature names to become understandable by end users
  Update kepler orbit version to R20130517111416
  Fix BatchRefUpdate progress-monitoring so it doesn't count twice
  Fix AnyObjectId's generic type declaration of Comparable
  Fix DiffFormatter NPEs for DiffEntry without content change
  Fix CommitCommand not to destroy repo
  Fix the parameters to an exception
  Prepare post 3.0.0 M7 builds
  JGit v3.0.0.201305080800-m7

Change-Id: Ia8441c9796f01497e0d90e672c0aaf60520a0098
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-29 12:28:10 +02:00
Matthias Sohn 0603519aad Prepare post 3.0.0-rc2 builds
Change-Id: Ic46832bcde80d0bf74c16cb094abd76b00552d14
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-29 10:37:17 +02:00
Matthias Sohn 30fad6758f JGit v3.0.0.201305281830-rc2
Change-Id: I490ad8cc7590f70783d3fbd6dd6f0e0446ae5afe
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-29 00:49:12 +02:00
Robin Stocker a51899c203 Support refspecs with wildcard in middle (not only at end)
The following refspec, which can be used to fetch GitHub pull requests,
is supported by C Git but was not yet by JGit:

  +refs/pull/*/head:refs/remotes/origin/pr/*

The reason is that the wildcard in the source is in the middle.

This change also includes more validation (e.g. "refs//heads" is not
valid) and test cases.

Bug: 405099
Change-Id: I9bcef7785a0762ed0a98ca95a0bdf8879d5702aa
2013-05-28 05:33:03 -04:00
Robin Stocker ec97912762 Fix multiple bugs in RawSubStringPattern used by MessageRevFilter
* Match at end of input was not handled correctly.
* When more than one character matched but not all, the next character
  was not considered as a match start (e.g. pattern "abab" didn't match
  input "abaabab").

Bug: 409144
Change-Id: Ia44682c618bfbb927f5567c194227421d222a160
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-28 01:40:13 +02:00
Robin Stocker 7bb2a1b844 Handle short branch/tag name for setBranch in CloneCommand
Before, it was not clear from the documentation what kind of branch name
was accepted. Users specifying "branch" (instead of "refs/heads/branch")
got no error message and ended up with a repository without HEAD and no
checkout.

With this, CloneCommand now tries "$branch", then "refs/heads/$branch"
and then "refs/tags/$branch". C Git only does the last two, but for
compatibility we should still allow "refs/heads/branch".

Bug: 390994
Change-Id: I4be13144f2a21a6583e0942f0c7c40da32f2247a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-26 01:25:10 +02:00
Roberto Tyley b4b3999f82 Fix BatchRefUpdate progress-monitoring so it doesn't count twice
I was seeing output like this while running The BFG:

Updating references:    200% (374/187)

...issue sneaked in with 5cf53fda I think.

The update call is also moved to the end of the loop, as update() is
only supposed to be called after work has been done ("Denote that some
work units have been completed").

Change-Id: I1620fa75be16dc80df44745d0e123ea512762e31
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-05-19 13:20:47 +02:00
Robin Stocker 92189b2df4 Fix DiffFormatter NPEs for DiffEntry without content change
DiffEntry.getOldId() returns null for a diff without an index line (e.g.
only mode changed, rename without content change).

Bug: 407743
Change-Id: I42eac87421f2a53c985af260a253338f578492bc
2013-05-15 12:23:40 +02:00
Christian Halstrick c93a593302 Fix CommitCommand not to destroy repo
There was a severe bug in CommitCommand which could corrupt
repos. When merging an annotated tag the JGit MergeCommand writes
correctly the ID of the tag (and not the id of the commit the tag was
pointing to) into MERGE_HEAD. Native git does the same. But
CommitCommand was reading this file and trusting blindly that it will
contain only IDs of commits. Then the CommitCommand created a
commit which has as parent a non-commit object (the tag object). That's
so corrupt that even native git gives up when you call "git log" in
such a repo.

To reproduce that with EGit simply right-click on a tag in the
Repository View and select Merge. The result was a corrupt repo!

Bug: 336291
Change-Id: I24cd5de19ce6ca7b68b4052c9e73dcc6d207b57c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-11 22:45:29 +02:00
Shawn Pearce 36144e12d8 Fix hardcoded use of target/trash in LocalDiskRepositoryTestCase
`pwd`/target is only valid in Maven Reactor builds where Maven
has moved into the project directory and created a target for
the build output. Most other build systems do not use "target"
and may not even perform a directory change between test suites.

Rewrite LocalDiskRepositoryTestCase's temporary directory code
to use the system specified location and create new unique names.
This prevents fixes between concurrently running tests and allows
the caller to specify the root using java.io.tmpdir.

Update the surefire command lines to use target within each project as
the system temporary directory during unit testing, preventing JGit's
own test suite from writing to /tmp or somewhere like C:\tmp.

Change-Id: I9e8431f6ddfc16fee89f677bcce67c99cfb56782
2013-05-08 17:59:34 -07:00
Matthias Sohn 4800ac50f9 Prepare post 3.0.0 M7 builds
Change-Id: I062c44529c7ae2f960d3c64a0923a45d2dc8a863
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-08 22:26:47 +02:00
Matthias Sohn 00108d01ff JGit v3.0.0.201305080800-m7
Change-Id: I377b174993862918a117f54e6cba4733dfc2307c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-08 13:58:26 +02:00
Matthias Sohn d7cc6eb002 Move org.eclipse.jgit.pgm's resource bundle to internal package
Translatable texts aren't API and shouldn't require maintenance of
@since tags to prevent API warnings.

Change-Id: I228ff37f17c0e792a6bc188c463a0d19138e88ac
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-06 23:48:19 +02:00
Shawn Pearce 75e1bdb3c1 Merge "URIish: Allow multiple slashes in paths" 2013-05-05 12:51:44 -04:00
Dave Borowitz b0326235e1 Remove unused repository field from RevWalk
The comment about legacy Tag and Object types no longer applies,
though prior to Idb273d5a92849b42935ac14eed73b796b80aad50 the field
was still being used by RewriteTreeFilter.

Change-Id: I9ee5da8f8a3b61c9cf543817c03117ee0609dd8f
2013-05-05 11:48:41 -04:00
Shawn Pearce a626f9fd66 Merge "Require a DiffConfig when creating a FollowFilter" 2013-05-05 11:47:53 -04:00
Dave Borowitz 0bdf030b26 Require a DiffConfig when creating a FollowFilter
The various rename detection options are an inherent part of the
filter, similar to the path being followed.

This fixes a potential NPE when a RevWalk with a FollowFilter is
created without a Repository, since the old code path tried to get
the DiffConfig from the RevWalk's possibly-missing repository.

Change-Id: Idb273d5a92849b42935ac14eed73b796b80aad50
2013-05-05 08:41:09 -07:00
Robin Rosenberg dd3181603e Extend the FS class for Java7
The most important difference is that in Java7 we have symbolic links
and for most operations in the work tree we want to operate on the link
itself rather than the link target, which the old File methods generally
do.

We also add support for the hidden attribute, which only makes sense
on Windows and exists, just since there are claims that Files.exists
is faster the File.exists.

A new bundle is only activated when run with a Java7 execution
environment. It is implemented as a fragment.

Tycho currently has no way to conditionally include optional features
based on the java version used to run the build, this means with this
change the jgit packaging build always needs to be run using java 7.

Change-Id: I3d6580d6fa7b22f60d7e54ab236898ed44954ffd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-04 02:01:56 +02:00
Robin Rosenberg b8e763fc19 TagCommand should be able to create unannotated tags too
Using the low level API's is just too cumbersome.

Change-Id: Id5b9f560ee095d6db0b2ea5b26aef3e53021626e
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-05-03 15:36:27 +02:00
Robin Stocker e8f720335f Add test for RefUpdate delete without HEAD
Bug: 406722
Change-Id: I555fb366ee64d885de2a71a67cf00833f4c62561
2013-05-03 09:18:09 -04:00
Robin Stocker f448d62d29 Update tags on fetch if --tags or tag refspec specified
When either --tags or a tag ref is explicitly specified on fetch, C Git
updates existing local tags if they are different.

Before this change, JGit returned REJECTED in such a case. Now it
updates it and returns FORCED.

Example:

    % mkdir a
    % cd a
    % git init -q
    % touch test.txt
    % git add test.txt
    % git commit -q -m 'Initial'
    % git tag v1
    % cd ..
    % git clone -q a b
    % cd a
    % echo Test > test.txt
    % git commit -q -a -m 'Second'
    % git tag -f v1
    Updated tag 'v1' (was bc85c08)
    % cd ../b
    % git fetch --tags
     - [tag update]      v1         -> v1

Bug: 388095
Change-Id: I5d5494c2ad1a2cdb8e9e614d3de445289734edfe
2013-05-01 16:02:01 +02:00
Robin Stocker 68b378a4b5 Only fetch tags that do not exist locally with auto-follow
This corresponds to what C Git does, quoting from the fetch man page:

  This is done by first fetching from the remote using the given
  <refspec>s, and if the repository has objects that are pointed by
  remote tags that it does not yet have, then fetch those missing tags.

Before, JGit would also fetch tags that exist locally but point to a
different object, resulting in REJECTED results for these.

Also add some test cases to cover more cases.

Bug: 388095
Change-Id: Ib03d2d82e9c4b60179d626cfd5174be1da6388b2
Also-by: Stefan Lay <stefan.lay@sap.com>
2013-05-01 16:00:42 +02:00
Robin Stocker 8bd1e86bb7 Abort before delete in FileUtils.delete EMPTY_DIRECTORIES_ONLY|RECURSIVE
Depending on the order in which items are traversed for RECURSIVE, an
empty directory may come first before detecting that there is a file and
aborting.

This fixes it by traversing files first.

Bug: 405558
Change-Id: I638b7da58e33ffeb0fee172b96f4c823943d29e9
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-04-29 01:00:35 +02:00
Robin Rosenberg 687b887c68 Merge "Make the Reflog a public API again" 2013-04-27 08:56:37 -04:00
Robin Stocker 23e3fb135b URIish: Allow multiple slashes in paths
It's also allowed by C Git.

Change-Id: Ie0a0d1f57d84e70fd5ef50b7844d22fea43d0e08
2013-04-27 14:35:12 +02:00
Robin Rosenberg 9dcd8c2c90 Make the Reflog a public API again
Change-Id: I8ced7098da5b345fd9af2fdfafd1ef6a44ccee0d
2013-04-26 00:57:17 +02:00
Shawn Pearce 1b4320f1fa Revert "Add tests for FileUtils.delete and EMPTY_DIREECTORIES_ONLY"
This reverts commit 7aa54967a2.
The unit test dependend upon the specific order of names that
listFiles() returned members in. The order is completely undefined
and may differ even on different versions of Linux based systems.

A proper unit test for this code would have considered both cases,
where the deletion function was able to remove an empty subdirectory,
or fail to remove a subdirectory because a file was still present
within. This is not such a test.

Change-Id: Ib0a706fea01e4b1ed8c8e859247d247a1279b4bc
2013-04-19 12:04:47 -07:00
Robin Stocker 1080cc5a0d IndexDiff: Provide stage state for conflicting entries
Adds a new method getConflictingStageStates() which returns a
Map<String, StageState> (path to stage state). StageState is an enum for
all possible stage combinations (BOTH_DELETED, ADDED_BY_US, ...).

This can be used to implement the conflict text for unmerged paths in
output of "git status" or in EGit for decorations/hints.

Bug: 403697
Change-Id: Ib461640a43111b7df4a0debe92ff69b82171329c
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2013-04-19 10:05:06 -05:00
Robin Rosenberg 1c40d83f52 Merge "A deleted work tree file is not a conflict when merge wants to delete it" 2013-04-19 07:39:39 -04:00
Robin Rosenberg f37e25e2c3 Merge "Untracked files should not be included in stash" 2013-04-19 07:36:29 -04:00
Matthias Sohn 427db940ca Do not export package org.eclipse.jgit from jgit tests
Commit 3344b93c erroneously exported the package org.eclipse.jgit.lib
from the org.eclipse.jgit.test bundle which made this a split package
since the bundle org.eclipse.jgit exports the same package. 

Split packages are evil in general and most probably caused the build
cycle errors observed recently when importing the jgit projects in
Eclipse [1].

[1] http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg02012.html

Change-Id: I89919e56b928acdbff0b90e3919808025a8562c6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-04-19 09:23:24 +02:00
Robin Rosenberg 7a42b7fb95 Untracked files should not be included in stash
The previous code stashed untracked files and left them
in the work tree.

Bug: 403282
Change-Id: I71727addb2b55fb8e409cae2b6af8138b1ff7ef1
2013-04-18 23:19:15 +02:00
Robin Rosenberg 526b6266a5 Remove some unnecessary dependencies on FileRepostory
Change-Id: Ib6ee3a2874a7e2240aa68f4ac32d00c4d1fab5ae
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2013-04-18 15:33:50 -05:00
Robin Rosenberg 6e90671a51 Merge "Remove unused dependencies" 2013-04-18 16:29:35 -04:00
Robin Stocker 78fca8a099 Improve test coverage of AutoCRLF(In|Out)putStream
Bug: 405672
Change-Id: I3894e98617fcee16dc2ac9853c203c62eb30c3ab
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2013-04-18 14:58:51 -05:00
Robin Rosenberg 4c638be79f Fix boundary conditions in AutoCRLFOutputStream
This fixes some problems with inputs around the size of the internal
buffer in AutoCRLFOutputStream (8000).

Tests supplied by Robin Stocker.

Bug: 405672
Change-Id: I6147897290392b3bfd4040e8006da39c302a3d49
2013-04-14 19:53:48 +02:00
Robin Rosenberg 4955301fac Merge "Consider working tree changes when stashing newly added files" 2013-04-11 02:06:54 -04:00
Shawn Pearce b5cbfa0146 Merge changes Ideecc472,I2b12788a,I6cb9382d,I12cd3326,I200baa0b,I05626f2e,I65e45422
* changes:
  Increase PackOutputStream copy buffer to 64 KiB
  Tighten object header writing in PackOutuptStream
  Skip main thread test in ThreadSafeProgressMonitor
  Declare members of PackOutputStream final
  Always allocate the PackOutputStream copyBuffer
  Disable CRC32 computation when no PackIndex will be created
  Steal work from delta threads to rebalance CPU load
2013-04-10 20:56:13 -04:00
Robin Rosenberg 8272f65730 Merge "LogCommand.all(): filter out refs that do not refer to commit objects" 2013-04-10 17:30:18 -04:00
Robin Rosenberg ad2ffc576b Merge "LogCommand.all(), peel references before using them" 2013-04-10 17:29:58 -04:00
Shawn Pearce d01fe32795 Skip main thread test in ThreadSafeProgressMonitor
update(int) is only invoked from a worker thread, in JGit's case
this is DeltaTask. The Javadoc of TSPM suggests update should only
ever be used by a worker thread.

Skip the main thread check, saving some cycles on each run of the
progress monitor.

Change-Id: I6cb9382d71b4cb3f8e8981c7ac382da25304dfcb
2013-04-10 12:59:11 -07:00
Robin Rosenberg 1bede91db2 Consider working tree changes when stashing newly added files
Bug: 402396
Change-Id: I50ff707c0c9abcab3f98eea21aaa6e824f7af63a
2013-04-09 21:28:15 +02:00
Matthias Sohn 135a78cfcb Remove unused dependencies
Change-Id: I3cd161ac360a2e2635bffe309725a41c9527694e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-04-09 16:57:54 +02:00
Matthias Sohn 011f7fd27d Fix plugin provider names to conform with release train requirement
According to release train requirements [1] the provider name for all
artifacts of Eclipse projects is "Eclipse <project name>".

[1] http://wiki.eclipse.org/Development_Resources/HOWTO/Release_Reviews#Checklist

Change-Id: I8445070d1d96896d378bfc49ed062a5e7e0f201f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-04-08 23:05:36 +02:00
Robin Rosenberg cc00feaa8d A deleted work tree file is not a conflict when merge wants to delete it
Bug: 405199
Change-Id: I4b2ef3dc432d2fad8a6fabd1c8aec407b5c8c5ac
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2013-04-08 22:43:39 +02:00
Tomasz Zarna 5453585773 Add the no-commit option to MergeCommand
Added also tests and the associated option for the command line Merge
command.

Bug: 335091
Change-Id: Ie321c572284a6f64765a81674089fc408a10d059
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-04-04 15:11:49 +02:00
Christian Halstrick 81b601de53 Merge "Fix PathFilterGroup not to throw StopWalkException too early" 2013-04-04 03:42:25 -04:00
Christian Halstrick ac0481039d Merge "Indicate initial commit on a branch in the reflog" 2013-04-04 03:41:56 -04:00
Robin Rosenberg c9a94dc1ee Fix PathFilterGroup not to throw StopWalkException too early
Due to the Git internal sort order a directory is sorted as if it ended
with a '/', this means that the path filter didn't set the last possible
matching entry to the correct value. In the reported issue we had the
following filters.

	org.eclipse.jgit.console
	org.eclipse.jgit

As an optimization we throw a StopWalkException when the walked tree
passes the last possible filter, which was this:
	org.eclipse.jgit.console

Due to the git sorting order, the tree was processed in this order:
	org.eclipse.jgit.console
	org.eclipse.jgit.test
	org.eclipse.jgit

At org.eclipse.jgit.test we threw the StopWalkException preventing the
walk from completing successfully.

A correct last possible match should be:
	org.eclipse.jgit/

For simplicit we define it as:
	org/eclipse/jgit/

This filter would be the maximum if we also had e.g. org and org.eclipse
in the filter, but that would require more work so we simply replace all
characters lower than '/' by a slash.

We believe the possible extra walking does not not warrant the extra
analysis.

Bug: 362430
Change-Id: I4869019ea57ca07d4dff6bfa8e81725f56596d9f
2013-04-03 14:07:23 -04:00
Robin Rosenberg 65027d8bb4 Indicate initial commit on a branch in the reflog
Bug: 393463
Change-Id: I4733d6f719bc0dc694e7a6a6ad2092de6364898c
2013-04-02 21:57:17 +02:00