]> source.dussan.org Git - jgit.git/log
jgit.git
13 years agoAllow application filters on smart HTTP operations 31/2731/8
Shawn O. Pearce [Tue, 15 Mar 2011 21:00:43 +0000 (14:00 -0700)]
Allow application filters on smart HTTP operations

Permit applications embedding GitServlet to wrap the
info/refs?service=$name and /$name operations with a
servlet Filter.

To help applications inspect state of the operation,
expose the UploadPack or ReceivePack object into a
request attribute.  This can be useful for logging,
or to implement throttling of requests like Gerrit
Code Review uses to prevent server overload.

Change-Id: Ib8773c14e2b7a650769bd578aad745e6651210cb
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPackWriter: Fix the way delta chain cycles are prevented 82/2782/4
Shawn O. Pearce [Fri, 18 Mar 2011 17:23:21 +0000 (10:23 -0700)]
PackWriter: Fix the way delta chain cycles are prevented

Take a very simple approach to avoiding delta chains during object
reuse: objects are now always selected from the oldest pack that
contains them.  This prevents cycles because a pack must not have
a cycle in the delta chain.  If both objects A and B are chosen
out of the same source pack then there cannot be an A->B->A cycle.

The oldest pack is also the most likely to have the smallest deltas.
Its the biggest pack in the system and probably came from the clone
(or last GC) of this repository, where all objects were previously
considered and packed tightly together.  If an object appears again
(for example due to a revert and a push into this repository) the
newer copy of won't be nearly as small as the older delta version
of it, even if the newer one is also itself a delta.

ObjectDirectory already enumerates objects during selection in this
newest->oldest order, so it already is supplying these assumptions
to PackWriter.  Taking advantage of this can speed up selection by
a tiny amount by avoiding some tests, but can also help to prevent
a cycle needing to be broken on the fly during writing.

The previous cycle breaking logic wasn't fully correct either.
If a different delta base was chosen, the new delta base might not
have been written into the output pack before the current object,
forcing the use of REF_DELTA when OFS_DELTA is always smaller.
This logic has now been reworked to always re-check the delta base
and ensure it gets written before the current object.

If a cycle occurs, it gets broken the same way as before, by
disabling delta reuse and finding an alternative form of the
object, which may require inflating/deflating in whole format.

Change-Id: I9953ab8be54ceb8b588e1280d6f7edd688887747
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPackWriter: Combine small reuse batches together 78/2778/4
Shawn O. Pearce [Fri, 18 Mar 2011 16:10:07 +0000 (09:10 -0700)]
PackWriter: Combine small reuse batches together

If the total number of objects to look for reuse on is under 4096
this is really close to a reasonable batch size for the DHT storage
system to lookup at once.  Combine all of the objects into a single
temporary list, perform reuse, and then prune the main lists if any
duplicate objects were detected from a selected CachedPack.

The intention here is to try and avoid 4 tiny sequential lookups
on the storage system when the time to wait for each of those to
finish is higher than the CPU time required to build (and later
GC) this temporary list.

Change-Id: I528daf9d2f7744dc4a6281750c2d61d8f9da9f3a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPackWriter: Remove dummy list 0 77/2777/4
Shawn O. Pearce [Fri, 18 Mar 2011 15:37:28 +0000 (08:37 -0700)]
PackWriter: Remove dummy list 0

Instead of looping over the objectsLists array, always set slot 0 to
null and explicitly work on the 4 indexes that matter.  This kills
some loops and increases the length of the code slightly, but I've
always really disliked that dummy 0 slot.

Change-Id: I5ad938501c1c61f637ffdaff0d0d88e3962d8942
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPackWriter: Speed up pruning of objects from cached packs 76/2776/4
Shawn O. Pearce [Fri, 18 Mar 2011 15:29:26 +0000 (08:29 -0700)]
PackWriter: Speed up pruning of objects from cached packs

During object enumeration for the thin pack, very few objects come
out that are duplicated with the cached pack. Typically these are
only cases where a blob or tree was cherry-picked forward, got a
copy or rename, or was reverted... all relatively infrequent events.

Speed up pruning of the thin pack object list by combining the phase
with the object representation selection. Implementers should already
be offering to reuse the object from the cached pack if it is stored
there, at which point the implementation can perform a very fast type
of containment test using the cached pack's identity rather than yet
another index lookup.  For the local disk case this is probably not a
big improvement, but it does help on the DHT implementation where the
two passes combined into one reduces latency.

