Commit Graph

588 Commits

Author SHA1 Message Date
Shawn O. Pearce 4b5d3d291b Qualify builds as 0.10.0
Change-Id: I54815c85b32b9492c059064b39f48677e68c5e90
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-16 17:26:53 -07:00
Shawn O. Pearce 5deb5b9a4a Merge branch 'stable-0.9'
* stable-0.9:
  Qualify post-0.9.3 builds
  JGit 0.9.3
  clone: Correct formatting of init message
  Fix cloning of repositories with big objects
  Qualify post-0.9.1 builds
  JGit 0.9.1
  Fix PlotCommitList to set lanes on child-less commits
2010-09-16 17:22:37 -07:00
Matthias Sohn 26f507f0df Qualify post-0.9.3 builds
Change-Id: Ideab4923a5d8055f0e8a36ddcf0bc8adbf71c329
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-09-16 01:49:03 +02:00
Matthias Sohn 2920fcdde8 JGit 0.9.3
Change-Id: I114106f3286c36f7d5e136748a7e5130f4da163f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-09-16 01:02:53 +02:00
Chris Aniszczyk cc5b3f3473 Merge "Qualify post-0.9.1 builds" into stable-0.9 2010-09-15 15:56:53 -04:00
Shawn O. Pearce 5fce8d81d8 Fix cloning of repositories with big objects
When running IndexPack we use a CachedObjectDirectory, which
knows what objects are loose and tries to avoid stat(2) calls for
objects that do not exist in the repository, as stat(2) on Win32
is very slow.

However large delta objects found in a pack file are expanded into
a loose object, in order to avoid costly delta chain processing
when that object is used as a base for another delta.

If this expand occurs while working with the CachedObjectDirectory,
we need to update the cached directory data to include this new
object, otherwise it won't be available when we try to open it
during the object verify phase.

Bug: 324868
Change-Id: Idf0c76d4849d69aa415ead32e46a435622395d68
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-15 08:42:14 -07:00
Shawn O. Pearce 3fe527624d Probe filesystem and set core.filemode correctly
When creating a new FileRepository, probe the capability of the
local filesystem and set core.filemode based on how it reacts.

We can't just rely on FS.supportsExecute() because a POSIX system
(which usually does support execute) might be storing the repository
on a partition that doesn't have execute support (e.g. plain FAT-32).

Creating a temporary file, setting both states, checking we get
the desired results will let us set the variable correctly on
all systems.

Change-Id: I551488ea8d352d2179c7b244f474d2e3d02567a2
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-15 07:59:38 -07:00
Matthias Sohn 7ae5e82d66 Qualify post-0.9.1 builds
Change-Id: I07a3391de03379f32ecfd055d45750e3860b2be4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-09-15 11:31:05 +02:00
Matthias Sohn 445a3a281d JGit 0.9.1
Change-Id: Ic411b1b8a7e6039ae3ff567e2c9cdd5db84f4d41
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-09-15 09:46:11 +02:00
Christian Halstrick 2dc031ad9b Fix PlotCommitList to set lanes on child-less commits
In PlotCommitList.enter() commits are positioned on lanes for visual
presentation. This implementation was buggy: commits without
children (often the starting points for the RevWalk) are not positioned
on separate lanes.

