Commit Graph

1158 Commits

Author SHA1 Message Date
Robin Rosenberg d9e07a574a Convert all JGit unit tests to JUnit 4
Eclipse has some problem re-running single JUnit tests if
the tests are in Junit 3 format, but the JUnit 4 launcher
is used. This was quite unnecessary and the move was not
completed. We still have no JUnit4 test.

This completes the extermination of JUnit3. Most of the
work was global searce/replace using regular expression,
followed by numerous invocarions of quick-fix and organize
imports and verification that we had the same number of
tests before and after.

- Annotations were introduced.
- All references to JUnit3 classes removed
- Half-good replacement for getting the test name. This was
  needed to make the TestRngs work. The initialization of
  TestRngs was also made lazily since we can not longer find
  out the test name in runtime in the @Before methods.
- Renamed test classes to end with Test, with the exception
  of TestTranslateBundle, which fails from Maven
- Moved JGitTestUtil to the junit support bundle

Change-Id: Iddcd3da6ca927a7be773a9c63ebf8bb2147e2d13
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-31 14:00:05 -08:00
Shawn Pearce 7cf8b8812f Merge "Add support for getting the system wide configuration" 2010-12-31 16:13:33 -05:00
Robin Rosenberg 797ebba307 Add support for getting the system wide configuration
These settings are stored in <prefix>/etc/gitconfig. The C Git
binary is installed in <prefix>/bin, so we look for the C Git
executable to find this location, first by looking at the PATH
environment variable and then by attemting to launch bash as
a login shell to find out.

Bug: 333216
Change-Id: I1bbee9fb123a81714a34a9cc242b92beacfbb4a8
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2010-12-31 11:48:34 +01:00
Shawn Pearce 4da775eaff Merge "IndexPack: Use stack-based recursion for delta resolution" 2010-12-30 19:52:47 -05:00
roberto b5f0a7d7ff IndexPack: Use stack-based recursion for delta resolution
Replace 'method' with 'heap'-based recursion for resolving deltas.

Git packfile delta-chain depth can exceed 50 levels in certain files
(the packfile of the JGit project itself has >800 objects with
chain-length >50). Using method-based recursion on such packfiles will
quickly throw a StackOverflowError on VMs with constrained stack.

Benefits:

* packfile delta-resolution no longer limited by the maximum number
  of stack frames permitted on the current thread.

* slight performance improvement
  (3% speed increase on the packfile of the JGit project)

Change-Id: I1d9b3a8ba3c6d874d83cb93ebf171c6ab193e6cc
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-30 16:49:24 -08:00
Matthias Sohn 65ccadeced [findbugs] Make CheckoutResult constants final
Change-Id: I9117f212e2ad7051fdc6e7417ebc7c2d15b357a8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-12-30 23:04:43 +01:00
Robin Rosenberg 240769e023 Refactor exec of a command and reading one line into utility
Change-Id: Ia9e5afe7f29c3e5e74b8d226441ed429fb229c82
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2010-12-30 12:41:22 -08:00
Robin Rosenberg 14b358a6fb Refactor search for a file within a PATH
Change-Id: I785ab6bf1823d174394b1d2b25c5bb202535e943
2010-12-30 12:38:18 -08:00
Shawn Pearce 558879d820 Merge "Add launchers for the JGit HTTP package test" 2010-12-30 15:32:33 -05:00
Shawn Pearce a3ac82977b Merge "Enable JUnit4 in the jgit.http package too" 2010-12-30 15:31:40 -05:00
Shawn Pearce 7a1bd7adb1 Merge "Fix FileSnapShot" 2010-12-30 15:31:06 -05:00
Shawn Pearce 488307ada7 Merge "Enable use of JUnit 4 with maven" 2010-12-30 15:27:26 -05:00
Robin Rosenberg 02ae788fa6 Add launchers for the JGit HTTP package test
Change-Id: I8bb5cb5342ab86fbc586d879dc56f70f4c0e6ace
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2010-12-30 01:37:04 +01:00
Robin Rosenberg bf4ee4e6d4 Enable JUnit4 in the jgit.http package too
There are currently no JUnit4 tests here, but since we made JUnit4
the default for maven, it should be for Eclipse builds too.