Change-Id: I6a07fc75d9075bf6233e967360b6546f9e9a2b33
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMake PacketLineIn public 55/2955/2
Shawn O. Pearce [Mon, 28 Mar 2011 17:26:30 +0000 (10:26 -0700)]
Make PacketLineIn public

PacketLineOut is already public. Make PacketLineIn partially public
in case an application needs to use some of the pkt-line protocol.

Change-Id: I5b383eca980bd9e16a7dbdb5aed040c6586d4f46
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMerge changes I2c8e917a,Ica9e50c0
Shawn Pearce [Fri, 1 Apr 2011 19:20:37 +0000 (15:20 -0400)]
Merge changes I2c8e917a,Ica9e50c0

* changes:
  Do not normalize URIishes
  Use Ignore to bypass unused test

13 years agoMerge "Fix broken git prefix detection"
Shawn Pearce [Fri, 1 Apr 2011 19:05:34 +0000 (15:05 -0400)]
Merge "Fix broken git prefix detection"

13 years agoBump jsch to 0.1.44 11/2211/4
Anatol Pomozov [Wed, 5 Jan 2011 20:02:22 +0000 (12:02 -0800)]
Bump jsch to 0.1.44

It fixes 'Corrupted MAC on input' ssh issue.

CQ: 4728
Change-Id: I7de63cb3482488ac938566706edebee8a1cdad3a
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoLet CloneCommand not checkout HEAD on bare repos 68/2968/1
Christian Halstrick [Wed, 30 Mar 2011 00:29:47 +0000 (02:29 +0200)]
Let CloneCommand not checkout HEAD on bare repos

If the clone command clones into a bare repository it should not try
to checkout HEAD in the end. For bare repos checkout is not possible.

Change-Id: I359719d421b93c9d2e962e3c0eccc2b59235c3d1
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
13 years agoAdded Merge command to the CLI 20/320/7
Christian Halstrick [Fri, 5 Mar 2010 08:31:33 +0000 (09:31 +0100)]
Added Merge command to the CLI

This merge command accepts the merge strategy as option and uses the
resolve strategy as default. It expects exactly one other
revision which is merged with current head.

Change-Id: Ia8c188b93ade4afabe6a9ccf267faf045f359a3a
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoAllow InitCommand to run on existing git repos 59/2959/1
Christian Halstrick [Tue, 29 Mar 2011 13:03:25 +0000 (15:03 +0200)]
Allow InitCommand to run on existing git repos

To be more consistent with what native git does we should allow
to run the InitCommand also on existing git repos.

Change-Id: I833637842631b37dce96ed9729b3a6ed24054056
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
13 years agoMerge "Do not categorize merge failures as 'abnormal'"
Christian Halstrick [Tue, 29 Mar 2011 08:23:56 +0000 (04:23 -0400)]
Merge "Do not categorize merge failures as 'abnormal'"

13 years agoFix possible NPE in DirCache.isModified() 51/2951/1
Philipp Thun [Mon, 28 Mar 2011 15:54:24 +0000 (17:54 +0200)]
Fix possible NPE in DirCache.isModified()

The snapshot field of a DirCache object for a newly created repository
can be null. This fix prevents a NPE when isModified() is called in
such a situation.

Change-Id: I61a1b45db2d60fdcc0f87373ac6fd75ac4c4a202
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
13 years agoDo not categorize merge failures as 'abnormal' 48/2948/1
Philipp Thun [Mon, 28 Mar 2011 14:01:44 +0000 (16:01 +0200)]
Do not categorize merge failures as 'abnormal'

This change contains a simple renaming. Instead of using the
expression 'abnormal failure', we just treat this kind of situation
as 'failure'. This is specific enough as conflicts are already handled
separately.

Change-Id: I535acdc7d022543ed0f5ac6151b09a6985f4ef38
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
13 years agoDo not normalize URIishes 42/2942/2
Robin Rosenberg [Sun, 27 Mar 2011 20:42:57 +0000 (22:42 +0200)]
Do not normalize URIishes

We used to normalize URI's since it seems simple. This however causes
inconsistencies to the user and to out tests. Just pass backslashes
through and make sure our parser can handle them.

Bug: 341062
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Change-Id: I2c8e917a086faabcd8749160c2acc9dd05a42838

13 years agoUse Ignore to bypass unused test 41/2941/2
Robin Rosenberg [Sun, 27 Mar 2011 20:53:26 +0000 (22:53 +0200)]
Use Ignore to bypass unused test

