Commit Graph

1711 Commits

Author SHA1 Message Date
Shawn O. Pearce 68cc21b60d PackWriter: Skip progress messages on fast operations
If the "Finding sources" phase will complete in <1 second with no
delta compression enabled, don't bother showing the progress meter for
this phase.  Small repositories on the local filesystem tend to rip
through this phase always subsecond and the ProgressMonitor display
can actually slow the operation down.

If delta compression is enabled, there are two phases that may run
very quickly. Set the timer to 500 milliseconds instead, reducing the
risk that the user has to wait longer than 1 second before any sort of
output from the packer occurs.

Change-Id: I58110f17e2a5ffa0134f9768b94804d16bbb8399
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-07-28 10:22:50 -07:00
Shawn O. Pearce c81f6ab3ab IndexPack: Defer the "Resolving deltas" progress meter
If delta resolution completes in < 1000 milliseconds, don't bother
showing the progress meter. This is actually very common for a Gerrit
Code Review server, where the client is probably sending 1 commit and
only a few trees/blobs modified... and the base objects are hot in the
process buffer cache.

The 1000 millisecond delay is just a guess at a reasonable time to wait.

Change-Id: I440baa64ab0dfa21be61deae8dcd3ca061bed8ce
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-07-28 10:22:50 -07:00
Shawn O. Pearce e0111b18c8 IndexPack: Fix "Resolving deltas" progress meter
This progress meter never reached 100% as it did not update while
resolving the external bases in thin packs.

Instead of updating in batches at the top level, update once per delta
that is resolved. The batching progress meter type should smooth out
the frequent updates to an update rate that is more reasonable to send
to the UI, while also ensuring a successful pack parse always reaches
100% deltas resolved.

Change-Id: Ic77dcac542cfa97213a6b0194708f9d3c256d223
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-07-28 10:22:50 -07:00
Shawn O. Pearce d16085b3b9 Make PackReverseIndex a public structure
Repository inspection tools may find building a reverse index on a
pack useful, as they can then locate an object by offset. As both
C Git and JGit sometimes produce error messages with the offset
rather than the SHA-1, it may be useful to expose this type.

Change-Id: I487bf32e85a8985cf8ab382d4c82fcbe1fc7da6c
2011-07-28 10:07:10 -07:00
Shawn O. Pearce d60cb2a3f5 Make lookup methods on PackIndex public
There isn't a good reason to hide all of these as package-private.
Make them public so applications can inspect pack files.

Change-Id: Ia418daf65d63e9e015b8dafdf3d06a1ed91d190b
2011-07-28 10:07:10 -07:00
Shawn O. Pearce 38c5b26245 PackIndex: Support reading from any InputStream
Change-Id: If065a9e33a8f3a03e9758eb7612af2fc460c87e5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-07-28 10:07:09 -07:00
Shawn O. Pearce d1f130f7f9 Add String form of PackInvalidException constructor
This way the path can be supplied as a string, without first
converting to a java.io.File.

Change-Id: I54d9bb9867556cd98b378c0762054b31497459cb
2011-07-28 10:07:09 -07:00
Shawn O. Pearce 14680f6e6e Add copy constructor to PackConfig
Some embeddings of UploadPack (e.g. Gerrit Code Review) set their own
PackConfig from a server-wide configuration, overriding any JGit
defaults or settings that may exist at the local repository level.

Make a copy constructor form of PackConfig so this server-wide
configuration object can be copied and then merged with repository
specific configuration data.

Change-Id: I4463c95aeaf7d6536c3ab132dec9c50ee528d9e0
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-07-27 10:00:41 -07:00
Shawn O. Pearce bfa62d88d4 Don't close ObjectDatabase after parsing pack
The cached object databases should not require a close to release
their cached resources. Most object databases just return their
own reference for newCachedDatabase(), so a close() here kills
the real database's internal caches, and possibly underlying files,
resulting in poor performance for the callers of PackParser like
ReceivePack or FetchProcess trying to then go look up objects that
were just parsed, or that current references point to.

Change-Id: Ia4a239093866e5b9faf82744f729fb73f4373f1a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-07-27 10:00:41 -07:00
Robin Rosenberg c536873c87 Fix reading of ref names containing characters that sort before /
A set of ref names like ('a/b' and 'a+b') would cause the RefDirectory
to think that the set of refs have changed because it traversed the
'a' directory in the subtree before looking at 'a+b', but it then
compared with the know refs which are sorted with 'a+b' first.

Fix this by traversing the refs tree in another order. Treat a directory
as if they ends with a '/' before deciding on the order to traverse
the refs tree.

