]> source.dussan.org Git - jgit.git/log
jgit.git
13 years agoFS: Allow gitPrefix to be set and cached 10/2710/1
Shawn O. Pearce [Mon, 14 Mar 2011 16:07:53 +0000 (09:07 -0700)]
FS: Allow gitPrefix to be set and cached

This permits callers to modify the meaning of gitPrefix, which
may be useful if their application allows the user to select
the location where C Git is installed.

Bug: 337101
Change-Id: I07362a5772da4955e01406bdeb8eaf87416be1d6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoFS: Overload detect() with no arguments 09/2709/1
Shawn O. Pearce [Mon, 14 Mar 2011 16:06:16 +0000 (09:06 -0700)]
FS: Overload detect() with no arguments

This allows callers to perform the logic that constructed the
current FS.DETECTED value.

Change-Id: Id8517d131dcc3f675c60b2d935730872695ed1b0
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoAvoid NullPointerException in PlotCommit 02/2702/1
Mathias Kinzler [Mon, 14 Mar 2011 14:40:22 +0000 (15:40 +0100)]
Avoid NullPointerException in PlotCommit

Bug: 339289
Change-Id: Idf36f080ae6638c2bdbe11d69a4ad870851622b1
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
13 years agoObjectIdOwnerMap: More lightweight map for ObjectIds 90/2690/2
Shawn O. Pearce [Thu, 10 Mar 2011 23:42:32 +0000 (15:42 -0800)]
ObjectIdOwnerMap: More lightweight map for ObjectIds

OwnerMap is about 200 ms faster than SubclassMap, more friendly to the
GC, and uses less storage: testing the "Counting objects" part of
PackWriter on 1886362 objects:

  ObjectIdSubclassMap:
    load factor 50%
    table: 4194304 (wasted 2307942)
    ms spent 36998 36009 34795 34703 34941 35070 34284 34511 34638 34256
    ms avg 34800 (last 9 runs)

  ObjectIdOwnerMap:
    load factor 100%
    table: 2097152 (wasted 210790)
    directory: 1024
    ms spent 36842 35112 34922 34703 34580 34782 34165 34662 34314 34140
    ms avg 34597 (last 9 runs)

The major difference with OwnerMap is entries must extend from
ObjectIdOwnerMap.Entry, where the OwnerMap has injected its own
private "next" field into each object. This allows the OwnerMap to use
a singly linked list for chaining collisions within a bucket. By
putting collisions in a linked list, we gain the entire table back for
the SHA-1 bits to index their own "private" slot.

Unfortunately this means that each object can appear in at most ONE
OwnerMap, as there is only one "next" field within the object instance
to thread into the map. For types that are very object map heavy like
RevWalk (entity RevObject) and PackWriter (entity ObjectToPack) this
is sufficient, these entity types are only put into one map by their
container.  By introducing a new map type, we don't break existing
applications that might be trying to use ObjectIdSubclassMap to track
RevCommits they obtained from a RevWalk.

The OwnerMap uses less memory. Each object uses 1 reference more (so
we're up 1,886,362 references), but the table is 1/2 the size (2^20
rather than 2^21). The table itself wastes only 210,790 slots, rather
than 2,307,942. So OwnerMap is wasting 200k fewer references.

OwnerMap is more friendly to the GC, because it hardly ever generates
garbage. As the map reaches its 100% load factor target, it doubles in
size by allocating additional segment arrays of 2048 entries. (So the
first grow allocates 1 segment, second 2 segments, third 4 segments,
etc.)  These segments are hooked into the pre-allocated directory of
1024 spaces. This permits the map to grow to 2 million objects before
the directory itself has to grow. By using segments of 2048 entries,
we are asking the GC to acquire 8,204 bytes in a 32 bit JVM. This is
easier to satisfy then 2,307,942 bytes (for the 512k table that is
just an intermediate step in the SubclassMap). By reusing the
previously allocated segments (they are re-hashed in-place) we don't
release any memory during a table grow.

When the directory grows, it does so by discarding the old one and
using one that is 4x larger (so the directory goes to 4096 entries on
its first grow). A directory of size 4096 can handle up to 8 millon
objects. The second directory grow (16384) goes to 33 million objects.
At that point we're starting to really push the limits of the JVM
heap, but at least its many small arrays. Previously SubclassMap would
need a table of 67108864 entries to handle that object count, which
needs a single contiguous allocation of 256 MiB. That's hard to come
by in a 32 bit JVM. Instead OwnerMap uses 8192 arrays of about 8 KiB
each. This is much easier to fit into a fragmented heap.

Change-Id: Ia4acf5cfbf7e9b71bc7faa0db9060f6a969c0c50
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMerge "ObjectIdSubclassMap: Micro-optimize wrapping at end of table"
Shawn O. Pearce [Sun, 13 Mar 2011 23:28:01 +0000 (19:28 -0400)]
Merge "ObjectIdSubclassMap: Micro-optimize wrapping at end of table"

13 years agoRegister TransportProtocols using services 67/2667/2
Shawn O. Pearce [Mon, 7 Mar 2011 23:39:03 +0000 (15:39 -0800)]
Register TransportProtocols using services

Use the Java 6 like services approach to find all supported
TransportProtocols within the CLASSPATH and load them all for use.

This allows users to inject additional protocol implementations simply
by putting their JARs on the application CLASSPATH, provided the
protocol author has written the proper services file.

Change-Id: I7a82d8846e4c4ed012c769f03d4bb2461f1bd148
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMake the supported Transports extensible and discoverable 66/2666/2
Shawn O. Pearce [Mon, 7 Mar 2011 23:01:49 +0000 (15:01 -0800)]
Make the supported Transports extensible and discoverable

The new TransportProtocol type describes what a particular Transport
implementation wants in order to support a connection.  3rd parties
can now plug into the Transport.open() logic by implementing their
own TransportProtocol and Transport classes, and registering with
Transport.register().

GUI applications can help the user configure a connection by looking
at the supported fields of a particular TransportProtocol type, which
makes the GUI more dynamic and may better support new Transports.

Change-Id: Iafd8e3a6285261412aac6cba8e2c333f8b7b76a5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMerge "Don't auto follow non-annotated tags in fetch"
Shawn O. Pearce [Sun, 13 Mar 2011 23:22:31 +0000 (19:22 -0400)]
Merge "Don't auto follow non-annotated tags in fetch"

13 years agoAdd -o option to commit command 35/2635/5
Philipp Thun [Fri, 11 Mar 2011 13:25:46 +0000 (14:25 +0100)]
Add -o option to commit command

This change adds the --only/ -o option to the commit command.