Change-Id: Ica9e50c0d512865d217f55bf0d100f27878031b9
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
13 years agoFix broken git prefix detection 39/2939/3
Robin Rosenberg [Sun, 27 Mar 2011 18:44:38 +0000 (20:44 +0200)]
Fix broken git prefix detection

If JGit got a cygwin path it would fail to resolve directories
relative to it.

Also add system property to debug problems with the FS utilities.
Enable debug using -Djgit.fs.debug=1

Furthermore use -Djgit.gitprefix=<path> to set the git prefix
manually.

Change-Id: I5a58ee45c2d2ae5322f87fd6972526169b2918c8
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
13 years agoMerge "Detaching HEAD when checking out the same commit."
Shawn Pearce [Sun, 27 Mar 2011 20:55:54 +0000 (16:55 -0400)]
Merge "Detaching HEAD when checking out the same commit."

13 years agoMerge "Fix: possible IndexOutOfBoundsException in ReflogReader"
Shawn Pearce [Sun, 27 Mar 2011 20:48:45 +0000 (16:48 -0400)]
Merge "Fix: possible IndexOutOfBoundsException in ReflogReader"

13 years agoMerge "Registering the Checkout command and fixed a typo."
Shawn Pearce [Sun, 27 Mar 2011 20:46:39 +0000 (16:46 -0400)]
Merge "Registering the Checkout command and fixed a typo."

13 years agoDetaching HEAD when checking out the same commit. 25/2925/2
Sasa Zivkov [Fri, 25 Mar 2011 13:28:56 +0000 (14:28 +0100)]
Detaching HEAD when checking out the same commit.

Detaching HEAD didn't work in some corner checkout cases.  If, for example,
HEAD is symbolic ref to refs/heads/master, refs/heads/master is ref to commit
c0ffee... then:

    checkout c0ffee...

would leave the HEAD unchanged.

The same symptom occurs when checking out a remote tracking branch or a tag
that references the same commit as refs/heads/master.

In the above case, the RefUpdate class didn't have enough information to decide
if the update needed to detach symbolic ref because it dealt only with new/old
objectIDs. Therefore, this fix introduced the RefUpdate.detachingSymbolicRef
flag.

Bug: 315166
Change-Id: I085c98b77ea8f9104a213978ea0d4ac6fd58f49b
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
13 years agoPrevent NPE during fetch and push via SSH 22/2922/1
Matthias Sohn [Fri, 25 Mar 2011 02:01:50 +0000 (19:01 -0700)]
Prevent NPE during fetch and push via SSH

Bug: 340928
Change-Id: I870b77eeffa70a57891d7253a06ad7d44d808ee4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoIntroduce FAILED result for RebaseCommand 47/2647/3
Philipp Thun [Thu, 24 Mar 2011 11:24:23 +0000 (12:24 +0100)]
Introduce FAILED result for RebaseCommand

In case an underlying cherry-pick fails due to uncommitted changes, a
RebaseCommand shall fail and roll-back changes.

Change-Id: Ic22eb047fb03ac2c8391f777036b7dbf22a1b061
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
13 years agoRegistering the Checkout command and fixed a typo. 04/2904/2
Sasa Zivkov [Thu, 24 Mar 2011 10:13:16 +0000 (11:13 +0100)]
Registering the Checkout command and fixed a typo.

The Checkout command line command was added to JGit but it wasn't
registered in the list of available commands.
Additionally, the 'force' option was named '---force' (triple '-').

Change-Id: I259773932fa9aec3bb29e215740e67c834566f6f
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
13 years agoMerge "Introduce CherryPickResult"
Mathias Kinzler [Thu, 24 Mar 2011 07:18:32 +0000 (03:18 -0400)]
Merge "Introduce CherryPickResult"

13 years agoAdd status command to GIT api 90/2890/2
Christian Halstrick [Tue, 22 Mar 2011 23:06:07 +0000 (00:06 +0100)]
Add status command to GIT api

Allow users of the GIT api to get to know the state of their
workingtree and index by adding a status command. The implementation
is mainly a wrapper around IndexDiff class. Better support for multiple
stages in the index (conflict situations) is still missing. An
appropriate change to IndexDiff and StatusCommand will come in a
subsequent commit.

Bug: 337296
Change-Id: Idb390375a68611853c1c903299ec678c89b081dc
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoCreate RemoteSession interface 83/2583/5
Roland Schulz [Sat, 5 Mar 2011 00:50:14 +0000 (19:50 -0500)]
Create RemoteSession interface

