Commit Graph

3670 Commits

Author SHA1 Message Date
Dave Borowitz a46b28808b RenameDetector: Clarify rename limits <= 0
Change-Id: I8da386e02272316b8e5e5c2f31ce10ad98bcdb28
2017-05-24 09:26:40 -04:00
Zhen Chen 099dbe6ef5 Remove unnecessary cast for DfsReader
Change-Id: I22aaccfc9d589750f9d1d711b655dd0fd543fa57
Signed-off-by: Zhen Chen <czhen@google.com>
2017-05-22 10:27:20 -07:00
David Pursehouse 9a4486003f Merge "Fix javadoc of TooLargeObjectInPackException" 2017-05-22 01:12:10 -04:00
Shawn Pearce 1513a5632d Allow DfsReader to be subclassed
Necessary if a DFS implementation wants to override close()
to record DfsReaderIoStats.

Change-Id: I144575f9bf1abf2c1fd72030550c4f0795fcf44d
2017-05-19 13:50:36 -07:00
Shawn Pearce 562de51239 Track read IO for DfsReader
Compute how much disk IO a DfsReader is performing, and how long the
sum of those operations took on this reader instance. Implementations
of DFS and interested applications can get the stats by calling the
new DfsReader.getIoStats() method at or after close().

Change-Id: If585741301f29182617933d6406d4a70497f2ca7
2017-05-19 12:23:02 -07:00
Matthias Sohn ef0237564e Fix javadoc of TooLargeObjectInPackException
The API exception should have the same javadoc like the internal
exception org.eclipse.jgit.errors.TooLargeObjectInPackException

Change-Id: Ia7508c77609e53c8e808412ac523a93194648e49
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-05-19 11:22:05 +02:00
Terry Parker c46c720e99 Exclude refs/tags from bitmap commit selection
Commit db77610 ensured that all refs/tags commits are added to the
primary GC pack. It did that by adding all of the refs/tags commits
to the primary GC pack PackWriter's "interesting" object set.

Unfortunately, all commit objects in the "interesting" set are
selected as commits for which bitmap indices will be built. In a
repository like chromium with lots of tags, this changed the number of
bitmaps created from <700 to >10000. That puts huge memory pressure on
the GC task.

This change restores the original behavior of ignoring tags when
selecting commits for bitmaps.

In the "uninteresting" set, commits for refs/heads and refs/tags for
unannotated tags can not be differentiated. We instead identify
refs/tags commits by passing their ObjectIds as a new "noBitmaps"
parameter to the PackWriter.preparePack() methods.
PackWriterBitmapPreparer.setupTipCommitBitmaps() can then use that
"noBitmaps" parameter to exclude those commits.

Change-Id: Icd287c6b04fc1e48de773033fe432a9b0e904ac5
Signed-off-by: Terry Parker <tparker@google.com>
2017-05-18 15:25:21 -07:00
Matthias Sohn 69d5e89e99 [findBugs] Use UTF-8 to write to the error stream in TextProgressMonitor
Change-Id: Ic85db2043d6f673f268bf781917daad45d28f8cd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-05-15 10:30:24 +02:00
Matthias Sohn f1dd61f646 [findBugs] Use UTF-8 to read git-rebase-todo file
Change-Id: I7c6f71e13ef106678157eae1aa3f9d39712e577b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-05-15 10:29:47 +02:00
Matthias Sohn 0aa1a19cab [findBugs] Use UTF-8 when writing to the error stream in GitHook
Change-Id: Ica8a40b909ed45cf8e538714e4f26b64ff9a3d21
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-05-15 10:28:53 +02:00
Matthias Sohn 9f98d3e2e4 Add shutdown hook to cleanup unfinished clone when JVM is killed
Bug: 516303
Change-Id: I5181b0e8096af3537296848ac7dd74dff0b6d279
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-05-13 17:23:34 +02:00
Thomas Wolf 09d96f8d46 Clean up the disk when cloning fails
CloneCommand.call() has three stages: preparation, then the actual
clone (init/fetch), and finally maybe checking out the working
directory.