Change-Id: I44352d56877f8204d985cb7a35a2e0faffb7d341
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
13 years agoObjectIdSubclassMap: Micro-optimize wrapping at end of table 89/2689/1
Shawn O. Pearce [Thu, 10 Mar 2011 18:09:58 +0000 (10:09 -0800)]
ObjectIdSubclassMap: Micro-optimize wrapping at end of table

During a review of the class, Josh Bloch pointed out we can use
"i = (i + 1) & mask" to wrap around at the end of the table, instead
of a conditional with a branch.  This is generally faster due to one
less branch that will be mis-predicted by the CPU.

Change-Id: Ic88c00455ebc6adde9708563a6ad4d0377442bba
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMerge changes I0d797533,I128522af,I6dd076eb,Ief6f81b9,I83d01e5c
Shawn O. Pearce [Thu, 10 Mar 2011 18:02:59 +0000 (13:02 -0500)]
Merge changes I0d797533,I128522af,I6dd076eb,Ief6f81b9,I83d01e5c

* changes:
  ObjectIdSubclassMap: Avoid field loads in inner loops
  ObjectIdSubclassMap: Manually inline index()
  ObjectIdSubclassMap: Change initial size to 2048
  ObjectIdSubclassMap: Grow before insertions
  ObjectIdSubclassMap: Use & rather than % for hashing

13 years agoMerge "Cache gitPrefix in FS_Win32"
Shawn Pearce [Thu, 10 Mar 2011 18:02:24 +0000 (13:02 -0500)]
Merge "Cache gitPrefix in FS_Win32"

13 years agoFix Bundle-Version of jgit source bundle 88/2688/1
Matthias Sohn [Thu, 10 Mar 2011 13:23:39 +0000 (14:23 +0100)]
Fix Bundle-Version of jgit source bundle

Bug: 339033
Change-Id: Idaf965cb684d5ed3f3634b0f3d256c92182d7c58
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoCache gitPrefix in FS_Win32 87/2687/1
Marc Strapetz [Thu, 10 Mar 2011 12:17:57 +0000 (13:17 +0100)]
Cache gitPrefix in FS_Win32

readPipe() may consume rather much time, so
gitPrefix should be cached. If the git executable changes,
users should run FS.detect() again to get a new
instance of FS_Win32.

13 years agoObjectIdSubclassMap: Avoid field loads in inner loops 85/2685/1
Shawn O. Pearce [Wed, 9 Mar 2011 22:44:14 +0000 (14:44 -0800)]
ObjectIdSubclassMap: Avoid field loads in inner loops

Ensure the JIT knows the table cannot be changed during the critical
inner loop of get() or insert() by loading the field into a final
local variable.  This shouldn't be necessary, but the instance member
is declared non-final (to resizing) and it is not very obvious to the
JIT that the table cannot be modified by AnyObjectId.equals().

Simplify the JIT's decision making by making it obvious, these
values cannot change during the critical inner loop, allowing
for better register allocation.

Change-Id: I0d797533fc5327366f1207b0937c406f02cdaab3
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoObjectIdSubclassMap: Manually inline index() 84/2684/1
Shawn O. Pearce [Wed, 9 Mar 2011 22:38:35 +0000 (14:38 -0800)]
ObjectIdSubclassMap: Manually inline index()

This method is trivial in definition, and is called in only 3
places. Inline the method manually to ensure its really going
to be inlined by the JIT at runtime.

Change-Id: I128522af8167c07d2de6cc210573599038871dda
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoObjectIdSubclassMap: Change initial size to 2048 83/2683/1
Shawn O. Pearce [Wed, 9 Mar 2011 22:34:27 +0000 (14:34 -0800)]
ObjectIdSubclassMap: Change initial size to 2048

32 is way to small for the map. Most applications using the map
will need to load more than 16 objects just from the root refs
being read from the Repository.

Default the initial size to 2048. This cuts out 6 expansions in
the early life of the table, reducing garbage and rehashing time.

Change-Id: I6dd076ebc0b284f1755855d383b79535604ac547
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoObjectIdSubclassMap: Grow before insertions 82/2682/1
Shawn O. Pearce [Wed, 9 Mar 2011 22:32:43 +0000 (14:32 -0800)]
ObjectIdSubclassMap: Grow before insertions

If the table needs to be grown, do it before the current insertion
rather than after. This is a tiny micro-optimization that allows
the compiler to reuse the result of "++size" to compare against
previously pre-computed size at which the table should rehash itself.

Change-Id: Ief6f81b91c10ed433d67e0182f558ca70d58a2b0
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoObjectIdSubclassMap: Use & rather than % for hashing 81/2681/1
Shawn O. Pearce [Wed, 9 Mar 2011 22:26:39 +0000 (14:26 -0800)]
ObjectIdSubclassMap: Use & rather than % for hashing

Bitwise and is faster than integer modulus operations, and since
the table size is always a power of 2, this is simple to use for
index operation.

Change-Id: I83d01e5c74fd9e910c633a98ea6f90b59092ba29
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoObjectIdSubclassMap: Fix non-standard naming conventions 80/2680/1
Shawn O. Pearce [Wed, 9 Mar 2011 22:28:14 +0000 (14:28 -0800)]
ObjectIdSubclassMap: Fix non-standard naming conventions

obj_hash doesn't match our naming conventions, camelCaseNames
are the preferred format.

Change-Id: I72da199daccb60a98d17b6af1e498189bf149515
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoFixed ordering of Config.getSubsections(...) 79/2679/1
Jesse Greenwald [Wed, 9 Mar 2011 17:48:52 +0000 (09:48 -0800)]
Fixed ordering of Config.getSubsections(...)

A standard HashSet was being used to store the list of subsections as
they were being parsed.  This was changed to use a LinkedHashSet so
that iterating over the set would return values in the same order as
they are listed in the config file.

Change-Id: I4251f95b8fe0ad59b07ff563c9ebb468f996c37d

13 years ago[findbugs] ProgressReportingFilter can be a static inner class 74/2674/1
Matthias Sohn [Tue, 8 Mar 2011 23:05:36 +0000 (00:05 +0100)]
[findbugs] ProgressReportingFilter can be a static inner class

Change-Id: I628b1f25f04c9297655d5ac451ae5a133db53896
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years ago[findbugs] Avoid futile attempt to change max pool size 73/2673/1
Matthias Sohn [Tue, 8 Mar 2011 22:41:47 +0000 (23:41 +0100)]
[findbugs] Avoid futile attempt to change max pool size