The RemoteSession interface operates like a simplified version of
java.lang.Runtime with a single exec method (and a disconnect
method). It returns a java.lang.Process, which should begin execution
immediately. Note that this greatly simplifies the interface for
running commands. There is no longer a connect method, and most
implementations will contain the bulk of their code inside
Process.exec, or a constructor called by Process.exec. (See the
revised implementations of JschSession and ExtSession.)
Implementations can now configure their connections properly without
either ignoring the proper use of the interface or trying to adhere
to an overly strict interface with odd rules about what methods are
called first.  For example, Jsch needs to create the output stream
before executing, which it now does in the process constructor. These
changes should make it much easier to add alternate session
implementations in the future.

Also-by: John D Eblen <jdeblen@comcast.net>
Bug: 336749
CQ: 5004
Change-Id: Iece43632086afadf175af6638255041ccaf2bfbb
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoIntroduce CherryPickResult 46/2646/4
Philipp Thun [Wed, 23 Mar 2011 09:24:14 +0000 (10:24 +0100)]
Introduce CherryPickResult

In order to distinguish cherry-pick failures caused by conflicts vs.
'abnormal failures' (e.g. due to unstaged changes or a dirty
worktree), a CherryPickResult class is introduced and returned by
CherryPickCommand.call() instead of a RevCommit. This new class is
similar to MergeResult and RebaseResult. The CherryPickResult contains
all necessary information, e.g. paths causing the cherry-pick (a merge
called within, respectively) to fail. This allows callers to better
react on failures.

Change-Id: I5db57b9259e82ed118e4bf4ec94463efe68b8c1f
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
13 years agoPullCommand: Use short ref name in merge message 86/2886/1
Robin Stocker [Tue, 22 Mar 2011 18:39:39 +0000 (19:39 +0100)]
PullCommand: Use short ref name in merge message

Add a test case for PullCommand for the successful merge case and test
that the short ref name is used.

Change-Id: I16cbbc88595f73e5512f984e67f93f87ee0fe242
Signed-off-by: Robin Stocker <robin@nibor.org>
13 years agoFix: possible IndexOutOfBoundsException in ReflogReader 83/2783/3
Marc Strapetz [Mon, 21 Mar 2011 07:33:40 +0000 (08:33 +0100)]
Fix: possible IndexOutOfBoundsException in ReflogReader

java.lang.IndexOutOfBoundsException
at java.nio.ByteBuffer.wrap(ByteBuffer.java:352)
at org.eclipse.jgit.util.RawParseUtils.decodeNoFallback(RawParseUtils.java:913)
at org.eclipse.jgit.util.RawParseUtils.decode(RawParseUtils.java:880)
at org.eclipse.jgit.util.RawParseUtils.decode(RawParseUtils.java:839)
at org.eclipse.jgit.storage.file.ReflogReader$Entry.<init>(ReflogReader.java:102)
at org.eclipse.jgit.storage.file.ReflogReader.getReverseEntries(ReflogReader.java:183)
at org.eclipse.jgit.storage.file.ReflogReader.getReverseEntries(ReflogReader.java:162)

Change-Id: I22a18bc7193962e5018c40a75337f9976b585c40

13 years agoImprove MergeResult 45/2645/3
Philipp Thun [Mon, 21 Mar 2011 11:33:58 +0000 (12:33 +0100)]
Improve MergeResult

Add paths causing abnormal merge failures (e.g. due to unstaged
changes) to the MergeResult returned by MergeCommand. This helps
callers to better handle (e.g. present) merge results.

Change-Id: Idb8cf04c5cecfb6a12cb880e16febfc3b9358564
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
13 years agoRefactor test cases 34/2734/2
Philipp Thun [Mon, 21 Mar 2011 08:40:14 +0000 (09:40 +0100)]
Refactor test cases

This change moves commonly used methods into the RepositoryTestCase
base class.

Change-Id: I56a46c31ee1661c7ce22eb755ab23da8bc9f5da2
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
13 years agoMerge "PackWriter: Collect stats by object type"
Chris Aniszczyk [Sat, 19 Mar 2011 16:33:19 +0000 (12:33 -0400)]
Merge "PackWriter: Collect stats by object type"

13 years agoMerge "BlockList: Micro-optimize appending from another BlockList"
Chris Aniszczyk [Sat, 19 Mar 2011 16:32:19 +0000 (12:32 -0400)]
Merge "BlockList: Micro-optimize appending from another BlockList"

13 years agoMerge "PackFile: Cache the packName string"
Chris Aniszczyk [Fri, 18 Mar 2011 21:28:05 +0000 (17:28 -0400)]
Merge "PackFile: Cache the packName string"