Change-Id: Ic910df1705fa8d6ac26e97a41947cb8e5526d334
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2010-12-30 01:25:18 +01:00
Robin Rosenberg c3f52c62a8 Fix FileSnapShot
We cannot use SystemReader to get the time, unless we do that consistently,
which is harder to do and be sure we are really testing what we want.

Then we need to update our lastRead variable whenever we conclude that
our file is not racily clean according to lastRead. It may well be clean,
but we do not know that until we check the system clock again.

Finally add a test for this class.

Change-Id: I1894b032b9bd359d1b5325e5472d48e372599e4c
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2010-12-30 01:15:59 +01:00
Robin Rosenberg 1f25f85f4d Enable use of JUnit 4 with maven
Change-Id: If1948232ae73bc9cf1ce6ce1e953172e0a8bcee6
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2010-12-30 01:15:39 +01:00
Shawn Pearce 4170913b1b Merge "CheckoutResult: return paths instead of Files" 2010-12-29 14:29:49 -05:00
Robin Rosenberg f0ca6b5585 Enable use of JUnit 4 with the jgit.test project
Some enablement was done earlier, but we need to add the org.junit package
and hamcrest to make it work.

junit.textui removed, probably a mistake at some time in the past.

Change-Id: I6922a2f40eb0c077a8ade5ed073ecf0e90425544
2010-12-28 17:14:32 +01:00
Shawn O. Pearce 6533994bc9 Fix ArrayIndexOutOfBoundsException in DirCacheIterator
If the 'TREE' extension contains an invalid subtree that has
been removed, DirCacheIterator still tried to access it due to
an invalid childCnt field within the parent DirCacheTree object.
This is easy for a user to do, they just need to move all files
out of a subdirectory.

For example, the input for the JUnit test case for this bug was
built using the following C Git sequence:

  mkdir -p a/b
  touch a/b/c q
  git add a/b/c q
  git write-tree
  git mv a/b/c a/a

After the last step, the subdirectory a/b is empty, as its only
file was moved into the parent directory.  Because of the earlier
`git write-tree` operation, there is a 'TREE' extension present, but
the a and a/b subdirectories have been marked invalid by the rename.

When JGit tried to iterate over the a tree, it tried to correct
childCnt to be zero as a/b no longer exists, but it failed to
update childCnt.

Change-Id: I7a0f78fc48a36b1a83252d354618f6807fca0426
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-22 14:11:22 -08:00
Shawn O. Pearce edeea800a6 DirCacheIteratorTest: Use newInCore instead of disk
Avoid the dependency on the local filesystem by using only an in-core
DirCache instance.  Each test case builds up the index from scratch
anyway through a DirCacheBuilder.

Change-Id: I5decf6bffc3ed35bf1d3e4ad5cc095891c80b772
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-22 13:39:38 -08:00
Shawn O. Pearce 0cd76ab65d Correct GIT_INDEX_FILE environment variable
This is GIT_INDEX_FILE, not GIT_INDEX.

Change-Id: Ib3af28ba196f74c8cb4d318b57ea346bb90f9a1e
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-22 11:26:33 -08:00
Mathias Kinzler e272ca0f14 CheckoutResult: return paths instead of Files
As discussed in

http://egit.eclipse.org/r/#change,2127

we should use paths relative the working directory instead of Files to
notify the caller about conflicts and nondeleted files.

Change-Id: I034c7bd846f0df78d97bc246f38d411f29713dde
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2010-12-21 10:06:19 +01:00
Chris Aniszczyk 8f419dc5e6 Merge "FileBasedConfig: Use FileSnapshot for isOutdated()" 2010-12-20 12:06:00 -05:00
Mathias Kinzler f91ee9afcc Fix CheckoutCommandTest
Change-Id: Ieacae01de20d7729ef34e6e6a1523fbaf9db41a8
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2010-12-20 16:54:41 +01:00
Mathias Kinzler befeff16e7 Fix JDK 6 Usage of String.getBytes(Charset)
Change-Id: I619b00d8a3b0770c9fd1dc3314794f915ea80604
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2010-12-20 16:52:52 +01:00
Mathias Kinzler 89a4dcf71f Checkout: fix handling if name does not refer to a local branch
The CheckoutCommand does not handle names other than local branch
names properly; it must detach HEAD if such a name is encountered (for
example a commit ID or a remote tracking branch).