Restructure such that if we fail or are cancelled during the actual
clone (middle phase), we do clean up the disk again. This prevents
leaving behind a partial clone in an inconsistent state: either we
have a fully successfully built clone, or nothing at all.

Bug: 516303
Change-Id: I9b18c60f8f99816d42a3deb7d4a33a9f22eeb709
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2017-05-12 05:11:13 -04:00
Christian Halstrick 501af12c19 Checkout should not use too long filenames
DirCacheCheckout is generating names for temporary files. It was not checking
the length of this filenames. It may happen that a generated filename is
longer than 255 chars which causes problems on certain platforms. Make sure
that filenames for temporary files do not exceed 255 chars.

Bug: 508823
Change-Id: I9475c04351ce3faebdc6ad40ea4faa3c326815f4
2017-05-10 00:33:44 +02:00
Mickael Istria 5b84e25fa3 Support pull on detached HEAD
Bug: 485396
Change-Id: I82be09385c9b0bcc0054fea5a9cb9d178a41e278
Signed-off-by: Mickael Istria <mistria@redhat.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-05-08 00:38:25 +02:00
Zhen Chen 8f7d0a4fbe Reset ObjectWalker when it starts a new walk
The ObjectWalker in PackWriterBitmapWalker needs to be reset whenever it
starts a new walk. Move this responsibility from the caller to the
method when the new walk starts.

Change-Id: Ib66003be1b5bdc80f46b9bbbb17d45e616714912
Signed-off-by: Zhen Chen <czhen@google.com>
2017-05-03 15:02:33 -07:00
Shawn Pearce d377a885a9 Fix stack overflow in MergeBaseGenerator
Some repository topologies can cause carryOntoHistory to overflow the
thread stack, due to its strategy of recursing into the 2nd+ parents
of a merge commit.  This can easily happen if a project maintains a
local fork, and frequently pulls from the upstream repository, which
itself may have a branchy history.

Rewrite the carryOntoHistory algorithm to use a fixed amount of thread
stack, pushing the save points onto the heap.  By using heap space the
thread stack depth is no longer a concern.  Repositories are instead
limited by available memory.

The algorithm is now structured as two loops:

  carryOntoHistory: This outer loop pops saved commits off the top of
  the stack, allowing the inner loop algorithm to dive down that path
  and carry bits onto commits along that part of the graph.  The loop
  ends when there are no more stack elements.

  carryOntoHistoryInner: The inner loop walks along a single path of
  the graph. For a string of pearls (commits with one parent each)

    r <- s <- t <- u

  the algorithm walks backwards from u to r by iteratively updating
  its local variable 'c'.  This avoids heap allocation along a simple
  path that does not require remembering state.

  The inner loop breaks in the HAVE_ALL case, when all bits have been
  found to be previously set on the commit.  This occurs when a prior
  iteration of the outer loop (carryOntoHistory) explored a different
  path to this same commit, and copied the bits onto it.

  When the inner loop encounters a merge commit, it pushes all parents
  onto the heap based stack by allocating individual CarryStack
  elements for each parent.  Parents are pushed in order, allowing
  side branches to be explored first.

  A small optimization is taken for the last parent, avoiding pushing
  it and instead updating 'c', allowing the side branch to be entered
  without allocating a CarryStack.

Change-Id: Ib7b67d90f141c497fbdc61a31b0caa832e4b3c04
2017-05-02 11:38:59 -07:00
David Pursehouse 005e5feb4e Clone: add --recurse-submodules option
Add the --recurse-submodules option on the command, which causes
submodules to also be initialized and updated.

Add a callback interface on CloneCommand and SubmoduleUpdateCommand to
them to provide progress feedback for clone operations.