13 years agoPackWriter: Collect stats by object type 75/2775/2
Shawn O. Pearce [Fri, 18 Mar 2011 14:27:41 +0000 (07:27 -0700)]
PackWriter: Collect stats by object type

Frequently enough I'm wondering how much of a pack is commits vs.
trees, and the total line doesn't really tell us this because its
a gross total from the pack. Computing the counts per object type
is simple during packing, as PackWriter already has everything in
memory broken up by object type.  Its virtually free to get these
values and track them.

Change-Id: Id5e6b1902ea909c72f103a0fbca5d8bc316f9ab3
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoBlockList: Micro-optimize appending from another BlockList 74/2774/1
Shawn O. Pearce [Fri, 18 Mar 2011 16:07:25 +0000 (09:07 -0700)]
BlockList: Micro-optimize appending from another BlockList

Simple variant of addAll() that knows how to copy large segments
quickly using System.arraycopy() rather than looping through with
an Iterator object.

Change-Id: Icb50a8f87fe9180ea28b6920f473bb9e70c300f1
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPackFile: Cache the packName string 73/2773/1
Shawn O. Pearce [Fri, 18 Mar 2011 15:21:39 +0000 (08:21 -0700)]
PackFile: Cache the packName string

Instead of computing this on every request, compute it once and
hold onto the result. This improves performance for LocalCachedPack
which does a lot of tests against the pack name string.

Change-Id: I3803745e3a5dda7b5f0faf39aae9423e2c777e7f
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoAbort merge when file to be checked out is dirty 33/2733/3
Philipp Thun [Thu, 17 Mar 2011 09:48:44 +0000 (10:48 +0100)]
Abort merge when file to be checked out is dirty

In case a file needs to be checked out (from THEIRS) during a merge
operation, it has to be checked if the worktree version of this file
is dirty. If this is true, merge shall fail.

Change-Id: I17c24845584700aad953c3d4f2bea77a0d665ec4
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
13 years agoMerge "Refactor ResolveMerger"
Christian Halstrick [Fri, 18 Mar 2011 15:34:15 +0000 (11:34 -0400)]
Merge "Refactor ResolveMerger"

13 years agoRefactor ResolveMerger 54/2754/2
Philipp Thun [Fri, 18 Mar 2011 12:33:36 +0000 (13:33 +0100)]
Refactor ResolveMerger

1. Perform an explicit check for untracked files.
2. Extract 'dirty checks' into separate methods
3. Clean up comments.
4. Tests: also check contents of files not affected by merge.

Change-Id: Ieb089668834d0a395c9ab192c555538917dfdc47
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
13 years agoMerge "Moved tests for commit -o option to own test class"
Mathias Kinzler [Fri, 18 Mar 2011 06:58:19 +0000 (02:58 -0400)]
Merge "Moved tests for commit -o option to own test class"

13 years agoMoved tests for commit -o option to own test class 32/2732/4
Christian Halstrick [Fri, 18 Mar 2011 06:54:35 +0000 (07:54 +0100)]
Moved tests for commit -o option to own test class

We test the -o option of the commit command very accurate by
writing tests for each line of a decision table. In order to
still be able to point new jgit users to the CommitAndLogCommandTest
to find out how to use log() and commit() I factored out these 1200
lines of very specific tests into their own class.

Change-Id: Icf7c517f790a8fa79c8afd9b7f4a2805cf79196e
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
13 years agoAdd path filtering to LogCommand 67/2767/2
Chris Aniszczyk [Thu, 17 Mar 2011 19:30:55 +0000 (14:30 -0500)]
Add path filtering to LogCommand

Bug: 340049
Change-Id: I825b93b3412a3041aca225962fc8463a8f180650
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoAssume refs of alternates are reachable during fetch 17/2717/2
Shawn O. Pearce [Tue, 15 Mar 2011 01:52:00 +0000 (18:52 -0700)]
Assume refs of alternates are reachable during fetch

When fetching from a remote peer, consider all of the refs of any
alternate repository to be reachable locally, in addition to the refs
of the local repository.  This mirrors the push protocol and may avoid
unnecessary object transfer when the local repository is empty, but
its alternate and the remote share a lot of common history.

Junio C Hamano recently proposed a similar change to C Git's fetch
client, in order to work around a performance bug I identified when
fetching between two repositories that actually shared the same
alternate repository on the local system.