Bug: 348834
Change-Id: I23377f8df00c7252bf27dbcfba5da193c5403917
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-07-22 11:51:41 +02:00
Jens Baumgart dcf9ba411b Ignore missing MERGE_MSG when deleting MERGE_MSG
Repository.writeMergeCommitMsg(null) no longer fails if the MERGE_MSG
file is missing. This was done to avoid CommitCommand to fail in case of
a missing MERGE_MSG file.

Bug: 352243
Change-Id: Iddf43533d133f8f22199ed6e2393a552670e7d1f
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
2011-07-19 17:31:50 +02:00
Tomasz Zarna e15037b3c7 Merge doesn't remove empty folders
Bug: 349848
Change-Id: I2aa5a1a7259889428e4845046b900538262f3c84
2011-07-13 15:42:33 +02:00
Dariusz Luksza 1d1f572771 Add support for reseting on directories
Reset command should works recursively and allows reset all changed
files in given directory.

Bug: 348524
Change-Id: I441db34f226be36548c61cef77958995971498de
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-07-12 11:14:28 -05:00
Sasa Zivkov 1d4a1fe772 Fixed creation of branch from a tag
Creation of a branch X from an annotated tag, as the starting point,
resulted into .git/refs/heads/X containing the ID of the annotated tag
instead of the ID of the tagged commit.

This fix peels the tag ref before using it as the starting point for
the newly created branch.

Bug: 340836
Change-Id: I01c7325770ecb37f5bf8ddb2a22f802466524f24
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-07-12 10:48:59 -05:00
Chris Aniszczyk f0060f64a7 Merge "Merge in JGit CLI is missing break statement" 2011-07-12 09:53:51 -04:00
Tomasz Zarna 1efecaa9f9 Merge in JGit CLI is missing break statement
Change-Id: I2095601b848e66e54d5dac828ef6ed1a4c5ae66c
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-07-12 08:48:53 -05:00
Adrian Goerler ad74bbf9c1 Cleanup directories leftover by test.
Use the temporary file management from superclass.

Change-Id: I3042951dc21860b4b85dd72a6bf41ee7cfe2aba4
Signed-off-by: Adrian Goerler <adrian.goerler@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-07-07 23:16:40 +02:00
Adrian Goerler 172a9f0521 Cloning should fail when destination directory exists and is not empty
When trying to clone into a folder that already contains a cloned
repository native git will fail with a message "fatal: destination path
'folder' already exists and is not an empty directory.". Now JGit will
also fail in this situation throwing a JGitInternalException.

The test case was provided by Tomasz Zarna.

Bug: 347852
Change-Id: If9e9919a5f92d13cf038dc470c21ee5967322dac
Also-by: Tomasz Zarna <Tomasz.Zarna@pl.ibm.com>
Signed-off-by: Adrian Goerler <adrian.goerler@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-07-06 23:10:53 +02:00
Stefan Lay 7e1b2466e3 Do not catch Exception in test cases
Exception handling is already done by JUnit.

Change-Id: Ia25d768c311d384d728f281aced92f598e5e2041
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2011-07-06 23:10:52 +02:00
Christian Halstrick 9ea9537d7c Merge "Cleanup curly braces" 2011-07-06 04:44:54 -04:00
Adrian Goerler 2062d623e3 Cleanup curly braces
Change-Id: I2de6439a3ad951a99d89e4aee02006c745d16510
Signed-off-by: Adrian Goerler <adrian.goerler@sap.com>
2011-07-06 10:29:56 +02:00
Christian Halstrick 18e10b41c9 Merge "Add lookup to remote config if the refSpec is not explicitly set" 2011-07-06 04:14:49 -04:00
Stefan Lay e2815f0121 Add lookup to remote config if the refSpec is not explicitly set
If no refSpec is explicitly set, the PushCommand should first check the
remote config and then as a fallback use the current behavior.


Change-Id: I2bc648abc517b1d01b2de15d383423ace2081e72
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2011-07-04 13:20:51 +02:00
Shawn Pearce ac56c024c1 Merge "Enable PlotWalk to show additional refs" 2011-07-01 11:58:24 -04:00
Stefan Lay 872c1fec17 Enable PlotWalk to show additional refs
Change-Id: Ic85f8859571dc2aef7f146ce56a6c9b8ec142e60
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2011-07-01 17:38:01 +02:00
Shawn O. Pearce 622d922ddc Merge "Improve performance when writing trees and small blobs" 2011-07-01 11:04:41 -04:00
Shawn O. Pearce 532f9eba3b Merge "TemporaryBuffer: Fix reading from in-memory InputStream" 2011-07-01 10:55:16 -04:00
Shawn Pearce 186b71f7e6 Merge "Implement Serializable interface in PersonIdent class." 2011-07-01 10:55:02 -04:00
Matthias Sohn 5223cb6e5a Merge "Fix compilation with Java 1.5" 2011-07-01 07:20:48 -04:00
Kevin Sawicki a5b5d5a9b2 Implement Serializable interface in PersonIdent class.
Change-Id: I3229f4ec85e7604cb45642813757975b30f1227e
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-06-30 09:38:43 -07:00
Jens Baumgart eb46d7ffdc DirCacheCheckout: unlock DirCache in case of failure
DirCacheCheckout did not unlock the index if e.g. an IOException occured
during checkout.