Change-Id: I41b1668bc0d0bdfa46a9a89882c9657ea3063fc1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-04-27 09:19:08 +02:00
Thirumala Reddy Mutchukota 5e250e45be Delete expired garbage even when there is no GC pack present.
Delete the condition to check whether the garbage pack creation time
is older than the last GC operation, because it's not possible to
find the last GC operation time when there is no GC pack.

Add additional tests to make sure the contents of the expired garbage
packs are considered during the GC operation and any actively
referenced objects from the garbage packs are copied successfully
into the GC pack before deleting the garbage pack.

Change-Id: I09e8b2656de8ba7f9b996724ad1961d908e937b6
Signed-off-by: Thirumala Reddy Mutchukota <thirumala@google.com>
2017-04-21 14:06:58 -07:00
Martin Fick f9b69677f6 Add parseCommit(AnyObjectId) method to Repository.
It is quite common to want to parse a commit without already having a
RevWalk.  Provide a shortcut to do so to make it more convenient, and to
ensure that the RevWalk is released afterwards.

Signed-off-by: Martin Fick<mfick@codeaurora.org>
Change-Id: I9528e80063122ac318f115900422a24ae49a920e
2017-04-19 09:42:47 +02:00
Dan Willemsen b6fc8e2f3c RepoCommand: Add linkfile support.
Android wants them to work, and we're only interested in them for bare
repos, so add them just for that.

Make sure to use symlinks instead of just using the copyfile
implementation. Some scripts look up where they're actually located in
order to find related files, so they need the link back to their
project.

Change-Id: I929b69b2505f03036f69e25a55daf93842871f30
Signed-off-by: Dan Willemsen <dwillemsen@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Jeff Gaston <jeffrygaston@google.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-04-18 10:33:37 +02:00
Jonathan Nieder f9e13efe47 Merge "Process all "have"s even when MissingObjectException is encountered" 2017-04-17 14:53:27 -04:00
Jonathan Nieder c2e6e7abc9 Process all "have"s even when MissingObjectException is encountered
Because objects described by the client using "have" lines do not need
to be reachable by any ref on the server, it is possible for them to
point to missing objects in the reachability graph.  When such an
object is encountered, I1097a2defa4a9dcf502ca8baca5d32880378818f (Only
throw MissingObjectException when necessary, 2017-03-29) aborts the
"have" walk early to salvage the fetch.  The downside of that change
is that remaining "have"s are ignored unless they pointed directly to
an object with a bitmap.  In the worst case this can increase the
bandwidth cost of a fetch to the cost of a clone because most "have"s
are ignored.

Avoid this cost by bypassing the failed "have" completely and moving
on to the remaining "have"s.

Change-Id: Iac236b6d05f735078c9935abfa6e58d1eb47f388
2017-04-17 11:50:28 -07:00
David Pursehouse a6df70569a Merge "Prevent alternates loop" 2017-04-17 12:01:55 -04:00
Martin Fick e4714a2a5f Prevent alternates loop
When looping through alternates, prevent visiting the same object
directory twice. This could happen when the objects/info/alternates file
includes itself directly or indirectly via a another repo and its
alternates file.

Change-Id: I79bb3da099ebc3c262d2e6c61ed4578eb1aa3474
Signed-off-by: James Melvin <jmelvin@codeaurora.org>
Signed-off-by: Martin Fick <mfick@codeaurora.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-04-14 23:35:17 +02:00
Matthias Sohn 3af4afdfbf Add missing @since tag for new API RepoCommand.setTargetURI()
Change-Id: I4531b94e3a04606a69eeb3c3d154510b87507012
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-04-14 19:49:19 +02:00
David Pursehouse c80d8c5901 Bazel: Restrict src globs to Java source files
Generating the src list with an unrestricted wildcard causes all
files in the source tree to be included. This results in junk files
such as .orig (generated during merge conflict resolution) to be
included, which causes in a build error:

  in srcs attribute of java_library rule //org.eclipse.jgit:jgit:
  file '//org.eclipse.jgit:src/org/eclipse/jgit/gitrepo/RepoCommand.java.orig'
  is misplaced here (expected .java, .srcjar or .properties).