Change-Id: Iffb0b70e1223901ce2caac3b87ba7e0d6634d265
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoUploadPack: Report invalid want lines with ERR 51/2751/2
Shawn O. Pearce [Thu, 17 Mar 2011 04:50:42 +0000 (21:50 -0700)]
UploadPack: Report invalid want lines with ERR

Instead of aborting hard with a server-side exception, report an error
to the client with "ERR %s" in a context where the client is expecting
ACK/NAK.  Older clients will report this text to the user, but newer
ones know how to format this message in a more user-friendly way.

Change-Id: I1879b38988ba66f648c069c10dbfa14c3f34adb2
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoHandle "ERR %s" when ACK/NAK is expected 50/2750/2
Shawn O. Pearce [Thu, 17 Mar 2011 04:44:34 +0000 (21:44 -0700)]
Handle "ERR %s" when ACK/NAK is expected

If the remote peer replies with "ERR %s" instead of "ACK %s common" or
"NAK" during ancestor negotiation in the fetch-pack/upload-pack
protocol, treat that as an exception that aborts processing with the
error text as supplied by the remote system.

This matches behavior with "ERR %s" during the advertisements, which
is also a way for the remote to abort processing.

Change-Id: I2fe818e75c7f46156744ef4f703c40173cbc76d0
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPacketLineIn: Reuse internal lineBuffer for small strings 49/2749/2
Shawn O. Pearce [Thu, 17 Mar 2011 04:33:25 +0000 (21:33 -0700)]
PacketLineIn: Reuse internal lineBuffer for small strings

Most "ACK %s continue", "ACK %s common", "NAK" strings that are read
by the readACK() method and readString() are shorter than the
lineBuffer already available.  Reuse that buffer when reading from
the network stream and converting to a string with RawParseUtils to
avoid unnecessary temporary byte array allocations.

Change-Id: Ibc778d9f7721943a065041d80fc427ea50d90fff
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMerge "Expose if name or email is based on a guess"
Shawn Pearce [Thu, 17 Mar 2011 17:45:52 +0000 (13:45 -0400)]
Merge "Expose if name or email is based on a guess"

13 years agoCommitCommand: add option to insert a change id 60/2760/2
Jens Baumgart [Thu, 17 Mar 2011 17:15:41 +0000 (18:15 +0100)]
CommitCommand: add option to insert a change id

An option to insert a change id into the commit message was added
to CommitCommand.
This change is a prerequisite for removing GitIndex from EGit.

Change-Id: Iff9e26a8aaf21d8224bfd6ce3c98821c077bcd82
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
13 years agoMerge "Remove deprecated Repository.mapTree"
Mathias Kinzler [Thu, 17 Mar 2011 11:07:15 +0000 (07:07 -0400)]
Merge "Remove deprecated Repository.mapTree"

13 years agoExpose if name or email is based on a guess 28/2728/2
Matthias Sohn [Wed, 16 Mar 2011 15:23:14 +0000 (16:23 +0100)]
Expose if name or email is based on a guess

This enables applications to differentiate between explicitly set
configuration parameters and best effort attempts to guess these
parameters from the operating system.

Change-Id: I67cc4099238a40c6dca795e64f0155ced6008ef1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoUse parent directory in InitCommand if directory is "." 30/2730/1
Philipp Thun [Wed, 16 Mar 2011 00:36:56 +0000 (01:36 +0100)]
Use parent directory in InitCommand if directory is "."

If no directory is set before executing an InitCommand, the current
directory (".") is used by default. By calling File.getParentFile() we
get the actual directory this points to. Using this directory makes it
easier to read paths.

Change-Id: I6245941395dae920e4f90b8985be6ef3cce570d3
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
13 years agoMerge "Improve native Git transport when following repository"
Chris Aniszczyk [Tue, 15 Mar 2011 16:03:38 +0000 (12:03 -0400)]
Merge "Improve native Git transport when following repository"

13 years agoTransportProtocol: Allow null Repository in canHandle() 13/2713/2
Shawn O. Pearce [Mon, 14 Mar 2011 17:48:58 +0000 (10:48 -0700)]
TransportProtocol: Allow null Repository in canHandle()

This allows callers to determine if a URI is supported, before
worrying about the local repository.

Suggested-by: Dariusz Luksza <dariusz@luksza.org>
Change-Id: Ifc76a4ba841f2e2e7354bd51306b87b3b9d7f6ab
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoMerge "FS: Allow cloning an FS instance"
Chris Aniszczyk [Tue, 15 Mar 2011 15:09:16 +0000 (11:09 -0400)]
Merge "FS: Allow cloning an FS instance"