Bug: 350677
Change-Id: Ie9fa09f7a404080da7cdccafb9be3a8c845e4869
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
2011-06-29 14:18:00 +02:00
Carsten Pfeiffer 46110935b5 Fix compilation with Java 1.5
Change-Id: I785f59fcf2018cd923d4d1617b923049dbde9809
2011-06-29 09:45:31 +02:00
Shawn Pearce 553920088d Merge "RFC: Ugly fix for i18n of metaVar CLI arguments" 2011-06-24 18:47:32 -04:00
Shawn O. Pearce 1eecc82cec Improve performance when writing trees and small blobs
ObjectDirectoryInserter was always creating a temporary file,
writing the complete compressed contents of a tree, fsync()'ing
that to stable storage, and only then checking to see if there
was already an object with the same SHA-1 in the repository.

For commits this strategy makes some sense, the commit is very
unlikely to exist in the repository, as there are embedded times
and these change with each commit.

However for trees coming out of DirCache, it is more common for the
tree to already exist in the repository. Most subdirectories are
not modified in any given commit.  Doing all of this local file IO
for things that already exist is very slow.

Try to detect cases where the object is "small enough" that it can
be processed entirely in memory, and avoid doing disk IO entirely
if the object already exists.

Also increase the size of the output buffer for the deflation.
This should boost the average write(2) syscall size from 512 bytes
to 8192 bytes, making streaming of large compressed contents to
disk slightly more efficient.

Change-Id: I1d40364e8725468522435814631916d73174c92b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-06-24 12:55:19 -07:00
Shawn O. Pearce 826fb260a3 TemporaryBuffer: Fix reading from in-memory InputStream
I had the conditions wrong here, causing the in-memory InputStream
to always appear to be at EOF.

Change-Id: I6811d6187a34eaf1fd6c5002550d631decdfc391
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-06-24 12:37:58 -07:00
Chris Aniszczyk 2cebb7dbc7 Add ReflogCommand
Adds a git-reflog command and associated tests.

Bug: 347859
Change-Id: Iba146ac842cc9ca0be43d3381b4082c9e92bf56f
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-06-22 18:32:50 -05:00
Chris Aniszczyk 65606dc086 Refactor out ReflogEntry
It's useful to have ReflogEntry refactored out so it can be
used by clients via the JGit API.

Change-Id: I03044df9af9f9547777545b7c9b93bdf5f8b7cb5
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-06-20 10:25:50 -05:00
Robin Rosenberg 529a348961 RFC: Ugly fix for i18n of metaVar CLI arguments
This patch possibly ties to a specific version of args4j.

Bug: 318286
Change-Id: I05d4ecf6bd25deec7fb2efbfa61913f4ec4e04e5
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-06-20 00:55:13 +02:00
Robin Rosenberg b19924f150 Merge changes Ie393fb8b,Ib11a077a
* changes:
  Push errors back over sideband when possible
  Report progress while updating references
2011-06-17 11:26:38 -04:00
Marc Strapetz 929862f322 Fix IndexOutOfBoundsException when parsing PersonIdent
IndexOutOfBoundsException could occur when parsing
PersonIdent for which no name is present, as part of a
RevCommit (nameB > 0).
2011-06-14 16:56:48 +02:00
Shawn O. Pearce d34ec12019 DHT: Change DhtReadher caches to be dynamic by workload
Instead of fixing the prefetch queue and recent chunk queue as
different sizes, allow these to share the same limit but be scaled
based on the work being performed.

During walks about 20% of the space will be given to the prefetcher,
and the other 80% will be used by the recent chunks cache. This
should improve cases where there is bad locality between chunks.

During writing of a pack stream, 90-100% of the space should be
made available to the prefetcher, as the prefetch plan is usually
very accurate about the order chunks will be needed in.

Change-Id: I1ca7acb4518e66eb9d4138fb753df38e7254704d
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-06-09 19:10:15 -07:00
Shawn O. Pearce 1e6b02643c DHT: Use a proper HashMap for RecentChunk lookups
A linear search is somewhat acceptable for only 4 recent chunks, but
a HashMap based lookup would be better. The table will have 16 slots
by default and given the hashCode() of ChunkKey is derived from the
SHA-1 of the chunk, each chunk will fall into its own bucket within
the table and thus evaluate only 1 entry during lookup instead of 4.