Javadoc for ScheduledThreadPoolExecutor says [1]:
While ScheduledThreadPoolExecutor inherits from ThreadPoolExecutor, a
few of the inherited tuning methods are not useful for it. In
particular, because it acts as a fixed-sized pool using corePoolSize
threads and an unbounded queue, adjustments to maximumPoolSize have no
useful effect.

[1]
http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html

Change-Id: I8eccb7d6544aa6e27f5fa064c19dddb2a706523f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoPackWriter: Reduce GC during enumeration 68/2668/1
Shawn O. Pearce [Tue, 8 Mar 2011 01:49:08 +0000 (17:49 -0800)]
PackWriter: Reduce GC during enumeration

Instead of resizing an ArrayList until all objects have been added,
append objects into a specialized List type that uses small arrays
of 1024 entries for each 1024 objects added.

For a large repository like linux-2.6, PackWriter will now allocate
1,758 smaller arrays to hold the object list, without creating any
garbage from the intermediate states due to list expansion.

1024 was chosen as the block size (and initial directory size) as this
is a reasonable balance for the PackWriter code.  Each block uses
approximately 4096 bytes in a 32 bit JVM, as does the default top
level block directory.  The top level directory doesn't expand until 1
million items have been added to the list, which for linux-2.6 won't
yet occur as the lists are per-object-type and are thus bounded to
about 1/3 of 1.8 million.

Change-Id: If9e4092eb502394c5d3d044b58cf49952772f6d6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoRemove deprecated TreeVisitor 63/2663/1
Shawn O. Pearce [Mon, 7 Mar 2011 20:29:59 +0000 (12:29 -0800)]
Remove deprecated TreeVisitor

This type and its associated methods has been deprecated for a while
now.  Time to remove it.  Applications can use a TreeWalk instead to
access the elements of any tree-like object.

Change-Id: I047e552ac77b77e2de086f63cb4fb318da57c208
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoRemove deprecated TreeIterator 62/2662/1
Shawn O. Pearce [Mon, 7 Mar 2011 20:26:51 +0000 (12:26 -0800)]
Remove deprecated TreeIterator

This interface has been deprecated for a while now.
Applications can use a TreeWalk instead.

Change-Id: I751d6e919e4b501c36fc36e5f816b8a8c5379cb9
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoRemove deprecated IndexTreeVisitor 61/2661/1
Shawn O. Pearce [Mon, 7 Mar 2011 20:23:15 +0000 (12:23 -0800)]
Remove deprecated IndexTreeVisitor

This has been deprecated for some time now.  Applications should
instead use DirCache within a TreeWalk.

Change-Id: I8099d93f07139c33fe09bdeef8d739782397da17
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoRemove deprecated WriteTree 60/2660/1
Shawn O. Pearce [Mon, 7 Mar 2011 20:20:44 +0000 (12:20 -0800)]
Remove deprecated WriteTree

This class has been deprecated for a long time now.
Time to remove it.  Applications can use the newer
DirCache.writeTree() as a replacement.

Change-Id: I91dc9507668d8a3ecadd6acd4f1c8b7bd7760cc3
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoRemove deprecated WorkDirCheckout 59/2659/1
Shawn O. Pearce [Mon, 7 Mar 2011 20:18:12 +0000 (12:18 -0800)]
Remove deprecated WorkDirCheckout

This class has been deprecated for a long time now.
Time to remove it.  Applications can use the newer
DirCacheCheckout class as a replacement.

Change-Id: Id66d29fcca5a7286b8f8838303d83f40898918d2
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoRemove deprecated Treeish interface 58/2658/1
Shawn O. Pearce [Mon, 7 Mar 2011 20:12:20 +0000 (12:12 -0800)]
Remove deprecated Treeish interface

This interface has been deprecated for a long time now.
Time to remove it.

Change-Id: I29a938657e4637b2a9d0561940b38d70866613f7
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoAllow to amend a commit with CommitCommand 56/2656/3
Tomasz Zarna [Mon, 7 Mar 2011 15:33:53 +0000 (16:33 +0100)]
Allow to amend a commit with CommitCommand

Bug: 339088
Change-Id: I57dc727688c4bb6968ac076b176661c857c05afa
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoEnable test methods in CommitAndLogCommandTests 55/2655/3
Tomasz Zarna [Mon, 7 Mar 2011 15:47:04 +0000 (16:47 +0100)]
Enable test methods in CommitAndLogCommandTests

Change-Id: I52bbf19416cba42340004f0235e17a436cad1058
Bug: 339086
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoPackFile: Fix copy as-is for small objects 49/2649/1
Shawn O. Pearce [Sat, 5 Mar 2011 02:56:16 +0000 (18:56 -0800)]
PackFile: Fix copy as-is for small objects

When I disabled validation I broke the code that handled copying small
objects whose contents were below 8192 bytes in size but spanned over
the end of one window and into the next window.  These objects did not
ever populate the temporary write buffer, resulting in garbage writing
into the output stream instead of valid object contents.

Change-Id: Ie26a2aaa885d0eee4888a9b12c222040ee4a8562
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMerge "PushCommand: Test for update of tracking branch"
Shawn Pearce [Fri, 4 Mar 2011 21:55:32 +0000 (16:55 -0500)]
Merge "PushCommand: Test for update of tracking branch"

13 years agoMerge "Fix DirCache re-read."
Shawn Pearce [Fri, 4 Mar 2011 15:19:06 +0000 (10:19 -0500)]
Merge "Fix DirCache re-read."

13 years agoMerge "Use generics in RepositoryFilter constructor"
Shawn Pearce [Fri, 4 Mar 2011 15:17:27 +0000 (10:17 -0500)]
Merge "Use generics in RepositoryFilter constructor"

13 years agoDon't auto follow non-annotated tags in fetch 42/2642/1
Shawn O. Pearce [Fri, 4 Mar 2011 15:14:50 +0000 (07:14 -0800)]
Don't auto follow non-annotated tags in fetch

When fetch TagOpt is AUTO_FOLLOW do not follow refs/tags/ names that
point directly to commits which are on unreleated side branches.

Change-Id: Iea6eee5a05ae7402a7f256fd9c1e3d3b5ccb58dd
Reported-by: Slawomir Ginter <sginter@atlassian.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoFix DirCache re-read. 41/2641/1
Robin Rosenberg [Fri, 4 Mar 2011 15:00:25 +0000 (16:00 +0100)]
Fix DirCache re-read.

During unit tests and most likely elsewhere, updates come too fast for
a simple timestamp comparison (with one seconds resolution) to work.
I.e. DirCache thinks it hasn't changed.

Use FileSnapshot instead which has more advanced logic.

