Commit Graph

2207 Commits

Author SHA1 Message Date
Robin Stocker 252b1dd5c2 Fix warnings about assigning paramter in util.io
Change-Id: I08bed4275af9ec52aa4d7054067ac82f6a3c9781
2013-05-01 16:48:14 +02:00
Robin Stocker f448d62d29 Update tags on fetch if --tags or tag refspec specified
When either --tags or a tag ref is explicitly specified on fetch, C Git
updates existing local tags if they are different.

Before this change, JGit returned REJECTED in such a case. Now it
updates it and returns FORCED.

Example:

    % mkdir a
    % cd a
    % git init -q
    % touch test.txt
    % git add test.txt
    % git commit -q -m 'Initial'
    % git tag v1
    % cd ..
    % git clone -q a b
    % cd a
    % echo Test > test.txt
    % git commit -q -a -m 'Second'
    % git tag -f v1
    Updated tag 'v1' (was bc85c08)
    % cd ../b
    % git fetch --tags
     - [tag update]      v1         -> v1

Bug: 388095
Change-Id: I5d5494c2ad1a2cdb8e9e614d3de445289734edfe
2013-05-01 16:02:01 +02:00
Robin Stocker 68b378a4b5 Only fetch tags that do not exist locally with auto-follow
This corresponds to what C Git does, quoting from the fetch man page:

  This is done by first fetching from the remote using the given
  <refspec>s, and if the repository has objects that are pointed by
  remote tags that it does not yet have, then fetch those missing tags.

Before, JGit would also fetch tags that exist locally but point to a
different object, resulting in REJECTED results for these.

Also add some test cases to cover more cases.

Bug: 388095
Change-Id: Ib03d2d82e9c4b60179d626cfd5174be1da6388b2
Also-by: Stefan Lay <stefan.lay@sap.com>
2013-05-01 16:00:42 +02:00
Robin Stocker 8bd1e86bb7 Abort before delete in FileUtils.delete EMPTY_DIRECTORIES_ONLY|RECURSIVE
Depending on the order in which items are traversed for RECURSIVE, an
empty directory may come first before detecting that there is a file and
aborting.

This fixes it by traversing files first.

Bug: 405558
Change-Id: I638b7da58e33ffeb0fee172b96f4c823943d29e9
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-04-29 01:00:35 +02:00
Robin Rosenberg 687b887c68 Merge "Make the Reflog a public API again" 2013-04-27 08:56:37 -04:00
Robin Rosenberg a5e78a3f06 Merge "Remove unused logger from RecursiveMerger" 2013-04-27 08:55:32 -04:00
Robin Stocker 23e3fb135b URIish: Allow multiple slashes in paths
It's also allowed by C Git.

Change-Id: Ie0a0d1f57d84e70fd5ef50b7844d22fea43d0e08
2013-04-27 14:35:12 +02:00
Robin Stocker 664d738c9f Refer to getEntryPathLength in docs of getEntryPathBuffer
Change-Id: Icca41d80bd0791cd2d4bf03297795d161afbee70
2013-04-27 14:18:59 +02:00
Alex Blewitt 37f0e324b5 Allow deletions to occur when there is no HEAD
If the HEAD is not present in a repository, then there is a
NullPointerException thrown in the delete code. Since this only
exists to verify if the deletion is not the HEAD reference, then
skip this check if the HEAD cannot be found.

Bug: 406722
Change-Id: I882497202d986096513a4d791cd07fa935a3f9e4
Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
2013-04-27 11:42:58 +01:00
Jonathan Nieder 31d79ae0af Remove unused logger from RecursiveMerger
JGit doesn't currently use java.util.logging.Logger.  Remove this
never-used Logger introduced in ab99b78ca0 (Implement recursive
merge strategy, 2013-02-21) to make that easier to see.

Change-Id: I92c578e7f3617085a667de7c992174057be3eb71
2013-04-26 10:16:09 -07:00
Robin Rosenberg 9dcd8c2c90 Make the Reflog a public API again
Change-Id: I8ced7098da5b345fd9af2fdfafd1ef6a44ccee0d
2013-04-26 00:57:17 +02:00
Robin Rosenberg 2af9a4c7b1 Merge "status: Print conflict description for unmerged paths" 2013-04-25 17:45:35 -04:00
Robin Stocker 3699ea648e Document RevTag#getObject() that returned object is unparsed
Change-Id: I238d388e40362721eecf37f64ad7d48a399ff129
2013-04-22 18:22:18 +02:00
Robin Stocker 60f0eb748c Improve class documentation of TagCommand
Change-Id: I9c636b927fa2d7cfbe1eb5535a9e702b2209f51d
2013-04-22 15:35:26 +02:00
Robin Stocker a50ed5666f status: Print conflict description for unmerged paths
Prefix unmerged paths with conflict description (e.g. "both modified:"),
the same way C Git does.

Change-Id: I083cd191ae2ad3e2460aa4052774aed6e36c2699
2013-04-19 19:55:24 +02:00
Robin Rosenberg ee222a3be1 Create constants in ConfigConstants for the "diff" section
Change-Id: I5cf5fe60374d1e94eb031488e4f92c8e521f41a6
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2013-04-19 10:29:45 -05:00
Robin Stocker 2396bab339 Fix examples with refs/heads/ in RefSpec Javadoc
Change-Id: I06c1c7242a1b4c8f499c27a598cca714803799b7
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2013-04-19 10:14:39 -05:00
Robin Stocker 1080cc5a0d IndexDiff: Provide stage state for conflicting entries
Adds a new method getConflictingStageStates() which returns a
Map<String, StageState> (path to stage state). StageState is an enum for
all possible stage combinations (BOTH_DELETED, ADDED_BY_US, ...).

This can be used to implement the conflict text for unmerged paths in
output of "git status" or in EGit for decorations/hints.

Bug: 403697
Change-Id: Ib461640a43111b7df4a0debe92ff69b82171329c
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2013-04-19 10:05:06 -05:00
Robin Rosenberg 1c40d83f52 Merge "A deleted work tree file is not a conflict when merge wants to delete it" 2013-04-19 07:39:39 -04:00
Robin Rosenberg f37e25e2c3 Merge "Untracked files should not be included in stash" 2013-04-19 07:36:29 -04:00
Robin Rosenberg 7a42b7fb95 Untracked files should not be included in stash
The previous code stashed untracked files and left them
in the work tree.

Bug: 403282
Change-Id: I71727addb2b55fb8e409cae2b6af8138b1ff7ef1
2013-04-18 23:19:15 +02:00
Robin Rosenberg 526b6266a5 Remove some unnecessary dependencies on FileRepostory
Change-Id: Ib6ee3a2874a7e2240aa68f4ac32d00c4d1fab5ae
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2013-04-18 15:33:50 -05:00
Robin Stocker 78fca8a099 Improve test coverage of AutoCRLF(In|Out)putStream
Bug: 405672
Change-Id: I3894e98617fcee16dc2ac9853c203c62eb30c3ab
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2013-04-18 14:58:51 -05:00
Shawn Pearce fa1bc6abb7 Merge changes Id2848c16,I7621c434
* changes:
  Rescale "Compressing objects" progress meter by size
  Split delta search buckets by byte weight
2013-04-17 14:53:13 -04:00
Shawn Pearce 5d8a9f6f3f Rescale "Compressing objects" progress meter by size
Instead of counting objects processed, count number of bytes added
into the window. This should rescale the progress meter so that 30%
complete means 30% of the total uncompressed content size has been
inflated and fed into the window.

In theory the progress meter should be more accurate about its
percentage complete/remaining fraction than with objects. When
counting objects small objects move the progress meter more rapidly
than large objects, but demand a smaller amount of work than large
objects being compressed.

Change-Id: Id2848c16a2148b5ca51e0ca1e29c5be97eefeb48
2013-04-17 14:43:01 -04:00
Shawn Pearce 21e4aa2b9e Split delta search buckets by byte weight
Instead of assuming all objects cost the same amount of time to
delta compress, aggregate the byte size of objects in the list
and partition threads with roughly equal total bytes.

Before splitting the list select the N largest paths and assign
each one to its own thread. This allows threads to get through the
worst cases in parallel before attempting smaller paths that are
more likely to be splittable.

By running the largest path buckets first on each thread the likely
slowest part of compression is done early, while progress is still
reporting a low percentage. This gives users a better impression of
how fast the phase will run. On very complex inputs the slow part
is more likely to happen first, making a user realize its time to
go grab lunch, or even run it overnight.

If the worst sections are earlier, memory overruns may show up
earlier, giving the user a chance to correct the configuration and
try again before wasting large amounts of time. It also makes it
less likely the delta compression phase reaches 92% in 30 minutes
and then crawls for 10 hours through the remaining 8%.

Change-Id: I7621c4349b99e40098825c4966b8411079992e5f
2013-04-17 11:31:00 -07:00
Shawn Pearce e74263e743 Merge "Support excluding objects during DFS compaction" 2013-04-17 14:19:21 -04:00
Shawn Pearce 3c27ee1a91 Support excluding objects during DFS compaction
By excluding objects the compactor can avoid storing objects that
are already well packed in the base GC packs, or any other pack
not being replaced by the current compaction operation.

For deltas the base object is still included even if the base exists
in another exclusion set.  This favors keeping deltas for recent
history, to support faster fetch operations for clients.

Change-Id: Ie822fe075fe5072fe3171450fda2f0ca507796a1
2013-04-16 17:54:23 -07:00
Matthias Sohn aa7be667bc Make recursive merge strategy the default merge strategy
Use recursive merge as the default strategy since it can successfully
merge more cases than the resolve strategy can. This is also the default
in native Git.

Change-Id: I38fd522edb2791f15d83e99038185edb09fed8e1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-04-15 21:46:12 +02:00
Colby Ranger eaa52b12f5 Update PackBitmapIndexRemapper to handle mappings not in the new pack.
Previously, the code assumed all commits in the old pack would also
be present in the new pack. This assumption caused an
ArrayIndexOutOfBoundsException during remapping of ids. Fix the
iterator to only return entries that may be remapped. Furthermore,
update getBitmap() to return null if commit does not exist in the
new pack.

Change-Id: I065babe8cd39a7654c916bd01c7012135733dddf
2013-04-15 09:35:07 -07:00
Robin Rosenberg 4c638be79f Fix boundary conditions in AutoCRLFOutputStream
This fixes some problems with inputs around the size of the internal
buffer in AutoCRLFOutputStream (8000).

Tests supplied by Robin Stocker.

Bug: 405672
Change-Id: I6147897290392b3bfd4040e8006da39c302a3d49
2013-04-14 19:53:48 +02:00
Robin Rosenberg a6ed390ea7 NLS warning cleanup
Change-Id: Ia76aa02dd330a1f88096c2b059b363aa38d653e9
2013-04-14 00:41:55 +02:00
Robin Rosenberg 5db307a695 Merge "Fix a possible NPE" 2013-04-13 06:16:11 -04:00
Shawn Pearce 5f03dc61b4 Merge changes I845caede,Ie25c6d3a,I5caec313,Ib11ff99f,I9ccf20c3,Ic7826f29,I1bdd8b58,Idb84c1d7,I078841f9
* changes:
  Always attempt delta compression when reuseDeltas is false
  Avoid TemporaryBuffer.Heap on very small deltas
  Correct distribution of allowed delta size along chain length
  Split remaining delta work on path boundaries
  Replace DeltaWindow array with circularly linked list
  Micro-optimize copy instructions in DeltaEncoder
  Micro-optimize DeltaWindow primary loop
  Micro-optimize DeltaWindow maxMemory test to be != 0
  Mark DeltaWindowEntry methods final
2013-04-12 16:16:09 -04:00
Shawn Pearce c9707e6353 Always attempt delta compression when reuseDeltas is false
If reuseObjects=true but reuseDeltas=false the caller wants attempt
a delta for every object in the input list. Test for reuseDeltas
to ensure every object passes through the searchInWindow() method.

If no delta is possible for an object and it will be stored whole
(non-delta format), PackWriter may still reuse its content from any
source pack. This avoids an inflate()-deflate() cycle to recompress
the object contents.

Change-Id: I845caeded419ef4551ef1c85787dd5ffd73235d9
2013-04-12 12:59:02 -07:00
Shawn Pearce a5c6aac76c Avoid TemporaryBuffer.Heap on very small deltas
TemporaryBuffer is great when the output size is not known, but must
be bound by a relatively large upper limit that fits in memory, e.g.
64 KiB or 20 MiB.  The buffer gracefully supports growing storage by
allocating 8 KiB blocks and storing them in an ArrayList.

