Commit Graph

1293 Commits

Author SHA1 Message Date
Shawn O. Pearce 37a10e3006 PackWriter: Don't include edges in progress meter
When compressing objects, don't include the edges in the progress
meter.  These cost almost no CPU time as they are simply pushed into
and popped out of the delta search window.

Change-Id: I7ea19f0263e463c65da34a7e92718c6db1d4a131
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-02-01 08:55:43 -06:00
Chris Aniszczyk cc5295c4b4 Merge "Show resolving deltas progress to push clients" 2011-02-01 09:40:57 -05:00
Chris Aniszczyk c1de63262e Merge "ObjectWalk: Fix reset for non-commit objects" 2011-02-01 09:38:30 -05:00
Chris Aniszczyk 4112884ede Add git-clone to the Git API
Enhance the Git API to support cloning repositories.

Bug: 334763
Change-Id: Ibe1191498dceb9cbd1325aed85b4c403db19f41e
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-01-31 16:56:56 -06:00
Shawn O. Pearce 168114fd39 Show resolving deltas progress to push clients
CGit push clients 1.6.6 and later support progress messages on the
side-band-64k channel during push, as this was introduced to handle
server side hook errors reported over smart HTTP.

Since JGit's delta resolution isn't always as fast as CGit's is,
a user may think the server has crashed and failed to report
status if the user pushed a lot of content and sees no feedback.
Exposing the progress monitor during the resolving deltas phase
will let the user know the server is still making forward progress.

This also helps BasePackPushConnection, which has a bounded timeout
on how long it will wait before assuming the remote server is dead.
Progress messages pushed down the side-band channel will reset the
read timer, helping the connection to stay alive and avoid timing
out before the remote side's work is complete.

Change-Id: I429c825e5a724d2f21c66f95526d9c49edcc6ca9
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-01-31 12:31:52 -08:00
Shawn O. Pearce c2ab3421a2 ObjectWalk: Fix reset for non-commit objects
Non-commits are added to a pending queue, but duplicates are
removed by checking a flag.  During a reset that flag must be
stripped off the old roots, otherwise the caller cannot reuse
the old roots after the reset.

RevWalk already does this correctly for commits, but ObjectWalk
failed to handle the non-commit case itself.

Change-Id: I99e1832bf204eac5a424fdb04f327792e8cded4a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-01-31 12:31:52 -08:00
Chris Aniszczyk cefd59f98b Merge "Revert Ie48d6556" 2011-01-31 12:27:02 -05:00
Chris Aniszczyk fbd61646b3 Merge "Proper handling of rebase during pull" 2011-01-31 11:02:57 -05:00
Chris Aniszczyk 1ef0343a0c Revert Ie48d6556
This was a mistake that was missed due to historical reasons.

"The first /r/ tells our Apache to redirect the request to Gerrit.
The second /r/ tells Gerrit that the thing following is a Git SHA-1
and it should try to locate the changes that use that commit object.
Nothing I can easily do about it now. The second /r/ is historical
and comes from Gerrit 1.x days."

Change-Id: Iec2dbf5e077f29c0e0686cab11ef197ffc705012
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-01-31 09:59:42 -06:00
Robert Munteanu f009b872d1 Fix incorrect review url in IP log file
Change-Id: Ie48d655698dc1f4cd4f00606436a57c451c13179
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-01-31 09:40:30 -06:00
Mathias Kinzler b15b9d5df2 Proper handling of rebase during pull
After consulting with Christian Halstrick, it turned out that the
handling of rebase during pull was implemented incorrectly.

Change-Id: I40f03409e080cdfeceb21460150f5e02a016e7f4
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2011-01-31 12:12:48 +01:00
Robin Rosenberg 9ffcf2a8b3 Merge changes I3a74cc84,I219f864f
* changes:
  [findbugs] Do not ignore exceptional return value of createNewFile()
  Do not create files to be updated before checkout of DirCache entry