Change-Id: Ib850f84398ef7d4b8a8a6f5a0ae6963e37f2b470
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
13 years agoPushCommand: Test for update of tracking branch 39/2639/2
Robin Stocker [Mon, 28 Feb 2011 18:12:37 +0000 (19:12 +0100)]
PushCommand: Test for update of tracking branch

Bug 317411 (Push does not update remote tracking branch) is assigned to
JGit. This test verifies that JGit does the right thing.

Bug: 317411
Change-Id: I8f632e3e6c8a4f16a1170b1dba92e8fd3d6267d0

13 years agoMerge changes I52054d7b,If5865ac9
Shawn O. Pearce [Fri, 4 Mar 2011 14:21:59 +0000 (09:21 -0500)]
Merge changes I52054d7b,If5865ac9

* changes:
  resolve(): Fix wrong parsing of branch "foo-gbed2-dev"
  RemoteRefUpdate: Accept Ref and ObjectId arguments for source

13 years agoMerge "Adapt to Jetty 7.3 API change coming with Indigo"
Christian Halstrick [Fri, 4 Mar 2011 08:32:20 +0000 (03:32 -0500)]
Merge "Adapt to Jetty 7.3 API change coming with Indigo"

13 years agoresolve(): Fix wrong parsing of branch "foo-gbed2-dev" 38/2638/1
Shawn O. Pearce [Fri, 4 Mar 2011 00:17:29 +0000 (16:17 -0800)]
resolve(): Fix wrong parsing of branch "foo-gbed2-dev"

When parsing a string such as "foo-gbed2" resolve() was assuming the
suffix was from git describe output.  This lead to JGit trying to find
the completion for the object abbreviation "bed2", rather than using
the current value of the reference.  If there was only one such object
in the repository, JGit might actually use the wrong value here, as
resolve() would return the completion of the abbreviation "bed2"
rather than the current value of the reference "refs/heads/foo-gbed2".

Move the parsing of git describe abbreviations out of the operator
portion of the resolve() method and into the simple portion that is
supposed to handle only object ids or reference names, and only do the
describe parsing after all other approaches have already failed to
provide a resolution.

Add new unit tests to verify the behavior is as expected by users.

Bug: 338839
Change-Id: I52054d7b89628700c730f9a4bd7743b16b9042a9
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoRemoteRefUpdate: Accept Ref and ObjectId arguments for source 37/2637/1
Shawn O. Pearce [Thu, 3 Mar 2011 22:36:19 +0000 (14:36 -0800)]
RemoteRefUpdate: Accept Ref and ObjectId arguments for source

Applications may already have a Ref or ObjectId on hand that they want
the remote to be updated to.  Instead of converting these into a
String and relying on the parsing rules of resolve(), allow the
application to supply the Ref or ObjectId directly.

Bug: 338839
Change-Id: If5865ac9eb069de1c8f224090b6020fc422f9f12
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoImprove readability of timestamps shown by debug-show-dir-cache 32/2632/2
Matthias Sohn [Thu, 3 Mar 2011 15:19:47 +0000 (16:19 +0100)]
Improve readability of timestamps shown by debug-show-dir-cache

The old format is hard to read.

Change-Id: I27f3a7dbd92b26256993d27d5223b743fef70902
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoEnhance debug-show-dir-cache command to show stage 31/2631/1
Matthias Sohn [Thu, 3 Mar 2011 09:56:38 +0000 (10:56 +0100)]
Enhance debug-show-dir-cache command to show stage

Change-Id: I6fb17ec7f04f8bfaf1253b2ff08200ef9fc51898
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoPackWriter: Validate reused cached packs 30/2630/1
Shawn O. Pearce [Wed, 2 Mar 2011 20:49:00 +0000 (12:49 -0800)]
PackWriter: Validate reused cached packs

If object reuse validation is enabled, the output pack is going to
probably be stored locally.  When reusing an existing cached pack
to save object enumeration costs, ensure the cached pack has not
been corrupted by checking its SHA-1 trailer.  If it has, writing
will abort and the output pack won't be complete.  This prevents
anyone from trying to use the output pack, and catches corruption
before it can be carried any further.

Change-Id: If89d0d4e429d9f4c86f14de6c0020902705153e6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPackWriter: Avoid CRC-32 validation when feeding IndexPack 29/2629/1
Shawn O. Pearce [Wed, 2 Mar 2011 20:23:55 +0000 (12:23 -0800)]
PackWriter: Avoid CRC-32 validation when feeding IndexPack

There is no need to validate the object contents during
copyObjectAsIs if the result is going to be parsed by unpack-objects
or index-pack.  Both programs will compute the SHA-1 of the object,
and also validate most of the pack structure.  For git daemon
like servers, this work is already done on the client end of the
connection, so the server doesn't need to repeat that work itself.

Disable object validation for the 3 transport cases where we know
the remote side will handle object validation for us (push, bundle
creation, and upload pack).  This improves performance on the server
side by reducing the work that must be done.

Change-Id: Iabb78eec45898e4a17f7aab3fb94c004d8d69af6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPackWriter: Position tags after commits 22/2622/1
Shawn O. Pearce [Tue, 1 Mar 2011 00:30:23 +0000 (16:30 -0800)]
PackWriter: Position tags after commits

Annotated tags need to be parsed by many viewing tools, but putting
them at the end of the pack hurts because kernel prefetching might
not have loaded them, since they are so far from the commits they
reference.

Position tags right behind the commits, but before the trees.
Typically the annotated tag set for a repository is very small,
so the extra prefetch burden it puts on tools that don't need
annotated tags (but do need commits and trees) is fairly low.

Change-Id: Ibbabdd94e7d563901c0309c79a496ee049cdec50
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPackWriter: Refactor object writing loop 21/2621/1
Shawn O. Pearce [Tue, 1 Mar 2011 00:08:05 +0000 (16:08 -0800)]
PackWriter: Refactor object writing loop

This simple refactoring makes it easier to pre-process each of the
object lists before its handed into the actual write routine.

Change-Id: Iea95e5ecbc7374f6bcbb43d1c75285f4f564d09d
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPackWriter: Don't reuse commit or tag deltas 20/2620/1
Shawn O. Pearce [Mon, 28 Feb 2011 23:39:31 +0000 (15:39 -0800)]
PackWriter: Don't reuse commit or tag deltas

JGit doesn't generate deltas for commit or tag objects when it packs
a repository from scratch.  This is an explicit design decision that
is (mostly) justified by the fact that these objects do not delta
compress well.

Annotated tags are made once on stable points of the project history,
it is unlikely they will ever appear again with sufficient common
text to justify using a delta over just deflating the raw content.
JGit never tries to delta compress annotated tags and I take the
stance that these are best stored as non-deltas given how frequently
they might be accessed by repository viewers.