In a Git repository many deltas are less than 8 KiB.  Typical tree
objects are well below this threshold, and their deltas must be
encoded even smaller.

For these much smaller cases avoid the 8 KiB minimum allocation used
by TemporaryBuffer.  Instead allocate a very small OutputStream
writing to an array that is sized at the limit.

Change-Id: Ie25c6d3a8cf4604e0f8cd9a3b5b701a592d6ffca
2013-04-12 12:07:11 -07:00
Shawn Pearce 8a7c2f97d0 Correct distribution of allowed delta size along chain length
Nicolas Pitre discovered a very simple rule for selecting between two
different delta base candidates:

  - if based whole object, must be <= 50% of target
  - if at end of a chain, must be <= 1/depth * 50% of target

The rule penalizes deltas near the end of the chain, requiring them to
be very small in order to be kept by the packer.  This favors deltas
that are based on a shorter chain, where the read-time unpack cost is
much lower.  Fewer bytes need to be consulted from the source pack
file, and less copying is required in memory to rebuild the object.

Junio Hamano explained Nico's rule to me today, and this commit fixes
DeltaWindow to implement it as described.

When no base has been chosen the computation is simply the statements
denoted above.  However once a base with depth of 9 has been chosen
(e.g.  when pack.depth is limited to 10), a non-delta source may
create a new delta that is up to 10x larger than the already selected
base.  This reflects the intent of Nico's size distribution rule no
matter what order objects are visited in the DeltaWindow.

With this patch and my other patches applied, repacking JGit with:

  [pack]
    reuseObjects = false
    reuseDeltas = false
    depth = 50
    window = 250
    threads = 4
    compression = 9

  CGit (all) 5,711,735 bytes; real 0m13.942s user 0m47.722s [1]
  JGit heads 5,718,295 bytes; real 0m11.880s user 0m38.177s [2]
       rest      9,809 bytes

The improved JGit result for the head pack is only 6.4 KiB larger than
CGit's resulting pack.  This patch allowed JGit to find an additional
39.7 KiB worth of space savings.  JGit now also often runs 2s faster
than CGit, despite also creating bitmaps and pruning objects after the
head pack creation.

[1] time git repack -a -d -F --window=250 --depth=50
[2] time java -Xmx128m -jar jgit debug-gc

Change-Id: I5caec31359bf7248cabdd2a3254c84d4ee3cd96b
2013-04-12 12:07:09 -07:00
Shawn Pearce 3b7924f403 Split remaining delta work on path boundaries
When an idle thread tries to steal work from a sibling's remaining
toSearch queue, always try to split along a path boundary. This
avoids missing delta opportunities in the current window of the
thread whose work is being taken.

The search order is reversed to walk further down the chain from
current position, avoiding the risk of splitting the list within
the path the thread is currently processing.

When selecting which thread to split from use an accurate estimate
of the size to be taken. This avoids selecting a thread that has
only one path remaining but may contain more pending entries than
another thread with several paths remaining.

As there is now a race condition where the straggling thread can
start the next path before the split can finish, the stealWork()
loop spins until it is able to acquire a split or there is only
one path remaining in the siblings.

Change-Id: Ib11ff99f90a4d9efab24bf4a85342cc63203dba5
2013-04-12 12:03:38 -07:00
Shawn Pearce 65f44bef23 Remove DFS locality ordering during packing
PackWriter generally chooses the order for objects when it builds the
object lists.  This ordering already depends on history information to
guide placing more recent objects first and historical objects last.

Allow PackWriter to make the basic ordering decisions, instead of
trying to override them.  The old approach of sorting the list caused
DfsReader to override any ordering change PackWriter might have tried
to make when repacking a repository.

This now better matches with WindowCursor's implementation, where
PackWriter solely determines the object ordering.

Change-Id: Ic17ab5631ec539f0758b962966c3a1823735b814
2013-04-12 07:10:30 -07:00
Shawn Pearce af33a911d0 Replace DeltaWindow array with circularly linked list
Typical window sizes are 10 and 250 (although others are accepted).
In either case the pointer overhead of 1 pointer in an array or
2 pointers for a double linked list is trivial.  A doubly linked
list as used here for window=250 is only another 1024 bytes on a
32 bit machine, or 2048 bytes on a 64 bit machine.

The critical search loops scan through the array in either the
previous direction or the next direction until the cycle is finished,
or some other scan abort condition is reached.  Loading the next
object's pointer from a field in the current object avoids the
branch required to test for wrapping around the edge of the array.
It also saves the array bounds check on each access.

When a delta is chosen the window is shuffled to hoist the currently
selected base as an earlier candidate for the next object. Moving
the window entry is easier in a double-linked list than sliding a
group of array entries.

Change-Id: I9ccf20c3362a78678aede0f0f2cda165e509adff
2013-04-11 10:44:51 -07:00
Shawn Pearce 0f32901ab7 Micro-optimize copy instructions in DeltaEncoder
The copy instruction formatter should not to compute the shifts and
masks twice.  Instead compute them once and assume there is a register
available to store the temporary "b" for compare with 0.

Change-Id: Ic7826f29dca67b16903d8f790bdf785eb478c10d
2013-04-11 01:17:35 -07:00
Shawn Pearce 1db50c9d91 Micro-optimize DeltaWindow primary loop
javac and the JIT are more likely to understand a boolean being
used as a branch conditional than comparing int against 0 and 1.
Rewrite NEXT_RES and NEXT_SRC constants to be booleans so the
code is clarified for the JIT.

Change-Id: I1bdd8b587a69572975a84609c779b9ebf877b85d
2013-04-11 01:17:28 -07:00
Shawn Pearce 6903fa4a34 Micro-optimize DeltaWindow maxMemory test to be != 0
Instead of using a compare-with-0 use a does not equal 0.
javac bytecode has a special instruction for this, as it
is very common in software. We can assume the JIT knows
how to efficiently translate the opcode to machine code,
and processors can do != 0 very quickly.

Change-Id: Idb84c1d744d2874517fd4bfa1db390e2dbf64eac
2013-04-11 01:17:22 -07:00
Robin Rosenberg 4955301fac Merge "Consider working tree changes when stashing newly added files" 2013-04-11 02:06:54 -04:00
Shawn Pearce 4db695c1c6 Mark DeltaWindowEntry methods final
This class and all of its methods are only package visible.
Clarify the methods as final for the benefit of the JIT to
inline trivial code.

Change-Id: I078841f9900dbf299fbe6abf2599f0208ae96856
2013-04-10 21:20:24 -07:00
Shawn Pearce b5cbfa0146 Merge changes Ideecc472,I2b12788a,I6cb9382d,I12cd3326,I200baa0b,I05626f2e,I65e45422
* changes:
  Increase PackOutputStream copy buffer to 64 KiB
  Tighten object header writing in PackOutuptStream
  Skip main thread test in ThreadSafeProgressMonitor
  Declare members of PackOutputStream final
  Always allocate the PackOutputStream copyBuffer
  Disable CRC32 computation when no PackIndex will be created
  Steal work from delta threads to rebalance CPU load
2013-04-10 20:56:13 -04:00
Robin Rosenberg 8272f65730 Merge "LogCommand.all(): filter out refs that do not refer to commit objects" 2013-04-10 17:30:18 -04:00
Robin Rosenberg ad2ffc576b Merge "LogCommand.all(), peel references before using them" 2013-04-10 17:29:58 -04:00
Shawn Pearce 6c0bb4351d Increase PackOutputStream copy buffer to 64 KiB
Colby just pointed out to me the buffer was 16 KiB. This may
be very small for common objects. Increase to 64 KiB.

Change-Id: Ideecc4720655a57673252f7adb8eebdf2fda230d
2013-04-10 13:05:58 -07:00
Shawn Pearce 46ef61a702 Tighten object header writing in PackOutuptStream
Most objects are written as OFS_DELTA with the base in the pack,
that is why this case comes first in writeHeader(). Rewrite the
condition to always examine this first and cache the PackWriter's
formatting flag for use of OFS_DELTA headers, in modern Git networks
this is true more often then it it is false.

Assume the cost of write() is high, especially due to entering the
MessageDigest to update the pack footer SHA-1 computation. Combine
the OFS_DELTA information as part of the header buffer so that the
entire burst is a single write call, rather than two relatively
small ones. Most OFS_DELTA headers are <= 6 bytes, so this rewrite
tranforms 2 writes of 3 bytes each into 1 write of ~6 bytes.

Try to simplify the objectHeader code to reduce branches and use
more local registers. This shouldn't really be necessary if the
compiler is well optimized, but it isn't very hard to clarify data
usage to either javac or the JIT, which may make it easier for the
JIT to produce better machine code for this method.

Change-Id: I2b12788ad6866076fabbf7fa11f8cce44e963f35
2013-04-10 12:59:11 -07:00
Shawn Pearce d01fe32795 Skip main thread test in ThreadSafeProgressMonitor
update(int) is only invoked from a worker thread, in JGit's case
this is DeltaTask. The Javadoc of TSPM suggests update should only
ever be used by a worker thread.

Skip the main thread check, saving some cycles on each run of the
progress monitor.

Change-Id: I6cb9382d71b4cb3f8e8981c7ac382da25304dfcb
2013-04-10 12:59:11 -07:00
Shawn Pearce 66192817cd Declare members of PackOutputStream final
These methods cannot be sanely overridden anywhere. Most methods
are package visible only, or are private. A few public methods do
exist but there is no useful way to override them since creation
of PackOutputStream is managed by PackWriter and cannot be delegated.

Change-Id: I12cd3326b78d497c1f9751014d04d1460b46e0b0
2013-04-10 12:59:09 -07:00
Shawn Pearce 2be6927d8e Always allocate the PackOutputStream copyBuffer
The getCopyBuffer() is almost always used during output. All known
implementations of ObjectReuseAsIs rely on the buffer to be present,
and the only sane way to get good performance from PackWriter is to
reuse objects during packing.

Avoid a branch and test when obtaining this buffer by making sure
it is always populated.

Change-Id: I200baa0bde5dcdd11bab7787291ad64535c9f7fb
2013-04-10 12:58:51 -07:00
Shawn Pearce eb17495ca4 Disable CRC32 computation when no PackIndex will be created
If a server is streaming 3GiB worth of pack data to a client there
is no reason to compute the CRC32 checksum on the objects. The
CRC32 code computed by PackWriter is used only in the new index
created by writeIndex(), which is never invoked for the native Git
network protocols.

Object reuse may still compute its own CRC32 to verify the data
being copied from an existing pack has not been corrupted. This
check is done by the ObjectReader that implements ObjectReuseAsIs
and has no relationship to the CRC32 being skipped during output.

Change-Id: I05626f2e0d6ce19119b57d8a27193922636d60a7
2013-04-10 12:58:50 -07:00
Shawn Pearce d0a5337625 Steal work from delta threads to rebalance CPU load
If the configuration wants to run 4 threads the delta search work
is initially split somewhat evenly across the 4 threads. During
execution some threads will finish early due to the work not being
split fairly, as the initial partitions were based on object count
and not cost to inflate or size of DeltaIndex.

When a thread finishes early it now tries to take 50% of the work
remaining on a sibling thread, and executes that before exiting.
This repeats as each thread completes until a thread has only 1
object remaining.

Repacking Blink, Chromium's new fork of WebKit (2.2M objects 3.9G):

  [pack]
    reuseDeltas = false
    reuseObjects = false
    depth = 50
    threads = 8
    window = 250
    windowMemory = 800m

  before: ~105% CPU after 80%
  after:  >780% CPU to 100%

Change-Id: I65e45422edd96778aba4b6e5a0fd489ea48e8ca3
2013-04-10 11:34:50 -07:00
Robin Rosenberg 1bede91db2 Consider working tree changes when stashing newly added files
Bug: 402396
Change-Id: I50ff707c0c9abcab3f98eea21aaa6e824f7af63a
2013-04-09 21:28:15 +02:00
Robin Rosenberg 0a824f5996 Add a constant for info/exclude
Change-Id: Ifd537ce4e726cb9460ea332f683428689bd3d7f4
2013-04-08 18:08:23 -04:00
Robin Rosenberg cc00feaa8d A deleted work tree file is not a conflict when merge wants to delete it
Bug: 405199
Change-Id: I4b2ef3dc432d2fad8a6fabd1c8aec407b5c8c5ac
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2013-04-08 22:43:39 +02:00
Matthias Sohn 2f93551e18 Add missing @since tags for new API methods
Change-Id: I38f10d622c30f19d1154a4901477e844cb411707
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-04-07 23:22:48 +02:00
Gustav Karlsson b3e9626743 Added characters to be escaped in file name patterns
Originally, characters could not be escaped in FileNameMatcher patterns.
This breaks file name matching when escaped brackets "\[" and "\]" are
used in the pattern. A fix has been implemented to allow for any
character to be escaped by prepending it with a '\'