Change-Id: I5d55177f4029bcc34fc2649fd564b125a2929cc4
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-12-20 09:30:40 -06:00
Shawn O. Pearce 0c22243c4a clone: Use DirCacheCheckout
This simple change lets us get rid of WorkDirCheckout from JGit,
and all of its supporting code.

Change-Id: I1a5aabe9ab4a2b156fd37cc7e9ededb4ed70f53a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-12-20 09:28:29 -06:00
Chris Aniszczyk a92bda5adf Merge "Extract pack directory last modified check code" 2010-12-20 10:27:33 -05:00
Shawn O. Pearce d02f01e7c8 Remove deprecated WriteTree from tests
These tests doesn't need to use WriteTree anymore.  There are
other means of creating tree objects in the repository that aren't
deprecated, so use those instead.

Change-Id: I89cd8ab54c66964a5fddc0a045f1c0f1c7c49055
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-20 09:22:02 -06:00
Mathias Kinzler 645d262de6 Checkout: expose a CheckoutResult
This is needed by callers to determine checkout conflicts and
possible files that were not deleted during the checkout so that they
can present the end user with a better Exception description and retry
to delete the undeleted files later, respectively.

Change-Id: I037930da7b1a4dfb24cfa3205afb51dc29e4a5b8
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2010-12-20 10:21:49 +01:00
Robin Rosenberg 94a2cbb407 Fix wrong javadoc comment in Repository
Change-Id: I9fc084b48418884ce1ccf16d56e800f1d3594885
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2010-12-19 11:03:23 +01:00
Robin Rosenberg 33c6eb848e Merge "Move TransferConfig to transport package" 2010-12-18 10:43:26 -05:00
Matthias Sohn 485917598e Qualify post 0.10 builds
Change-Id: Ifcb8fdea95286779c8aea6bf4d7647e8c1c98d63
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-12-17 15:49:30 +01:00
Matthias Sohn 67d8f3a338 Merge branch 'stable-0.10' 2010-12-17 15:41:27 +01:00
Matthias Sohn 51d1af9489 Qualify post 0.10.1 builds
Change-Id: I320f1f739f3689daf11d532a55ae1133785aec8e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-12-17 15:23:14 +01:00
Matthias Sohn 1fdc17bfe4 JGit 0.10.1
Change-Id: I4a46d35d354193e5d4f28ef7dfae75944be8ffcf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-12-17 03:10:07 +01:00
Mathias Kinzler 73f36aa8f7 DirCacheCheckout: fix getToBeDeleted()
This wrongly returns the same as getConflicts()
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>

Change-Id: Id37c625458fc5a9b3987f05b684620e24fdfe852
2010-12-16 08:41:36 +01:00
Shawn O. Pearce 34454465c2 Move TransferConfig to transport package
This doesn't belong in the main lib package.

Change-Id: Idb20bf5849138b34a7277250fe0795c2a1f22447
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-15 17:04:03 -08:00
Shawn Pearce c19093bbad Merge "Do not rely on filemode differences in case of symbolic links" 2010-12-15 18:55:59 -05:00
Shawn O. Pearce 3922e026e0 FileBasedConfig: Use FileSnapshot for isOutdated()
Relying only on the last modified time for a file can be tricky.
The "racy git" problem may cause some modifications to be missed.

Use the new FileSnapshot code to track when a configuration file
has been modified, and needs to be reloaded in memory.

Change-Id: Ib6312fdd3b2403eee5af3f8ae711294b0e5f9035
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-15 15:14:05 -08:00
Shawn O. Pearce c8db22f355 Extract pack directory last modified check code
Pulling the last modified checking logic out of ObjectDirectory
makes it possible to reuse this code for other files, such as
the $GIT_DIR/config or $GIT_DIR/packed-refs files.

