Commit Graph

423 Commits

Author SHA1 Message Date
Sasa Zivkov 7cd812940d NoteMap implements Iterable<Note>
We will need to iterate over all notes of a NoteMap, at least this will be
needed for testing purposes. This change also implied making the Note class
public.

Change-Id: I9b0639f9843f457ee9de43504b2499a673cd0e77
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
2011-01-05 08:24:13 +01:00
Shawn O. Pearce b7f887f120 Cleanup configuration of Maven JUnit runner
Set the plugin version in the top-level pom, not the unit test pom.
This ensures the same plugin is used for all JUnit tests within the
overall project.

Drop the include **/*Test.java definition, as its no longer necessary
with the JUnit 4 based test suite.  All of the test classes now end
with "Test" and include @Test annotations on the test methods.

Change-Id: Ib2c180bf531e1a97e31979fcc281fa0fc5a1abb3
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-01-02 14:35:04 -08:00
Shawn O. Pearce e026cfab38 Fix NLSTest and RootLocalTest for JUnit 4
These test classes needed new @Test annotations to be found by the
JUnit 4 test runner.

Change-Id: I61b6a8ebd468fa2d13fad5bf9cbd8f81a6f67e41
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-01-02 14:32:02 -08:00
Shawn Pearce 117d081f44 Merge "Implement a revert command" 2011-01-02 17:21:58 -05:00
Robin Rosenberg b3e59bd9d6 Implement a revert command
This is almost reverted cherry-pick, and the implementation is
almost identical. It orders the input to merge differently to get
the effect and produces a different commit message with the
default author, rather than the original author.

Change-Id: I39970091d9f7406ae7168b8efaab23a5e2c16bad
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-01-02 22:15:07 +01:00
Robin Rosenberg ff7149fb95 Require the hamcrest packaging that comes with Eclipse
The other one gets installed with SWTBot, but you do not
need it if you do not hack EGit. Using import-package
instead of require-bundle fixes the dependency. Actually
we do not need hamcrest at this time, but JUnit wants it.

Change-Id: I59873618f86d02e8439d40c1f322ea8e5c4fe3fc
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-01-01 19:05:00 +01:00
Robin Rosenberg 2465e3a653 Drop unneccessary @SuppressWarnings
Change-Id: I3a5b877efd3a58ad463c47bb663d073baea81dda
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2010-12-31 14:05:42 -08:00
Robin Rosenberg 952a86b3ad Fix TestTranslationBundle
The test was never run from maven, because its name did not end
in a way that was recognized by the pom. After rename it failed
because it did not find its resources.

Rename test class and move resources to the resources folder

Change-Id: I74a7ef1373cd902e1d05ff6ea38f8648b5fc5700
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2010-12-31 14:01:34 -08:00
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
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 7a1bd7adb1 Merge "Fix FileSnapShot" 2010-12-30 15:31:06 -05: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
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
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
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 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
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
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 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
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
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
Mathias Kinzler 9b039b42e0 Rebase: abort on unknown/unsupported command in git-rebase-todo
This is needed to ensure interoperability with the command line: if
the git-rebase-todo file was created manually (by git rebase -i in the
command line), and any commands other than pick are used (reword,
edit, fixup, squash) JGit must abort as it does not understand these
commands yet.
The same is true if an unknown command is found (e.g. due to a typo);
this is the same behavior as shown by the command line.

Change-Id: I2322014f69460361f7fc09da223e8a5c31f100dd
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2010-12-10 09:44:51 +01:00
Shawn Pearce 93a7b2b24d Merge "IndexPack: Remove blob-streaming size threshold" 2010-12-09 19:33:58 -05:00
roberto 941b3d8a81 IndexPack: Remove blob-streaming size threshold
Always use streaming (for SHA-checksum & collision detection)
when indexing whole blobs, regardless of their size.

Positives:
* benefits of bugfix #312868 will apply to all runtimes, without
  additional conf for mem-constrained JVMs (5MB huge for some)
* no byte array allocation
  (re-uses readBuffer instead of allocating new full-size array)
* mildly better overall performance
  (given the usual blob-does-not-need-collision-checking case)
* removes unnecessary code

Negative:
* doubles the disk IO for a blob comparision
  (comparitively rare occurance)

I perf-tested a range of threshold sizes against a random selection
of packfiles I found on my harddrive, the results are here:

https://spreadsheets.google.com/ccc?key=tLCQElyyd2RKN9QevfvgwGQ&hl=en_GB#gid=1

My interpretation of the results is that the streaming size threshold
isn't beneficial (actually seems to be very slightly detrimental) -so
we should just get rid of it. This tallies with some of the comments
Shawn & I had for the default value of streamFileThreshold in the
review for I862afd4c:

http://egit.eclipse.org/r/#patch,sidebyside,2040,2,org.eclipse.jgit/src/org/eclipse/jgit/transport/IndexPack.java

The perf-test code is here: https://gist.github.com/735402
It's a bit scruffy but basically does 10 runs (in randomised order)
for each threshold size on various packfiles, waiting a second
between each pack-indexing to allow GC to catch up. I know it's not
perfect - proper perf testing is hard to do :-)
2010-12-09 23:46:47 +00:00
Chris Aniszczyk a3475fb664 Merge "Add option to skip deletion of non-existing files" 2010-12-09 18:31:48 -05:00
Chris Aniszczyk bcf706d94a Merge "Add further unit tests for IndexDiffFilter" 2010-12-09 18:31:04 -05:00
Matthias Sohn cbd1ecff4d Add option to skip deletion of non-existing files
For convenience provide an option to skip deletion of non-existing
files. Also add some tests for deletion methods in FileUtils.

Change-Id: I33e355cfcdc19367d50208150ee49a4a06394890
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-12-10 00:21:23 +01:00
Philipp Thun 6736f3bae5 Add further unit tests for IndexDiffFilter
This change contains a bunch of unit tests for the newly introduced
IndexDiffFilter. With these tests the code coverage of
IndexDiffFilter.include() is now 100%, i.e. every special case is
tested at least once.

Change-Id: Ib248d1cd16084f9c8e099006af151814c63c5941
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
2010-12-09 20:34:53 +01:00
Mathias Kinzler 2a7cd0086b Rebase: fix wrong update if original HEAD after Merge+Skip
Rebase would update the original HEAD to the wrong commit when
"skipping" the last commit after a merged commit.

Includes a test for the specific situation.

Change-Id: I087314b1834a3f11a4561f04ca5c21411d54d993
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2010-12-09 19:22:11 +01:00
Christian Halstrick 1783749e16 Add a performance optimized variant of the ANY_DIFF filter
If a treewalk walks also over index and the workingtree then the
IndexDiffFilter filter can be used which works much faster then
the semantically equivalent ANY_DIFF filter. This is because this
filter can better avoid computing SHA-1 ids over the content of
working-tree files which is very costly.

This fix will significantly improve the performance of e.g.
EGit's commit dialog.

Change-Id: I2a51816f4ed9df2900c6307a54cd09f50004266f
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
2010-12-09 18:51:33 +01:00
Mathias Kinzler 6bca46e168 Implement rebase --continue and --skip
For --continue, the Rebase command asserts that there are no unmerged
paths in the current repository. Then it checks if a commit is needed.
If yes, the commit message and author are taken from the author_script
and message files, respectively, and a commit is performed before the
next step is applied.
For --skip, the workspace is reset to the current HEAD before applying
the next step.

Includes some tests and a refactoring that extracts Strings in the
code into constants.


Change-Id: I72d9968535727046e737ec20e23239fe79976179
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-12-09 16:10:21 +01:00
Shawn O. Pearce a66a7d90fd IndexDiff: Use isModified() when comparing index-worktree
The isModified() is more efficient because it can skip over files that
are stat clean, without needing to scan them.

This is useful to efficently work on paths that were already staged
and thus differ between HEAD and the index, but not between the index
and the working tree.

Change-Id: I4418202e612f0571974e0898050d987c6c280966
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-08 10:03:20 -08:00
Shawn O. Pearce 11fd0fe03a Clarify WorkingTreeOptions and filemode usage
To improve runtime performance, caching the WorkingTreeOptions inside
of the Config object using the Config.SectionParser API allows
the WorkingTreeOptions to be accessed more efficiently whenever a
FileTreeIterator is constructed for the Repository.

Instead of passing the filemode handling option into isModified(),
the WorkingTreeIterator should always honor whatever setting has
been configured in this repository, as defined by its own copy of
the WorkingTreeOptions.  This simplifies all of the callers as they
no longer need to lookup core.filemode on their own.

A few locations were changed from always using a hardcoded "true"
on the file mode to passing what is actually configured in the
repository.  This is a behavior change, but corrects what should be
considered to be bugs as the core.filemode variable wasn't always
being used.

Change-Id: Idb176736fa0dc97af372f1d652a94ecc72fb457c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-08 10:03:19 -08:00
Shawn O. Pearce c181e1ab8a IndexPack: Use streaming for large whole blobs
When indexing large blobs that are stored whole (non-delta form),
avoid allocating the entire blob in memory and instead stream it
through the SHA-1 checksum computation.  This reduces the size
of memory required by IndexPack when processing very big blobs,
such as a 500 MiB uncompressable binary.

If the large blob already exists in the local repository, its
contents needs to be compared byte-for-byte after the entire pack
has been indexed, to ensure there isn't an unexpected SHA-1 collision
which may result in later data corruption.  This compare is performed
as a streaming compare, again avoiding the large object allocation.

This change doesn't improve on memory utilization for large objects
stored as deltas.  The change also doesn't improve handling for
any large commits, trees or annotated tags.  There isn't much to
be done here for those objects, because they need to be passed down
to the ObjectChecker as a byte[].  Fortunately it isn't common for
these object types to be that large,

Bug: 312868
Change-Id: I862afd4cb78013ee033d4ec68c067b1774a05be8
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
CC: Roberto Tyley <roberto.tyley@guardian.co.uk>
2010-12-08 11:30:11 -06:00
Shawn O. Pearce a02be9725c Remove empty iterator from TreeWalk
Its confusing that a new TreeWalk() needs to have reset() invoked
on it before addTree().  This is a historical accident caused by
how TreeWalk was abused within ObjectWalk.

Drop the initial empty tree from the TreeWalk and thus remove a
number of pointless reset() operations from unit tests and some of
the internal JGit code.

Existing application code which is still calling reset() will simply
be incurring a few unnecessary field assignments, but they should
consider cleaning up their code in the future.

Change-Id: I434e94ffa43491019e7dff52ca420a4d2245f48b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-12-07 16:49:51 -08:00
Matthias Sohn 45731756a5 [findbugs] Do not ignore exceptional return value
java.io.File.delete() reports failure as an exceptional
return value false. Fix the code which silently ignored
this exceptional return value. Also remove some duplicate
deletion helper methods.

Change-Id: I80ed20ca1f07a2bc6e779957a4ad0c713789c5be
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-12-07 16:18:30 -08:00
Chris Aniszczyk a51f44edb0 Merge "Rebase Interoperability second part: fix "pop steps"" 2010-12-07 09:19:35 -05:00
Chris Aniszczyk a2469bb5d2 Merge "Add InitCommand" 2010-12-06 17:08:55 -05:00
Chris Aniszczyk 643de8323a Merge "Remove result id from CommitBuilder, TagBuilder" 2010-12-06 10:09:59 -05:00
Chris Aniszczyk f7a566c1aa Add InitCommand
Adds git-init support to the Git API.

Change-Id: I1428b861f22cabe4d92cadf3d9114dddeec75b40
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-12-05 19:01:43 -06:00
Shawn O. Pearce 064ecc25ce Fix findGitDir() with no ceiling directories
Bug: 322866
Change-Id: I64205bb0315a725dfa523ccff1796de50f465162
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
CC: Ketan Padegaonkar <KetanPadegaonkar@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-12-05 15:42:57 +01:00
Shawn O. Pearce cf52ef5531 Remove result id from CommitBuilder, TagBuilder
These objects don't need to be updated with the resulting ObjectId of
the formatted content, callers can get that from the ObjectInserter on
their own.

Change-Id: Idc5f097de9f7beafc5e54e597383d82daf9d7db4
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Reviewed-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-12-03 12:38:31 -08:00
Shawn O. Pearce f996fb1796 Correct CommitBuilder, TagBuilder method to be build()
The correct names for these is build(), as that is what a Java
developer will expect given the "builder" pattern.

Bug: 323541
Change-Id: I35042bdc95a955beeaee29e54bde10e4240b2a71
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Reviewed-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-12-03 12:28:00 -08:00
Chris Aniszczyk 39fe52ccc7 Merge "Rebase Interoperability first part: write "interactive" file" 2010-12-02 21:19:10 -05:00
Christian Halstrick deabacc420 Fixed Merge Algorithm regarding concurrent file creations
When in OURS and THEIRS a new file is created we want a conflict
when the two contents differ. If on two branches the same file
with the same content is created this should not be a conflict.
But: the current merge algorithm is throwing NPEs in this case.
Fix this by choosing an empty RawText as common base if the
base is empty.

Change-Id: I21cb23f852965b82fb82ccd66ec961c7edb3ac3d
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-12-02 13:15:59 +01:00
Mathias Kinzler 59e62ba7e1 Rebase Interoperability second part: fix "pop steps"
If the CLI stops a rebase upon conflict, the current
step is already popped from the git-rebase-todo and appended to the
"done" file. The current implementation wrongly pops the step only
after successful cherry-pick.

Change-Id: I8640dda0cbb2a5271ecf75fcbad69410122eeab6
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2010-12-01 15:10:13 +01:00
Mathias Kinzler 7aa1b85821 Rebase Interoperability first part: write "interactive" file
The Repository is then in state "Rebase interactive".

Change-Id: I5d2de57f8670e1d4c71ed22509ab17f04e2561b5
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2010-12-01 15:08:07 +01:00
Stefan Lay b4359cb829 Include list of assume unchanged files in IndexDiff
The IndexDiff had not collected the info if the flag
"assume-unchanged" is set. This information is useful for clients
which may want to decide if specific actions are allowed on a file.

Bug: 326213
Change-Id: I14bb7b03247d6c0b429a9d8d3f6b10f21d8ddeb1
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2010-11-30 10:51:21 -08:00
Stefan Lay 9225b88ae6 Check assume unchanged flag in Add command
When the assume unchanged flag is set the Add command must not update
the index for this file if any changes are present in the working
directory.

Bug: 331351
Change-Id: I255870f689225a1d88971182e0eb377952641b42
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2010-11-29 17:58:38 +01:00
Chris Aniszczyk 3da6dbaf81 Merge "Change default diff algorithm to histogram and add tests" 2010-11-26 06:04:50 -05:00
Chris Aniszczyk c9bc3ebb4c Merge "Do some more tests for rebase --abort" 2010-11-26 05:45:49 -05:00
Christian Halstrick 12a5c8d413 Change default diff algorithm to histogram and add tests
The referenced bug showed that JGit produced different merge results
compared to C Git. Unit test was added to reproduce the issue. The
problem can be solved by switching to histogram diff algorithm.

Bug: 331078
Change-Id: I54f30afb3a9fef1dbca365ca5f98f4cc846092e3
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
2010-11-26 00:44:05 +01:00
Christian Halstrick 049827d708 Make diff algorithm configurable
The diff algorithm which is used by Merge, Cherry-Pick, Rebase
should be configurable. A new configuration parameter "diff.algorithm"
is introduced which currently accepts the values "myers" or
"histogram". Based on this parameter for example the ResolveMerger
will choose a diff algorithm. The reason for this is bug 331078.
This bug shows that JGit is more compatible with C Git when
histogram diff is in place. But since histogram diff is quite new we
need an easy way to fall back to Myers diff.

Bug: 331078
Change-Id: I2549c992e478d991c61c9508ad826d1a9e539ae3
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
2010-11-26 00:30:08 +01:00
Stefan Lay 91958b7045 Do some more tests for rebase --abort
Check for deletion of temporary files in .git folder.
Check for deletion and creation of files.

Change-Id: I60b0b2975724f2e3582e8674d9f876dcbf62b350
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2010-11-25 15:01:17 +01:00
Christian Halstrick 7e298c9ed5 Add more tests for rebase and externalized missing Strings
Coverage tests showed that we are missing to test certain areas
in the rebase command. Add the missing tests.

Change-Id: Ia4a272d26cde7e1861dac30496e4b6799fc8187a
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-11-24 15:59:08 +01:00
Chris Aniszczyk 923443f94f Add CheckoutCommand
Add the ability to checkout a branch to the working tree.

Bug: 330860
Change-Id: Ie06b9e799a9e1be384da0b8996efa7209b32eac3
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-11-22 15:53:35 -06:00
Matthias Sohn 34962b4700 Merge "Fix bug regarding handling of non-versioned files during merge" 2010-11-22 16:43:43 -05:00
Christian Halstrick 5adef23365 Fix bug regarding handling of non-versioned files during merge
There was a bug introduced by commit 0e815fe. For non-versioned files
the merge algorithm detected an incoming deletion from THEIRS.
Consequently such files were deleted. That's a severe bug which was
fixed by more precisely detecting incoming deletions.

Change-Id: I4385d3c990db11d62e371a385dc8ee89841db84a
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-11-22 22:41:25 +01:00
Chris Aniszczyk f7690cceef Add RmCommand to Git API
Bug: 330827
Change-Id: I0b74bb92254d0ee988139d25022d06d16ed89d58
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-11-22 11:02:28 -06:00
Mathias Kinzler e5b96a7848 Initial implementation of a Rebase command
This is a first iteration to implement Rebase. At the moment, this
does not implement --continue and --skip, so if the first
conflict is found, the only option is to --abort the command.

Bug: 328217
Change-Id: I24d60c0214e71e5572955f8261e10a42e9e95298
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-11-22 09:58:36 -06:00
Christian Halstrick da1ea27fa2 Fixed checkouts when HEAD is ignored
In the case where DirCacheCheckout was used to checkout a tree
without taking HEAD into account (e.g. during a clone or hard reset)
we didn't handle conflicts correctly. E.g. if there are conflicts
(entries with stage != 0) in the index and we tried to hard reset
we have been processing the conflicting pathes multiple times (once
for every stage). With this fix we will update the index with the
entry from the "merge" state (the state we want checkout) when we
detect existing conflicts.

Change-Id: Iffbddccaa588cf0d1460a5e44dabaf540d996e26
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-11-13 11:42:13 -06:00
Chris Aniszczyk 7bce473c92 Merge "Add simple unit tests for Base64" 2010-11-13 12:40:18 -05:00
Chris Aniszczyk 1b3abe75f8 Merge "Split note leaf buckets at 256 elements" 2010-11-13 12:37:30 -05:00
Chris Aniszczyk e9002a45ce Merge "Allow writing a NoteMap back to the repository" 2010-11-13 12:31:58 -05:00
Chris Aniszczyk 56a802104a Merge "Add in-memory updating support to NoteMap" 2010-11-13 12:31:02 -05:00
Shawn O. Pearce 51bf8ea2a4 Merge branch 'rename-detection'
* rename-detection:
  RenameDetector: Only scan deletes if adds exist
  SimilarityRenameDetector: Initialize sizes to 0
  SimilarityRenameDetector: Avoid allocating source index
  SimilarityRenameDetector: Only attempt to index large files once
  SimilarityIndex: Don't overflow internal counter fields
  SimilarityIndex: Accept files larger than 8 MB
  SimilarityIndex: Correct comment explaining the logic
2010-11-12 16:15:43 -08:00
Shawn O. Pearce b923ec9eba Add simple unit tests for Base64
Change-Id: I22ef1eb63ae8ddb9884526099013979856ab7bd9
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-12 16:05:00 -08:00
Shawn O. Pearce 2b0df15f7f Split note leaf buckets at 256 elements
Leaf level notes trees are split into a new fan-out tree if an
insertion occurs and the tree already contains >= 256 notes in it.

The splitting may occur multiple times if all of the notes have the
same prefix; in the worst case this produces a tree path such as
"00/00/00/00/00/00/00/00/00/00/00/00/00/00/00/00/00/00/00/be" if all
of the notes begin with zeros.

Change-Id: I2d7d98f35108def9ec49936ddbdc34b13822a3c7
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-12 14:01:28 -08:00
Shawn O. Pearce 3e2b9b691e Allow writing a NoteMap back to the repository
This is necessary to allow applications to wrap the note tree in
a commit and update the note branch with the new state.

Change-Id: Idbd7ead4a1b16ae2b64a30a4a01a29cfed548cdf
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-12 14:01:28 -08:00
Shawn O. Pearce faa0747cce Add in-memory updating support to NoteMap
NoteMap now supports editing in-memory, allowing applications to
modify the NoteMap once it has been loaded from the branch.  The
ability to write the branch back to tree objects is not yet done,
so the edits are strictly transient.

Change-Id: I63448954abfca2a8e3e95369cd84c0d1176cdb79
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-12 14:01:24 -08:00
Shawn O. Pearce d63887127e SimilarityIndex: Accept files larger than 8 MB
Files bigger than 8 MB (2^23 bytes) tended to overflow the internal
hashtable, as the table was capped in size to 2^17 records.  If a
file contained 2^17 unique data blocks/lines, the table insertion
got stuck in an infinite loop as the able couldn't grow, and there
was no open slot for the new item.

Remove the artifical 2^17 table limit and instead allow the table
to grow to be as big as 2^30.  With a 64 byte block size, this
permits hashing inputs as large as 64 GB.

If the table reaches 2^30 (or cannot be allocated) hashing is
aborted.  RenameDetector no longer tries to break a modify file pair,
and it does not try to match the file for rename or copy detection.

Change-Id: Ibb4d756844f4667e181e24a34a468dc3655863ac
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-12 11:56:59 -08:00
Robin Rosenberg 8c706ab464 Use capital L for long constants
Change-Id: Ib7b8c5f982dc72c68cf3d81e45a536c464837f7d
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2010-11-12 10:28:13 +01:00
Shawn O. Pearce 936820988f Define NoteMap, a simple note tree reader
The NoteMap makes it easy to read a small notes tree as created by
the `git notes` command in C Git.  To make the initial implementation
simple a notes tree is read recursively into a map in memory.
This is reasonable if the application will need to access all notes,
or if there are less than 256 notes in the tree, but doesn't behave
well when the number of notes exceeds 256 and the application
doesn't need to access all of them.

We can later add support for lazily loading different subpaths,
thus fixing the large note tree problem described above.

Currently the implementation only supports reading.  Writing notes
is more complex because trees need to be expanded or collapsed at
the exact 256 entry cut-off in order to retain the same tree SHA-1
that C Git would use for the same content.  It also needs to retain
non-note tree entries such as ".gitignore" or ".gitattribute" files
that might randomly appear within a notes tree.  We can also add
writing support later.

Change-Id: I93704bd84ebf650d51de34da3f1577ef0f7a9144
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-11-11 10:06:43 -06:00
Chris Aniszczyk 6043d4638c Merge "Add MutableObjectId setByte to modify a mutable id" 2010-11-11 10:52:37 -05:00
Chris Aniszczyk 9e28cf2fa3 Merge "Add ObjectId getByte for random access" 2010-11-10 18:00:36 -05:00
Shawn Pearce 17b1003ff2 Merge "Fix broken MergeCommandTest" 2010-11-09 18:58:34 -05:00
Matthias Sohn 2cba7b3522 Fix broken MergeCommandTest
Test was broken by commit b087bba3 changing formatting of merge
commit messages.

Change-Id: I98b1b936b9b6cbaa50fbc59d243a43e66a6ee9f9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-11-10 00:11:12 +01:00
Shawn O. Pearce 6af7e4d91a Fix URIish parsing of absolute scp-style URIs
We stopped handling URIs such as "example.com:/some/p ath", because
this was confused with the Windows absolute path syntax of "c:/path".
Support absolute style scp URIs again, but only when the host name
is more than 2 characters long.

Change-Id: I9ab049bc9aad2d8d42a78c7ab34fa317a28efc1a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-09 14:36:01 -08:00
Shawn Pearce b087bba3bd Merge "Format merge commit messages like C Git" 2010-11-09 17:14:11 -05:00
Jens Baumgart 2dc2dd8b1b IndexDiff: support state [removed, untracked]
IndexDiff was extended to detect files which are both removed from the
index and untracked.  Before this change these files were only added
to the removed collection.

Change-Id: I971d8261d2e8932039fce462b59c12e143f79f90
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-08 15:32:03 -08:00
Chris Aniszczyk 5dc72352f5 Merge "CommitAndLogCommandTests: add a test for LogCommand.addRange()" 2010-11-08 07:50:43 -05:00
Christian Halstrick 0e815fe8c5 Fixed ResolveMerger regarding handling of deletions
There was a bug in ResolveMerger which is one reason for
bug 328841. If a merge was failing because of conflicts
deletions where not handled correctly. Files which have
to be deleted (because there was a non-conflicting deletion
coming in from THEIRS) are not deleted. In the
non-conflicting case we also forgot to delete the file but
in this case we explicitly checkout in the end these files
get deleted during that checkout.

This is fixed by handling incoming deletions explicitly.

Bug: 328841
Change-Id: I7f4c94ab54138e1b2f3fcdf34fb803d68e209ad0
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-11-07 14:59:01 +01:00
Robin Stocker 6290ca3a63 Format merge commit messages like C Git
The automatically generated commit message of a merge should have the
same structure as in C Git for consistency (as per git fmt-merge-msg).

Before this change:

  merging refs/heads/a into refs/heads/master

After:

  Merge branch 'a'

Plurals, "into" and joining by "," and "and" also work.

Change-Id: I9658ce2817adc90d2df1060e8ac508d7bd0571cb
2010-11-06 13:48:11 +01:00
Shawn Pearce d1e8e97316 Merge "Add a test for merging deleted files" 2010-11-05 18:03:19 -04:00
Mathias Kinzler af31a97c82 CommitAndLogCommandTests: add a test for LogCommand.addRange()
There were also some compiler warning due to empty catch blocks that
were fixed.

Change-Id: I165bcddcdfacd34f020d1b938a41954916eb106e
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2010-11-05 12:26:56 +01:00
Shawn O. Pearce e488f1cacd Add MutableObjectId setByte to modify a mutable id
This mirrors the getByte() API in ObjectId and allows the caller to
modify a single byte, which is useful when updating it as part of a
loop walking through 0x00..0xff inside of a range of objects.

Change-Id: I57fa8420011fe5ed5fc6bfeb26f87a02b3197dab
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-04 19:12:13 -07:00
Shawn O. Pearce b22a4e8488 Add ObjectId getByte for random access
Processing git notes requires random access to part of the raw data
of each ObjectId... which isn't easy because ObjectIds are stored
with an internal representation of 5 ints.  Expose random access
to the individual data bytes through new methods, avoiding the
need to convert first to a byte[20].

Change-Id: I99e64700b27fc0c95aa14ef8ad46a0e8832d4441
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-04 19:12:13 -07:00
Christian Halstrick f5076d8b04 Add a test for merging deleted files
The JGit merge algorithm or the Merge Command may have problems with handling
deletions always correctly. Therefore one additional test is added to check
this.

Change-Id: Id6aa49136996b29047c340994fe7faba68858e8c
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-11-03 13:37:45 +01:00
Christian Halstrick 99771f04bc Fixed merge algorithm regarding adjacent modifications
JGit merge algorithm behaved differently from C Git when
we had adjacent modifications. If line 9 was modified by
OURS and line 10 by theirs then C Git will return a
conflict while JGit was seeing this as independent
modifications. This change is not only there to achieve
compatibility, but there where also some really wrong
merge results produced by JGit in the area of adjacent
modifications.

Change-Id: I8d77cb59e82638214e45b3cf9ce3a1f1e9b35c70
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-11-02 18:29:35 +01:00