Commit Graph

212 Commits

Author SHA1 Message Date
Marc Strapetz 6a05904e53 Extend DirCache test case to check "intent to add" flag. 2010-08-31 21:57:10 +02:00
Marc Strapetz 253b36d27a Partial support for index file format "3".
Extended flags are processed and available via DirCacheEntry's
new isSkipWorkTree() and isIntentToAdd() methods.  "resolve-undo"
information is completely ignored since its an optional extension.

Change-Id: Ie6e9c6784c9f265ca3c013c6dc0e6bd29d3b7233
2010-08-31 12:08:09 -07:00
Shawn O. Pearce 7d7365548a Add test for RawParseUtils.formatBase10
Change-Id: I3ad3533d03990c9e84186e53b9d755784b2a3758
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-31 11:26:26 -07:00
Christian Halstrick 0c017188b4 Improve MergeAlgorithm to produce smaller conflicts
The merge algorithm was reporting conflicts which where to big.

Example: The common base was "ABC", the "ours" version contained
"AB1C" (the addition of "1" after pos 2) and the "theirs" version also
contained "AB1C". We have two potentially conflicting edits in the
same region which happen to bring in exactly the same content. This
should not be a conflict - but was previously reported as
"AB<<<1===1>>>C".

This is fixed by checking every conflicting chunk whether the
conflicting regions have a common prefix or suffix and by removing
this regions from the conflict.

Change-Id: I4dc169b8ef7a66ec6b307e9a956feef906c9e15e
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-08-31 17:14:07 +02:00
Christian Halstrick 45e79a526c Added merge strategy RESOLVE
This adds the first merge strategy to JGit which does real
content-merges if necessary. The new merge strategy "resolve" takes as
input three commits: a common base, ours and theirs. It will simply takeover
changes on files which are only touched in ours or theirs. For files
touched in ours and theirs it will try to merge the two contents
knowing taking into account the specified common base.

Rename detection has not been introduced for now.

Change-Id: I49a5ebcdcf4f540f606092c0f1dc66c965dc66ba
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2010-08-31 01:21:54 +02:00
Chris Aniszczyk 77f79659f5 Merge "Add one more test to ReadTreeTest" 2010-08-30 16:59:15 -04:00
Matthias Sohn fb1c7b136f Wait for JIT optimization before measuring diff performance
On Mac OS X MyerDiffPerformanceTest was failing since during the
first few tests the JIT compiler is running in parallel slowing down
the tests. When setting the JVM option -Xbatch forcing the JIT to do
its work prior to running the code this effect can be avoided. Instead
we chose to run some tests without recording prior to the recorded
tests since relying on -X JVM parameters isn't portable across JVMs.

Use 10k * powers of 2 as sample size instead of odd numbers used
before and also improve formatting of performance readings.

Bug: 323766
Change-Id: I9a46d73f81a785f399d3cf5a90c8c0516526e048
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-08-30 15:56:52 -05:00
Shawn O. Pearce e6bd689d2c Improve LargeObjectException reporting
Use 3 different types of LargeObjectException for the 3 major ways
that we can fail to load an object.  For each of these use a unique
string translation which describes the root cause better than just
the ObjectId.name() does.

Change-Id: I810c98d5691b74af9fc6cbd46fc9879e35a7bdca
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-30 11:53:25 -07:00
Christian Halstrick 0bdf73db7f Add one more test to ReadTreeTest
Add an explicit test case to check that we don't
overwrite dirty files in case Head & Index are
equal.

Change-Id: I6266d0a449e55369d2d0a048694dca5565c5fcf3
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-08-30 09:34:17 +02:00
Robin Rosenberg 236899204a Revert "Hide Maven target directories from Eclipse"
This reverts commit db4c516f67 since
it breaks compatibility with Eclipse 3.5 which can no longer import
the projects

Bug: 323390
Change-Id: I3cc91364a6747cfcb4c611a9be5258f81562f726
2010-08-28 09:50:50 +02:00
Chris Aniszczyk f54e883566 Add TagCommand
A tag command is added to the Git porcelain API. Tests were
also added to stress test the tag command.