2011-01-29 17:52:12 -05:00
Tomasz Zarna 9fbda22392 Add setCredentialsProvider to PullCommand
Bug: 335703
Change-Id: Id9713a4849c772e030fca23dd64b993264f28366
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-01-28 14:06:47 -06:00
Chris Aniszczyk a880233d7f Merge "ObjectIdSubclassMap: Support duplicate additions" 2011-01-28 12:45:39 -05:00
Shawn O. Pearce 17dc6bdafd ObjectIdSubclassMap: Support duplicate additions
The new addIfAbsent() method combines get() with add(), but does
it in a single step so that the common case of get() returning null
for a new object can immediately insert the object into the map.

Change-Id: Ib599ab4de13ad67665ccfccf3ece52ba3222bcba
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-01-28 08:17:20 -08:00
Chris Aniszczyk bf69401fee Merge "Make PullCommand work with Rebase" 2011-01-28 10:52:38 -05:00
Chris Aniszczyk 0b2ac1e929 Merge "RebaseCommand: detect and handle fast-forward properly" 2011-01-28 10:38:27 -05:00
Shawn O. Pearce 065a0a8122 Revert "Teach PackWriter how to reuse an existing object list"
This reverts commit f5fe2dca3c.

I regret adding this feature to the public API.  Caches aren't always
the best idea, as they require work to maintain.  Here the cache is
redundant information that must be computed, and when it grows stale
must be removed.  The redundant information takes up more disk space,
about the same size as the pack-*.idx files are.  For the linux-2.6
repository, that's more than 40 MB for a 400 MB repository.  So the
cache is a 10% increase in disk usage.

The entire point of this cache is to improve PackWriter performance,
and only PackWriter performance, and only when sending an initial
clone to a new client.  There may be better ways to optimize this, and
until we have a solid solution, we shouldn't be using a separate cache
in JGit.
2011-01-28 07:20:26 -08:00
Mathias Kinzler 14ca80bc90 Make PullCommand work with Rebase
Rebase must honor the upstream configuration

branch.<branchname>.rebase

Change-Id: Ic94f263d3f47b630ad75bd5412cb4741bb1109ca
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2011-01-28 15:04:52 +01:00
Mathias Kinzler e8a1328d05 RebaseCommand: detect and handle fast-forward properly
This bug was hidden by an incomplete test: the current Rebase
implementation using the "git rebase -i" pattern does not work
correctly if fast-forwarding is involved. The reason for this is that
the log command does not return any commits in this case.
In addition, a check for already merged commits was introduced to
avoid spurious conflicts.

Change-Id: Ib9898fe0f982fa08e41f1dca9452c43de715fdb6
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2011-01-28 15:03:02 +01:00
Mathias Kinzler c544e96a4c TransportHttp wrongly uses JDK 6 constructor of IOException
IOException constructor taking Exception as parameter is
new for JDK 6.

Change-Id: Iec349fc7be9e9fbaeb53841894883c47a98a7b29
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2011-01-28 09:24:20 +01:00
Matthias Sohn a6e3f53069 [findbugs] Do not ignore exceptional return value of createNewFile()
Properly handle return value of java.io.File.createNewFile().

Change-Id: I3a74cc84cd126ca1a0eaccc77b2944d783ff0747
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-01-28 01:11:12 +01:00
Matthias Sohn 38eec8f4a2 [findbugs] Do not ignore exceptional return value of mkdir
java.io.File.mkdir() and mkdirs() report failure as an exceptional
return value false. Fix the code which silently ignored this
exceptional return value.

Change-Id: I41244f4b9d66176e68e2c07e2329cf08492f8619
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-01-28 01:11:12 +01:00
Matthias Sohn 9ec97688b9 Do not create files to be updated before checkout of DirCache entry
DirCacheCheckout.checkoutEntry() prepares the new file content using a
temporary file and then renames it to the file to be written during
checkout. For files to be updated checkout() created each file before
calling checkoutEntry(). Hence renaming the temporary file always
failed which was corrected in exception handling by retrying to rename
the file after deleting the just newly created file.