Bug: 340715
Change-Id: Ie46fd211931fa09ef3a6a712bd1da3d7fb64c5e3
Signed-off-by: Gustav Karlsson <gustav.karlsson@tieto.com>
2013-04-06 18:23:33 +02:00
Matthias Sohn 41cba241d8 DfsReaderOptions are options for a DFS stored repository
Change-Id: I2af0bf686188f1402fb53bf6dbe0ecb228069ace
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-04-06 01:28:20 +02:00
Shawn Pearce 5d446f410d Support cutting existing delta chains longer than the max depth
Some packs built by JGit have incredibly long delta chains due to a
long standing bug in PackWriter. Google has packs created by JGit's
DfsGarbageCollector with chains of 6000 objects long, or more.

Inflating objects at the end of this 6000 long chain is impossible
to complete within a reasonable time bound. It could take a beefy
system hours to perform even using the heavily optimized native C
implementation of Git, let alone with JGit.

Enable pack.cutDeltaChains to be set in a configuration file to
permit the PackWriter to determine the length of each delta chain
and clip the chain at arbitrary points to fit within pack.depth.

Delta chain cycles are still possible, but no attempt is made to
detect them. A trivial chain of A->B->A will iterate for the full
pack.depth configured limit (e.g. 50) and then pick an object to
store as non-delta.

When cutting chains the object list is walked in reverse to try
and take advantage of existing chain computations. The assumption
here is most deltas are near the end of the list, and their bases
are near the front of the list. Going up from the tail attempts to
reuse chainLength computations by relying on the memoized value in
the delta base.

The chainLength field in ObjectToPack is overloaded into the depth
field normally used by DeltaWindow. This is acceptable because the
chain cut happens before delta search, and the chainLength is reset
to 0 if delta search will follow.

Change-Id: Ida4fde9558f3abbbb77ade398d2af3941de9c812
2013-04-05 10:07:14 -07:00
Shawn Pearce 01a0699acc Micro-optimize reuseDeltaFor in PackWriter
This switch is called mostly for OBJ_TREE and OBJ_BLOB types, which
typically make up 66% of the objects in a repository. Simplify the
test for these common types by testing for the one bit they have in
common and returning early.

Object type 5 is currently undefined. In the old code it would hit
the default and return true. In the new code it will match the early
case and also return true. In either implementation 5 should never show
up as it is not a valid type known to Git.

Object type 6 OFS_DELTA is not permitted to be supplied here.
Object type 7 REF_DELTA is not permitted to be supplied here.

Change-Id: I0ede8acee928bb3e73c744450863942064864e9c
2013-04-05 09:43:02 -07:00
Shawn Pearce 8e83c36e27 Static import OBJ_* constants into PackWriter
Shortens most of the code that touches the objectLists.

Change-Id: Ib14d366dd311e544e7ba50e9ce07a6f3ce0cf254
2013-04-05 09:43:02 -07:00
Shawn Pearce 6a5019f539 Renumber internal ObjectToPack flags
Now that WANT_WRITE is gone renumber the flags to move the unused
bit next to the type. Recluster AS_IS and DELTA_ATTEMPTED to be
next to each other since these bits are tested as a pair.

Change-Id: I42994b5ff1f67435e15c3f06d02e3b82141e8f08
2013-04-04 19:44:41 -07:00
Shawn Pearce 241eed844d Move wantWrite flag to be special offset 1
Free up the WANT_WRITE flag in ObjectToPack by switching the test
to use the special offset value of 1. The Git pack file format
calls for the first 4 bytes to be 'PACK', which means any object
must start at an offset >= 4. Current versions require another 8
bytes in the header, placing the first object at offset = 12.

So offset = 1 is an invalid location for an object, and can be
used as a marker signal to indicate the writing loop has tried
to write the object, but recursed into the base first. When an
object is visited with offset == 1 it means there is a cycle in
the delta base path, and the cycle must be broken.

Change-Id: I2d05b9017c5f9bd9464b91d43e8d4b4a085e55bc
2013-04-04 17:53:01 -07:00
Shawn Pearce 1eed78657f Don't delta compress garbage objects
Garbage is randomly ordered and unlikely to delta compress against
other garbage. Disable delta compression allowing objects to switch
to whole form when moving to the garbage pack.

Because the garbage is not well compressed assume deltas were not
attempted during a normal GC cycle.

Override the reuse settings, garbage that can be reused should be
reused as-is into the garbage pack rather than switching something
like the compression level during a GC. It is intended that garbage
will eventually be removed from the repository so expending CPU
time on a compression switch is not worthwhile.

Change-Id: I0e8e58ee99e5011d375d3d89c94f2957de8402b9
2013-04-04 15:25:56 -07:00
Shawn Pearce 56497be34d Delete broken DFS read-ahead support
This implementation has been proven to deadlock in production server
loads. Google has been running with it disabled for a quite a while,
as the bugs have been difficult to identify and fix.

Instead of suggesting it works and is useful, drop the code. JGit
should not advertise support for functionality that is known to
be broken.

In a few of the places where read-ahead was enabled by DfsReader
there is more information about what blocks should be loaded when.
During object representation selection, or size lookup, or sending
object as-is to a PackWriter, or sending an entire pack as-is the
reader knows exactly which blocks are required in the cache, and it
also can compute when those will be needed. The broken read-ahead
code was stupid and just read a fixed amount ahead of the current
offset, which can waste IOs if more precise data was available.

DFS systems are usually slow to respond so read-ahead is still
a desired feature, but it needs to be rebuilt from scratch and
make better use of the offset information.

Change-Id: Ibaed8288ec3340cf93eb269dc0f1f23ab5ab1aea
2013-04-04 15:14:23 -07:00
Robin Rosenberg d90656f536 Fix a possible NPE
String.valueOf is an overloaded and the compiler unfortunately picks
the wrong one since null contains no type information.

Change-Id: Icd197eaa046421f3cfcc5bf3e7601dc5bc7486b6
2013-04-04 18:08:06 -04:00
Shawn Pearce d72416afbb Optimize DFS object reuse selection code
Rewrite this complicated logic to examine each pack file exactly
once. This reduces thrashing when there are many large pack files
present and the reader needs to locate each object's header.

The intermediate temporary list is now smaller, it is bounded to
the same length as the input object list. In the prior version of
this code the list contained one entry for every representation of
every object being packed.

Only one representation object is allocated, reducing the overall
memory footprint to be approximately one reference per object found
in the current pack file (the pointer in the BlockList). This saves
considerable working set memory compared to the prior version that
made and held onto a new representation for every ObjectToPack.

Change-Id: I2c1f18cd6755643ac4c2cf1f23b5464ca9d91b22
2013-04-04 14:21:34 -07:00
Shawn Pearce 93a27ce728 Simplify size test in PackWriter
Clip the configured limit to Integer.MAX_VALUE at the top of the
loop, saving a compare branch per object considered. This can cut
2M branches out of a repacking of the Linux kernel.

Rewrite the logic so the primary path is to match the conditional;
most objects are larger than BLKSZ (16 bytes) and less than limit.
This may help branch prediction on CPUs if the CPU tries to assume
execution takes the side of the branch and not the second.

Change-Id: I5133d1651640939afe9fbcfd8cfdb59965c57d5a
2013-04-04 11:25:57 -07:00
Shawn Pearce d45277a691 Declare critical exposed methods of ObjectToPack final
There is no reasonable way for a subclass to correctly override and
implement these methods. They depend on internal state that cannot
otherwise be managed.

Most of these methods are also in critical paths of PackWriter.
Declare them final so subclasses do not try to replace them,
and so the JIT knows the smaller ones can be safely inlined.

Change-Id: I9026938e5833ac0b94246d21c69a143a9224626c
2013-04-04 11:18:41 -07:00
Shawn Pearce 1d362e35bc Declare internal flag accessors of ObjectToPack final
None of these methods should ever be overridden at runtime by an
extension class. Given how small they are the JIT should perform
inlining where reasonable. Hint this is possible by marking all
methods final so its clear no replacement can be loaded later on.

Change-Id: Ia75a5d36c6bd25b24169e2bdfa360c8f52b669cd
2013-04-04 11:16:04 -07:00
Shawn Pearce 876a2ffb21 Remove unused method isDeltaAttempted()
This flag is never checked on its own. It is only checked as part
of a pair through the doNotAttemptDelta() method. Delete the method
so there is less confusion about the flag being used on its own.

Change-Id: Id7088caa649599f4f11d633412c2a2af0fd45dd8
2013-04-04 11:04:32 -07:00
Shawn Pearce 594d4ceb12 Simplify setDoNotDelta() to always set the flag
This method is only invoked with true as the argument.
Remove the unnecessary parameter and branch, making
the code easier for the JIT to optimize.

Change-Id: I68a9cd82f197b7d00a524ea3354260a0828083c6
2013-04-04 10:56:42 -07:00
Tomasz Zarna 5453585773 Add the no-commit option to MergeCommand
Added also tests and the associated option for the command line Merge
command.

Bug: 335091
Change-Id: Ie321c572284a6f64765a81674089fc408a10d059
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-04-04 15:11:49 +02:00
Christian Halstrick 81b601de53 Merge "Fix PathFilterGroup not to throw StopWalkException too early" 2013-04-04 03:42:25 -04:00
Christian Halstrick ac0481039d Merge "Indicate initial commit on a branch in the reflog" 2013-04-04 03:41:56 -04:00
Robin Rosenberg c9a94dc1ee Fix PathFilterGroup not to throw StopWalkException too early
Due to the Git internal sort order a directory is sorted as if it ended
with a '/', this means that the path filter didn't set the last possible
matching entry to the correct value. In the reported issue we had the
following filters.

	org.eclipse.jgit.console
	org.eclipse.jgit

As an optimization we throw a StopWalkException when the walked tree
passes the last possible filter, which was this:
	org.eclipse.jgit.console

Due to the git sorting order, the tree was processed in this order:
	org.eclipse.jgit.console
	org.eclipse.jgit.test
	org.eclipse.jgit

At org.eclipse.jgit.test we threw the StopWalkException preventing the
walk from completing successfully.

A correct last possible match should be:
	org.eclipse.jgit/

For simplicit we define it as:
	org/eclipse/jgit/

This filter would be the maximum if we also had e.g. org and org.eclipse
in the filter, but that would require more work so we simply replace all
characters lower than '/' by a slash.

We believe the possible extra walking does not not warrant the extra
analysis.

Bug: 362430
Change-Id: I4869019ea57ca07d4dff6bfa8e81725f56596d9f
2013-04-03 14:07:23 -04:00
Robin Rosenberg 65027d8bb4 Indicate initial commit on a branch in the reflog
Bug: 393463
Change-Id: I4733d6f719bc0dc694e7a6a6ad2092de6364898c
2013-04-02 21:57:17 +02:00
Arthur Baars 35be98fb8f LogCommand.all(): filter out refs that do not refer to commit objects
1. I have authored 100% of the content I'm contributing,
 2. I have the rights to donate the content to Eclipse,
 3. I contribute the content under the EDL

Change-Id: I48b1828e0b1304f76276ec07ebac7ee9f521b194
2013-03-31 15:36:47 +01:00
Arthur Baars 2b9c440fd1 LogCommand.all(), peel references before using them
Problem:
LogCommand.all() throws an IncorrectObjectTypeException when
there are tag references, and the repository does not contain
the file "packed-refs". It seems that the references were not properly
peeled before being added to the markStart() method.

Solution:
Call getRepository().peel() on every Ref that has isPeeled()==false
in LogCommand.all() .

Added test case for LogCommand.all() on repo with a tag.

 1. I have authored 100% of the content I'm contributing,
 2. I have the rights to donate the content to Eclipse,
 3. I contribute the content under the EDL

Bug: 402025
Change-Id: Idb8881eeb6ccce8530f2837b25296e8e83636eb7
2013-03-31 15:36:47 +01:00
Robin Rosenberg 5cf53fdacf Speed up clone/fetch with large number of refs
Instead of re-reading all refs after each update, execute
the deletes first, then read all refs once and perform
the check for conflicting ref names in memory.