The problem was that when handling commits with multiple children
(that's where branches fork out) it was not handled that some of the
children may not have been positioned on a lane yet. I fixed that and
added a number of tests which specifically test the layout of commits
on lanes.

Bug: 300282
Bug: 320263
Change-Id: I267b97ecccb5251cec54cec90207e075ab50503e
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-09-14 18:19:44 +02:00
Shawn O. Pearce 276d38065b Define a subsequence utility type
A diff algorithm may find this type useful if it wants to delegate a
particular range of elements to another algorithm, without changing
the underlying sequence types.

Change-Id: I4544467781233e21ac8b35081304b2bad7db00f6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-10 22:18:54 -07:00
Shawn O. Pearce 307ba53eb6 Define DiffAlgorithm as an abstract function
This makes it easier to parametrize DiffFormatter with a different
implementation, as we later plan to add PatienceDiff to JGit.

Change-Id: Id35ef478d5fa20fe10a1ba297f9436fd7adde9ce
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-10 22:18:54 -07:00
Shawn O. Pearce 9d14f56442 Merge branch 'stable-0.9'
* stable-0.9:
  Correct Javadoc for WS_IGNORE_CHANGE comparator
2010-09-10 22:17:50 -07:00
Shawn O. Pearce db1a9c6a8c Correct Javadoc for WS_IGNORE_CHANGE comparator
Change-Id: I8aa1e7c7ae192ed28b2c8aaa3c5884b7b4666e9c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-10 22:15:27 -07:00
Chris West (Faux) 2a52359454 Allow ../relative paths in remotes
git allows remotes to be relative paths, but the regex
validating urls wouldn't accept anything starting with "..".
Other functionality works fine with these paths.

Bug: 311300
Change-Id: Ib74de0450a1c602b22884e19d994ce2f52634c77
2010-09-10 21:04:01 +01:00
Shawn O. Pearce 41dd9ed1c0 Unpack and cache large deltas as loose objects
Instead of spooling large delta bases into temporary files and then
immediately deleting them afterwards, spool the large delta out to
a normal loose object.  Later any requests for that large delta can
be answered by reading from the loose object, which is much easier
to stream efficiently for readers.

Since the object is now duplicated, once in the pack as a delta and
again as a loose object, any future prune-packed will automatically
delete the loose object variant, releasing the wasted disk space.

As prune-packed is run automatically during either repack or gc, and
gc --auto triggers automatically based on the number of loose objects,
we get automatic cache management for free.  Large objects that were
unpacked will be periodically cleared out, and will simply be restored
later if they are needed again.

After a short offline discussion with Junio Hamano today, we may want
to propose a change to prune-packed to hold onto larger loose objects
which also exist in pack files as deltas, if the loose object was
recently accessed or modified in the last 2 days.

Change-Id: I3668a3967c807010f48cd69f994dcbaaf582337c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-07 22:28:06 -07:00
Shawn O. Pearce 3f66e65e71 Remember loose objects and fast-track their lookup
Recently created objects are usually what branches point to, and
are usually written out as loose objects.  But due to the high cost
of asking the operating system if a file exists, these are the last
thing that ObjectDirectory examines when looking for an object by
its ObjectId.

Caching recently seen loose objects permits the opening code to
jump directly to the loose object, accelerating lookup for branch
heads that are accessed often.

To avoid exploding the cache its limited to approximately 2048
entries.  When more ids are added, the table is simply cleared
and reset in size.

Change-Id: I18f483217412b102f754ffd496c87061d592e535
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-07 22:28:06 -07:00
Shawn O. Pearce eb64ccad6d Correctly name DeltaBaseCache
This class is used only to cache the unpacked form of an object that
was used as a base for another object.  The theory goes that if an
object is used as a delta base for A, it will probably also be a
delta base for B, C, D, E, etc. and therefore having an unpacked copy
of it on hand will make delta resolution for the others very fast.

However since objects are usually only accessed once, we don't want
to cache everything we unpack, just things that we are likely to
need again.  The only things we need again are the delta bases.
Hence, its a delta base cache.

This gets us the class name UnpackedObjectCache back, so we can
use it to actually create a cache of unpacked object information.

Change-Id: I121f356cf4eca7b80126497264eac22bd5825a1d
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-07 18:18:59 -07:00
Shawn O. Pearce 9f61c615e8 Support core.autocrlf = input
The core.autocrlf variable can take on three values: false, true,
and input.  Parsing it as a boolean is wrong, we instead need to
parse a tri-state enumeration.

Add support for parsing and setting enum values from Java from and
to the text based configuration file, and use that to handle the
autocrlf variable.

Bug: 301775
Change-Id: I81b9e33087a33d2ef2eac89ba93b9e83b7ecc223
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-07 17:14:27 -07:00
Shawn O. Pearce 67263e2056 Refactor diff sequence API
Instead of making the sequence itself responsible for the equivalence
function, use an external function that is supplied by the caller.
This cleans up the code because we now say cmp.equals(a, ai, b, bi)
instead of a.equals(ai, b, bi).

This refactoring also removes the odd concept of creating different
types of sequences to have different behaviors for whitespace
ignoring.  Instead DiffComparator now supports singleton functions
that apply a particular equivalence algorithm to a type of sequence.

Change-Id: I559f494d81cdc6f06bfb4208f60780c0ae251df9
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-06 21:37:11 -05:00
Chris Aniszczyk 18aadc826d Merge "Reduce compares in Edit.getType" 2010-09-06 22:33:09 -04:00
Shawn O. Pearce ba984ba2e0 Fix checkReferencedIsReachable to use correct base list
When checkReferencedIsReachable is set in ReceivePack we are trying
to prove that the push client is permitted to access an object that
it did not send to us, but that the received objects link to either
via a link inside of an object (e.g. commit parent pointer or tree
member) or by a delta base reference.

To do this check we are making a list of every potential delta base,
and then ensuring that every delta base used appears on this list.
If a delta base does not appear on this list, we abort with an error,
letting the client know we are missing a particular object.

Preventing spurious errors about missing delta base objects requires
us to use the exact same list of potential delta bases as the remote
push client used.  This means we must use TOPO ordering, and we
need to enable BOUNDARY sorting so that ObjectWalk will correctly
include any trees found during the enumeration back to the common
merge base between the interesting and uninteresting heads.

To ensure JGit's own push client matches this same potential delta
base list, we need to undo 60aae90d4d ("Disable topological
sorting in PackWriter") and switch back to using the conventional
TOPO ordering for commits in a pack file.  This ensures that our
own push client will use the same potential base object list as
checkReferencedIsReachable uses on the receiving side.

Change-Id: I14d0a326deb62a43f987b375cfe519711031e172
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-06 12:12:43 -07:00
Shawn O. Pearce 6f385076e1 Discard object bodies when checking connectivity
Since we are only checking the links between objects we don't need
to hold onto commit messages after their headers have been parsed
by the walker.  Dropping them saves a bit of memory, which is always
good when accepting huge pack files.

Change-Id: I378920409b6acf04a35cdf24f81567b1ce030e36
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-06 11:36:08 -07:00
Shawn O. Pearce 741659fed4 DeltaStream: Fix data corruption when reading large copies
If the copy instruction was larger than the input buffer given to us,
we copied the wrong part of the base stream during the next read().

This occurred on really big binary files where a copy instruction
of 64k wasn't unreasonable, but the caller's buffer was only 8192
bytes long.  We copied the first 8192 bytes correctly, but then
reseeked the base stream back to the start of the copy region on
the second read of 8192 bytes.  Instead of a sequence like ABCD
being read into the caller, we read AAAA.

Change-Id: I240a3f722a3eda1ce8ef5db93b380e3bceb1e201
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-06 10:09:12 -07:00
Shawn O. Pearce 693f454e71 Use 8192 as default buffer size in ObjectLoader copyTo
As ObjectStreams are supposed to be buffered, most implementors will
be wrapping their underlying stream inside of a BufferedInputStream
in order to satisfy this requirement.  Because developers are by
nature lazy, they will use the default buffer size rather than
specify their own.

The OpenJDk JRE implementations use 8192 as the default buffer
size, and when the higher level reader uses the same buffer size
the buffers "stack" nicely by avoiding a copy to the internal
buffer array.  As OpenJDK is a popular virtual machine, we should
try to benefit from this nice stacking property during copyTo().

Change-Id: I69d53f273b870b841ced2be2e9debdfd987d98f4
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-06 10:09:12 -07:00
Chris Aniszczyk 88adf21c47 Merge "Add helper methods to Edit" 2010-09-06 13:04:51 -04:00
Shawn O. Pearce 2b0c5c7207 Merge "Use 5 MiB for RevWalk default limit" 2010-09-06 11:37:29 -04:00
Robin Rosenberg 8145e40233 cleanup: Remove unnecessary @SuppressWarnings
Change-Id: I1b239b587e1cc811bbd6e1513b07dc93a891a842
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2010-09-05 00:00:57 +02:00
Shawn O. Pearce 6938f99ef3 Reduce compares in Edit.getType
We can slightly optimize this method by removing some compares
based on knowledge of how the orderings have to work.  This way
a getType() invocation requires at most 2 int compares for any
result, vs. the 6 required to find REPLACE before.

Change-Id: I62a04cc513a6d28c300d1c1496a8608d5df4efa6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-03 23:55:46 -07:00
Shawn O. Pearce fe8fe13349 Add helper methods to Edit
Exposing isEmpty, getLengthA, getLengthB make it easier to examine
the state of an edit and work with it from higher level code.

The before and after cut routines make it easy to split an edit
that contains another edit, such as to decompose a REPLACE that
contains a common sequence within it.

Change-Id: Id63d6476a7a6b23acb7ab237d414a0a1a7200290
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-03 23:55:46 -07:00
Shawn O. Pearce 2aa4196f1f Fix QuotedString.GIT_PATH escaping rules
We shouldn't escape non-special ASCII characters such as '@' or '~'.
These are valid in a path name on POSIX systems, and may appear as
part of a path in a GNU or Git style patch script.  Escaping them
into octal just obfuscates the user's intent, with no gain.

When parsing an escaped octal sequence, we must parse no more
than 3 digits.  That is, "\1002" is actually "@2", not the Unicode
character \u0202.

Change-Id: I3a849a0d318e69b654f03fd559f5d7f99dd63e5c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-03 13:02:01 -07:00
Shawn O. Pearce 34a755f1df Remove costly quoting test in DiffFormatter
QuotedString.GIT_PATH returns the input reference exactly if
the string does not require quoting, otherwise it returns a
copy that contains the quotes on either end, plus escapes in
the middle where necessary to meet conventions.

Testing the return against '"' + name + '"' is always false,
because GIT_PATH will never return it that way.  The only way
we have quotes on either end is if there is an escape in the
middle, in which case the string isn't equal anyway.

Change-Id: I4d21d8e5c7da0d7df9792c01ce719548fa2df16b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-03 12:59:53 -07:00
Shawn O. Pearce 33837e44c3 Merge branch 'unpack-error'
* unpack-error:
  ReceivePack: Rethrow exceptions caught during indexing

Change-Id: I0d0239d69cb5cd1a622bdee879978f0299e0ca40
2010-09-03 11:09:52 -07:00
Shawn O. Pearce 9239c10385 ReceivePack: Rethrow exceptions caught during indexing
If we get an exception while indexing the incoming pack, its likely
a stream corruption.  We already report an error to the client, but
we eat the stack trace, which makes debugging issues related to a
bug inside of JGit nearly impossible.  Rethrow it under a new type
UnpackException, so embedding servers or applications can catch the
error and provide it to a human who might be able to forward such
traces onto a JGit developer for evaluation.

Change-Id: Icad41148bbc0c76f284c7033a195a6b51911beab
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-03 10:57:55 -07:00
Shawn O. Pearce b505e2a558 Use 5 MiB for RevWalk default limit
Instead of getting the limit from CoreConfig, use the larger of the
reader's limit or 5 MiB, under the assumption that any annotated tag
or commit of interest should be under 5 MiB.  But if a repository
was really insane and had bigger objects, the reader implementation
can set its streaming limit higher in order to allow RevWalk to
still process it.

Change-Id: If2c15235daa3e2d1f7167e781aa83fedb5af9a30
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-02 11:38:40 -07:00
Shawn O. Pearce e29cd27961 Move ObjectDirectory streaming limit to WindowCacheConfig
IDEs like Eclipse offer up the settings in WindowCacheConfig to the
user as a global set of options that are configured for the entire
JVM process, not per-repository, as the cache is shared across the
entire JVM.  The limit on how much we are willing to allocate for
an object buffer is similar to the limit on how much we can use for
data caches, allocating that much space impacts the entire JVM and
not just a single repository, so it should be a global limit.

Change-Id: I22eafb3e223bf8dea57ece82cd5df8bfe5badebc
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-02 11:38:39 -07:00
Shawn O. Pearce 59a262d5d2 Support creating the working directory difference
If the iterators passed into a diff formatter are working tree
iterators, we should enable ignoring files that are ignored, as
well as actually pull up the current content from the working tree
rather than getting it from the repository.

Because we abstract away the working directory access logic,
we can now actually support rename detection between the working
directory and the local repository when using a DiffFormatter.
This means its possible for an application to show an unstaged
delete-add pair as a rename if the add path is not ignored.
(Because the ignored file wouldn't show up in our difference output.)

Even more interesting is we can now do rename detection between any
two working trees, if both input iterators are WorkingTreeIterators.

Unfortunately we don't (yet) optimize for comparing the working
tree with the index involved so we can take advantage of cached
stat data to rule out non-dirty paths.

Change-Id: I4c0598afe48d8f99257266bf447a0ecd23ca7f5e
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-02 11:38:39 -07:00
Shawn O. Pearce 6f00a3e651 Fix TreeWalk bug comparing DirCache and WorkingTree with ANY_DIFF
When comparing a DirCache and a WorkingTree using ANY_DIFF we
sometimes didn't recursive into a subtree of both sides gave us
zeroId() back for the identity of a subtree.  This happens when the
DirCache doesn't have a valid cache tree for the subtree, as then
it uses zeroId() for the ObjectId of the subtree, which then appears
to be equal to the zeroId() of the WorkingTreeIterator's subtree.

We work around this by adding a hasId() method that returns true
only if this iterator has a valid ObjectId.  The idEquals method
on TreeWalk than only performs a compare between two iterators if
both iterators have a valid id.

Change-Id: I695f7fafbeb452e8c0703a05c02921fae0822d3f
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-02 11:38:39 -07:00
Shawn O. Pearce ec2fdbf2ba Move rename detection, path following into DiffFormatter
Applications just want a quick way to configure our diff
implementation, and then just want to use it without a lot of fuss.

Move all of the rename detection logic and path following logic
out of our pgm package and into DiffFormatter itself, making it
much easier for a GUI to take advantage of the features without
duplicating a lot of code.

Change-Id: I4b54e987bb6dc804fb270cbc495fe4cae26c7b0e
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-02 11:38:39 -07:00
Chris Aniszczyk 0f5eae53d6 Merge "Fix RepositoryState.MERGING" 2010-09-02 12:10:10 -04:00
Jens Baumgart f714988c61 Fix RepositoryState.MERGING
canResetHead now returns true.
Resetting mixed / hard works in EGit in merging state.

Change-Id: I1512145bbd831bb9734528ce8b71b1701e3e6aa9
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
2010-09-02 18:01:47 +02:00
Chris Aniszczyk a2f57dd491 Merge "Add reset() to AbstractTreeIterator API" 2010-09-02 11:30:31 -04:00
Chris Aniszczyk 0fea04adfd Merge "Improve DiffFormatter text file access" 2010-09-02 11:29:58 -04:00
Chris Aniszczyk 097406ba5e Merge "Correct diff header formatting" 2010-09-02 11:28:33 -04:00
Chris Aniszczyk df0c9309c5 Merge "Remove duplicated code in DiffFormatter" 2010-09-02 11:20:43 -04:00
Christian Halstrick 2d71808ae0 Merge "Adding sorting to LongList" 2010-09-02 07:53:15 -04:00
Christian Halstrick f7f7c55bca Merge "Use int[] rather than IntList for RawText hashes" 2010-09-02 07:46:50 -04:00
Shawn O. Pearce 6b65211505 Adding sorting to LongList
Sorting the array can be useful when its being used as a map of pairs
that are appended into the array and then later merge-joined against
another array of similar semantics.

Change-Id: I2e346ef5c99ed1347ec0345b44cda0bc29d03e90
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-02 00:28:15 -07:00
Chris Aniszczyk 7a504b8d7c Merge "Add toString and improve Javadoc of NotIgnoredFilter" 2010-09-01 20:39:41 -04:00
Shawn O. Pearce 3fa7d3a2d2 Use int[] rather than IntList for RawText hashes
We know exactly how many lines we need by the time we compute our
per-line hashes, as we have already built the lines IntList to give
us the starting position of each line in the buffer.  Using that
we can properly size the array, and don't need the dynamic growing
feature of IntList.  So drop the indirection and just use a fixed
size array.

Change-Id: I5c8c592514692a8abff51e5928aedcf71e100365
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-01 16:54:20 -07:00
Chris Aniszczyk 38327a54a8 Refactor Git API exceptions to a new package
Create a new 'org.eclipse.jgit.api.errors' package to contain
exceptions related to using the Git porcelain API.

Change-Id: Iac1781bd74fbd520dffac9d347616c3334994470
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-09-01 15:27:43 -07:00
Shawn O. Pearce 028a613ced Add toString and improve Javadoc of NotIgnoredFilter
Today while debugging some TreeWalk related code I noticed this
filter did not have a toString(), making it harder to see what the
filter graph was at a glance in the debugger.  Add a toString()
for debugging to match other TreeFilters, and clean up the Javadoc
slightly so its a bit more clear about the purpose of the filter.

While we are mucking about with some of this code, simplify
the logic of include so its shorter and thus faster to read.
The pattern now more closely matches that of SkipWorkTreeFilter.

Change-Id: Iad433a1fa6b395dc1acb455aca268b9ce2f1d41b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-01 15:24:32 -07:00
Marc Strapetz ea4ff61ad3 IndexDiff honors Index entries' "skipWorkTree" flag.
Change-Id: I428d11412130b64fc46d7052011f5dff3d653802
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-01 15:19:22 -07:00
Shawn Pearce 97695c4ca3 Merge "Avoid double quotes in Git Config" 2010-09-01 18:02:44 -04:00
Shawn Pearce c7e1199b56 Merge "Add FS.detect() for detection of file system abstraction." 2010-09-01 17:59:55 -04:00
Shawn O. Pearce 408d4b5375 Add reset() to AbstractTreeIterator API
This allows callers to force the iterator back to its starting point,
so it can be traversed again.  The default way to do this is to use
back(1) until first() is true, but this isn't very efficient for any
iterator.  All current implementations have better ways to implement
reset without needing to seek backwards.

Change-Id: Ia26e6c852fdac8a0e9c80ac72c8cca9d897463f4
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-01 10:19:43 -07:00
Shawn O. Pearce 9f323462be Improve DiffFormatter text file access
When we are asked to create a difference between two files the caller
really wants to see that output.  Instead of punting because a file
is too big to process, consider it to be binary.  This reduces the
accuracy of our output display, but makes it a lot more likely that
the formatter can still generate something semi-useful.

We set our default binary threshold to 50 MiB, which is the same
threshold that PackWriter uses before punting and deciding a file
is too big to delta compress.  Anything under this size we try to
load and process, anything over that size (or that won't allocate
in the heap) gets tagged as binary.

Change-Id: I69553c9ef96db7f2058c6210657f1181ce882335
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-01 10:19:43 -07:00
Shawn O. Pearce df8adefe86 Correct diff header formatting
When adding or deleting a file, we shouldn't ever prefix /dev/null
with the a/ or b/ prefixes.  Doing so is a mistake and confuses a
patch parser which handles /dev/null magically, while a/dev/null is
a file called null in the dev directory of the project.

Also when adding or deleting the "diff --git" line has the "real"
path on both sides, so we should see the following when adding the
file called foo:

  diff --git a/foo b/foo
  --- /dev/null
  +++ b/foo

The --- and +++ lines do not appear in a pure rename or copy delta,
C Git diff seems to omit these, so we now omit them as well.  We also
omit the index line when the ObjectIds are exactly equal.

Change-Id: Ic46892dea935ee8bdee29088aab96307d7ec6d3d
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-01 10:19:43 -07:00
Shawn O. Pearce 797d5c4d40 Remove duplicated code in DiffFormatter
Instead of trying to stream out the header, we can drop a redundant
code path by formatting the header into a temporary buffer and then
streaming out the actual line differences later.

Its a small amount of unnecessary work to buffer the file header,
but these are typically very tiny so the cost to format and reparse
is relatively low.

Change-Id: Id14a527a74ee0bd7e07f46fdec760c22b02d5bdf
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-01 10:19:43 -07:00
Shawn O. Pearce 1ea356b346 Move DiffFormatter default initialization to fields
Other fields in this class are initialized in their declaration, make
the code consistent with itself and use only one style.

Change-Id: I49a007e97ba52faa6b89f7e4b1eec85dccac0fa4
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-01 10:19:42 -07:00
Shawn O. Pearce 9df493a318 Correct Javadoc of DiffFormatter class
This class does a lot more than just reflow a patch script, it now is
the primary means of creating a diff output.

Change-Id: I74467c9a53dc270ef8c84e7c75f388414ec8ba8f
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-09-01 10:19:42 -07:00
Marc Strapetz a46abab244 Add FS.detect() for detection of file system abstraction.
To give the user more control on which file system abstraction
should be used on Windows, FS.detect() may be configured
to assume a Cygwin installation or nor.
2010-09-01 17:14:16 +02:00
Mathias Kinzler 2941d23e7e Avoid double quotes in Git Config
Currently, if a branch is created that has special chars ('#' in the bug),
Config will surround the subsection name with double quotes during
it's toText method which will result in an invalid file after saving the
Config.

Bug: 318249
Change-Id: I0a642f52def42d936869e4aaaeb6999567901001
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2010-09-01 09:13:19 +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 Pearce b3aa5802b9 Merge "DirCacheEntry: UPDATE_NEEDED should be in-core flag." 2010-08-31 14:29:03 -04:00
Marc Strapetz 80f4947e8b Fix RawParseUtils.formatBase10 to work with negative values
Change-Id: Iffa220de76c5e180796fa46c4d67f52a1b3b2e35
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-31 11:20:54 -07:00
Chris Aniszczyk b7465b8fe5 Remove deprecated PersonIdent constructor
Change-Id: I3831de1b6df25a52df30d367f0216573e6ee6b53
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-08-31 11:55:27 -05: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
Marc Strapetz 2eb5426aa9 DirCacheEntry: UPDATE_NEEDED should be in-core flag.
In correspondance to CGit, UPDATE_NEEDED flag should not be
written to disk. Furthermore, it currently intersects CGit's
CE_EXTENDED flag.
2010-08-31 11:25:16 +02:00
Christian Halstrick 47f4171315 Let Resolve be the default Merge strategy
the merge command should use by default the "resolve" merge strategy.

Change-Id: I6c6973a3397cca12bd8a6bd950d04b1766a08b4c
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-08-31 01:29:49 +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
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
Shawn O. Pearce a3945d1bc8 IndexPack: Use byte limited form of getCachedBytes
Currently our algorithm requires that we have the delta base as
a contiguous byte array... but getCachedBytes() might not work
if the object is considered to be large by its underlying loader.
Use the limited form to obtain the object as a byte array instead.

Change-Id: I33f12a8811cb6a4a67396174733f209db8119b42
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-30 11:40:01 -07:00
Shawn O. Pearce 1709800f27 Undo translation of protocol string 'unpack error'
This string is part of the network protocol, and isn't meant to
be translated into another language.  Clients actually scan for
the string "unpack error " off the wire and react magically to
this information.  If it were translated, they would instead have
a protocol exception, which isn't very useful when there is already
an error occurring.

Change-Id: Ia5dc8d36ba65ad2552f683bb637e80b77a7d92f0
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-30 10:58:25 -07:00
Shawn O. Pearce bc0359c42f Merge "Buffer very large delta streams to reduce explosion of CPU work" 2010-08-28 20:31:24 -04: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
Shawn O. Pearce b24f907e3e Buffer very large delta streams to reduce explosion of CPU work
Large delta streams are unpacked incrementally, but because a delta
can seek to a random position in the base to perform a copy we may
need to inflate the base repeatedly just to complete one delta.
So work around it by copying the base to a temporary file, and then
we can read from that temporary file using random seeks instead.
Its far more efficient because we now only need to inflate the
base once.

This is still really ugly because we have to dump to a temporary
file, but at least the code can successfully process a large
file without throwing OutOfMemoryError.  If speed is an
issue, the user will need to increase the JVM heap and ensure
core.streamFileThreshold is set to a higher value, so we don't use
this code path as often.

Unfortunately we lose the "optimization" of skipping over portions
of a delta base that we don't actually need in the final result.
This is going to cause us to inflate and write to disk useless
regions that were deleted and do not appear in the final result.
We could later improve on our code by trying to flatten delta
instruction streams before we touch the bottom base object, and
then only store the portions of the base we really need for the
final result and that appear out-of-order.  Since that is some
pretty complex code I'm punting on it for now and just doing this
simple whole-object buffering.

Because the process umask might be permitting other users to read
files we create, we put the temporary buffers into $GIT_DIR/objects.
We can reasonably assume that if a reader can read our temporary
buffer file in that directory, they can also read the base pack
file we are pulling it from and therefore its not a security breach
to expose the inflated content in a file.  This requires a reader
to have write access to the repository, but only if the file is
really big.  I'd rather err on the side of caution here and refuse
to read a very big file into /tmp than to possibly expose a secured
content because the Java 5 JVM won't let us create a protected
temporary file that only the current user can access.

Change-Id: I66fb80b08cbcaf0f65f2db0462c546a495a160dd
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-27 13:28:35 -07: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
Christian Halstrick 0e7a38b60f Add getBaseCommit() to Merger
The Merger was was only exposing the merge base as an
AbstractTreeIterator. Since we need the merge base as
RevCommit to generate the merge result I expose it here.

Change-Id: Ibe846370a35ac9bdb0c97ce2e36b2287577fbcad
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-26 18:52:26 -07:00
Shawn Pearce 7d9bfa390f Merge "Fix parsing of multiple authors in PersonIdent." 2010-08-26 15:00:58 -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
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 cb0c05b5b4 Increase the default streaming threshold to 15 MiB
Applying deltas in the large streaming mode is horrifically slow.
Trying to pack icu4c is impossible because a single 11 MiB file
sits on top of a 15 MiB file though a 10 deep delta chain, which
results in this very slow inflate process.

Upping the default limit to 15 MiB lets us process this large in a
reasonable time, but its still sufficiently low enough to prevent
exploding the heap of a very large process like Eclipse or Gerrit
Code Review.

We have to revisit the streaming delta application process and do
something much smarter, like flatten the delta chain before we apply
it to the base.  But even that is ugly, I've seen a 155 MiB delta
sitting on top of a 450 MiB file to produce a 300 MiB result object.
If the chain is deep, we may have trouble flatting it down.

Change-Id: If5a0dcbf9d14ea683d75546f104b09bb8cd8fdbb
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-25 17:07:13 -07:00
Shawn O. Pearce 7a9edb3662 Fix reuse from pack file for REF_DELTA types
We miscomputed the CRC32 checksum for a REF_DELTA type of object, by
not including the full 20 byte ObjectId of the delta base in the CRC
code we use when the delta is too large to go through our two faster
small reuse code paths.  This resulted in a corruption error during
packing, where the PackFile erroneously suspected the data was wrong
on the local filesystem and aborted writing, because the CRC didn't
match what we had read from the index.

Change-Id: I7d12cdaeaf2c83ddc11223ce0108d9bd6886e025
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-25 17:07:13 -07:00
Shawn O. Pearce 3a972f8664 Cleanup and correct resolve Javadoc
We didn't fully cover what we support and what we don't.  It was
also a bit hard to follow the syntaxes supported.  Clean that up
by documenting it.

Change-Id: I7b96fa6cbefcc2364a51f336712ad361ae42df2d
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-25 17:07:13 -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 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 c44495fa2f Complete an abbreviation when formatting a patch
If we are given a DiffEntry header that already has abbreviated
ObjectIds on it, we may still be able to resolve those locally and
output the difference.  Try to do that through the new resolve API
on ObjectReader.

Change-Id: I0766aa5444b7b8fff73620290f8c9f54adc0be96
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-25 17:07:12 -07:00
Shawn O. Pearce 127a5f95e1 Use limited getCachedBytes in RevWalk
Parsing is rewritten to use the size limited form of getCachedBytes,
thus freeing the revwalk infrastructure from needing to care about
a large object vs. a small object when it gets an ObjectLoader.

Right now we hardcode our upper bound for a commit or annotated
tag to be 15 MiB.  I don't know of any that is more than 1 MiB in
the wild, so going 15x that should give us some reasonable headroom.

Change-Id: If296c211d8b257d76e44908504e71dd9ba70ffa8
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-25 17:07:12 -07:00
Shawn O. Pearce c11711f98e Use limited getCachedBytes code to reduce duplication
Rather than duplicating this block everywhere, reuse the limited size
form of getCachedBytes to acquire the content of an object.

Change-Id: I2e26a823e6fd0964d8f8dbfaa0fc2e8834c179c1
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-08-25 19:05:53 -05: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
Chris Aniszczyk e69dcc703d Merge "Add ObjectId to the LargeObjectException" 2010-08-25 19:54:32 -04:00
Shawn O. Pearce 1f4b48a37c Add ObjectId to the LargeObjectException
A chunk of code that throws LargeObjectException may or may not have
the specific ObjectId on hand when its thrown.  If it does, we want
to cache it in the exception, and put that in the message.  If it is
missing we want to be able to set it later from a higher level stack
frame that does have the object handy.

Change-Id: Ife25546158868bdfa886037e4493ef8235ebe4b9
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-08-25 18:54:07 -05:00
Chris Aniszczyk f74d474f3c Merge "Don't copy more than the object size" 2010-08-25 19:52:36 -04:00
Chris Aniszczyk 595a20a064 Merge "Use the ObjectStream size during copyTo" 2010-08-25 19:50:43 -04:00
Benjamin Muskalla 700b8b4514 Fixed typo in DirCache documentation
Change-Id: Ifc2e9047a45d57829fce59c66618e5de9120a5bb
Signed-off-by: Benjamin Muskalla <bmuskalla@eclipsesource.com>
2010-08-25 15:52:18 +02:00
Shawn O. Pearce 7cfe2f12ff Don't copy more than the object size
If the loader's stream is broken and returns to us more content
than it originally declared as the size of the object, don't
copy that onto the output stream.  Instead throw EOFException
and abort fast.  This way we don't follow an infinite stream,
but instead will at least stop when the size was reached.

Change-Id: I7ec0c470c875f03b1f12a74a9b4d2f6e73b659bb
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-24 17:37:07 -07:00
Shawn O. Pearce b474de1da3 Use the ObjectStream size during copyTo
If the stream is a delta decompression stream, getting the size
can be expensive.  Its cheaper to get it from the stream itself
rather than from the object loader.

Change-Id: Ia7f0af98681f6d56ea419a48c6fa8eea09274b28
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-08-24 17:37:07 -07:00