Commits only have sufficient common text when they are cherry-picked
to forward-port or back-port a change from one branch to another.
Even in these cases the distance between the commits as returned
by the log traversal has to be small enough that they would both
appear in the delta search window at the same time in order to
delta compress one of the messages against the other.  JGit never
tries to delta compress commits, as it requires a lot of CPU time
but typically does not produce a smaller pack file.

Avoid reusing deltas for either of these types when constructing a
new pack.  To avoid killing performance during serving of network
clients, UploadPack disables this code change by allowing PackWriter
to reuse delta commits.  Repositories that were already repacked by
C Git will not have their delta commits decompressed and recompressed
on the fly during object writing, saving server-side CPU resources.

Change-Id: I749407e7c5c677e05e4d054b40db7656cfa7fca8
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPackWriter: Do not delta compress already packed objects 19/2619/1
Shawn O. Pearce [Tue, 1 Mar 2011 17:28:11 +0000 (09:28 -0800)]
PackWriter: Do not delta compress already packed objects

This is a tiny optimization to how delta search works.  Checking for
isReuseAsIs() avoids doing delta compression search on non-delta
objects already stored in packs within the repository.  Such objects
are not likely to be delta compressable, as they were already delta
searched when their containing pack was generated and they were
not delta compressed at that time.  Doing delta compression now is
unlikely to produce a different result, but would waste a lot of CPU.

The isReuseAsIs() flag is checked before isDoNotDelta() because it
is very common to reuse objects in the output pack.  Most objects
get reused, and only a handful have the isDoNotDelta() bit set.
Moving the check earlier allows the loop to more quickly skip
through objects that will never need to be considered.

Change-Id: Ied757363f775058177fc1befb8ace20fe9759bac
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPaper bag fix BatchingProgressMonitor alarm queue 17/2617/1
Shawn O. Pearce [Tue, 1 Mar 2011 18:06:39 +0000 (10:06 -0800)]
Paper bag fix BatchingProgressMonitor alarm queue

The alarm queue threads were started with an empty task body, which
meant the thread started and terminated immediately, leaving the
queue itself with no worker.

Change-Id: I2a9b5fe9c2bdff4a5e0f7ec7ad41a54b41a4ddd6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMerge "ProgressMonitor: Refactor to use background alarms"
Chris Aniszczyk [Tue, 1 Mar 2011 17:05:59 +0000 (12:05 -0500)]
Merge "ProgressMonitor: Refactor to use background alarms"

13 years agoMerge "Show notes in Log CLI command - Part 2"
Chris Aniszczyk [Tue, 1 Mar 2011 16:13:00 +0000 (11:13 -0500)]
Merge "Show notes in Log CLI command - Part 2"

13 years agoShow notes in Log CLI command - Part 2 97/2597/2
Sasa Zivkov [Thu, 24 Feb 2011 10:12:06 +0000 (11:12 +0100)]
Show notes in Log CLI command - Part 2

This change fixes issues identified in the commit
5f3d577e5a1e8f23a2b6ea6a2bf24516806e01b8.

Change-Id: Idbd935f5f60ad043faa0d4982b3e101ef7c07d60
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
13 years agoProgressMonitor: Refactor to use background alarms 15/2615/1
Shawn O. Pearce [Tue, 1 Mar 2011 03:34:06 +0000 (19:34 -0800)]
ProgressMonitor: Refactor to use background alarms

Instead of polling the system clock on every update(1) method call,
use a scheduled executor to toggle a volatile once per second until
the task is done.  Check the volatile on each update(int), looking
to see if output should occur.

This limits progress output to either once per 1% complete, or once
per second.  To save time during update calls the timer isn't reset
during each 1% of output, which means we may see one unnecessary
output trigger if at least 1% completed during the one second of the
alarm time.

Change-Id: I8fdd7e31c37bef39a5d1b3da7105da0ef879eb84
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoAdapt to Jetty 7.3 API change coming with Indigo 71/2171/2
Matthias Sohn [Tue, 1 Mar 2011 01:04:07 +0000 (02:04 +0100)]
Adapt to Jetty 7.3 API change coming with Indigo

Indigo comes with Jetty 7.3 bringing some API changes. This still
works with Jetty 7.1.6 shipped with Helios.

Change-Id: If4f9d6ef6b45c94f8bb097f8b02c10317b47547b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoFix NPE on checkout of remote tracking branch 14/2614/1
Matthias Sohn [Mon, 28 Feb 2011 23:21:14 +0000 (00:21 +0100)]
Fix NPE on checkout of remote tracking branch

Checkout of remote tracking branch failed when no local branch
existed. Also enhance RepositoryTestCase to enable checking index
state of another test repository.

Bug: 337695
Change-Id: Idf4c05bdf23b5161688818342b2bf9a45b49f479
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoMerge branch 'stable-0.11' 05/2605/1
Shawn O. Pearce [Sat, 26 Feb 2011 01:24:55 +0000 (17:24 -0800)]
Merge branch 'stable-0.11'

* stable-0.11:
  JGit 0.11.3
  Fix NullPointer when pulling from a deleted local branch
  smart-http: Fix recognition of gzip encoding
  Fix processing of broken symbolic references in RefDirectory
  CreateBranchCommand: Wrong existence check
  Qualify post 0.11.1 builds

Conflicts:
org.eclipse.jgit.console/META-INF/MANIFEST.MF
org.eclipse.jgit.console/pom.xml
org.eclipse.jgit.http.server/META-INF/MANIFEST.MF
org.eclipse.jgit.http.server/pom.xml
org.eclipse.jgit.http.test/META-INF/MANIFEST.MF
org.eclipse.jgit.http.test/pom.xml
org.eclipse.jgit.iplog/META-INF/MANIFEST.MF
org.eclipse.jgit.iplog/pom.xml
org.eclipse.jgit.junit.http/META-INF/MANIFEST.MF
org.eclipse.jgit.junit.http/pom.xml
org.eclipse.jgit.junit/META-INF/MANIFEST.MF
org.eclipse.jgit.junit/pom.xml
org.eclipse.jgit.packaging/org.eclipse.jgit.feature/feature.xml
org.eclipse.jgit.packaging/org.eclipse.jgit.feature/pom.xml
org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/feature.xml
org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/pom.xml
org.eclipse.jgit.packaging/org.eclipse.jgit.source.feature/feature.xml
org.eclipse.jgit.packaging/org.eclipse.jgit.source.feature/pom.xml
org.eclipse.jgit.packaging/org.eclipse.jgit.updatesite/pom.xml
org.eclipse.jgit.packaging/pom.xml
org.eclipse.jgit.pgm/META-INF/MANIFEST.MF
org.eclipse.jgit.pgm/pom.xml
org.eclipse.jgit.test/META-INF/MANIFEST.MF
org.eclipse.jgit.test/pom.xml
org.eclipse.jgit.ui/META-INF/MANIFEST.MF
org.eclipse.jgit.ui/pom.xml
org.eclipse.jgit/META-INF/MANIFEST.MF
org.eclipse.jgit/META-INF/SOURCE-MANIFEST.MF
org.eclipse.jgit/pom.xml
pom.xml