Change-Id: I17d0b3ccc27f868c8497607d8e57bf7082e65ba3
2013-03-30 13:36:44 +01:00
Robin Rosenberg 4796fe7043 Merge "When renaming the lock file succeeds the lock isn't held anymore" 2013-03-28 15:57:38 -04:00
Shawn Pearce 1f51aecf95 Fix CommitCommand amend mode to preserve parent order
Change-Id: I476921ff8dfa6a357932d42ee59340873502b582
2013-03-28 13:58:21 -04:00
Andreas König d9d3439617 Fixed parsing of URI with a IPv6-address
Allowed ipv6-address in a uri like:
  http://[::1]:8080/repo.git

Change-Id: Ia00a20f694b2e9314892df77f9b11f551bb1d34e
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2013-03-27 10:44:13 -04:00
Matthias Sohn edd47d10b9 Merge "File.renameTo behaves differently on Unix and Windows" 2013-03-27 09:09:04 -04:00
Matthias Sohn b1d191a155 Merge "Extend FileUtils.rename to common git semantics" 2013-03-27 09:03:23 -04:00
Matthias Sohn d059f85c0b When renaming the lock file succeeds the lock isn't held anymore
This wrong book-keeping caused IOExceptions to be thrown because
LockFile.unlock() erroneously tried to delete the non-existing lock
file. These IOExeptions were hidden since they were silently caught. 

Change-Id: If42b6192d92c5a2d8f2bf904b16567ef08c32e89
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-03-26 21:26:07 +01:00
Shawn Pearce 7f1c2ec1eb Always add FileExt to DfsPackDescription
Instead of forcing the implementation of the DFS backend to handle
making sure the extension bits are set correctly, have the common
callers in JGit set the extension at the same time they supply the
file sizes to the pack description. This simplifies assumptions for
an implementation of the DFS backend.

Change-Id: I55142ad8ea08a3e2e8349f72b3714578eba9c342
2013-03-26 14:00:57 -04:00
Robin Rosenberg edf0da9c6e File.renameTo behaves differently on Unix and Windows
On Windows renameTo will not overwrite a file, so it must be deleted
first. The fix for Bug 402834 did not account for that.

Bug: 403685
Change-Id: I3453342c17e064dcb50906a540172978941a10a6
2013-03-26 00:48:44 +01:00
Robin Rosenberg d0e92885e9 Extend FileUtils.rename to common git semantics
Unlike the OS or Java rename this method will (on *nix) try (on Windows)
replace the target with the source provided the target does not exist,
the target does exist and is a file, or if it is a directory which only
contains directories. In the latter case the directory hierarchy will be
deleted.
If the initial rename fails and the target is an existing file the the
target file will be deleted first and then the rename is retried.

Change-Id: Iae75c49c85445ada7795246a02ce02f7c248d956
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2013-03-26 00:48:00 +01:00
Matthias Sohn a040a8f127 Grant access to jgit internals to junit and http.server bundles
Change-Id: Ib34f9635b4d060f5d17a6c823ec91af1d934a180
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-03-22 21:35:16 +01:00
Matthias Sohn dd6f41e401 Add missing @since tags
Change-Id: I6b20d78e6bd1f245fdca331554c106f8bae44b9c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-03-22 21:21:07 +01:00
Tomasz Zarna 48f30b8614 Fix @since tags in JGit, version 2.4 never existed
Change-Id: Iaca88ec28b412e6b58e7b39a0762ba54b25f9471
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-03-21 18:03:20 -04:00
Shawn Pearce 9aee4e0a26 Merge changes If98b0b97,I7c9c09b4
* changes:
  Add convenience factory method for most used builder pattern
  Don't use internal type FileRepository in public API
2013-03-21 03:52:33 -04:00
André Dietisheim a31920555f Allow users to show server messages while pushing
Allow users to provide their OutputStream (via Transport#
push(monitor, refUpdates, out)) so that server messages can be written
to it (in SideBandInputStream) while they're coming in.

CQ: 7065
Bug: 398404
Change-Id: I670782784b38702d52bca98203909aca0496d1c0
Signed-off-by: Andre Dietisheim <andre.dietisheim@gmail.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-03-21 00:30:30 +01:00
Matthias Sohn 8fcde4b31b Don't verify host name when sslVerify is false
Native git also doesn't verify host names when http.sslVerify=false.
See native git's commit a5ccc597.

See: http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg02047.html
Change-Id: I42f509fea8e4ac89fad646aec3dfbf1753ae7e3d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-03-19 20:39:38 -04:00
Edwin Kempin e02708a8b3 Fix formatting of PackConfig.toString() & GC.RepoStatistics.toString()
Change-Id: I7e0c74ecfd0e0615d10fb582b2897d33be23440a
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-03-20 00:48:30 +01:00
Edwin Kempin b37b1c9165 Allow to get repo statistics from GarbageCollectionCommand before gc
When running the garbage collection for a repository it is often
interesting to compare the repository statistics from before and after
the garbage collection to understand the effect of the garbage
collection. This is why it makes sense that the
GarbageCollectionCommand provides a method to retrieve the repository
statistics before running the garbage collection.

So far without running the garbage collection the repository statistics
can only be retrieved by using JGit internal classes. This is what EGit
and Gerrit do at the moment, but it would be better to have an API for
this.

Change-Id: Id7e579157e9fbef5cfd1fc9f97ada45f0ca8c379
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-03-20 00:46:27 +01:00
Matthias Sohn 38cac0acf3 Add convenience factory method for most used builder pattern
This will simplify to adapt EGit to the removal of FileRepository from
jgit's public API in change I2ab1327c202ef2003565e1b0770a583970e432e9.

Change-Id: If98b0b97e8f13a94d4ea7ba1be0f90d82b0fba4b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-03-20 00:44:24 +01:00
Matthias Sohn d35586a431 Don't use internal type FileRepository in public API
Change-Id: I7c9c09b4f190fa7cb830563bcdf2071407ee2ce0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-03-20 00:44:24 +01:00
Matthias Sohn 509c0b58ee Merge "Fix GC for FileRepo in case packfile renames fail" 2013-03-19 13:07:47 -04:00
Shawn Pearce 60f5f46550 Fix location of DfsText.properties
The file was not moved when the package was renamed to internal.

Change-Id: I29a078d6316daa4e4407db9ecedc8b7ed05535cd
2013-03-19 07:16:48 -07:00
Christian Halstrick bd5e4eabc2 Fix GC for FileRepo in case packfile renames fail
Only on Windows the rename operation which renames temporary Packfiles
(and index-files and bitmap-files) sometime fails. This happens only
when renaming a temporary Packfile to a Packfile which already exists.
Such situations occur if you run GC twice on a repo without modifying
the repo inbetween.

In such situations there was bug in GC which led to a corrupted repo
whithout any packfiles anymore. This commit fixes the problem by
introducing a utility method which renames a file and throws an
IOException if it fails. This method also takes care to repeat a
failing rename if our FS class has found out we are running on a
platform with a unreliable File.renameTo() method.

I am searching for a better solution because even with this utility
method in hand a GC on a already GC'ed repo will fail on Windows. But
at least with this fix we will not produce corrupted repos anymore.

Bug: 389305
Change-Id: Iac1ab3e0b8c419c90404f2e2f3559672eb8f6d28
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-03-19 14:28:24 +01:00
Christian Halstrick 67b98d5d40 Make GC more robust against corrupt reflogs
With JGit it is possible to write reflog entries where new objectid and
old objectid is null. Such reflogs cause FileRepository GC to crash
because it doesn't expect the new objectid to be null. One case where
this happened is in Gerrit's allProjects repo. In the same way as we
expect the old objectid to be potentially null we should also ignore
null values in the new objectid column.

Change-Id: Icf666c7ef803179b84306ca8deb602369b8df16e
2013-03-19 11:23:45 +01:00
Shawn Pearce f32b861243 JGit 3.0: move internal classes into an internal subpackage
This breaks all existing callers once. Applications are not supposed
to build against the internal storage API unless they can accept API
churn and make necessary updates as versions change.

Change-Id: I2ab1327c202ef2003565e1b0770a583970e432e9
2013-03-18 09:30:43 -07:00
Shawn Pearce 462bbc052e Merge changes I2645d482,Ic81fefb1,Id64ab38d
* changes:
  Remove cached_packs support in favor of bitmaps
  Remove objects before optimization from DfsGarbageCollector
  Simplfy caching of DfsPackDescription from PackWriter.Statistics
2013-03-18 10:35:31 -04:00
Robin Stocker 44ea46dd40 Use RawParseUtils.prevLF in RebaseCommand
As noticed by Robin Rosenberg in review of
I4eb87c850078ca187b38b81cc91c92afb1176945.

Change-Id: If96d66b6c025ad8f2f47829c933f3c65ab6cbeef
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-03-16 23:32:29 +01:00
Robin Stocker 0e9f1cf57d Support aborting non-interactive rebase started from C Git
Continuing is trickier, as .git/rebase-apply contains no message file
and no git-rebase-todo.

Bug: 336820
Change-Id: I4eb87c850078ca187b38b81cc91c92afb1176945
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-03-16 23:32:13 +01:00
Dave Borowitz bba74ba2e0 NameRevCommand: Don't use merge cost for first parent
Treat first parent traversals as 1 and higher parents as MERGE_COST,
to match git name-rev. Allow overriding the merge cost during tests to
avoid creating 2^16 commits on the fly.

Change-Id: I0175e0c3ab1abe6722e4241abe2f106d1fe92a69
2013-03-15 08:58:14 -07:00
Robin Rosenberg 0adcbba149 Merge "A folder does not constitute a dirty work tree" 2013-03-15 11:33:08 -04:00
Christian Halstrick e607d2a4d7 Merge "Add toString() for PackConfig" 2013-03-15 07:23:52 -04:00
Edwin Kempin eac218b7b4 Add toString() for PackConfig
This is helpful for writing the pack configuration into a log file.

Change-Id: I5e7f5ff7e01c9538ca12a1860844ba9b467bdf05
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2013-03-15 10:24:58 +01:00
Edwin Kempin 9b20a3b0dd Add toString() for RepoStatistics
This is helpful for writing the repository statistics into a log file.

Change-Id: I0e8cd9ad05f123ab3851960890a50213f353a373
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2013-03-15 09:42:19 +01:00
Shawn Pearce 3760e4319b Remove cached_packs support in favor of bitmaps
The bitmap code in PackWriter knows exactly when to use a pack as
a "cached pack". It enables cached pack usage only when the pack
has a bitmap and its entire closure of objects needs to be sent.
This is a much simpler code path to maintain, and JGit actually
has a way to write the necessary index.

Change-Id: I2645d482f8733fdf0c4120cc59ba9aa4d4ba6881
2013-03-14 16:36:57 -07:00
Shawn Pearce b2c0021b8a Remove objects before optimization from DfsGarbageCollector
Just counting objects is not sufficient. There are some race
conditions with receive packs and delta base completion that
may confuse such a simple algorithm.

Instead always do the larger set computations, and rely on the
PackWriter having no objects pending as the way to avoid creating
an empty pack file.

Change-Id: Ic81fefb158ed6ef8d6522062f2be0338a49f6bc4
2013-03-14 16:36:36 -07:00
Shawn Pearce fc6b898cbe Simplfy caching of DfsPackDescription from PackWriter.Statistics
Let the pack description copy the relevant stats values. This
moves it out of the garbage collector and compactor algorithms,
co-locating with something that might care.

Remove some unnecessary code from the DfsPackCompactor, the stats
tracks the same information and can supply it.

Change-Id: Id64ab38d507c0ed19ae0d106862d175b7364eba3
2013-03-14 16:36:04 -07:00
Dave Borowitz 8e2a24a3b6 NameRevCommand: Use ~ notation for first parents of merges
Prefer ~(N+1) to ^1~N. Although both are correct, the former is
cleaner and matches "git name-rev".

Change-Id: I772001a219e5eb346f5552c92e6d98c70b2cfa98
2013-03-14 09:35:00 -07:00
Dave Borowitz d2a6c4b955 Allow adding single refs or all tags to NameRevCommand
Change-Id: I90e85bc835d11278631afd0e801425a292578bba
2013-03-13 12:28:58 -07:00
Shawn Pearce e175daf123 Merge "Cluster UNREACHABLE_GARBAGE packs at the end of the search list" 2013-03-12 17:56:48 -04:00
Shawn Pearce 7e229c75c1 Merge "Avoid repacking unreachable garbage in DfsGarbageCollector" 2013-03-12 17:55:47 -04:00
Shawn Pearce c017d7ef45 Merge changes Icd550359,If7aad533
* changes:
  Avoid looking at UNREACHABLE_GARBAGE for client have lines
  Simplify UploadPack by parsing wants separately from haves