Change-Id: I219f864f2ed8d68051d7b5955d0659964fa27274
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-01-28 01:11:12 +01:00
Shawn O. Pearce f5fe2dca3c Teach PackWriter how to reuse an existing object list
Counting the objects needed for packing is the most expensive part of
an UploadPack request that has no uninteresting objects (otherwise
known as an initial clone).  During this phase the PackWriter is
enumerating the entire set of objects in this repository, so they can
be sent to the client for their new clone.

Allow the ObjectReader (and therefore the underlying storage system)
to keep a cached list of all reachable objects from a small number of
points in the project's history.  If one of those points is reached
during enumeration of the commit graph, most objects are obtained from
the cached list instead of direct traversal.

PackWriter uses the list by discarding the current object lists and
restarting a traversal from all refs but marking the object list name
as uninteresting.  This allows PackWriter to enumerate all objects
that are more recent than the list creation, or that were on side
branches that the list does not include.

However, ObjectWalk tags all of the trees and commits within the list
commit as UNINTERESTING, which would normally cause PackWriter to
construct a thin pack that excludes these objects.  To avoid that,
addObject() was refactored to allow this list-based enumeration to
always include an object, even if it has been tagged UNINTERESTING by
the ObjectWalk.  This implies the list-based enumeration may only be
used for initial clones, where all objects are being sent.

The UNINTERESTING labeling occurs because StartGenerator always
enables the BoundaryGenerator if the walker is an ObjectWalk and a
commit was marked UNINTERESTING, even if RevSort.BOUNDARY was not
enabled.  This is the default reasonable behavior for an ObjectWalk,
but isn't desired here in PackWriter with the list-based enumeration.
Rather than trying to change all of this behavior, PackWriter works
around it.

Because the list name commit's immediate files and trees were all
enumerated before the list enumeration itself starts (and are also
within the list itself) PackWriter runs the risk of adding the same
objects to its ObjectIdSubclassMap twice.  Since this breaks the
internal map data structure (and also may cause the object to transmit
twice), PackWriter needs to use a new "added" RevFlag to track whether
or not an object has been put into the outgoing list yet.

Change-Id: Ie99ed4d969a6bb20cc2528ac6b8fb91043cee071
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-01-27 09:38:19 -08:00
Shawn O. Pearce a017fdf112 Allow ObjectReuseAsIs to resort objects during writing
It can be very handy for the implementation to resort the
object list based on data locality, improving prefetch in
the operating system's buffer cache.

Export the list to the implementation was a proper List,
and document that its mutable and OK to be modified.  The
only caller in PackWriter is already OK with these rules.

Change-Id: I3f51cf4388898917b2be36670587a5aee902ff10
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-01-27 08:58:55 -08:00
Shawn O. Pearce c218a0760d PackWriter: Use TOPO order only for incremental packs
When performing an initial clone of a repository there are no
uninteresting commits, and the resulting pack will be completely
self-contained.  Therefore PackWriter does not need to honor C
Git standard TOPO ordering as described in JGit commit ba984ba2e0
("Fix checkReferencedIsReachable to use correct base list").

Switching to COMMIT_TIME_DESC when there are no uninteresting commits
allows the "Counting objects" phase to emit progress earlier, as the
RevWalk will not buffer the commit list.  When TOPO is set the RevWalk
enumerates all commits first, before outputing any for PackWriter to
mark progress updates from.

Change-Id: If2b6a9903b536c7fb3c45f85d0a67ff6c6e66f22
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-01-27 08:58:44 -08:00
Shawn O. Pearce 559c4661c3 Remove getObjectsDirectory, openPack from base API
These two methods are specific to the FileRepository implementation
and should not be exposed as part of the base Repository API.  Now
that PackParser is generic and does not require these two methods
to import a pack stream into a repostiory, it is safe to remove
these and get them out of the public view.

Change-Id: I8990004d08074657f467849dabfdaa7e6674e69a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-01-27 08:56:35 -08:00
Shawn Pearce cc983454c0 Merge "Support for self signed certificate (HTTPS)" 2011-01-27 11:46:49 -05:00
Matthias Sohn 91af19de56 Hard reset should not report conflict on untracked file
This problem surfaced since EGit Core ResetOperationTest is failing
since change I26806d21. JGit detected checkout conflict for untracked
files which never were tracked by the repository. 