Change-Id: I08067c028666f194687943a574512f5bc5ca9552

13 years agoUnpackedObject: Fix readSome() when initial read is short 04/2604/1
Shawn O. Pearce [Sat, 26 Feb 2011 01:20:14 +0000 (17:20 -0800)]
UnpackedObject: Fix readSome() when initial read is short

JDK7 changed behavior slightly on some InputStream types, resulting in
the first read being shorter than the count requested.  That caused us
to overwrite the earlier part of the buffer with later data, as the
offset index wasn't updated in the loop.

Fix the loop to increment offset by the number of bytes read in this
iteration, so the next read appends to the buffer rather than doing an
overwrite.

Bug: 338119
Change-Id: I222fb2f993cd9b637b6b8d93daab5777ef7ec7a6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoUse generics in RepositoryFilter constructor 40/2640/1
Robin Rosenberg [Fri, 25 Feb 2011 22:11:47 +0000 (23:11 +0100)]
Use generics in RepositoryFilter constructor

Change-Id: I461786baffab15515365ead1d9c350a1880443ea

13 years agoMerge "RevWalk: Don't release during inMergeBase()"
Chris Aniszczyk [Thu, 24 Feb 2011 16:23:47 +0000 (11:23 -0500)]
Merge "RevWalk: Don't release during inMergeBase()"

13 years agoMerge "Fix formatting of pom.xml"
Shawn Pearce [Thu, 24 Feb 2011 15:29:47 +0000 (10:29 -0500)]
Merge "Fix formatting of pom.xml"

13 years agoFetchCommand: do not set a null credentials provider 86/2586/2
Matthias Sohn [Thu, 24 Feb 2011 12:52:24 +0000 (13:52 +0100)]
FetchCommand: do not set a null credentials provider

FetchCommand now does not set a null credentials provider on
Transport because in this case the default provider is replaced with
null and the default mechanism for providing credentials is not
working.

Change-Id: I44096aa856f031545df39d4b09af198caa2c21f6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoFix formatting of pom.xml 87/2587/2
Matthias Sohn [Thu, 24 Feb 2011 11:44:59 +0000 (12:44 +0100)]
Fix formatting of pom.xml

Change-Id: I508def09cb2d4e5bd27b412f4ad5d43984388749
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoRevWalk: Don't release during inMergeBase() 82/2582/2
Shawn O. Pearce [Wed, 23 Feb 2011 20:00:25 +0000 (12:00 -0800)]
RevWalk: Don't release during inMergeBase()

In bc1af8459e ("RevWalk: Don't reset ObjectReader when stopping") we
stopped releasing the reader when the current log traversal is over.
This should have also been applied to the merge base logic that is
buried within MergeGenerator, but got missed.

Change-Id: I8328f43f02cba06fd545e22134872e781b9d4d36
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMerge "Respect core.excludesfile to enable global ignore rules "
Shawn Pearce [Wed, 23 Feb 2011 23:08:50 +0000 (18:08 -0500)]
Merge "Respect core.excludesfile to enable global ignore rules "

13 years agoRespect core.excludesfile to enable global ignore rules 75/2575/2
Matthias Sohn [Wed, 23 Feb 2011 22:44:50 +0000 (23:44 +0100)]
Respect core.excludesfile to enable global ignore rules

Also use FS.resolve() to properly resolve files from path strings.

Bug: 328428 (partial fix)
Change-Id: I41d94694f220dcb85605c9acadfffb1fa23beaeb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoPackWriter: Add missing timers to Statistics 81/2581/1
Shawn O. Pearce [Wed, 23 Feb 2011 02:56:51 +0000 (18:56 -0800)]
PackWriter: Add missing timers to Statistics

We did not record the time spent on the object reuse search or the
object size lookup, both of which occur between the counting phase and
the compressing phase.  If there are enough objects involved, these
times can be significant so its worth timing them and recording it.

Change-Id: I89084acfc598bb6533d75d90cb8de459f0ed93be
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoShow notes in Log CLI command 64/2564/3
Sasa Zivkov [Mon, 21 Feb 2011 15:43:06 +0000 (16:43 +0100)]
Show notes in Log CLI command

Support for --no-standard-notes and --show-notes=REF options is added
to the Log command. The --show-notes option can be specified more than
once if more than one notes branch should be used for showing notes.

The notes are displayed from note branches in the order how the note
branches are specified in the command line. However, the standard note,
from the refs/notes/commits, is always displayed as first unless
the --no-standard-notes options is given.

Change-Id: I4e7940804ed9d388b625b8e8a8e25bfcf5ee15a6
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoPackWriter: Fix total delta count 72/2572/1
Shawn O. Pearce [Wed, 23 Feb 2011 00:53:22 +0000 (16:53 -0800)]
PackWriter: Fix total delta count

The total delta count is supposed to include reused deltas, not
just newly created deltas.

Change-Id: I98cbdcef80d59714a4f62ff322e7b709b08b6d26
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMerge "Create empty GIT_DIR/hooks directory"
Shawn O. Pearce [Tue, 22 Feb 2011 15:46:09 +0000 (10:46 -0500)]
Merge "Create empty GIT_DIR/hooks directory"

13 years agoMerge "Fix potential NullPointerException in PlotCommit"
Shawn Pearce [Tue, 22 Feb 2011 15:45:51 +0000 (10:45 -0500)]
Merge "Fix potential NullPointerException in PlotCommit"

13 years agoCreate empty GIT_DIR/hooks directory 66/2566/1
Shawn O. Pearce [Tue, 22 Feb 2011 15:38:51 +0000 (07:38 -0800)]
Create empty GIT_DIR/hooks directory

Bug: 337801
Change-Id: I5e0c4d838a211509fb4cc7e048dba6efaec15d5c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoFix potential NullPointerException in PlotCommit 56/2556/2
Mathias Kinzler [Tue, 22 Feb 2011 08:11:42 +0000 (09:11 +0100)]
Fix potential NullPointerException in PlotCommit