2013-03-12 17:45:31 -04:00
Shawn Pearce ef91da3605 Merge "Add a NameRevCommand for describing IDs in terms of refnames" 2013-03-11 18:33:55 -04:00
Dave Borowitz 30ba407a9a Add a NameRevCommand for describing IDs in terms of refnames
The walk logic does not use RevWalk because it needs to walk all paths
to each of the requested commits, keeping track of each path along which
the commit was found in the RevCommit subclass. From these paths, a
single "best" path is chosen based on the total path length, with a
penalty applied for paths that traverse merges.

This functionality parallels "git name-rev".

Change-Id: I92bfb47dd16c898313d2ee525395609c3bf72ebe
2013-03-11 12:47:28 -07:00
Robin Rosenberg 3cd089f04c A folder does not constitute a dirty work tree
This fixes two cases:
- A folder without tracked content exist both in the workdir and merged
commit, as long as there names within that folder does not conflict.
- An empty folder structure exists with the same name as a file in the
merged commit.

Bug: 402834
Change-Id: I4c5b9f11313dd1665fcbdae2d0755fdb64deb3ef
2013-03-10 16:53:23 +01:00
Robin Stocker 9105e1c9af Add isRebasing to RepositoryState
See EGit change Ic69f5c952a49f023c0949f04b3e976be1b267fbe where this
could be used.

Change-Id: I9ec8568fa1100d2e9c8d4ca0e347bf77ec6d8734
2013-03-09 16:20:57 +01:00
Shawn Pearce 4e9fe58bb5 Avoid looking at UNREACHABLE_GARBAGE for client have lines
Clients send a bunch of unknown objects to UploadPack on each round
of negotiation. Many of these are not known to the server, which
leads the implementation to be looking at indexes for garbage packs.

Disable examining the index of a garbage pack, allowing servers to
avoid reading them from disk during negotiation.

The effect of this change is the server will only ACK a have line
if the object was reachable during the last garbage collection,
or was recently added to the repository. For most repositories
there is no impact in this behavior change.

If a repository rewinds a branch, runs GC, and then resets the
branch back to where it was before, the now current tip is going to
be skipped by this change. A client that has the commit may wind up
getting a slightly larger data transfer from the server as an older
common ancestor will be chosen during negotiation. This is fixable
on the server side by running GC again to correct the layout of
objects in pack files.

Change-Id: Icd550359ef70fc7b701980f9b13d923fd13c744b
2013-03-08 12:45:28 -08:00
Shawn Pearce 437be8dfad Simplify UploadPack by parsing wants separately from haves
The DHT backend was very slow at parsing objects. To work around
that performance limitation I obfuscated UploadPack by folding both
the want and have sets together in a single parse queue. Since DHT
was removed the complexity is no longer constructive to JGit.

Doing this refactoring prepares the code for a slightly future
change where the have lines need to be handled specially from the
want lines. Splitting the parsing up into two phases makes such
a modification trivial.

Change-Id: If7aad533b82448bbb688278e21f709282e5ccf4b
2013-03-08 12:25:12 -08:00
Shawn Pearce ea5eef912a Cluster UNREACHABLE_GARBAGE packs at the end of the search list
Garbage is unlikely to be used by a reader. Ensure they always
cluster at the end of the search list, no matter what timestamp
was used on the pack files.

Change-Id: I3bed89e9569ee3363c36bb3f73fcd34057a3883f
2013-03-08 11:19:44 -08:00
Shawn Pearce bb002c619b Avoid repacking unreachable garbage in DfsGarbageCollector
If a repository has significant amounts of unreachable garbage the
final phase to coalesce it can take longer than any other part of the
garbage collection phase. Provide a setting for applications to tweak
the threshold where coalescing ends and files just remain on disk.

Change-Id: I5f11a998a7185c75ece3271d8bc6181bb83f54c1
2013-03-08 11:07:51 -08:00
Robin Stocker 3ee04e3531 Include the number of ms in timeout error message
Noticed that while analyzing bug 402131.

Change-Id: If3fd40b64d5088c4579946271a67346cbd9e6556
2013-03-08 18:00:19 +01:00
Robin Rosenberg 3ad454497c Do not cherry-pick merge commits during rebase
Rebase computes the list of commits that are included in
the merges, just like Git does, so do not try to include
the merge commits. Re-recreating merges during rebase is
a bit more complicated and might be a useful future extension,
but for now just linearize during rebase.

Change-Id: I61239d265f395e5ead580df2528e46393dc6bdbd
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-03-08 16:40:19 +01:00
Robin Rosenberg 08d5ede281 Extend FileUtils.delete with option to delete empty directories only
The new option EMPTY_DIRECTORIES_ONLY will make delete() only delete
empty directories. Any attempt to delete files will fail. Can be
combined with RECURSIVE to wipe out entire tree structures and
IGNORE_ERRORS to silently ignore any files or non-empty directories.

Change-Id: Icaa9a30e5302ee5c0ba23daad11c7b93e26b7445
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-03-08 16:26:10 +01:00
Shawn Pearce 913cccd5c4 Do not attempt to read bitmap from invalid pack
If a pack file has been marked invalid due to a prior IOException
accessing its contents, do not offer its bitmap index to callers.
The pack cannot be used so its bitmap should be off limits from
any reader trying to work from a bitmap.

Change-Id: Ia44e46558abdddee560bb184158b1e0af9437eee
2013-03-06 12:48:25 -08:00
Shawn Pearce 88c962484f Rename DfsPackFile getBitmap method to match PackFile
There is no reason for these to differ in name. Match the
shorter name used by PackFile.

Change-Id: I2d3a299069acc5ce276b1b5439ff2258903c6ff3
2013-03-06 12:47:37 -08:00
Colby Ranger c660362768 Write the bitmap index correctly in DFS GC.
A bug caused the .bitmap to actually have the .idx contents.

Change-Id: I428bb27d419e8b1b69b6f3e2fd07cd29703669ad
2013-03-06 12:33:05 -08:00
Colby Ranger e6883dfe4b Enable writing bitmaps during GC by default.
Bitmaps provide a huge performance boost for counting objects and they
play nice with the cgit implementation.

Change-Id: I33b05a6c8f1ee2df7770f0b9fdc50d0b4bbf1029
2013-03-05 11:16:08 -08:00
Colby Ranger f82821728b Enable writing pack indexes with bitmaps in the GC.
Update the dfs and file GC implementations to prepare and write
bitmaps on the packs that contain the full closure of the object
graph. Update the DfsPackDescription to include the index version.

Change-Id: I3f1421e9cd90fe93e7e2ef2b8179ae2f1ba819ed
2013-03-05 11:15:19 -08:00
Colby Ranger 43ea887c8b Enable serving upload requests using bitmaps.
If the pack index has bitmaps, allow the PackWriter to use the bitmaps
for upload requests.

Change-Id: Iefa995fe927a11e4fd78afb34530995614221fc0
2013-03-05 11:14:48 -08:00
Colby Ranger dafcb8f6db Support creating pack bitmap indexes in PackWriter.
Update the PackWriter to support writing out pack bitmap indexes,
a parallel ".bitmap" file to the ".pack" file.
Bitmaps are selected at commits every 1 to 5,000 commits for
each unique path from the start. The most recent 100 commits are
all bitmapped. The next 19,000 commits have a bitmaps every 100
commits. The remaining commits have a bitmap every 5,000 commits.
Commits with more than 1 parent are prefered over ones
with 1 or less. Furthermore, previously computed bitmaps are reused,
if the previous entry had the reuse flag set, which is set when the
bitmap was placed at the max allowed distance.

Bitmaps are used to speed up the counting phase when packing, for
requests that are not shallow. The PackWriterBitmapWalker uses
a RevFilter to proactively mark commits with RevFlag.SEEN, when
they appear in a bitmap. The walker produces the full closure
of reachable ObjectIds, given the collection of starting ObjectIds.

For fetch request, two ObjectWalks are executed to compute the
ObjectIds reachable from the haves and from the wants. The
ObjectIds needed to be written are determined by taking all the
resulting wants AND NOT the haves.

For clone requests, we get cached pack support for "free" since
it is possible to determine if all of the ObjectIds in a pack file
are included in the resulting list of ObjectIds to write.

On my machine, the best times for clones and fetches of the linux
kernel repository (with about 2.6M objects and 300K commits) are
tabulated below:

Operation                   Index V2               Index VE003
Clone                       37530ms (524.06 MiB)     82ms (524.06 MiB)
Fetch (1 commit back)          75ms                 107ms
Fetch (10 commits back)       456ms (269.51 KiB)    341ms (265.19 KiB)
Fetch (100 commits back)      449ms (269.91 KiB)    337ms (267.28 KiB)
Fetch (1000 commits back)    2229ms ( 14.75 MiB)    189ms ( 14.42 MiB)
Fetch (10000 commits back)   2177ms ( 16.30 MiB)    254ms ( 15.88 MiB)
Fetch (100000 commits back) 14340ms (185.83 MiB)   1655ms (189.39 MiB)

Change-Id: Icdb0cdd66ff168917fb9ef17b96093990cc6a98d
2013-03-05 11:14:45 -08:00
Colby Ranger 3b325917a5 Added read/write support for pack bitmap index.
A pack bitmap index is an additional index of compressed
bitmaps of the object graph. Furthermore, a logical API of the index
functionality is included, as it is expected to be used by the
PackWriter.

Compressed bitmaps are created using the javaewah library, which is a
word-aligned compressed variant of the Java bitset class based on
run-length encoding. The library only works with positive integer
values. Thus, the maximum number of ObjectIds in a pack file that
this index can currently support is limited to Integer.MAX_VALUE.

Every ObjectId is given an integer mapping. The integer is the
position of the ObjectId in the complete ObjectId list, sorted
by offset, for the pack file. That integer is what the bitmaps
use to reference the ObjectId. Currently, the new index format can
only be used with pack files that contain a complete closure of the
object graph e.g. the result of a garbage collection.

The index file includes four bitmaps for the Git object types i.e.
commits, trees, blobs, and tags. In addition, a collection of
bitmaps keyed by an ObjectId is also included. The bitmap for each entry
in the collection represents the full closure of ObjectIds reachable
from the keyed ObjectId (including the keyed ObjectId itself). The
bitmaps are further compressed by XORing the current bitmaps against
prior bitmaps in the index, and selecting the smallest representation.
The XOR'd bitmap and offset from the current entry to the position
of the bitmap to XOR against is the actual representation of the entry
in the index file. Each entry contains one byte, which is currently
used to note whether the bitmap should be blindly reused.

Change-Id: Id328724bf6b4c8366a088233098c18643edcf40f
2013-03-05 11:09:44 -08:00
Shawn Pearce 234b4e0432 Merge "Break the dependency on RevObject when creating a newObjectToPack()." 2013-03-04 20:12:35 -05:00
Shawn Pearce 374406ac46 Merge "Fix RefUpdate performance for existing Refs" 2013-03-04 19:11:08 -05:00
Shawn Pearce 22625cd1d8 Merge "Fix corrupted CloneCommand bare-repo fetch-refspec (#402031)" 2013-03-04 17:53:02 -05:00
Colby Ranger be7a135e94 Break the dependency on RevObject when creating a newObjectToPack().
Update the ObjectReuseAsIs API to support creating new
ObjectToPack with only the AnyObjectId and Git object type. This is
needed to support the future pack index bitmaps, which only contain
this information and do not want the overhead of creating a temporary
object for every ObjectId.

Change-Id: I906360b471412688bf429ecef74fd988f47875dc
2013-03-04 14:43:22 -08:00
Colby Ranger 8d4f227c13 Merge "Remove the unused method PackFile.hasExt()." 2013-03-04 17:30:27 -05:00
Colby Ranger 1512d0ab4e Remove the unused method PackFile.hasExt().
It will be used in a future change, so just include it with that change.