"git reset --hard" in c git also doesn't remove such untracked files.

Change-Id: Icc8e1c548ecf6ed48bd2979c81eeb6f578d347bd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-01-27 17:20:04 +01:00
Roberto Tyley afa7c7ab07 Rename PlotWalk.getTags() to getRefs()
Change-Id: I170685e70d9ac09a010df69d26ec1c38bde60174
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-01-26 22:35:41 -06:00
Roberto Tyley 6ac8279ae7 Provide access to the Refs of a PlotCommit
This information is generally useful - have followed the
accessor pattern of 'children' and 'parents'

Change-Id: I79b3ddd6f390152aa49e6b7a4c72a4aca0d6bc72
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-01-26 22:03:41 -06:00
Robin Rosenberg 24e7f0f6fa Fix tests broken by fix for adding files in a network share
The change Ie0350e032a97e0d09626d6143c5c692873a5f6a2 was not
done properly. The renamed file was not write protected, and
this broke a test.

Bug: 335388
Change-Id: I41b2235b7677bc5fddc70dda2a56cdd2cb53ce5d
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-01-26 13:52:58 -06:00
Mathias Kinzler a5b36ae1ea FetchCommand: allow to set "TagOpt"
This is needed for implementing Fetch in EGit using the API.

Change-Id: Ibdcc95906ef0f93e3798ae20d4de353fb394f2e2
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2011-01-26 20:03:02 +01:00
Christian Halstrick 0d7dd6625a Make sure not to overwrite untracked not-ignored files
When DirCacheCheckout was checking out it was silently
overwriting untracked files. This is only ok if the
files are also ignored. Untracked and not ignored files
should not be overwritten. This fix adds checks for
this situation.
Because this change in the behaviour also broke tests
which expected that a checkout will overwrite untracked
files (PullCommandTest) these tests have to be modified
also.

Bug: 333093
Change-Id: I26806d2108ceb64c51abaa877e11b584bf527fc9
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-01-26 11:41:44 -06:00
Sasa Zivkov 65680da3ee Fixed several NPEs in the Fetch CLI
The Fetch command line was failing with NPE in case some options were omitted.
Additionally, it was setting a negative timeout when no timeout option was used
which caused HttpURLConnection to throw an IllegalArgumentException.

Change-Id: I2c67e2e1a03044284d183d73f0b82bb7ff79de95
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-01-26 11:38:59 -06:00
Sasa Zivkov 990498b75d Fixed NLS in JGit command line interface
There was one place where the parameter substitution wasn't done which caused
text fragments like "{0}" to appear in JGits output.

Bug: 325025
Change-Id: I89b881a8b5ef39f609437546310463ed4f6e1fb5
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-01-26 11:33:52 -06:00
Robin Rosenberg c4c8d80fd3 Fix adding files in a network share
We cannot always rename read-only files on network shares,
so rename the temp file for a new loose object first, and
then set it as read-only.

Bug: 335388
Change-Id: Ie0350e032a97e0d09626d6143c5c692873a5f6a2
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-01-26 11:26:55 -06:00
Chris Aniszczyk 509662653b Merge "Refactor and comment complicated if statements" 2011-01-26 12:23:26 -05:00
Chris Aniszczyk 9b8ac0151e Merge "MergeCommand should create missing branches" 2011-01-26 12:17:47 -05:00
Chris Aniszczyk 257315d80e Merge "Make setCredentialsProvider more convenient to use" 2011-01-26 12:05:57 -05:00
Mathias Kinzler 414e0cd329 Make setCredentialsProvider more convenient to use
Change-Id: I984836ea7d6a67fd2d1d05f270afa7c29f30971c
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2011-01-26 18:03:22 +01:00
Christian Halstrick b6d0bb2f94 Remove unneeded interface from test class
Change-Id: Ia876fda0d4cf91b5326d48014e88503de93a1f38
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-01-26 17:18:26 +01:00
Christian Halstrick 4cba86bfea Refactor and comment complicated if statements
When debugging and enhancing DirCacheCheckout.processEntry() I found
that some of if-statements where hard to read/understand. This
change just splits some long if statements and adds more comments
explaining in which state we are. This change is only a preparation
for followup commits which introduce checks for untracked+ignored
files.