Some users may also want to devote more memory to the recent chunks,
in which case expanding this list to a longer length will help to
reduce chunk faults, but would increase search time. Using a HashMap
will help this code to scale to larger sizes better.

Change-Id: Ia41b7a1cc69ad27b85749e3b74cbf8d0aa338044
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-06-09 17:59:22 -07:00
Shawn O. Pearce 57853e4949 DHT: Always have at least one recent chunk in DhtReader
The RecentChunks cache assumes there is always at least one recent
chunk in the maxSize that it receives from the DhtReaderOptions.
Ensure that is true by requiring the size to be at least 1.

Running with 0 recent chunk cache is very a bad idea, often
during commit walking the parents of a commit will be found
on the same chunk as the commit that was just accessed. In
these cases its a good idea to keep that last chunk around
so the parents can be quickly accessed.

Change-Id: I33b65286e8a4cbf6ef4ced28c547837f173e065d
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-06-09 17:55:52 -07:00
Shawn O. Pearce 7ff6eb584c Push errors back over sideband when possible
If an internal exception occurs while packing and the request
needs to abort, the HTTP response might already be committed due
to progress message having already been delivered to the client.
This prevents UploadPackServlet from resetting the response and
sending back an HTTP 500 response.

Try to catch all exceptions and report internal errors over the
sideband stream or as an ERR command during the initial ACK/NAK
negotiation phase. This allows JGit to transmit an error message
that the user will receive on their console without needing to
worry about resetting the (already gone) HTTP response.

Change-Id: Ie393fb8bb55d2b79ab1276adf71c781c1807f9fe
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-06-09 17:29:46 -07:00
Shawn O. Pearce d00f527d65 DHT: Fix NPE during prefetch
The Prefetcher may have loaded a chunk that is a fragment, if the
DhtReader is scanning the Prefetcher's chunks for a particular
object fragment chunks will be missing the index and NPE during
the findOffset() call into the index itself.

Change-Id: Ie2823724c289f745655076c5209acec32361a1ea
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-06-09 17:29:46 -07:00
Shawn O. Pearce 1a87a725be Report progress while updating references
If a fetch or push needs to apply more than a few references
to the local repository it may take more than 0.25 seconds to
process all of the updates.  This is especially true in the DHT
storage system during an initial push of a project with many tags.
The backend database may need to use a transaction to ensure each
tag reference creation is unique, and there may be large delays
caused by these transactions.

Change-Id: Ib11a077adfbd525253e425d327f2e2c2380804c7
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-06-09 17:29:46 -07:00
Shawn O. Pearce 0e1d5ad8f8 DHT: Drop leading hash digits from row keys
Originally I put the first two digits of the object SHA-1 into the
start of a row key to try and spread the load of objects around a DHT
service. Unfortunately this tends to not work as well as I had hoped.

Servers reading a repository need to contact every node in a DHT
cluster if the cluster tries to evenly distribute the object rows.
This is a lot of connections, especially if the cluster has many
backend storage servers.  If the library has an open connection
limit (possibly due to JVM file descriptor limitations) it may need
to open and close a lot of connections to access a repository,
rather than being able to reuse the same connection to a handful
of backend servers.  This results in a lot of connection thrashing
for some DHT type databases, and is inefficient.

Some DHTs are able to operate even if part of the database space
is currently unavailable.  For example, a DHT service might assign
some section of the key space to a node, and then fail that section
over to another node when the primary is noticed as being offline.
During that failover period that section of the key space is not
available, but other sections hosted by other backends are still
ready for service. Spreading keys all over the cluster makes it
likely that any single backend being temporarily down means the
entire cluster is down, rather than only some.

This is a massive schema change, but it should improve relability
and performance for any DHT system.

Change-Id: I6b65bfb4c14b6f7bd323c2bd0638b49d429245be
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-06-09 17:29:46 -07:00
Matthias Sohn 0ab7be9681 Merge branch 'stable-1.0'
* stable-1.0:
  Prepare post JGit v1.0.0.201106090707-r builds
  JGit v1.0.0.201106090707-r
  Include about.html files in maven build
  Prepare post v1.0.0.201106081625-r builds
  JGit v1.0.0.201106081625-r
  Add missing about.html files to all shipped bundles
  Prepare post v1.0.0.201106071701-r builds
  JGit v1.0.0.201106071701-r
2011-06-09 17:41:16 +02:00
Matthias Sohn 6646c72d17 Prepare post JGit v1.0.0.201106090707-r builds
Change-Id: I35292f9f6fb5ebc591308fdd2d069203413e189d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-06-09 14:11:23 +02:00
Matthias Sohn b26ff6ebd6 JGit v1.0.0.201106090707-r
Change-Id: Iba44e71b6441a0e39122ca8666b51989e605f25f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-06-09 13:11:58 +02:00