Change-Id: I7db28d86f8e8b282a403acd9a4c4defaae828f94
2013-03-04 14:16:36 -08:00
Roberto Tyley a46b042905 Fix corrupted CloneCommand bare-repo fetch-refspec (#402031)
CloneCommand has been creating fetch refspecs like this on bare clones:

[remote "origin"]
        url = ssh://example.com/my-repo.git
        fetch = +refs/heads/*:refs/heads//*

As you can see, the destination ref pattern has a superfluous slash.

It looks like this behaviour has always been the case for CloneCommand,
at least since cc2197ed when code catering to bare-clone fetch refspecs
was added. That was released with JGit v1.0 almost 2 years ago, so
there will probably be some bare repos in the wild which will have been
cloned with JGit and have these corrupted refspecs.

The effect of the corrupted fetch refspec is quite interesting. Up to
and including JGit 2.0, the corrupt refspec was tolerated and fetches
would work as intended with no indication to the user that anything was
amiss. With JGit 2.1, a change was introduced which made JGit less
tolerant, and fetches now attempt to update the non-existing ref
"refs/heads//master". No exception is raised, but the real ref -
"refs/heads/master" - is not updated.

This behaviour was noticed by a user of Agit (which does bare clones by
default and recently updated from JGit v2.0 to v2.2), reported here:

https://github.com/rtyley/agit/issues/92


If you run C-Git fetch on a bare-repo cloned by JGit, it flat-out
rejects the refspec (checked against v1.7.10.4):

fatal: Invalid refspec '+refs/heads/*:refs/heads//*'

Incidentally, C-Git does not create an explicit fetch refspec at all
when performing a bare clone - the full remote config generated by C-Git
looks like this:

[remote "origin"]
        url = ssh://example.com/my-repo.git

Using JGit on such a repository works fine, so omitting the fetch
refspec entirely is also an option.

Change-Id: I14b0d359dc69b8908f68e02cea7a756ac34bf881
2013-03-04 00:03:20 +00:00
Roberto Tyley f1dea3e279 Fix RefUpdate performance for existing Refs
No longer invoke the expensive RefDatabase.isNameConflicting() check on
updating existing refs, reducing batch ref update time by ~97%.

The RefDirectory implementation of isNameConflicting() is quite
slow (it has to do an expensive loose-ref scan) but it's only necessary
to perform this check on ref update if the ref is being *created* - if
the ref already exists, we can already guarantee that it does not
conflict with any other refs.

C-Git seems to use a similar condition before making the
is_refname_available() check:

https://github.com/git/git/blob/v1.8.1.4/refs.c#L1660-L1670

As an example of the effects on performance, here's a simple timing
experiment using The BFG to remove one file from the JGit repo:

---
$ wget http://repo1.maven.org/maven2/com/madgag/bfg-repo-cleaner/1.0.1/bfg-1.0.1.jar
$ git clone --mirror https://git.eclipse.org/r/p/jgit/jgit.git
$ java -jar bfg-1.0.1.jar -D make_jgit.sh jgit.git
....
Updating references:    100% (5760/5760)
...Ref update completed in 148,949 ms.

BFG run is complete!
---

The execution time for the run is completely dominated by the batch ref
update at the end. Repeating the experiment with BFG v1.0.2 (using JGit
patched with this change), the refs update is dramatically reduced:

---
Updating references:    100% (5760/5760)
...Ref update completed in 4,327 ms.
---

Change-Id: I9057bc4ee22f9cc269b1cc00c493841c71527cd6
2013-03-01 21:49:58 +00:00
Shawn Pearce 178d55c24d Merge "Improve the documentation of the ByteArraySet used by PathFilterGroup" 2013-02-28 19:21:59 -05:00
Colby Ranger 4a317a1790 Include supported extensions in PackFile constructor.
Previously a PackFile class was assumed to only support a .pack and .idx
file. Update the constructor to enumerate the supported extensions for
the pack file. This will allow the bitmap code to only be executed if
the bitmap extension file is known to exist.

Change-Id: Ie59041dffec5f60d7ea2771026ffd945106bd4bf
2013-02-28 11:35:07 -08:00
Gustaf Lundh 212fb3071c Fix while boundries in DateRevQueue.add()
In add(), "low" will never equals "first". This fact
should be reflected in the code.

Change-Id: I5cab51374e67bd2d3301e5d9dac47c4259b5e562
2013-02-25 18:30:03 +01:00
Shawn Pearce 9613b04d81 Merge "Performance fixes in DateRevQueue" 2013-02-25 11:50:21 -05:00
Gustaf Lundh 84afea9179 Performance fixes in DateRevQueue
When a lot of commits are added to DateRevQueue, the
sort-on-insertion approach is very heavy on CPU cycles.

One approach to fix this was made by Dave Borowitz:
https://git.eclipse.org/r/#/c/5491/

But using Java's PriorityQueue seems to have brought some
extra overhead, and the desired performance could not be
reached.

This fix takes another approach to the insertion problem,
without changing the expected behaviour or bringing extra
memory overhead:

If we detect over 1000 commits in the DateRevQueue, a
"seek-index" is rebuilt every 1000th added commit.

The index keeps track of every 100th commit in the
DateRevQueue. During insertions, it will be used for a
preliminary scanning (binary search) of the queue, with
the intention of helping add() find a good starting point
to start walking from. After finding this starting point,
add() will step commit-by-commit until the correct
insertion place in the queue is found (today, the queue
is expected to be sorted at all times).

When applied to repositories with many refs, this approach
has proven to bring huge performance gains and scales quite
well.

For instance, in a repository with close to 80000 refs,
we could cut down the time a typical Gerrit replication
of 1 commit would take (just a push from JGit's point of
view) from 32sec down to 3.5sec.

Below you see some typical times to add a specific amount
of commits (with random commit times) to the DateRevQueue
and the difference the preliminary seek-index makes:

Commits | Index | No Index
   1024     8ms        8ms
   2048    13ms        9ms
   4096     5ms       59ms
   8192    11ms      595ms
  16384    22ms     3058ms
  32768    64ms    13811ms
  65536   201ms    62677ms
 131072   783ms   331585ms

Only one extra reference is needed for every 100 inserted
commits (and only when we see more than 1000 commits in
the queue), so the memory overhead should be negligible.

Various index-stepping values were tested, and 100 seemed to
scale very well and be effective from start.

In the future, it should probably be dynamic and based on
the number of refs in the queue, but this should serve well
as a starting point.

Note: While other fundamentally different data structures may
be more suitable, the DateRevQueue is extremely central to
many of the Git core operations. This approach was chosen,
since the effect of the patch is easy to predict in conjuction
with the current implementation. A totally new data structure
will make it harder to predict behaviour in many common and
uncommon cases (in terms of breaking ties, memory usage, cost
when using few elements, object creation/disposing overhead,
etc).

Change-Id: Ie7b99f40eacf6324bfb4716d82073adeda64d10f
2013-02-25 12:36:29 +01:00
George C. Young ab99b78ca0 Implement recursive merge strategy
Extend ResolveMerger with RecursiveMerger to merge two tips
that have up to 200 bases.

Bug: 380314
CQ: 6854
Change-Id: I6292bb7bda55c0242a448a94956f2d6a94fddbaa
Also-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-22 23:51:50 +01:00
Robin Rosenberg 78606404de Improve the documentation of the ByteArraySet used by PathFilterGroup
Change-Id: I2ba7a67e8e1596aa6c33a9caddee03a6be48f008
2013-02-22 23:21:57 +01:00
Colby Ranger 95ef1e83d0 Fix off by one error in PackReverseIndex.
The last 32bit offset is at Integer.MAX_VALUE.

Change-Id: Idee8be3c7887e1d0c8339ff94aceff36dbf000db
2013-02-20 22:59:35 -08:00
Matthias Sohn c033f016c9 Merge branch 'stable-2.3'
* stable-2.3:
  Prepare 2.3.2-SNAPSHOT builds
  JGit v2.3.1.201302201838-r
  Accept Change-Id even if footer contains not well-formed entries
  Fix false positives in hashing used by PathFilterGroup

Change-Id: I5882aa3b482d6bcd40a45bed51e5ab03f018a5bc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-21 02:34:17 +01:00
Matthias Sohn 49ec6c1b3b Prepare 2.3.2-SNAPSHOT builds
Change-Id: I51a8a53194928416b1aef1f3fce0ce66aadceca4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-21 02:13:15 +01:00
Matthias Sohn 63dceceb0e JGit v2.3.1.201302201838-r
Change-Id: I0d79873137ad4042ecc2a0210fe1f6305608b851
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-21 01:00:08 +01:00
Matthias Sohn 301df23d9b Merge "Accept Change-Id even if footer contains not well-formed entries" into stable-2.3 2013-02-20 18:35:44 -05:00
Stefan Lay 3b41fcbd96 Accept Change-Id even if footer contains not well-formed entries
Instead of only looking for a Change-Id in the last section if it 
consists only of well-formed "key: value" lines replace the last
occurrence of a valid Change-Id line in the last section. Some tools
require footer lines e.g. without a colon.

Gerrit doesn't accept Change-Id lines in the footer if the Change-Id
line doesn't start at the beginning of the line.

Bug: 400818
Change-Id: Icce54872adc8c566994beea848448a2f7ca87085
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-20 23:49:43 +01:00
Robin Stocker 5d7b722f6e Fix false positives in hashing used by PathFilterGroup
The ByteArraySet failed to check the length of the entry correctly leading
to matches where no match should be.

Bug: 401249
Change-Id: I925bc48d9cafcdf13e1a797bb09fc2555eb270c5
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2013-02-20 00:37:57 +01:00
Matthias Sohn ba6ae0c7ec Prepare 2.4.0-SNAPSHOT builds
Change-Id: I4ab2baeb5d598d40d5dadfccdfe75152a1b9b7bf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-14 00:59:25 +01:00
Matthias Sohn 647acec3d9 Merge branch 'stable-2.3'
* stable-2.3:
  Prepare post 2.3.0.201302130906 builds
  JGit v2.3.0.201302130906
  Replace explicit version by property where possible
  Add better documentation to DirCacheCheckout
  Prepare post 2.3rc1 builds
  JGit v2.3.0.201302060400-rc1

Change-Id: I5a7626014dc38e7623937a4241dbf8a6db05c1f9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-13 23:12:40 +01:00
Matthias Sohn 9a5f4b46cc Prepare post 2.3.0.201302130906 builds
Change-Id: Ia11b4000557d0cf235c4e33cda4539cab25fef47
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-13 23:08:30 +01:00
Matthias Sohn 19d6cadeff JGit v2.3.0.201302130906
Change-Id: If2e5fcbc01c2a7f058ef13d60b0bba5f77300d52
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-13 15:24:41 +01:00
Robin Rosenberg 8a9074fe21 Implement core.checkstat = minimal
There is a huge performance issue when using both JGit (EGit) and Git
because JGit does not fill all dircache stat fields with the values Git
would expect. As a result thereof Git would typically revalidate a large
number of tracked files. This can take several minutes for large
repositories with many large files.

Since 1.8.2 Git will restrict stat checking to the size and whole second
part of the modification time stamp, if core.statinfo is set to
"minimal".

As JGit checks only size and modification time this is close to what
JGit already does. To make the match perfect ignore the sub-second part
of the modification time stamp if core.statinfo = minimal.

Change-Id: I8eaff1858a891571075a86db043f9d80da3d7503
2013-02-10 17:29:58 +01:00
Dave Borowitz 51d0e1f26e Fix Config.fromText to not skip a last line with no newline
Change-Id: Id6da6ff19296410806282bb7419fd8455e8c5475
2013-02-08 11:36:50 -08:00
Robin Rosenberg 3a4ebc0c24 Really handle annotated tags in MergeCommand
Repository.peel() must be called to ensure a tag is really peeled.

Change-Id: I83e25f09fad3ad55a3ffe41ab4758f249b7ac9f9
2013-02-08 07:27:37 +01:00
Christian Halstrick 1c4ee41dc0 Add better documentation to DirCacheCheckout
Change-Id: I282b702d9e4cb19063d8e9503604538f80e955b7
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2013-02-07 00:05:39 +01:00
Matthias Sohn e9cf705c6e Prepare post 2.3rc1 builds
Change-Id: I5c7daa5a735bfc2ecb9adc11c392b94d235102b6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-06 16:10:20 +01:00
Matthias Sohn ea060dd8e7 JGit v2.3.0.201302060400-rc1
Change-Id: Id1f1d174375f7399cee4c2eb23368d4dbb4c384a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-06 14:12:51 +01:00
Robin Stocker 60d538fe51 Add getConflictingNames to RefDatabase
This has the same logic as isNameConflicting, but instead of only
returning a boolean, it returns a collection of names that conflict.

It will be used in EGit to provide a better message to the user when
validating a ref name, see Ibea9984121ae88c488858b8a8e73b593195b15e0.

Existing implementations of isNameConflicting could be rewritten like
this:

  return !getConflictingNames(name).isEmpty();

But I'm not sure about that, as isNameConflicting can be implemented in
a faster way than getConflictingNames.

Change-Id: I11e0ba2f300adb8b3612943c304ba68bbe73db8a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-06 08:48:54 +01:00
Robin Rosenberg aae08070c6 Merge "Extract method to output the first header line of a git diff" 2013-02-02 15:06:22 -05:00
Tobias Pfeifer 2c40482d0f Fixed problems occuring when changing user in gerrit configuration
Bug: 399238
Change-Id: I255634bc9b3681f292190051daed22a4771d6e57
Signed-off-by: Tobias Pfeifer <to.pfeifer@sap.com>
2013-02-01 16:05:31 +01:00
Robin Rosenberg 878e78b307 Fix stash apply using merge logic
Instead of the complicated strange stuff, implement staah
apply as cherry-pick.

Provided there are no conflicts and it is requested that
the index should be applied, perform yet another cherry-pick,
but discard tha results thereof it that would result in conflicts.

Bug: 376035
Change-Id: I553f3a753e0124b102a51f8edbb53ddeff2912e2
2013-01-30 11:38:19 -05:00
Tobias Pfeifer 0d09b1cab7 Extract method to output the first header line of a git diff
In order to be able to determine the range of the first header line
(e.g. "diff --git a/file1 b/file2") in subclasses, the code that formats
the first header line is extracted.

Required by egit's change: Ia61398146c0336ab332234f24d341561292554db

Change-Id: I9dd5eb964ed8b6869745c3162159b7425ac2c44a
Signed-off-by: Tobias Pfeifer <to.pfeifer@sap.com>
2013-01-30 13:27:50 +01:00
Robin Rosenberg eb60932930 Fix Check for FF_ONLY merges again
Added more FF-mode tests

Change-Id: I33eed5737d9411cc1cf214da62ce719916a1b736
2013-01-29 08:05:00 +01:00
Robin Rosenberg 83032e9f66 Merge "Check for FF_ONLY merges correctly" 2013-01-28 19:02:18 -05:00
Robin Rosenberg ee413067fd Merge changes Ife0cc2da,If38507ef
* changes:
  Speed up PathFilterGroup for large sets of paths
  Add test case for PathFilterGroup
2013-01-28 19:00:00 -05:00
Robin Rosenberg 642ff2cd7d Check for FF_ONLY merges correctly
Bug: 398192
Change-Id: I1253c0ea0632185bbf9f77e32f13ba5842a6e18e
2013-01-29 00:48:56 +01:00
Colby Ranger aa2db859ea Merge "Reduce memory held and speed up DfsGarbageCollector." 2013-01-22 18:55:36 -05:00
Colby Ranger 7fbd6588be Reduce memory held and speed up DfsGarbageCollector.
getObjectList() returns a list of ObjectToPack. These can hold on to a
lot of memory. Furthermore, binary searching for objects in a sorted
array can be slow. Improve the speed and reduce the memory by creating a
copy of the ObjectId and inserting it into an ObjectIdOwnerMap.

Change-Id: Ib5aa5b7447e05938b47fa55812a87b9872c20ea7
2013-01-22 15:25:15 -08:00
Robin Stocker 75ddf2a0f4 Enable marking entries using TreeFilters in DiffEntry
This adds a new optional TreeFilter[] argument to DiffEntry.scan. All
filters will be checked during the scan to determine if an entry should
be "marked" with regard to that filter.

After having called scan, the user can then call isMarked(int) on the
entries to find out whether they matched the TreeFilter with the passed
index.

An example use case for this is in the file diff viewer of EGit's
History view, where we'd like to highlight entries that are matching the
current filter.

See EGit change I03da4b38d1591495cb290909f0e4c6e52270e97f.

Bug: 393610
Change-Id: Icf911fe6fca131b2567514f54d66636a44561af1
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-01-23 00:24:54 +01:00
Matthias Sohn 86759c23c2 Merge "Fix NPE FS_Win32 when looking up git executable and home directory avoiding redundant code" 2013-01-22 08:28:49 -05:00
Robin Rosenberg 522fc6a9c6 Speed up PathFilterGroup for large sets of paths
The ByteArraySet is a distorted copy of ObjectIdSubclassMap.

Bug: 397185
Change-Id: Ife0cc2da6cc46431be94a6b14f64f6adbe983afb
2013-01-21 15:54:56 +01:00
Robin Rosenberg 910a69d4c8 Merge "Improve handling of checkout conflicts" 2013-01-20 14:01:38 -05:00
Robin Rosenberg 9f7b97c90a Merge changes I7e7fae12,I87ecca00
* changes:
  Add conflicts message before footer
  Only replace the ChangeId in the footer, not in the body
2013-01-19 11:54:21 -05:00
Stefan Lay 215a74eceb Add conflicts message before footer
In case of a conflict during cherry-pick or revert the commit message
was amended after the footer. This made the footer invalid. Many users
do not understand that they have to edit the commit message in order to
make it valid again.

Change-Id: I7e7fae125129e2a0d8950510550acda766531835
Bug: 367416
2013-01-19 11:38:33 -05:00
Stefan Lay 1ca7c581a3 Only replace the ChangeId in the footer, not in the body
Additionally expose methods to find the first footer line and to find
the position of the ChangeId footer in the commit message in order to
enable reuse of these methods introduced for the fix.

Change-Id: I87ecca009ca3bff1ca0de3c436ebd95736bf5a10
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2013-01-19 17:37:09 +01:00
Robin Rosenberg 6a3c360984 Merge "Use correct method link in Javadoc" 2013-01-19 11:23:39 -05:00
Robin Rosenberg ab439eed6e Merge "Fix patch application WRT windows line endings." 2013-01-19 11:20:27 -05:00
Markus Duft 3d18f65af1 Fix patch application WRT windows line endings.
Previously the result of an application would have been \r\r\n in the
case of windows line endings, as RawText does not touch the \r, and
ApplyCommand adds "\r\n" if this is the ending of the first line in the
target file. Only always adding \n should be ok, since \r\n would be the
result if the file and the patch include windows line endings.

Also add according test.

Change-Id: Ibd4c4948d81bd1c511ecf5fd6c906444930d236e
2013-01-19 13:29:02 +01:00
Colby Ranger 38b503601a Merge "Update DfsGarbageCollector to not read back a pack index." 2013-01-18 19:38:08 -05:00
Colby Ranger 7c58f6282a Update DfsGarbageCollector to not read back a pack index.
Previously, the Dfs GC excluded objects from packs by passing a
previously written index to the PackWriter. Reading back a file on
Dfs is slow. Instead, allow the PackWriter to expose the objects
included in a pack and forward that to invocations of excludeObjects() .

Change-Id: I377cb4ab07f62cf790505e1eeb0b2efe81897c79
2013-01-18 16:22:10 -08:00
Robin Rosenberg de390e1480 Merge "Define a tree filter for user-visible changes between two indexes" 2013-01-18 19:07:30 -05:00
Shawn Pearce 372b2c0ca6 Merge "Add additional FastForwardMode enums for different config contexts" 2013-01-18 11:28:07 -05:00
Tomasz Zarna 6a8da4c134 Add additional FastForwardMode enums for different config contexts
FastForwardMode is represented by different strings depending on context 
it is set or get from. E.g. FastForwardMode.FF_ONLY for
branch.<name>.mergeoptions is "--ff-only" but for merge.ff it is "only".

Change-Id: I39ae93578e4783de80ebf4af29ae23b3936eec47
2013-01-18 12:04:17 +01:00
Dani Megert 5b13b579b3 Use correct method link in Javadoc
Change-Id: I7fb5a44910a4738bbb14ad025cee7cbedbba2d07
Signed-off-by: Dani Megert <Daniel_Megert@ch.ibm.com>
2013-01-18 09:17:53 +01:00
Colby Ranger 698705c754 Rename PackConstants to PackExt, a typed pack file extension.
PackConstants previously contained string values for the pack and pack
index extension. Change PackConstant to be PackExt, a typed wrapper
around the string pack file extension.

Change-Id: I86ac4db6da8f33aa42d6f37cfcc119e819444318
2013-01-17 15:14:43 -08:00
Robin Rosenberg 5213f6e2e8 Define a tree filter for user-visible changes between two indexes
The primary purpose of the filter is to detect an index change that
could possibly lead to a change in what files are visible in the staging
view and decorations. Besides what TreeFilter.ANY_DIFF does for trees in
general, this filter also looks at the assume-valid (CE_VALID) flag to
see whether changes should be ignored or not.

Change-Id: I13e9ed4ae62dc3851204fba598239edce07ca977
2013-01-15 19:13:46 -05:00
Colby Ranger 3f0176aea6 Remove getReverseIndexSize() from DfsPackDescription.
The method is used in only one location (DfsPackFile). Furthermore,
PackIndex already does an explicit computation of the size in
DfsPackFile. Simplify the DfsPackDescription by removing the method
and do the calculation similar to PackIndex.

Change-Id: I1391fdaaf7c2c3226d96ada1ae8647bcdff4794e
2013-01-15 15:12:55 -08:00
Colby Ranger 510a605546 Use file extension with DfsPackDescription get/set file size.
Previously the size getters and setters had explicit methods for index
and pack. Update the api to be based on the file extension. This will
make it possible to support other extensions in the future, such as
the forthcoming bitmap extensions.

Change-Id: Iab9d4abe0af65b2fc71ad71ef1db0feb6b3b5c58
2013-01-15 15:12:47 -08:00
Roberto Tyley 5dcc8693d7 Fix concurrent creation of fan-out object directories
If multiple threads attempted to insert loose objects into the same new
fan-out directory, the creation of that directory was subject to a race
condition that could lead to an unnecessary IOException being thrown -
because an inserter could not 'create' a directory that had just been
generated by a different thread. All we require is that the directory
does indeed *exist*, so not being able to _create_ it is not actually a
fatal problem. Setting 'skipExisting' to 'true' on the call to mkdir()
fixes the issue.

I found this issue as a real world occurrence while working on The BFG
Repo Cleaner (https://github.com/rtyley/bfg-repo-cleaner), a tool which
concurrently performs a lot of object creation.

In order to demonstrate the problem here I've added a small test case
which reliably reproduces the issue on the few different hardware
systems I've tried. The error thrown when the race-condition arises is
this:

java.io.IOException: Creating directory /home/roberto/repo.git/objects/e6 failed
at org.eclipse.jgit.util.FileUtils.mkdir(FileUtils.java:182)
at org.eclipse.jgit.storage.file.ObjectDirectory.insertUnpackedObject(ObjectDirectory.java:590)
at org.eclipse.jgit.storage.file.ObjectDirectoryInserter.insertOneObject(ObjectDirectoryInserter.java:113)
at org.eclipse.jgit.storage.file.ObjectDirectoryInserter.insert(ObjectDirectoryInserter.java:91)
at org.eclipse.jgit.lib.ObjectInserter.insert(ObjectInserter.java:329)

Change-Id: I88eac49bc600c56ba9ad290e6133d8a7113125ab
2013-01-13 18:59:59 -05:00
Markus Duft baf7ca9cc0 Improve handling of checkout conflicts
This converts a checkout conflict exception into a RebaseResult /
MergeResult containing the conflicting paths, which enables EGit (or
others) to handle the situation in a user-friendly way

Change-Id: I48d9bdcc1e98095576513a54a225a42409f301f3
2013-01-11 20:32:44 -05:00
Shawn Pearce 912ef3da19 Accept '-' instead of space in enum config values
This is necessary because some versions of JGit containing
the flawed c98abc9c05 were
used in the wild and wrote bad configuration files. We now
must accept this value in addition to the preferred case.

Change-Id: I3ed5451735658df6381532499130e5186805024a
2013-01-11 14:52:13 -08:00
Shawn Pearce 50eab4aa48 Revert "Add additional FastForwardMode enums for different config contexts"
This reverts commit c98abc9c05.

Change-Id: I1d2a0de81eb17860ee36b6d3d3c00959b880fb85
2013-01-11 14:39:51 -08:00
Shawn Pearce 5630686655 Fix enum parsing from Config files
Change-Id: Ib0b86ceab070d46903de7b55f2fd441714855141
2013-01-11 14:09:02 -08:00
Colby Ranger 8a63474518 Merge changes Ifc8fc3e5,I7c403b50
* changes:
  Remove packIndex field from FileObjDatabase openPack method.
  Update DfsObjDatabase API to open/write by pack extension.
2013-01-10 17:17:22 -05:00
Colby Ranger 82ecfb3e31 Remove packIndex field from FileObjDatabase openPack method.
Previously, the FileObjDatabase required both the pack file path and
index file path to be passed to openPack().  A future change to add
a bitmap index will add a .bitmap file parallel to the pack file
(similar to the .idx file). Update the PackFile to support
automatically loading pack index extensions based on the pack file
path.

Change-Id: Ifc8fc3e57f4afa177ba5a88df87334dbfa799f01
2013-01-10 14:02:28 -08:00
Colby Ranger 5d3c2b3def Update DfsObjDatabase API to open/write by pack extension.
Previously, the DfsObjDatabase had a hardcoded getPackFile() and
getPackIndex() methods which opens a .pack and .idx file, respectively.
A future change to add a bitmap index will need to be stored in a
parallel .bitmap file. Update the DfsObjDatabase to support opening and
writing of files for any pack extension.

Change-Id: I7c403b501e242096a2d435f6865d6025a9f86108
2013-01-10 14:02:18 -08:00
Dave Borowitz 891a2d75e7 Peel tags during resolve of foo^
Once we start talking about parents of tags, we are in the commit
graph, so treat all objects from this point as commits. This fixes
spurious IncorrectObjectTypeExceptions on resolving expressions like
tag^^.

Change-Id: I29ece1fdb49c9c5b9ca415efcd1876bc72e97120
2013-01-10 10:56:37 -08:00
Tobias Pfeifer 8315439401 Fix NPE FS_Win32 when looking up git executable and home directory
avoiding redundant code

Bug: 397336
Change-Id: I60e1baa52e00c5ec3915b859bfc6a4572611cc89
2013-01-10 15:35:45 +01:00
Robin Rosenberg 4407423d29 Merge "Revert "Speed up PathFilterGroup.include for large set of paths"" 2013-01-09 18:57:35 -05:00
Robin Rosenberg bc07097ebe Revert "Speed up PathFilterGroup.include for large set of paths"
This reverts commit 576e5acdd0

The comparator is broken.

Change-Id: Ic59110b154613f3ff4a215a6c1293a4c15cd3885
2013-01-09 18:47:16 -05:00
Robin Rosenberg 0421481978 Merge "Consider that some Java version on Linux only return integral timestamps" 2013-01-08 17:50:01 -05:00
Robin Rosenberg c5c683e7e9 Merge changes I3e9735c7,I76a16594
* changes:
  Speed up PathFilterGroup.include for large set of paths
  Speed up handling of "only" paths in the CommitCommand
2013-01-08 14:39:20 -05:00
Tomasz Zarna 928286ad8f Return info about config subsection when trying to get an invalid enum
Change-Id: Id4a72a68bdbd485619f4801683d38ad98f9841a2
2013-01-08 06:26:36 -05:00
Tomasz Zarna c98abc9c05 Add additional FastForwardMode enums for different config contexts
FastForwardMode should be represented by different enums depending on
context it is set or get from. E.g. FastForwardMode.FF_ONLY for
branch.<name>.mergeoptions is "--ff-only" but for merge.ff it is "only".

Change-Id: I3ecc16d48e715b81320b73ffae4caf3558f965f2
2013-01-06 19:12:10 -05:00
Robin Rosenberg 576e5acdd0 Speed up PathFilterGroup.include for large set of paths
This requires that we internally sort all paths so content of
directories follow the directory immediately.

Bug: 397185
Change-Id: I3e9735c7bdd99437929da8f9c9d4960a1273054b
2013-01-07 01:08:01 +01:00
Robin Rosenberg 549034500a Speed up handling of "only" paths in the CommitCommand
Use binary search to reduce the number of lookups for very large number
of paths.

Change-Id: I76a16594b756bffd95298897414485a9cd637819
2013-01-07 01:08:01 +01:00
Robin Rosenberg b7d11eace6 Consider that some Java version on Linux only return integral timestamps
This logic is similar to what we do on Windows, but in this case it's
Java that truncates the timestamps, not Git.

Bug: 395410
Change-Id: Ie55dcb9fa583f5c3dd10d7a1b582e5b04b45858d
2013-01-05 01:23:23 +01:00
Robin Rosenberg 5c49b93191 Ignore removed files with an assume-valid index entry
Bug: 347067
Change-Id: I5472e69dc77e26b5f248a4a04295775cf5051215
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2013-01-03 19:02:59 -06:00
Robin Rosenberg c8c258169f Merge "Revert "Stop PathFilter after walking all matching paths"" 2013-01-01 15:58:04 -05:00
Shawn Pearce 0b6387fe7c Revert "Stop PathFilter after walking all matching paths"
This reverts commit 75eb6a147f.
Applications that want a PathFilter to abort the walk early should be
using PathFilterGroup. When a PathFilterGroup is created with exactly
one path its implementation is the same that 75eb6 tried to perform,
but has been long documented as having the behavior of breaking a
higher level OR filter graph node.

Change-Id: I6c85d75c474784471c32e866eef3402b9f193c08
2013-01-01 12:25:26 -05:00
Robin Rosenberg 315f1cfa5c Update the revert command and things relating to revert
Cherry-pick has been fixed, but even though revert does
basically the same thing, the fixes were not carried over here.

- Recognize the revert-states, analogous to the cherry picking states
- Make reset handle a revert-in-progress
- Update REVERT_HEAD and MERGE_MSG when revert fails due to conflicts
- Clear revert state on commit and reset
- Format the message similarily to how cherry-pick does. This is
  not exactly how C Git does it.

The interface is still not the same as for cherry-picking.

Change-Id: I8ea956fcbc9526d62a2365360feea23a9280eba3
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-12-28 16:44:46 -06:00
Dave Borowitz 75eb6a147f Stop PathFilter after walking all matching paths
After the current path of the TreeWalk is no longer a prefix of the
PathFilter's path, there can be no more matching entries, but TreeWalk
will happily keep walking the rest of a (potentially very large and
recursive) tree unless StopWalkException is thrown. So, throw
StopWalkException from PathFilter.include() at the earliest
opportunity.

Change-Id: If6c4f395a3d5ed5b71bf68de23be9f2b0620e7f1
2012-12-27 12:24:50 -08:00
Colby Ranger 154e3c886b Do not enforce DeltaWindow maxMemory when zero.
The maxMemory for a DeltaWindow can be optionally disabled when it is
less than or equal to zero. Respect this configuration when enforcing
the limits on object load.

Change-Id: Ic0f4ffcabf82105f8e690bd0eb5e6be485a313b3
2012-12-27 11:22:35 -08:00
Colby Ranger 5a3d35e9e2 Merge "Enforce max memory for DeltaWindow." 2012-12-27 12:33:13 -05:00
Colby Ranger 51beee5568 Enforce max memory for DeltaWindow.
Previously, memory limits were enforced at the start of each iteration
of the delta search, based on objects that were currently loaded in
memory. However, new objects added to the window may be expanded in a
future iteration of the search and thus were not accounted for correctly
at the start of the search. To fix this, memory limits are now enforced
before each object is loaded.

Change-Id: I898ab43e7bf5ee7189831f3a68bb9385ae694b8f
2012-12-27 09:23:30 -08:00
Robin Rosenberg 7314b6c2c0 Make jgit diff obey core.autocrlf
Change-Id: I0a756943d95ee20f189c154b27cd2972a116f550
2012-12-27 12:22:14 -05:00
Robin Rosenberg 92893d1f92 Do not perform character translation on copies in patches
Translation is unnecessary and risks damaging the file. Also
ensure that we close the file if an I/O error occurs.

Change-Id: Ieae6eb941fdeaa61f2611f4cd14dd39117aa12f9
2012-12-27 17:29:13 +01:00
Robin Rosenberg c310fa0c80 Mark non-externalizable strings as such
A few classes such as Constanrs are marked with @SuppressWarnings, as are
toString() methods with many liternal, but otherwise $NLS-n$ is used for
string containing text that should not be translated. A few literals may
fall into the gray zone, but mostly I've tried to only tag the obvious
ones.

Change-Id: I22e50a77e2bf9e0b842a66bdf674e8fa1692f590
2012-12-27 16:57:38 +01:00
Matthias Sohn 706f8eb9fc Prepare 2.3.0 builds
Change-Id: I0ca539e8cfe444f96c64dc56d1f0ef33b66e0cff
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-12-21 00:48:45 +01:00
Matthias Sohn 2d78a8da97 Prepare post 2.2.0.201212191850-r builds
Change-Id: I1a0fe51c71551fcfc98f5dd435eb283fd661b77a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-12-21 00:31:26 +01:00
Matthias Sohn aa357c2a9f JGit v2.2.0.201212191850-r
Change-Id: Idc49f17d03886b6a1e61a94ff81e32625c8675d9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-12-20 00:59:41 +01:00
Robin Rosenberg af54f16635 DirCacheIterator: Fix reset() and back()
reset() was broken and probably only worked when the position was
at the beginning. More serious was that back() sometimes descended
into the tree rather than skipping backward at the same level. Sometimes
this would result in false conflicts, but one could suspect silent
errors too. back() is called by the NamingConflictTreeWalk when looking
for directory/file conflicts.

Also added toString to DirCacheTree to simplify debugging.

Bug: 396127
Change-Id: Iaa1b4e20e623d84c2e5ac26748f42e991080dbcd
2012-12-15 11:00:55 +01:00
Matthias Sohn 8d062dec0c [findBugs] Don't pass null for non-null parameter in RebaseCommand
Change-Id: Iee4d50aa9c6b75f9906d2c51a940ddc90a944192
2012-12-05 18:16:57 -05:00
Shawn Pearce e9a1df6c56 Merge "Commit message may not necessarily be in UTF-8" 2012-12-04 10:00:30 -05:00
Colby Ranger b9e485661d Fix DeltaWindow.clear() to release loaded buffer bytes.
It is possible for the buffer to be set but not the index. It
ocurrs when an exception occurs during creating an index, but
after the buffer is loaded. Furthermore, the cleared DeltaWindowEntry
should have been ent and not res.

Change-Id: I2e0d79540316635bf7aa43efd225e4eb38230844
2012-12-03 12:46:53 -08:00
Robin Stocker 4213a91c97 Enable reuse of FileTreeIterator and FileEntry for non subclasses
For EGit change I2c41d86b8b74c2a334433de1bbfed5b36af872bf,
ContainerTreeIterator also needs to create entries for File objects in
case of filtered resources. Instead of reimplementing FileEntry there,
make the constructor public so that it can be reused.

Also allow to pass a WorkingTreeIterator instead of a FileTreeIterator
in FileTreeIterator's constructor, which is enough and allows to pass
other subclasses.

Bug: 358901
Change-Id: Ie0f9c9434ef7d73a8d73d4fe46db4147ded1d267
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-12-03 11:26:39 -06:00
Robin Stocker beb16cec26 Support --cached in RmCommand
Also extend documentation and add examples.

Bug: 395599
Change-Id: Id1ddbc9da787472f82e58834092bc073224b262b
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-12-03 10:40:54 -06:00
Robin Rosenberg 257f3fe4a1 Commit message may not necessarily be in UTF-8
Trying different encoding makes presentation nicer
to user.

Change-Id: I2d2c2a95d0b5cd709855d7a67cbc247478434d2f
2012-11-27 08:34:40 +01:00
Marc Strapetz 67edd3eda7 RevWalk support for shallow clones
StartGenerator now processes .git/shallow to have the
RevWalk stop for shallow commits.

See RevWalkShallowTest for tests.

Bug: 394543
CQ: 6908
Change-Id: Ia5af1dab3fe9c7888f44eeecab1e1bcf2e8e48fe
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-21 10:46:02 -06:00
Dariusz Luksza 8eb4d92637 Add support for rebase interactive 'edit' command
The 'edit' command allows you to change arbitrary commit
content and the message of any commit in the repository.

Bug: 394577
Change-Id: I43a44782cdb10b29f13784fa75ab37fe5d4da01b
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-19 10:02:25 -06:00
Dariusz Luksza 84fb2b59d1 Add support for rebase interactive 'reword' command
'reword' command is used to change commit message of any
commit in git history.

Bug: 394575
Change-Id: Ic974e76dfd923fd6f0cb8f07d1a6fbecd9abbf31
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-19 09:40:53 -06:00
Matthias Sohn 9051af3c4d Add GarbageCollectCommand to porcelain API
Bug: 394544
Change-Id: I73faa55d860db64efc3412fee27386df47552a75
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-18 19:19:12 -06:00
Tomasz Zarna 20c3b6b8a0 Add config constant for "mergeoptions"
Bug: 336933
Change-Id: Idcc0fbc8a8143dd665e80e4d6f4a4adaeae287db
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-18 18:32:37 -06:00