Change-Id: Ib7f661a259561251e74337fa233036e041c42423
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
13 years agoJGit 0.11.3 47/2547/1 stable-0.11 v0.11.3
Matthias Sohn [Sun, 20 Feb 2011 23:59:47 +0000 (00:59 +0100)]
JGit 0.11.3

Change-Id: I0a3d4d4400e7643c43d64bf60e566d533b5dcee1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoFix NullPointer when pulling from a deleted local branch 46/2546/1
Stefan Lay [Wed, 16 Feb 2011 14:46:26 +0000 (15:46 +0100)]
Fix NullPointer when pulling from a deleted local branch

A checked Exception is thrown instead.

The reason for throwing an Exception is that the state of the
repository is inconsistent in this case: There is a merge
configuration containing a non-existing local branch. Ideally the
deletion of a local branch should also delete the corresponding
merge configuration.

Bug: 337315
Change-Id: I8ed57d5aaed60aaab685fc11a8695e474e60215f
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agosmart-http: Fix recognition of gzip encoding 45/2545/1
Shawn O. Pearce [Tue, 15 Feb 2011 22:09:42 +0000 (14:09 -0800)]
smart-http: Fix recognition of gzip encoding

Some clients coming through proxies may advertise a different
Accept-Encoding, for example "Accept-Encoding: gzip(proxy)".
Matching by substring causes us to identify this as a false positive;
that the client understands gzip encoding and will inflate the
response before reading it.

In this particular case however it doesn't.  Its the reverse proxy
server in front of JGit letting us know the proxy<->JGit link can
be gzip compressed, while the client<->proxy part of the link is not:

  client <-- no gzip --> proxy <-- gzip --> JGit

Use a more standard method of parsing by splitting the value into
tokens, and only using gzip if one of the tokens is exactly the
string "gzip".  Add a unit test to make sure this isn't broken in
the future.

Change-Id: Ib4c40f9db177322c7a2640808a6c10b3c4a73819
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoFix processing of broken symbolic references in RefDirectory 44/2544/1
Marc Strapetz [Wed, 9 Feb 2011 11:54:09 +0000 (12:54 +0100)]
Fix processing of broken symbolic references in RefDirectory

Change-Id: Ic1ceb9c99dca2c69e61ea0ef03ec64f13714b80a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoCreateBranchCommand: Wrong existence check 43/2543/1
Mathias Kinzler [Mon, 14 Feb 2011 14:48:43 +0000 (15:48 +0100)]
CreateBranchCommand: Wrong existence check

Bug: 337044
Change-Id: I89224719712c1f1ab80ea34280139dfeb00be3d0
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoQualify post 0.11.1 builds 42/2542/1
Matthias Sohn [Sun, 20 Feb 2011 23:41:45 +0000 (00:41 +0100)]
Qualify post 0.11.1 builds

Change-Id: I48cca12fcc6212fbe6c42109e44e4a2dc20ecada
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoPackWriter: Hoist and cluster reference targets 41/2541/1
Shawn O. Pearce [Sat, 19 Feb 2011 01:55:53 +0000 (17:55 -0800)]
PackWriter: Hoist and cluster reference targets

Many source browsers and network related tools like UploadPack need
to find and parse the target of all branches and annotated tags
within the repository during their startup phase.  Clustering these
together into the same part of the pack file will improve locality,
reducing thrashing when an application starts and needs to load
all of these into memory at once.