Change-Id: I670ff08310b72c858709b9e395f0aebb4b290a56
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-01-26 17:17:45 +01:00
Christian Halstrick 85f69c286b MergeCommand should create missing branches
If HEAD exists but points to an not-existing branch the merge
command should silently create the missing branch and check
it out. This happens if you pull into freshly initalized repo.
HEAD points to refs/heads/master but refs/heads/master doesn't
exist. If you know merge a commit X into HEAD then the branch
master should be created (pointing to X) the working tree should
be updated to reflect X. That is achieved by checkout with one
tree only (HEAD is missing).

A test for this functionality will come the the next proposal
in PullCommandTest.

Change-Id: Id4a0d56d944e0acebd4b3157428bb50bd3fdd872
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-01-26 17:17:44 +01:00
Per Salomonsson d49530ad86 Support for self signed certificate (HTTPS)
Add possibility to disable ssl verification, just as i can do with git
using: git config --global http.sslVerify false

To enable the feature, configure
Window->Preferences->Team->Git->Configuration
and add a new key/value: http.sslVerify=false

When handling repos over https, JGit will then check that flag to see
if security is loose and the ssl verification should be ignored.

Having it implemented as a key/value makes it not too obvious in the
GUI - so the user must know what he/she is doing when adding it. Being
aware of the risks etc.

Bug: 332487
Change-Id: I2a1b8098b5890bf512b8dbe07da41036c0fc9b72
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-01-26 01:17:01 +01:00
Shawn O. Pearce 36e396f8b9 Permit disabling birthday attack checks in PackParser
Reading a repository for millions of missing objects might be very
expensive to perform, especially if the repository is on a network
filesystem or some other costly RPC backend.  A repository owner
might choose to accept some risk in return for better performance,
so allow disabling collision checking when receiving a pack.

Currently there is no way for an end-user to disable this feature.
This is intentional, because it is generally *NOT* a good idea to
skip this check.  Instead this feature is supplied for storage
implementations to bypass the default checking logic, should they
have their own custom routines that is just as effective but can
be handled more efficiently.

Change-Id: I90c801bb40e86412209de0c43e294a28f6a767a5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-01-25 17:14:23 -06:00
Shawn O. Pearce d62350d907 Ensure all deltas were resolved in a pack
If a pack uses OFS_DELTA only (e.g. its an initial push to a
repository) and PackParser's implementation is broken such that the
delta chain that hangs below a particular object offset is empty, the
entryCount won't match the expected objectCount. Fail fast rather
than claiming the stream was parsed correctly.

The current implementation is not broken as described above.  I broke
the code when I implemented my own new subclass of PackParser (which
incorrectly mucked with the object offset information), leading me to
discover this consistency check was missing.

Change-Id: I07540f0ae1144ef6f3bda48774dbdefb8876e1d3
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-01-25 16:52:22 -06:00
Shawn O. Pearce 1bf0c3cdb1 Refactor IndexPack to not require local filesystem
By moving the logic that parses a pack stream from the network (or
a bundle) into a type that can be constructed by an ObjectInserter,
repository implementations have a chance to inject their own logic
for storing object data received into the destination repository.

The API isn't completely generic yet, there are still quite a few
assumptions that the PackParser subclass is storing the data onto
the local filesystem as a single file.  But its about the simplest
split of IndexPack I can come up with without completely ripping
the code apart.

Change-Id: I5b167c9cc6d7a7c56d0197c62c0fd0036a83ec6c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-01-25 16:43:06 -06:00
Jesse Greenwald 51dedfdc31 Parse RevCommit bodies before calling RevFilter.include()
RevFilter.include()'s documentation promises the RevCommit's
body is parsed before include is invoked.  This wasn't always
true if the commit was parsed once, had its body discarded,
the RevWalk was reset() and started a new traversal.

Change-Id: Ie5cafde09ae870712b165d8a97a2c9daf90b1dbd
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-01-25 16:39:00 -06:00