Change-Id: Iab282a918eb51b0e9c55f628a3396ff01c9eb9eb
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-08-27 21:11:31 +02:00
Christian Halstrick 2059ed205e Implement a Dircache checkout (needed for merge)
Implementation of a checkout (or 'git read-tree') operation which
works together with DirCache. This implementation does similar things
as WorkDirCheckout which main problem is that it works with deprecated
GitIndex. Since GitIndex doesn't support multiple stages of a file
which is required in merge situations this new implementation is
required to enable merge support.

Change-Id: I13f0f23ad60d98e5168118a7e7e7308e066ecf9c
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-08-27 16:06:49 +02:00
Matthias Sohn c869f187b7 Increase heap size for jgit tests
Otherwise PackFileTest.testDelta_LargeObjectChain() reproducibly
fails with OutOfMemoryError on Mac OS X 10.6.4.

Change-Id: I6a55ff9ba181102606a0d99ffd52392a1615a422
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-08-27 00:29:31 +02:00
Shawn Pearce 7d9bfa390f Merge "Fix parsing of multiple authors in PersonIdent." 2010-08-26 15:00:58 -04:00
Shawn Pearce 1edbefc5fa Merge "Use JUnit4 for tests" 2010-08-26 14:50:05 -04:00
Chris Aniszczyk d1edd00f56 Run formatter on edited lines via save action
Updates the project level settings to run the formatter
on save on only on the edited lines.

Change-Id: I26dd69d0c95e6d73f9fdf7031f3c1dbf3becbb79
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-08-26 12:33:09 -05:00
Chris Aniszczyk a005986ce7 Use JUnit4 for tests
We should use JUnit4 for tests. This patch updates
the MANIFEST.MF and respective launch configurations.

Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-08-26 12:26:38 -05:00
Marc Strapetz 80c622c49c Fix parsing of multiple authors in PersonIdent.
PersonIdent should be parsable for an invalid commit which
contains multiple authors, like "A <a@a.org>, B <b@b.org>".
PersonIdent(String) constructor now delegates to
RawParseUtils.parsePersonIdent().

Change-Id: Ie9798d36d9ecfcc0094ca795f5a44b003136eaf7
2010-08-26 12:58:03 +02:00
Shawn O. Pearce 6517a7c923 Increase temporary buffer for unit test
Because we are using the large stream size, we have to be
above the STREAM_THRESHOLD constant, which I just increased.

Change-Id: I6f10ec8558d9f751d4b547fcae05af94f1c8866b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-25 17:53:00 -07:00
Shawn O. Pearce dbd2d7c83b Support parsing commit:path style blob references
We can now resolve expressions that reference a path within a
commit, designating a specific revision of a specific tree or
file in the project.

Change-Id: Ie6a8be629d264d72209db894bd680c5900035cc0
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-25 17:07:13 -07:00
Shawn O. Pearce 8da17c5046 Support parsing git describe style output
We now match on the -gABBREV style output created by git describe
when its describing a non-tagged commit, and resolve that back to
the full ObjectId using the abbreviation resolution feature that
we already support.

Change-Id: Ib3033f9483d9e1c66c8bb721ff48d4485bcdaef1
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-25 17:07:13 -07:00
Shawn O. Pearce c59e3a493b Rename T0008_testparserev to RepositoryResolveTest
Calling it by the old numerical numbering system makes it really
hard to find the test that tests Repository.resolve(String).

Change-Id: I92d0ecbc8d66ce21bfed08888eeedf1300ffa594
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-25 17:07:13 -07:00
Shawn O. Pearce 401d3b2cc1 Throw AmbiguousObjectException during resolve if its ambiguous
Its wrong to return null if we are resolving an abbreviation and we
have proven it matches more than one object.  We know how to resolve
it if we had more nybbles, as there are two or more objects with the
same prefix.  Declare that to the caller quite clearly by giving them
an AmbiguousObjectException.

