Commit Graph

1041 Commits

Author SHA1 Message Date
Robin Rosenberg 14cd43e6df 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>
2014-02-12 01:35:25 +01:00
Robin Stocker 2852b6a07d 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>
2014-02-11 22:43:35 +01:00
Robin Rosenberg 078a9f6066 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>
2014-02-10 22:53:33 +01:00
Robin Rosenberg ff83f54d29 Failing to delete a directory with untracked content is actually ok
We had a test, but it was wrong.

Bug: 424630 
Change-Id: I926e0954c8623a323a50fe8be3ebe5e0ac6944c8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-10 11:25:02 +01:00
Robin Rosenberg e03f18941f Ban dangerous ref names in Windows
Bug: 423551 
Change-Id: I3e71ef1b4a8181f46d2902c9169859f150cd6ad0
Also-By: Robin Stocker <robin@nibor.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-05 10:47:12 +01:00
Robin Rosenberg 871ee53b52 Reset internal state canonical length in WorkingTreeIterator when moving
Bug: 426514
Change-Id: Ifb75a4fa12291aeeece3dda129a65f0c1fd5e0eb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-03 14:51:11 +01:00
Robin Rosenberg 5404e70dc6 Fix for core.autocrlf=input resulting in modified file
This version does not attempt to unsmudge, unlike the first attempt
in Idafad150553df14827eccfde2e3b95760e16a8b6.

Bug: 372834
Change-Id: I9300e735cb16d6208e1df963abb1ff69f688155d
Also-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-02-02 13:16:19 +01:00
Matthias Sohn 75b31767c4 Do not report ignored directories as untracked
Change-Id: I7e3f6b9fb1ac4b99d2cc9a78c63aad86f4fa5744
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-01-19 00:20:42 +01:00
SATO taichi 2f425cf30c Add git checkout --orphan implementation
Change-Id: I7bb583674641efed210d3cd5b86af27d7bb48e97
Signed-off-by: SATO taichi <ryushi@gmail.com>
2014-01-17 15:37:39 +09:00
Stefan Lay 3db6e05e52 Fix fast forward rebase with rebase.autostash=true
The folder .git/rebase-merge was not removed in this case. The
repository was then still in rebase state, but neither abort nor
continue worked.

Bug: 425742
Change-Id: I43cea6c9e5f3cef9d6b15643722fddecb40632d9
2014-01-15 13:23:49 +01:00
Colby Ranger ce5fd525be Upgrade javaewah to version 0.7.9
Package was renamed, so I had to update the imports. Also, I verified
bitmap serialization was still compatible.

Change-Id: I161ad3875b963b56001beab477ef8d072accee4f
2014-01-13 11:47:58 -08:00
Matthias Sohn aad7dee3ef 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>
2013-12-13 12:55:59 +01:00
Christian Halstrick ea04d2329d Don't use API exception in RebaseTodoLine
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>
2013-12-11 23:27:36 +01:00
Robin Rosenberg 3a063a0ed4 Merge "Fix aborting rebase with detached head" into stable-3.2 2013-12-10 16:15:55 -05:00
Stefan Lay e90438c0e8 Fix aborting rebase with detached head
Bug: 423670 
Change-Id: Ia6052867f85d4974c4f60ee5a6c820501e8d2427
2013-12-10 15:54:48 +01:00
Matthias Sohn 2e0d178855 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>
2013-12-06 14:27:42 +01:00
Matthias Sohn b14a939718 Prepare 3.3.0-SNAPSHOT builds
Change-Id: I7c7e7c1beec0c5d15b96c14c73ce93e3f09855c8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-12-05 22:42:47 +01:00
Stefan Lay f86a488e32 Implement rebase.autostash
This feature was introduced in native git with version 1.8.4.

Bug: 422951
Change-Id: I42f194174d64d7ada6631e2156c2a7bf93b5e91c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-12-04 22:02:22 +01:00
Christian Halstrick 77432969d3 Merge "More helpful InvalidPathException messages (include reason)" 2013-12-04 03:23:56 -05:00
Robin Stocker e0502ebb03 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>
2013-12-03 23:10:05 +01:00
Robin Stocker f4dae204a6 Fix IgnoreRule#isMatch returning wrong result due to missing reset
The matcher has to be reset before using it, as was already done in the
other cases.

Bug: 423039
Change-Id: I87abaa7ad7f0aac8651db6e88d41427cacb4d776
Also-by: Ondrej Vrabec <ovrabec@netbeans.org>
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-12-03 22:30:14 +01:00
Robin Stocker 7dc8a4f089 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>
2013-12-03 21:05:37 +01:00
Stefan Lay 591998c2d6 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>
2013-12-02 09:45:15 +01:00
Christian Halstrick af40635aba 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>
2013-11-29 22:32:36 +01:00
Stefan Lay dcd0dd4d9e Fix applying stash on other commit
Applying a stash on another commit failed because the merge base for the
cherry-pick of the stashed index state was not corectly set.

Bug: 422684
Change-Id: I9355352b2b9a7abefa3248ca3c17a9301177d0d6
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2013-11-29 10:36:53 -05:00
Shawn Pearce 53616a85ef 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.