13 years agoMerge "FS: Allow userHome to be set and cached"
Chris Aniszczyk [Tue, 15 Mar 2011 15:05:37 +0000 (11:05 -0400)]
Merge "FS: Allow userHome to be set and cached"

13 years agoMerge "FS: Allow gitPrefix to be set and cached"
Chris Aniszczyk [Tue, 15 Mar 2011 15:00:08 +0000 (11:00 -0400)]
Merge "FS: Allow gitPrefix to be set and cached"

13 years agoMerge "FS: Overload detect() with no arguments"
Chris Aniszczyk [Tue, 15 Mar 2011 14:57:58 +0000 (10:57 -0400)]
Merge "FS: Overload detect() with no arguments"

13 years agoPushCommand: Allow adding any reference string 05/2705/2
Shawn O. Pearce [Mon, 14 Mar 2011 15:14:46 +0000 (08:14 -0700)]
PushCommand: Allow adding any reference string

The simplified form of add(String) makes it easier for applications
to pass down user input and allow PushCommand to convert it to the
internal RefSpec object.

Change-Id: Ibd2e95852db0e52ea4a36032942c4c42a7fb4261
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPushCommand: Add utilities for --all, --tags 04/2704/2
Shawn O. Pearce [Mon, 14 Mar 2011 15:08:39 +0000 (08:08 -0700)]
PushCommand: Add utilities for --all, --tags