Change-Id: I01bb48e587e6d001b93da8575c2c81af3eda5a32
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-25 17:07:12 -07:00
Shawn O. Pearce 2292655e9e Add brute force byte array loading to ObjectLoader
Some algorithms are coded in a way that requires us to provide them
the entire object contents as a contiguous byte array.  The parsers
in RevCommit and RevTag, or our RawText objects are really good
examples of these.

Instead of duplicating this logic everywhere, lets put it into the
base ObjectLoader type.  That way the caller only needs to give us
their upper size bound, and we'll do the rest of the heavy work to
figure out if the object still fits within that bound, and get them
an array that has the complete contents.

Change-Id: Id95a7f79d2b97e39f6949370ccca2f2c9cfb1a0f
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-08-25 19:03:47 -05:00
Shawn O. Pearce 1c3f3fdbd2 Fix ObjectDirectory abbreviation resolution to notice new packs
If we can't resolve an abbreviation, it might be because there is
a new pack file we haven't picked up yet.  Try scanning the packs
again and recheck each pack if there were differences from the last
scan we did.

Because of this, we don't have to open a pack during the test where
we generate a pack on the fly.  We'll miss on the first loop during
which the PackList is the NO_PACKS magic initialization constant,
and pick up the newly created index during this retry logic.

Change-Id: I7b97efb29a695ee60c90818be380f7ea23ad13a3
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-24 17:37:07 -07:00
Shawn O. Pearce a5c18fcfc7 Fully implement SHA-1 abbreviations
ObjectReader implementations are now responsible for creating the
unique abbreviation of an ObjectId, or for resolving an abbreviation
back to its full form.  In this latter case the reader can offer up
multiple candidates to the caller, who may be able to disambiguate
them based on context.

Repository.resolve() doesn't take multiple candidates into account
right now, but it could in the future by looking for a remaining
^0 or ^{commit} suffix and take an expansion if there is only one
commit that matches the input abbreviation.  It could also use
the distance from an annotated tag to resolve "tag-NNN-gcommit"
style strings that are often output by `git describe`.

Change-Id: Icd3250adc8177ae05278b858933afdca0cbbdb56
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-23 15:53:11 -07:00
Shawn O. Pearce 32466c33ba Delete deprecated ObjectWriter
ObjectWriter is a deprecated API that people shouldn't be using.
So get rid of it in favor of the ObjectInserter API.

Change-Id: I6218bcb26b6b9ffb64e3e470dba5dca2e0a62fd4
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-23 10:59:30 -07:00
Shawn O. Pearce 6df5d3397c Move commit and tag formatting to CommitBuilder, TagBuilder
These objects should be responsible for their own formatting,
rather than delegating it to some obtuse type called ObjectInserter.

While we are at it, simplify the way we insert these into a database.
Passing in the type and calling format in application code turned
out to be a huge mistake in terms of ease-of-use of the insert API.

Change-Id: Id5bb95ee56aa2a002243e9b7853b84ec8df1d7bf
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-23 10:13:29 -07:00
Shawn O. Pearce 22b285695a Rename Commit, Tag to CommitBuilder, TagBuilder
Since these types no longer support reading, calling them a Builder
is a better description of what they do.  They help the caller to
build a commit or a tag object.

Change-Id: I53cae5a800a66ea1721b0fe5e702599df31da05d
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-23 09:46:14 -07:00
Marc Strapetz e2e38792b5 Perform automatic CRLF to LF conversion during WorkingTreeIterator
WorkingTreeIterator now optionally performs CRLF to LF conversion for
text files.  A basic framework is left in place to support enabling
(or disabling) this feature based on gitattributes, and also to
support the more generic smudge/clean filter system.  As there is
no gitattribute support yet in JGit this is left unimplemented,
but the mightNeedCleaning(), isBinary() and filterClean() methods
will provide reasonable places to plug that into in the future.