Change-Id: If2f27a89fc3b7adde7e65ff40bbca5d55b98b772
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-15 15:14:05 -08:00
Shawn O. Pearce 6f3b4d5d04 Save StoredConfig after modifications
When the Config is changed, it should be saved back to its local
file.  This ensure that a future call to getConfig() won't wipe
out the edits that were just made.

Change-Id: Id46d3f85d1c9b377f63ef861b72824e1aa060eee
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-15 15:14:05 -08:00
Shawn O. Pearce 013cb8de38 Reduce calls to Repository.getConfig
Each time getConfig() is called on FileRepository, it checks the
last modified time of both ~/.gitconfig and $GIT_DIR?config.  If
$GIT_DIR/config appears to have been modified, it is read back in
from disk and the current config is wiped out.

When mutating a configuration file, this may cause in-memory edits
to disappear.  To avoid that callers need to avoid calling getConfig
until after the configuration has been saved to disk.

Unfortunately the API is still horribly broken.  Configuration should
be modified only while a lock is held on the configuration file, very
similar to the way a ref is updated via its locking protocol.  But our
existing API is really broken for that so we'll have to defer cleaning
up the edit path for a future change.

Change-Id: I5888dd97bac20ddf60456c81ffc1eb8df04ef410
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-15 15:14:05 -08:00
Shawn O. Pearce 86847ee322 Support GIT_SSH=tortoiseplink
The tortoiseplink command does not understand -batch, even though
it smells like the putty plink command that does use it.  Don't add
-batch if GIT_SSH is tortoiseplink.

Change-Id: I638532a02faa2caf8c39d482094e7ff4f4ec7e78
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-15 10:18:03 -08:00
Shawn O. Pearce 8efbd378e1 Correct plink -batch option
When GIT_SSH is set to use plink, the correct option name is "-batch"
and not "--batch".  This was a typo introduced when we added support
for plink via GIT_SSH.

Change-Id: I391660e38f5d208bba11e3f2a8f25922de2af878
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-15 10:17:01 -08:00
Philipp Thun bab053afdd Do not rely on filemode differences in case of symbolic links
When checking whether a file in the working tree has been modified -
WorkingTreeIterator.isModified() - we should not trust the filemode
in case of symbolic links, but check the timestamp and also the
content, if requested. Without this fix symlinks will always be shown
in EGit as modified files on Windows systems.

Change-Id: I367c807df5a7e85e828ddacff7fee7901441f187
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
2010-12-14 11:31:41 +01:00
Shawn O. Pearce f5434c2a86 Remove remaining uses of FileWriter
FileWriter uses the platform default encoding, which might not
be UTF-8.  JGit prefers UTF-8 everywhere for string encodings,
so make the unit tests more predictable by ensuring use of UTF-8.

Change-Id: I75bb9f962ee230b73ca3a942bffd7a8a28674ba5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-13 16:03:29 -06:00
Shawn O. Pearce 5ac5871d16 Simplify NoteParser use of prefix.length()
Sasa pointed out we only ever use the length here, so instead of
holding onto the AbbreviatedObjectId, lets just hold onto the length
as a primitive int.

Change-Id: I2444f59f9fe5ddcaea4a3537d3f1064736ae3215
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
CC: Sasa Zivkov <zivkov@gmail.com>
2010-12-13 16:01:39 -06:00
Shawn O. Pearce 2bc13104a8 Fix HTTP digest authentication
JGit's internal implementation of the HTTP digest authentication
method wasn't conforming to RFC 2617 (HTTP Authentication: Basic
and Digest Access Authentication), resulting in authentication
failures when connecting to a digest protected site.

The code now more accurately matches section 3.2.2 (The Authorization
Request Header) from the standards document.

Change-Id: If41b5c2cbdd59ddd6b2dea143f325e42cd58c395
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-13 10:11:03 -08:00
Matthias Sohn c6ca443b61 File utilities for creating directories
The java.io.File methods for creating directories report failure by
returning false. To ease proper checking of return values provide
utility methods wrapping mkdir() and mkdirs() which throw IOException
on failure.

Also fix the tests to store test data under a trash folder and cleanup
after test.

Change-Id: I09c7f9909caf7e25feabda9d31e21ce154e7fcd5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-12-13 08:47:17 -06:00