The --all flag on the command line implies using refs/heads/* as
a push specification. Add this to the standard command object.

The --tags flag on the command line implies using refs/tags/* as
a push specification. Add this to the standard command object.

Change-Id: Iaef200b17cce77604548dbfb15cf2499b10687b5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMerge "PushCommand: Default to pushing HEAD"
Chris Aniszczyk [Tue, 15 Mar 2011 14:01:04 +0000 (10:01 -0400)]
Merge "PushCommand: Default to pushing HEAD"

13 years agoMerge "PushCommand: Set force-update in-place"
Chris Aniszczyk [Tue, 15 Mar 2011 14:00:33 +0000 (10:00 -0400)]
Merge "PushCommand: Set force-update in-place"

13 years agoMerge "Make --git-dir optional for 'jgit init'"
Chris Aniszczyk [Tue, 15 Mar 2011 13:59:24 +0000 (09:59 -0400)]
Merge "Make --git-dir optional for 'jgit init'"

13 years agoMerge "CloneCommand: add a test to ensure we fetch all tags"
Chris Aniszczyk [Tue, 15 Mar 2011 13:57:32 +0000 (09:57 -0400)]
Merge "CloneCommand: add a test to ensure we fetch all tags"

13 years agoMake --git-dir optional for 'jgit init' 20/2720/1
Philipp Thun [Fri, 11 Mar 2011 14:49:27 +0000 (15:49 +0100)]
Make --git-dir optional for 'jgit init'

For compatibility reasons with regards to native git and also to
make the init command easier to use from the command line,
argument --git-dir should not be required.

Additionally the path created in case --git-dir is not supplied now is
canonical and thus easier to read.

Change-Id: Idb7d77e983a78c4b21fbf232fc1e75ef581e5ed1
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
13 years agoReplace 'occured' by 'occurred' 19/2719/1
Philipp Thun [Tue, 15 Mar 2011 12:55:58 +0000 (13:55 +0100)]
Replace 'occured' by 'occurred'

This change fixes a common typo.

Signed-off-by: Philipp Thun <philipp.thun@sap.com>
13 years agoImprove native Git transport when following repository 15/2715/1
Shawn O. Pearce [Mon, 14 Mar 2011 22:36:17 +0000 (15:36 -0700)]
Improve native Git transport when following repository

If the client is only following the remote repository and has not
created any new non-common commits, the client will wind up sending
a "have %s" line for each tag in the repository.  For some projects
like git.git, this is 339 tags and growing, resulting in more than
16 KiB needing to be POSTed over 12 HTTP requests.

Teach UploadPack (server side) to always execute the okToGiveUp()
logic at least once per negotiation round to determine if the server
can compute a pack right now.  If it can, shove in an "ACK %s ready"
message to tell the client this and try to prevent receiving ancient
tags in future negotiation rounds.

Teach BasePackFetchConnection (client side) to honor a "ACK %s ready"
from the remote and break out of its SEND_HAVE loop once the remote
knows it can create a pack.  This avoids sending the remaining 307
tags of git.git.

These two changes together reduce the number of HTTP RPCs from 13
down to 3 in order to fetch from git.git over smart HTTP.  If either
side is missing the change, the older behavior (and its 13 RPCs)
is used.

Change-Id: I64736318fd0abf9ee5e56bd0b737707adb580b37
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMerge "PackWriter: Rename getObjectsNumber to getObjectCount"
Chris Aniszczyk [Mon, 14 Mar 2011 22:09:40 +0000 (18:09 -0400)]
Merge "PackWriter: Rename getObjectsNumber to getObjectCount"

13 years agoCloneCommand: add a test to ensure we fetch all tags 14/2714/1
Chris Aniszczyk [Mon, 14 Mar 2011 22:01:06 +0000 (17:01 -0500)]
CloneCommand: add a test to ensure we fetch all tags

Bug: 326611
Change-Id: Ibf9a7caa84d99f39fca88bebc10c03b01955146d
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoMerge "Always fetch tags during clone"
Chris Aniszczyk [Mon, 14 Mar 2011 21:33:36 +0000 (17:33 -0400)]
Merge "Always fetch tags during clone"

13 years agoCommitCommand: set correct Reflog message when amending 78/2678/2
Jens Baumgart [Wed, 9 Mar 2011 17:26:46 +0000 (18:26 +0100)]
CommitCommand: set correct Reflog message when amending

Change-Id: I2322d31b09ca63bdcee50e90340e326467dc5021
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoFS: Allow cloning an FS instance 12/2712/1
Shawn O. Pearce [Mon, 14 Mar 2011 16:19:39 +0000 (09:19 -0700)]
FS: Allow cloning an FS instance

This permits an application to create its own copy of FS.DETECTED
before manually setting the userHome or gitPrefix.

Bug: 337101
Change-Id: Ieea33c8d0ebdc801a4656b829d2a4b398559fd45
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoFS: Allow userHome to be set and cached 11/2711/1
Shawn O. Pearce [Mon, 14 Mar 2011 16:17:39 +0000 (09:17 -0700)]
FS: Allow userHome to be set and cached

This permits callers to modify the meaning of userHome, which
may be useful if their application allows the user to select
different user settings locations.

Bug: 337101
Change-Id: I076815edeec1c20dea028f7840be3930337dff77
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
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 agoAlways fetch tags during clone 08/2708/1
Shawn O. Pearce [Mon, 14 Mar 2011 15:53:41 +0000 (08:53 -0700)]
Always fetch tags during clone

C Git always fetches tags during clone, even if the tag doesn't
point to an object that was fetched by the branch specifications.
Match that behavior, as users expect it.

Bug: 326611
Change-Id: I81a82b7359a9649f18a172219da44ed54e77ca2f
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPushCommand: Default to pushing HEAD 01/2701/2
Shawn O. Pearce [Mon, 14 Mar 2011 14:20:02 +0000 (07:20 -0700)]
PushCommand: Default to pushing HEAD

If no RefSpec was specified, push the branch that is currently
checked out as HEAD.

Change-Id: I6f13ef6346188698a14e000fc590850afbc34b21
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPushCommand: Set force-update in-place 00/2700/2
Shawn O. Pearce [Mon, 14 Mar 2011 14:14:44 +0000 (07:14 -0700)]
PushCommand: Set force-update in-place

Rather than copying the entire list, just replace each element
with the version that has setForceUpdate(true) invoked on it.

Change-Id: I2eaa4466d497cb2408ce61dc62ca26e0c32fe841
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoPackWriter: Rename getObjectsNumber to getObjectCount 99/2699/2
Shawn O. Pearce [Mon, 14 Mar 2011 14:09:41 +0000 (07:09 -0700)]
PackWriter: Rename getObjectsNumber to getObjectCount

This better matches with PackFile and CachedPack's methods
that return the same value.

Change-Id: Idb9b7c71d2048dd2344a62c2cde20b4e34529ab7
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoFix dumb transport push 98/2698/2
Shawn O. Pearce [Mon, 14 Mar 2011 14:06:35 +0000 (07:06 -0700)]
Fix dumb transport push

PackWriter incorrectly returned 0 from getObjectsNumber() when the
pack has not been written yet. This caused dumb transports like
amazon-s3:// and sftp:// to abort early and never write out a pack,
under the assumption that the pack had no objects.

Until the pack header is written to the output stream, compute the
current object count each time it is requested. Once the header is
started, use the object count from the stats object.

Change-Id: I041a2368ae0cfe6f649ec28658d41a6355933900
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>