Modify the globs to only include Java source files.

Change-Id: Iaef3db33ac71d71047cd28acb0378e15cb09ece9
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-04-13 14:14:55 +09:00
Han-Wen Nienhuys fe5437e96b Fix RepoCommand to allow for relative URLs
This is necessary for deploying submodules on android.googlesource.com.

* Allow an empty base URL. This is useful if the 'fetch' field is "."
  and all names are relative to some host root.

* The URLs in the resulting superproject are relative to the
  superproject's URL. Add RepoCommand#setDestinationURI to
  set this. If unset, the existing behavior is maintained.

* Add two tests for the Android and Gerrit case, checking the URL
  format in .gitmodules; the tests use a custom RemoteReader which is
  representative of the use of this class in Gerrit's Supermanifest
  plugin.

Change-Id: Ia75530226120d75aa0017c5410fd65d0563e91b
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-04-13 10:53:58 +09:00
Jonathan Nieder e730fcce77 Merge "BundleWriter: Allow constructing from only an ObjectReader" 2017-04-12 21:12:15 -04:00
Terry Parker 56a1cced74 Merge "Only throw MissingObjectException when necessary" 2017-04-12 10:25:11 -04:00
Dave Borowitz c9c9e672e5 BundleWriter: Allow constructing from only an ObjectReader
Change-Id: I01821d6a9fbed7a5fe4619884e42937fbd6909ce
2017-04-12 08:27:57 -04:00
Matthias Sohn cc0dbbae43 Merge branch 'stable-4.7'
* stable-4.7:
  Cleanup and test trailing slash handling in ManifestParser
  ManifestParser: Throw exception if remote does not have fetch attribute

Change-Id: Ia9dc3110bcbdae05175851ce647ffd11c542f4c0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-04-11 00:54:16 +02:00
Han-Wen Nienhuys f17ec3928c Cleanup and test trailing slash handling in ManifestParser
This is a workaround for
https://bugs.openjdk.java.net/browse/JDK-4666701.

Change-Id: Idd04657e8d95a841d72230f8881b6b899daadbc2
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-04-11 00:37:38 +02:00
Han-Wen Nienhuys 84d855cda7 ManifestParser: Throw exception if remote does not have fetch attribute
In the repo manifest documentation [1] the fetch attribute is marked
as "#REQUIRED".

If the fetch attribute is not specified, this would previously result in
NullPointerException. Throw a SAXException instead.

[1] https://gerrit.googlesource.com/git-repo/+/master/docs/manifest-format.txt

Change-Id: Ib8ed8cee6074fe6bf8f9ac6fc7a1664a547d2d49
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-04-10 15:08:32 +02:00
Matthias Sohn b3cc05d886 Remove unused API filters
Change-Id: I1e00d71395228265aad4071b023024ee1bf855d5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-04-09 23:43:43 +02:00
Matthias Sohn 7adacbd19a Silence API error for new method added to abstract MergeStrategy
OSGi semantic versioning rules allow to break implementors of an API in
a minor version.

Change-Id: I4ada3e6455e8e8e1bb8fb71affa0a1b36bd46fc4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-04-06 18:17:22 +02:00
Matthias Sohn 4e8655c74d Fix @since tags of new API added after 4.7.0
Change-Id: I356f71cdef8e23a9b06cf0a4079060a116b9ed27
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-04-06 18:16:04 +02:00
Zhen Chen f5368dc97f Only throw MissingObjectException when necessary
When preparing the bitmap, the flag ignoreMissingStart only applied to
the start object. However, sometime the start object is present but some
related objects are not present during the walk, we should only release
the MissingObjectException when the ignoreMissingStart is set false.