Change-Id: I5eb177f78efd4aa8ac857d0d8b1a1fd81ca07790
2013-11-24 11:37:49 +01:00
Shawn Pearce 531d577658 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.

Change-Id: Ib5da18c832ae0cb29703706b99e99503f5cc819d
2013-11-24 05:27:21 -05:00
Shawn Pearce d54d19740a Move SampleDataRepositoryTestCase to org.eclipse.jgit.test
This class requires resources which are private to another
bundle. Move the class next to its resources, removing an
odd cross bundle dependency.

Change-Id: I30d5568b09ea5fb3bd3bb60b602f149c0867f49a
2013-11-24 05:27:14 -05:00
Matthias Sohn 7f7dd171df 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>
2013-11-23 22:06:08 -05:00
Stefan Lay 8339a07e83 Fix FIXUP error for blank lines in interactive rebase
Empty lines of discarded commit messages were added to the commit
message because they were not commented out properly.

Bug: 422246
Change-Id: I263e8a6b30a3392d8b4f09c0695505068a0a485d
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2013-11-22 16:50:44 -05:00
Stefan Lay 4feace2b9e Fix parsing Rebase todo lines when commit message is missing
Bug: 422253
Change-Id: I9739b16c91d2df31a481360a712d3479a4eeee2e
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2013-11-21 14:47:24 +01:00
Christian Halstrick 7dce16018e Add close() method to API
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>
2013-11-20 00:16:39 +01:00
Christian Halstrick 8da939221c 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 .

Change-Id: I0a19ae630186f07d0cc7fe9df246fa1cedeca8f6
2013-11-13 08:59:43 +01:00
Matthias Sohn f1c086f692 [findBugs] Remove nonsense call
Result of c.containsAll(c)  is always true for any collection c.

Change-Id: I853cbb44bdc03e2b54229bb9c36ae42e02dcc4d9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-11-10 16:01:09 -05:00
Matthias Sohn 1ec72e9a1c Remove unnecessary @SuppressWarnings("null")
Change-Id: I5bddcdab2c5cc92622144a7b207bad90cb601609
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-11-10 16:00:12 -05:00
Matthias Sohn b6cf49b2bd Don't import non-existing package org.eclipse.jgit.java7
Change-Id: Idc48cb1995050913498d2bad97a8e6e330dee94c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-11-10 00:01:51 +01:00
Stefan Lay 979e346711 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>
2013-11-08 23:43:11 +01:00
Stefan Lay 18069ffe8c Rebase interactive should finish if last step is edit
When the last step was an edit step, rebase interactive did not finish
after continuing the rebase. Instead, it returned with the status
FAST_FORWARD.

Change-Id: Ib19857474ac089dfeaae665ad5e95c66c21099b0
2013-11-06 09:43:31 +01:00
Matthias Sohn 34fbd814d4 Merge changes I40f2311c,I3c419094
* changes:
  Add additional RebaseResult for editing commits
  Add Squash/Fixup support for rebase interactive in RebaseCommand
2013-11-05 17:03:35 -05:00
Shawn Pearce b8eac43c0f Merge changes I85470d1d,I43711486,Ie6ade781,Ic9ab2b6e,Iebe50933,Id6fac253,Ia6becf30,I2af8b0ac
* 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
2013-11-05 12:41:12 -05:00
Stefan Lay cce2561e9f 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>
2013-11-05 18:05:03 +01:00
Tobias Pfeifer 765896febb 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>
2013-11-05 18:05:02 +01:00
Matthias Sohn 35331a916a 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>
2013-11-05 09:29:13 +01:00
Christian Halstrick b686fa45b6 Merge "testMaliciousPathEmpty fails on Windows" 2013-11-04 07:39:43 -05:00
Shawn Pearce 75cfa03e16 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.

Change-Id: I85470d1db2f4e80cba30f1559c0d99bdfa8ac410
2013-11-01 19:57:47 -07:00
Shawn Pearce 1c4216e4bc 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.

Change-Id: Ic9ab2b6ec74ac87ff4adda8a802ae343dd2a6235
2013-11-01 19:57:47 -07:00
Shawn Pearce cc3ec72734 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.

Change-Id: Iebe5093332343a90f51080614e083aac0d29c26d
2013-11-01 19:57:47 -07:00
Shawn Pearce e59b324095 Remove dependency on StatusCommandTest
Move the set constructor function to a Sets utility class,
allowing the tests to compile in parallel.

Change-Id: Id6fac2533fab8d423f949c892f199af2491a450b
2013-11-01 19:57:47 -07:00
Shawn Pearce 5f9656c404 Remove dependency on DiffFormatterReflowTest
Reference the resource from the root of the CLASSPATH, allowing the
test classes to be compiled in parallel with no dependencies.

Change-Id: Ia6becf30ccfe93b8585b82293d9a4863b0cf837e
2013-11-01 19:57:47 -07:00
Robin Rosenberg 98bc384d2b testMaliciousPathEmpty fails on Windows
Checking of spaces at the end of the file name caused the
test to fail for Windows only.

Bug: 396662
Change-Id: I47bcccb0fa32ce606276c3f30d454851d115ca11
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2013-11-01 16:43:46 +01:00