To prevent bottlenecking basic log viewing tools that are scannning
backwards from the tip of a current branch (and don't need tags)
we place this cluster of older targets after 4096 newer commits
have already been placed into the pack stream.  4096 was chosen as
a rough guess, but was based on a few factors:

  - log viewers typically show 5-200 commits per page
  - users only view the first page or two

  - DHT can cram 2200-4000 commits per 1 MiB chunk
    thus these will fall into the second commit chunk (roughly)

Unfortunately this placement hurts history tools that are scanning
backwards through the commit graph and completely ignored tags or
branch heads when they started.

An ancient tagged commit is no longer positioned behind its first
child (its now much earlier), resulting in a page fault for the
parser to reload this cluster of objects on demand.  This may be
an acceptable loss.  If a user is walking backwards and has already
scanned through more than 4096 commits of history, waiting for the
region to reload isn't really that bad compared to the amount of
time already spent.

If the repository is so small that there are less than 4096 commits,
this change has no impact on the placement of objects.

Change-Id: If3052e430d305e17878d94145c93754f56b74c61
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPackWriter: Parse tag target objects in a batch 40/2540/1
Shawn O. Pearce [Sat, 19 Feb 2011 01:31:32 +0000 (17:31 -0800)]
PackWriter: Parse tag target objects in a batch

If the underlying storage has a high latency per SHA-1 lookup
(e.g. the DHT support we are working on), parsing each wanted
annotated tag object back to its underlying commit is too slow,
its a sequential lookup for each tag.  With hundreds of tags in
a repository this takes far too long.

Instead queue up a list of the tags whose objects need to be found,
and then locate all of those in one parseAny batch.  This works
for the common case of annotated tag to single tree or commit.
For the less often used tag->tag->commit, it at least gets us
one level parsed in the larger batch before we have to go back to
sequential lookups.

Change-Id: I94beef3f14281406f15c8cf9fa02d83faf102a19
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPackWriter: Correct total delta count when reusing pack 38/2538/1
Shawn O. Pearce [Sat, 19 Feb 2011 01:21:09 +0000 (17:21 -0800)]
PackWriter: Correct total delta count when reusing pack

If the CachedPack knows its delta count, we need to increment both
the totalDeltas and reusedDeltas fields of the stats object.

Change-Id: I70113609c22476ce7f1e4d9a92f486e9b0f59e44
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPackWriter: Short-circuit counting on full cached pack reuse 39/2539/1
Shawn O. Pearce [Sat, 19 Feb 2011 01:06:36 +0000 (17:06 -0800)]
PackWriter: Short-circuit counting on full cached pack reuse

If one or more cached packs fully covers the request, don't bother
with looking up the objects and trying to walk the graph.  Just use
the cached packs and return immediately.

This helps clones of quiet repositories that have not been modified
since their last repack, its likely the cached packs are accurate
and no graph walking is required.

Change-Id: I9062a5ac2f71b525322590209664a84051fd5f8a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPackWriter: Fix warning about untyped collection 37/2537/1
Shawn O. Pearce [Sat, 19 Feb 2011 00:56:54 +0000 (16:56 -0800)]
PackWriter: Fix warning about untyped collection

Change-Id: I44699d8ab9768844ba91f7224a7d4ee685c93ce6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoBundleWriter: Always use OFS_DELTA 35/2535/2
Shawn O. Pearce [Fri, 18 Feb 2011 22:14:56 +0000 (14:14 -0800)]
BundleWriter: Always use OFS_DELTA

CGit just learned to always use OFS_DELTA when writing out bundle
files.  This makes sense because bundle came about well after
OFS_DELTA was established, so any version of CGit that can read a
bundle file can also read OFS_DELTA.  Since OFS_DELTA is smaller,
always use it when writing bundles.

Change-Id: I44f9921494798ea0c99e16eab58b87bebeb9aff5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMerge "PackWriter: Sort commits by parse order to improve locality"
Chris Aniszczyk [Fri, 18 Feb 2011 19:30:19 +0000 (14:30 -0500)]
Merge "PackWriter: Sort commits by parse order to improve locality"

13 years agoWrong constant used when configuring a repository 31/2531/2
Tomasz Zarna [Fri, 18 Feb 2011 10:41:19 +0000 (11:41 +0100)]
Wrong constant used when configuring a repository

Bug: 337546
Change-Id: Ib2f31d621caa5f8b24ce74ce82499889d4f30550

13 years agoPackWriter: Sort commits by parse order to improve locality 29/2529/1
Shawn O. Pearce [Thu, 17 Feb 2011 01:41:35 +0000 (17:41 -0800)]
PackWriter: Sort commits by parse order to improve locality

RevWalk in JGit and the revision code in C Git both parse commits out
of the pack file in an order that differs from strict timestamp and
topological sorting.  Both implementations pop a commit from the head
of a date queue, and then immediately parse all of its parents in
order to insert those into the date queue at the proper positions as
determined by their committer timestamp field.  This implies that the
parents are parsed when their most recent child is popped from the
queue, and not where they are popped during traversal.

Hoisting a parent commit to be immediately behind its child improves
locality by making sure all parents of a merge are clustered together,
and thus can be paged into the parser by the pack file buffering
system (aka WindowCache in JGit) together.

Change-Id: I80f9e64cafa2e8f082776b43845edf23065386a2
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMerge "Changed TreeWalk.forPath(...) to work with recursive paths."
Shawn Pearce [Fri, 18 Feb 2011 05:21:59 +0000 (00:21 -0500)]
Merge "Changed TreeWalk.forPath(...) to work with recursive paths."

13 years agoAdd Reset to the JGit CLI 23/2523/2
Chris Aniszczyk [Thu, 17 Feb 2011 17:03:48 +0000 (11:03 -0600)]
Add Reset to the JGit CLI

Change-Id: I85368c849c0964b9a539fa1991920adb2ace94df
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoChanged TreeWalk.forPath(...) to work with recursive paths. 10/2310/7
Jesse Greenwald [Sat, 22 Jan 2011 15:51:29 +0000 (07:51 -0800)]
Changed TreeWalk.forPath(...) to work with recursive paths.

Previously, this method would not (always) work when a recursive path
such as "a/b" was passed into it.

Change-Id: I0752a1f5fc7fef32064d8f921b33187c0bdc7227
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoAdd git-reset to the Git API 43/2443/4
Chris Aniszczyk [Tue, 1 Feb 2011 14:47:04 +0000 (08:47 -0600)]
Add git-reset to the Git API

Bug: 334764
Change-Id: Ice404629687d7f2a595d8d4eccf471b12f7e32ec
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoMerge "Fix NullPointer when pulling from a deleted local branch"
Shawn Pearce [Wed, 16 Feb 2011 15:15:31 +0000 (10:15 -0500)]
Merge "Fix NullPointer when pulling from a deleted local branch"

13 years agoFix NullPointer when pulling from a deleted local branch 14/2514/1
Stefan Lay [Wed, 16 Feb 2011 14:46:26 +0000 (15:46 +0100)]
Fix NullPointer when pulling from a deleted local branch

A checked Exception is thrown instead.

The reason for throwing an Exception is that the state of the
repository is inconsistent in this case: There is a merge
configuration containing a non-existing local branch. Ideally the
deletion of a local branch should also delete the corresponding
merge configuration.

Bug: 337315
Change-Id: I71e56ffb90e11e6e3c1bbd964ad63972d67990c0
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
13 years agosmart-http: Support progress in ReceivePack 11/2511/1
Shawn O. Pearce [Tue, 15 Feb 2011 22:46:30 +0000 (14:46 -0800)]
smart-http: Support progress in ReceivePack

As PackParser supports a progress meter for the "Resolving deltas"
phase of its work, we should export this to smart HTTP clients so
they know the server is still working on their (large) upload.

However this isn't as simple as just dropping in a binding for
the SmartOutputStream to flush when its told to.  We want to
avoid spurious flushes triggered by the use of sideband, or the
status report formatting in the send-pack/receive-pack protocol.

Change-Id: Ibd88022a298c5fed0edb23dfaf2e90278807ba8b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agosmart-http: Fix recognition of gzip encoding 10/2510/1
Shawn O. Pearce [Tue, 15 Feb 2011 22:09:42 +0000 (14:09 -0800)]
smart-http: Fix recognition of gzip encoding

Some clients coming through proxies may advertise a different
Accept-Encoding, for example "Accept-Encoding: gzip(proxy)".
Matching by substring causes us to identify this as a false positive;
that the client understands gzip encoding and will inflate the
response before reading it.

In this particular case however it doesn't.  Its the reverse proxy
server in front of JGit letting us know the proxy<->JGit link can
be gzip compressed, while the client<->proxy part of the link is not:

  client <-- no gzip --> proxy <-- gzip --> JGit

Use a more standard method of parsing by splitting the value into
tokens, and only using gzip if one of the tokens is exactly the
string "gzip".  Add a unit test to make sure this isn't broken in
the future.

Change-Id: I30cda8a6d11ad235b56457adf54a2d27095d964e
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agohttp.test: Delete badly named JUnit configurations 09/2509/1
Shawn O. Pearce [Tue, 15 Feb 2011 22:13:59 +0000 (14:13 -0800)]
http.test: Delete badly named JUnit configurations

We also have org.eclipse.jgit.http--All-Tests, which matches the
style of the org.eclipse.jgit.core--All-Tests name. Drop the others
as these are just redundant duplicates.

Change-Id: I8600a343f6a85d21dc07bda68a8cb834c82946b5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPackWriter: Try for accurate delta reuse on cached pack 08/2508/1
Shawn O. Pearce [Tue, 15 Feb 2011 17:40:16 +0000 (09:40 -0800)]
PackWriter: Try for accurate delta reuse on cached pack

If a cached pack is used, it might know how many deltas are contained
within it.  Record that count as part of our reusedDeltas field
for the stats line we show clients.

Change-Id: I1c61fb817305a95eeac654cccf132cba20b2339c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>