Change-Id: I1097a2defa4a9dcf502ca8baca5d32880378818f
Signed-off-by: Zhen Chen <czhen@google.com>
2017-04-05 19:09:16 -04:00
Matthias Sohn 6a311a071f Prepare 4.7.1-SNAPSHOT
Change-Id: I16a45035258276217446bccc0ad1b0991383aa0c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-04-06 00:16:53 +02:00
Dave Borowitz 4c3e274588 Support creating Mergers without a Repository
All that's really required to run a merge operation is a single
ObjectInserter, from which we can construct a RevWalk, plus a Config
that declares a diff algorithm. Provide some factory methods that don't
take Repository.

Change-Id: Ib884dce2528424b5bcbbbbfc043baec1886b9bbd
2017-04-05 17:50:54 -04:00
Matthias Sohn 9f4c10784b JGit v4.7.0.201704051617-r
Change-Id: Ic2bd6aca0b7a7e0597ffc1f7cf647b49878f9950
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-04-05 22:17:44 +02:00
Matthias Sohn aec22e74cf Prepare 4.8.0-SNAPSHOT builds
Change-Id: Ifea6750e79d417a8a2a891b3b5f96d68c7200011
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-04-05 14:49:49 +02:00
Andrey Loskutov 7476baebfc Fixed NP dereference error reported by ecj in UploadPack.stopBuffering()
Introduced via commit 3b2508b514.

Change-Id: I2b6175c095aea2868a8c302103095accde5170e3
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
2017-04-05 09:51:12 +02:00
Shawn Pearce db2493e7d8 Merge "Make diff locations more consistent" 2017-04-04 22:26:38 -04:00
Dave Borowitz e4672d1c16 NameConflictTreeWalk: Mark repo param @Nullable
This is passed directly to the super constructor, where it is also
@Nullable. Marking it here saves the reader a jump.

Change-Id: Icc8db2f2dc6aae6e591aa4f09a3c283336a5424c
2017-04-04 14:53:17 -04:00
Jonathan Nieder db58abbbe8 Merge "Buffer the response until request parsing has done" 2017-04-04 14:25:41 -04:00
Masaya Suzuki 3b2508b514 Buffer the response until request parsing has done
This is a continuation from https://git.eclipse.org/r/#/c/4716/. For a
non-bidirectional request, we need to consume the request before writing
any response. In UploadPack, we write "shallow"/"unshallow" responses
before parsing "have" lines. This has happened not to be a problem most
of the time in the smart HTTP protocol because the underlying
InputStream has a 32 KiB buffer in SmartOutputStream.

Change-Id: I7c61659e7c4e8bd49a8b17e2fe9be67bb32933d3
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
2017-04-04 10:52:49 -07:00
KB Sriram 4a985f5aa8 Make diff locations more consistent
DiffAlgorithms can return different edit locations for inserts or
deletes, if they can be "shifted" up or down repeating blocks of
lines. This causes the 3-way merge to apply both edits, resulting in
incorrectly removing or duplicating lines.

Augment an existing "tidy-up" stage in DiffAlgorithm to move all
shiftable edits (not just the last INSERT edit) to a consistent
location, and add test cases for previously incorrect merges.

Bug: 514095
Change-Id: I5fe150a2fc04e1cdb012d22609d86df16dfb0b7e
Signed-off-by: KB Sriram <kbsriram@google.com>
2017-04-03 16:45:13 -07:00
Matthias Sohn b65a764b6b Remove unused import from ManifestParser
Change-Id: Ie60ef9c7bc6ce0fdf017949ebfb9a21753e70506
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-03-31 00:38:36 +02:00
Han-Wen Nienhuys f32d65759c Document the intended use of RepoCommand#setURI()
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I4a59dd8278b7b0026094692127b7f55e89c10bae
2017-03-29 16:54:29 +02:00
Han-Wen Nienhuys 6e652846f6 Noop changes to ManifestParser
* Parse the base URL in ManifestParser construction.  This will signal
  errors earlier.

* Simplify stripping of trailing slashes.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I4a86f68c9d7737f71cf20352cfe26288fbd2b463
2017-03-29 13:51:37 +02:00