[sp: All bugs inside of WorkingTreeIterator are my fault, I wrote
     most of it while cherry-picking this patch and building it on
     top of Marc's original work.]

CQ: 4419
Bug: 301775
Change-Id: I0ca35cfbfe3f503729cbfc1d5034ad4abcd1097e
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-20 18:03:07 -07:00
Shawn O. Pearce 540df6c9fe Add a public RevTag.parse() method
Callers might have a canonical tag encoding on hand that they
wish to convert into a clean structure for presentation purposes,
and the object may not be available in a repository.  (E.g. maybe
its a "draft" tag being written in an editor.)

Change-Id: I387a462afb70754aa7ee20891e6c0262438fdf32
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-20 17:38:53 -07:00
Shawn O. Pearce b205597b91 Add a public RevCommit.parse() method
Callers might have a canonical commit encoding on hand that they
wish to convert into a clean structure for presentation purposes,
and the object may not be available in a repository.  (E.g. maybe
its a "draft" commit being written in an editor.)

Change-Id: I21759cff337cbbb34dbdde91aec5aa4448a1ef37
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-20 17:38:53 -07:00
Shawn O. Pearce 707912b35d Make Tag class only for writing
The Tag class now only supports the creation of an annotated tag
object.  To read an annotated tag, applictions should use RevTag.
This permits us to have exactly one implementation, and RevTag's
is faster and more bug-free.

Change-Id: Ib573f7e15f36855112815269385c21dea532e2cf
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-20 17:38:53 -07:00
Shawn O. Pearce b46b635c03 Make Commit class only for writing
The Commit class now only supports the creation of a commit object.
To read a commit, applictions should use RevCommit.  This permits
us to have exactly one implementation, and RevCommit's is faster
and more bug-free.

Change-Id: Ib573f7e15f36855112815269385c21dea532e2cf
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-20 17:38:52 -07:00
Christian Halstrick 9ac29d0e91 Fix ReadTreeTests to not rely on cached index
ReadTreeTests relied on Repository.getIndex() which on
platforms which coarse FileSystemTimers failed to detect
index modifications. By explicitly reloading and writing
the index this problem is solved.

Change-Id: I0a98babfc2068a3b6b7d2257834988e1154f5b26
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-08-20 10:23:03 +02:00
Shawn O. Pearce d0043e5d31 Remove unnecessary ObjectId.copy() calls
When RevObject overrode equals() to provide only reference equality
we used to need to convert a RevObject into an ObjectId by copy()
just to use standard Java tools like JUnit assertEquals(), or to
use contains() or get() on standard java.util collection types.

Now that we have removed this override and made ObjectId's equals()
final (preventing any of this mess in the future), some copy()
calls are unnecessary.  Anytime the value is being used as an input
to a lookup routine, or to an equals, we can avoid the copy().

However we still want to use copy() anytime we are given an ObjectId
that may exist long-term, where we don't want the high cost of the
additional storage from a RevCommit extension.  So we can't remove
all uses of copy(), just some of them.

Change-Id: Ief275dace435c0ddfa362ac8e5d93558bc7e9fc3
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-19 11:43:39 -07:00
Mathias Kinzler b7388637d8 Fix missing Configuration Change eventing
Configuration change events were not being triggered, now they are
forwarded from the FileConfig up to the Repository's listeners.

Change-Id: Ida94a59f5a2b7fa8ae0126e33c13343275483ee5
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-19 11:36:56 -07:00
Chris Aniszczyk 6c9d82b4ce Remove getter and setter for author in Tag
There was a duplicated getter and setter for tagger in Tag.
There's no needed to have two getters and setters that represent
the same things. The appropriate tests were updated also.

Change-Id: If46dc00c4c0f31ea4234c6d3bda3c03e6ebbafac
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-08-18 20:58:25 -05:00
Christian Halstrick 07a1d17858 Add blob-data to utility method indexState()
indexState() encodes the complete state of the index
into one readable String. This helps to write tests
against the index. indexState() is enhanced to optionally
also contain the content of the files in the index.

Change-Id: Ie988f93768d864f4cbd55809a786bd5759fc24a5
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-08-18 16:50:43 -07:00
Christian Halstrick e02b68a8b7 added resetIndex() to RepositoryTestCase
Added a utility method to set the reset an index to match exactly
some content in the filesystem. This can be used by tests to prepare
commits in the working-tree and set the index in one shot.

[sp: Cleaned up formatting, added getEntryFile(), released inserter.]

Change-Id: If38b1f7cacaaf769f51b14541c5da0c1e24568a5
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-18 16:45:56 -07:00
Shawn Pearce 9fc2cdadd2 Merge "Backout RevObject's object-identity based equals implementation" 2010-08-18 15:00:33 -04:00
Matthias Sohn 11c5c9f73b Set default file encoding used for JGit tests to UTF-8
This patch fixes the problem that JGit tests run from Maven fail on
Mac OS X [1]. In Eclipse the tests succeed since we set Eclipse
workspace encoding to UTF-8 via "Preferences > General > Workspace
> Text file encoding", checked via JConsole that this setting changes
the JVM system property of the test run. This change copies this 
setting to the Maven test environment so that we get consistent test
results on all platforms.

[1] http://kerneltrap.org/mailarchive/git/2009/2/6/4916414/thread

Change-Id: Ia657d4037c518411f7bc3c75626dbafb1f4706a2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-08-16 17:42:41 +02:00
Matthias Sohn 2d3a806271 Backout RevObject's object-identity based equals implementation
This restores the transitivity and symmetry properties of the equals
methods on the AnyObjectId type hierarchy as defined in [1]. 
Following [2] we declare these equals methods final to ensure that 
semantics of equals are consistent across AnyObjectId's type hierarchy.

[1] http://download-llnw.oracle.com/javase/6/docs/api/java/lang/Object.html#equals(java.lang.Object)
[2] http://www.angelikalanger.com/Articles/JavaSolutions/SecretsOfEquals/Equals.html

Bug: 321502
Change-Id: Ibace21fa268c4aa15da6c65d42eb705ab1aa24b3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-08-15 23:12:58 +02:00
Robin Rosenberg db4c516f67 Hide Maven target directories from Eclipse
Change-Id: I64f12a35423a90ced9c9bc83f6869d8ed766dd35
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2010-08-08 13:16:53 +02:00
Shawn O. Pearce 09130b8731 Merge branch 'rename-bug'
* rename-bug:
  Fix ArrayIndexOutOfBounds on non-square exact rename matrix

Conflicts:
	org.eclipse.jgit/src/org/eclipse/jgit/diff/RenameDetector.java

Change-Id: Ie0b8dd3e1ec174f79ba39dc4706bb0694cc8be29
2010-08-06 09:48:50 -07:00
Shawn O. Pearce e2f5716c94 Fix ArrayIndexOutOfBounds on non-square exact rename matrix
If the exact rename matrix for a particular ObjectId isn't square we
crashed with an ArrayIndexOutOfBoundsException because the matrix
entries were encoded backwards.  The encode function accepts the
source (aka deleted) index first, not second.  Add a unit test to
cover this non-square case to ensure we don't have this regression
in the future.

Change-Id: I5b005e5093e1f00de2e3ec104e27ab6820203566
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-06 09:39:10 -07:00
Shawn O. Pearce 8e9cc826e9 Merge changes I39bfefee,I47795987,I70d120fb,I58cc5e01,I96bee7b9
* changes:
  Enable configuration of non-standard pack settings
  Pass PackConfig down to PackWriter when packing
  Simplify UploadPack use of options during writing
  Move PackWriter configuration to PackConfig
  Allow PackWriter callers to manage the thread pool
2010-08-05 21:11:31 -04:00
Chris Aniszczyk b69900a415 Merge "Add "all" parameter to the commit Command" 2010-08-05 15:02:59 -04:00
Chris Aniszczyk ad4274abcc Merge "Add the parameter "update" to the Add command" 2010-08-05 15:01:53 -04:00
Chris Aniszczyk bc27ac66cd Merge "add fsTick() to RepositoryTestCase" 2010-08-05 14:57:14 -04:00