]> source.dussan.org Git - jgit.git/log
jgit.git
6 years agoTreeWalk: Make getEolStreamType(OperationType) public 06/111206/5
David Pursehouse [Wed, 8 Nov 2017 11:20:45 +0000 (20:20 +0900)]
TreeWalk: Make getEolStreamType(OperationType) public

and deprecate getEolStreamType().

This resolves a TODO that was apparently supposed to be done in
version 4.4.

Change-Id: I5c9861aedabdc3f99dcf47519b3959a979e6a591

6 years agoTreeWalk: Fix indentation 05/111205/4
David Pursehouse [Wed, 8 Nov 2017 11:21:28 +0000 (20:21 +0900)]
TreeWalk: Fix indentation

Change-Id: I040aaaf4e3f1e3458e0ece52d1d046f501272fc2
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoMerge "ObjectDirectory: Add pack directory getter"
David Pursehouse [Wed, 15 Nov 2017 01:37:26 +0000 (20:37 -0500)]
Merge "ObjectDirectory: Add pack directory getter"

6 years agoMerge "Add return tag"
David Pursehouse [Wed, 15 Nov 2017 01:37:14 +0000 (20:37 -0500)]
Merge "Add return tag"

6 years agoMerge "ReftableCompactor should accept 0 for minUpdateIndex"
Jonathan Nieder [Tue, 14 Nov 2017 20:05:19 +0000 (15:05 -0500)]
Merge "ReftableCompactor should accept 0 for minUpdateIndex"

6 years agoReftableCompactor should accept 0 for minUpdateIndex 02/111502/5
Minh Thai [Tue, 14 Nov 2017 04:17:16 +0000 (20:17 -0800)]
ReftableCompactor should accept 0 for minUpdateIndex

Do not use 0 as the unset value for minUpdateIndex, as input reftables
may have minUpdateIndex starting at 0.

Change-Id: Ie040a6b73d4a5eba5521e51d0ee4580713c84a3e
Signed-off-by: Minh Thai <mthai@google.com>
6 years agoObjectDirectory: Add pack directory getter 74/111374/5
Hector Caballero [Sat, 4 Nov 2017 11:37:39 +0000 (07:37 -0400)]
ObjectDirectory: Add pack directory getter

So far, in order to get the pack directory it was necessary to resolve
it from the object directory. This resolution is already done when
creating the object directory, so simplify the call by just adding a
getter to the pack directory.

Change-Id: I69e783141dc6739024e8b3d5acc30843edd651a7
Signed-off-by: Hector Caballero <hector.caballero@ericsson.com>
6 years agoAdd return tag 48/111548/1
Hector Caballero [Tue, 14 Nov 2017 15:06:26 +0000 (10:06 -0500)]
Add return tag

Eclipse was complaining about the missing tag for the return type.

Change-Id: I43c7e823c3090b19dc8202c1e4d7968e1fa8e6bb
Signed-off-by: Hector Caballero <hector.caballero@ericsson.com>
6 years agoFileUtils.toPath to convert File to Path 93/110593/3
Marc Strapetz [Tue, 14 Nov 2017 09:02:07 +0000 (10:02 +0100)]
FileUtils.toPath to convert File to Path

When invoking File.toPath(), an (unchecked) InvalidPathException may be
thrown which should be converted to a checked IOException.

For now, we will replace File.toPath() by FileUtils.toPath() only for
code which can already handle IOExceptions.

Change-Id: I0f0c5fd2a11739e7a02071adae9a5550985d4df6
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
6 years agoSilence invalid @since 3.5 API warning on ResolveMerge#processEntry 95/111495/1
Matthias Sohn [Mon, 13 Nov 2017 21:41:57 +0000 (22:41 +0100)]
Silence invalid @since 3.5 API warning on ResolveMerge#processEntry

This method was removed in 4.9 and reintroduced in
I48ba4308dee73925fa32d6c2fd6b5fd89632c571 as deprecated in 4.9.1 in
order to help EMF Compare to avoid breakage.

Change-Id: Ia638517178313da42ae13ebcf88ad535d9a02723
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge changes I335587ee,I4182a174
David Pursehouse [Sat, 11 Nov 2017 03:05:50 +0000 (22:05 -0500)]
Merge changes I335587ee,I4182a174

* changes:
  Merge branch 'stable-4.9'
  Remove an unused import from PackParserTest

6 years agoAdd a setting for fsck to check connectivity only 17/111417/4
Zhen Chen [Sat, 11 Nov 2017 00:05:28 +0000 (16:05 -0800)]
Add a setting for fsck to check connectivity only

The object checks may take a long time and sometimes we are only
interested in connectivity check.

This is similar to 'git fsck --connectivity-only'.

Change-Id: I654e8fdccdb16d796f920088429d188cc96734bc
Signed-off-by: Zhen Chen <czhen@google.com>
6 years agoMerge branch 'stable-4.9' 01/111401/2
Matthias Sohn [Fri, 10 Nov 2017 18:01:14 +0000 (19:01 +0100)]
Merge branch 'stable-4.9'

* stable-4.9:
  Work around a Jsch bug: ensure the user name is set from URI
  Reintroduce protected method which removal broke EMF Compare

Change-Id: I335587eee279f91bd36c9ba9fc149b17a6db6110
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoRemove an unused import from PackParserTest 00/111400/2
Matthias Sohn [Fri, 10 Nov 2017 18:00:55 +0000 (19:00 +0100)]
Remove an unused import from PackParserTest

Change-Id: I4182a1746b09dedab648e457d1ece6d667a01f12
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge changes I22a8874b,I68ed4abd,I740bc4bf,Icbd17d15
Jonathan Nieder [Fri, 10 Nov 2017 23:52:53 +0000 (18:52 -0500)]
Merge changes I22a8874b,I68ed4abd,I740bc4bf,Icbd17d15

* changes:
  BitmapWalker: do not revisit objects in bitmap
  Use bitmaps for non-commit reachability checks
  Make PackWriterBitmapWalker public
  UploadPackTest: construct commits in test method

6 years agoBitmapWalker: do not revisit objects in bitmap 86/111086/8
Jonathan Tan [Thu, 2 Nov 2017 01:20:54 +0000 (18:20 -0700)]
BitmapWalker: do not revisit objects in bitmap

Currently, BitmapWalker walks through every object returned by the
internal ObjectWalk, regardless of whether that object has already
been marked in the bitmap. Set an object filter to ensure that only
bitmap-unmarked objects are walked through.

Change-Id: I22a8874b1e571df3c33643b365036d95f52fe7c7
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
6 years agoUse bitmaps for non-commit reachability checks 85/111085/8
Jonathan Tan [Thu, 2 Nov 2017 00:36:18 +0000 (17:36 -0700)]
Use bitmaps for non-commit reachability checks

Currently, unless RequestPolicy#ANY is used, UploadPack rejects all
non-commit "want" lines unless they were advertized. This is fine,
except when "uploadpack.allowreachablesha1inwant" is true
(corresponding to RequestPolicy#REACHABLE_COMMIT), in which case one
would expect that "want"-ing anything reachable would work.

(There is no restriction that "want" lines must only contain commits -
it is allowed for refs to directly point to trees and blobs, and
requesting for them using "want" lines works.)

This commit has been written to avoid performance regressions as much
as possible. In the usual (and currently working) case where the only
unadvertized things requested are commits, we do a standard RevWalk in
order to avoid incurring the cost of loading bitmaps. However, if
unadvertized non-commits are requested, bitmaps are used instead, and
if there are no bitmaps, a WantNotValidException is thrown (as is
currently done).

Change-Id: I68ed4abd0e477ff415c696c7544ccaa234df7f99
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
6 years agoMake PackWriterBitmapWalker public 84/111084/7
Jonathan Tan [Wed, 25 Oct 2017 21:09:17 +0000 (14:09 -0700)]
Make PackWriterBitmapWalker public

Make PackWriterBitmapWriter class public and move it to a more central
location, in preparation for its use by another class (in a subsequent
commit).

One of its inner static classes, AddUnseenToBitmapFilter, previously
package-private, is also used directly in its former package. Therefore,
AddUnseenToBitmapFilter and its sibling class have been moved to an
internal package instead.

Change-Id: I740bc4bfc4e4e3c857d1ee7d25fe45e90cd22a75
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
6 years agoWork around a Jsch bug: ensure the user name is set from URI 59/111359/1
Thomas Wolf [Tue, 7 Nov 2017 07:19:56 +0000 (08:19 +0100)]
Work around a Jsch bug: ensure the user name is set from URI

JSch unconditionally overrides the user name given in the connection
URI by the one found in ~/.ssh/config (if that does specify one for
the used host). If the SSH config file has a different user name,
we'll end up using the wrong name, which typically results in an
authentication failure or in Eclipse/EGit asking for a password for
the wrong user.

Unfortunately there is no way to prevent or circumvent this Jsch
behavior up front; it occurs already in the Session constructor at
com.jcraft.jsch.Session() and the Session.applyConfig() method. And
while there is a Session.setUserName() that would enable us to correct
this, that latter method has package visibility only.

So resort to reflection to invoke that setUserName() method to ensure
that Jsch uses the user name from the URI, if there is one.

Bug: 526778
Change-Id: Ia327099b5210a037380b2750a7fd76ff25c41a5a
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
6 years agoReject pack if delta exceeds array size limit 12/111312/3
Shawn Pearce [Thu, 9 Nov 2017 17:12:59 +0000 (09:12 -0800)]
Reject pack if delta exceeds array size limit

JGit's delta handling code requires the target to be a single byte
array. Any attempt to inflate a delta larger than fits in the 2GiB
limit will fail with some form of array index exceptions. Check for
this overflow early and abort pack parsing.

Change-Id: I5bb3a71f1e4f4e0e89b8a177c7019a74ee6194da

6 years agoCheck non-flushed packs for existence of object 76/111176/4
Zhen Chen [Tue, 7 Nov 2017 20:48:47 +0000 (12:48 -0800)]
Check non-flushed packs for existence of object

Change-Id: Id466909d70ec6f828c904692139891dec880305e
Signed-off-by: Zhen Chen <czhen@google.com>
6 years agoSuppress "Unlikely argument type for equals()" warnings in tests 61/106061/4
David Pursehouse [Sun, 1 Oct 2017 05:08:17 +0000 (06:08 +0100)]
Suppress "Unlikely argument type for equals()" warnings in tests

This new warning was introduced in Eclipse 4.7 Oxygen [1].

The only instances of the warning are in test code that is asserting
that some class does not compare equal to Strings. As in the Gerrit
project [2] these asserts are arguably overkill, but arguably also
a reasonable test of an equals implementation. Ignore the warning in
these cases.

Note that if the project is opened in an earlier version of Eclipse,
a warning "Unsupported @SuppressWarnings" will be emitted.

[1] https://www.eclipse.org/eclipse/news/4.7/M6/
[2] https://gerrit-review.googlesource.com/#/c/gerrit/+/110339/

Change-Id: I08ea33d71e6009cf0f37e6492a475931f447256b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoUpdate spotbugs-maven-plugin to 3.1.0-RC7 48/110948/2
Matthias Sohn [Thu, 2 Nov 2017 21:48:00 +0000 (22:48 +0100)]
Update spotbugs-maven-plugin to 3.1.0-RC7

Change-Id: Ic1c2c5b6e3955a1404780e51206513d226600e4b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge "Reintroduce protected method which removal broke EMF Compare" into stable-4.9
Matthias Sohn [Thu, 2 Nov 2017 16:59:11 +0000 (12:59 -0400)]
Merge "Reintroduce protected method which removal broke EMF Compare" into stable-4.9

6 years agoUploadPackTest: construct commits in test method 83/111083/1
Jonathan Tan [Wed, 1 Nov 2017 23:23:32 +0000 (16:23 -0700)]
UploadPackTest: construct commits in test method

In a subsequent commit, more tests will be added. This commit allows
those tests to reuse fields.

Change-Id: Icbd17d158cfe3ba4dacbd8a11a67f9e7607b41b3
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
6 years agoMerge branch 'stable-4.9' 90/110890/1
David Pursehouse [Wed, 1 Nov 2017 23:29:56 +0000 (08:29 +0900)]
Merge branch 'stable-4.9'

* stable-4.9:
  PackInserter: Implement newReader()
  Move some strings from DfsText to JGitText
  FileRepository: Add pack-based inserter implementation
  ObjectDirectory: Factor a method to close open pack handles
  ObjectDirectory: Remove last modified check in insertPack

Change-Id: Ifc9ed6f5d8336bc978818a64eae122bceb933e5d

6 years agoPackInserter: Implement newReader() 66/110866/3
Dave Borowitz [Wed, 1 Nov 2017 15:46:48 +0000 (11:46 -0400)]
PackInserter: Implement newReader()

Change-Id: Ib9e7f6439332eaed3d936f895a5271a7d514d3e9

6 years agoMove some strings from DfsText to JGitText 65/110865/2
Dave Borowitz [Wed, 1 Nov 2017 15:45:22 +0000 (11:45 -0400)]
Move some strings from DfsText to JGitText

Change-Id: I60050e5127d12b6139d81859dba929fcfaabe504

6 years agoFileRepository: Add pack-based inserter implementation 64/110864/2
Dave Borowitz [Tue, 31 Oct 2017 14:05:29 +0000 (10:05 -0400)]
FileRepository: Add pack-based inserter implementation

Applications that use ObjectInserters to create lots of individual
objects may prefer to avoid cluttering up the object directory with
loose objects. Add a specialized inserter implementation that produces a
single pack file no matter how many objects. This inserter is loosely
based on the existing DfsInserter implementation, but is simpler since
we don't need to buffer blocks in memory before writing to storage.

An alternative for such applications would be to write out the loose
objects and then repack just those objects later. This operation is not
currently supported with the GC class, which always repacks existing
packs when compacting loose objects. This in turn requires more
CPU-intensive reachability checks and extra I/O to copy objects from old
packs to new packs.

So, the choice was between implementing a new variant of repack, or not
writing loose objects in the first place. The latter approach is likely
less code overall, and avoids unnecessary I/O at runtime.

The current implementation does not yet support newReader() for reading
back objects.

Change-Id: I2074418f4e65853b7113de5eaced3a6b037d1a17

6 years agoObjectDirectory: Factor a method to close open pack handles 63/110863/2
Dave Borowitz [Wed, 1 Nov 2017 14:42:46 +0000 (10:42 -0400)]
ObjectDirectory: Factor a method to close open pack handles

Change-Id: I9490c4583fdf801de9c0bb09595ebb8fb4926988

6 years agoObjectDirectory: Remove last modified check in insertPack 62/110862/1
Dave Borowitz [Wed, 1 Nov 2017 14:19:38 +0000 (10:19 -0400)]
ObjectDirectory: Remove last modified check in insertPack

GC explicitly handles the case where a new pack has the same name as an
existing pack due to it containing the exact same set of objects. In
this case, the pack passed to insertPack will have the same name as an
existing pack, but it will also almost certainly have a later mtime than
the existing pack.

The loop in insertPack tried to short-circuit when inserting a new pack,
to avoid walking more of the pack list than necessary. Unfortunately,
this means it will never get to the check for an identical name,
resulting in a duplicate entry for the same PackFile in the pack list.
Remove the short-circuit so that insertPack does not insert a duplicate
entry.

Change-Id: I00711b28594622ad3bd104332334e8a3592cda7f

6 years agoUpgrade error_prone_core to 2.1.2 23/110623/2
David Pursehouse [Thu, 26 Oct 2017 05:30:45 +0000 (14:30 +0900)]
Upgrade error_prone_core to 2.1.2

Change-Id: I2e6ea106ed5e6568eaf421ce5794bfe446c6cadb
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoMove loggers to the top of their class 74/110674/2
Saša Živkov [Fri, 27 Oct 2017 10:29:52 +0000 (12:29 +0200)]
Move loggers to the top of their class

There is a possibility of hitting NPE on a logger if it is not the first
statically initialized member. For example, if another static
initializer creates an instance of its class and the logger is used
from the constructor.

Change-Id: I51fa855a8883c107f2e4ef5ac039dc12a571a7ae

6 years agoMerge "Align PackStatistics and DfsPackDescription list length"
Terry Parker [Thu, 26 Oct 2017 22:22:49 +0000 (18:22 -0400)]
Merge "Align PackStatistics and DfsPackDescription list length"

6 years agoUpdate .mailmap 86/110586/1
David Pursehouse [Wed, 25 Oct 2017 01:56:00 +0000 (10:56 +0900)]
Update .mailmap

Before:

$ git shortlog -n -s | grep Han
    14    Han-Wen Nienhuys
     1    Han-Wen NIenhuys

After:

$ git shortlog -n -s | grep Han
    15    Han-Wen Nienhuys

Change-Id: I2874713f120f09bcbd33a1c48645e25fb5bf9259
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoReintroduce protected method which removal broke EMF Compare 79/110579/1
Matthias Sohn [Tue, 24 Oct 2017 21:13:37 +0000 (23:13 +0200)]
Reintroduce protected method which removal broke EMF Compare

So far we follow OSGi semantic versioning [1] which says the following:

"A change in the second (minor) part of the version signals that the
change is backward compatible with consumers of the API package but not
with the providers of that API. That is, when the API package goes from
version 1.5 to 1.6 it is no longer compatible with a provider of that
API but consumers of that API are backward compatible with that API
package."

The change Ib5fbf17bdaf727bc5d0e106ce88f2620d9f87a6f broke EMF Compare
which subclasses ResolveMerger since we added a new parameter to the
protected ResolveMerger.processEntry() method. According to the above
cited OSGi semantic versioning this is ok, implementers should expect
that they break on minor version changes of the API they implement.

This change reintroduces the old processEntry() method in order to help
avoid breakage for existing EMF Compare versions which expect breakage
also for the implementer case only for major version change (in this
case from JGit 4.x to 5.x).

[1] http://www.osgi.org/wp-content/uploads/SemanticVersioning1.pdf

See: https://dev.eclipse.org/mhonarc/lists/jgit-dev/msg03431.html
Change-Id: I48ba4308dee73925fa32d6c2fd6b5fd89632c571
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoRevert "Throw BinaryBlobException from RawParseUtils#lineMap." 67/110567/2
Han-Wen NIenhuys [Tue, 24 Oct 2017 15:25:50 +0000 (11:25 -0400)]
Revert "Throw BinaryBlobException from RawParseUtils#lineMap."

This reverts commit f2e64cd895a6aa4f18ab3b876f13b7814fb98f04.

The newly added throws clause breaks backward compatibility.

Change-Id: Ifa76a1b95935e52640b81cd53c171eb17da175c2
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
6 years agoFix typo in comment 57/110557/2
Han-Wen Nienhuys [Tue, 24 Oct 2017 13:13:10 +0000 (15:13 +0200)]
Fix typo in comment

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I04912b32b55dd61ad2d2e7ccb5d688655b1dc335

6 years agoThrow BinaryBlobException from RawParseUtils#lineMap. 09/110209/7
Han-Wen Nienhuys [Tue, 17 Oct 2017 13:17:34 +0000 (15:17 +0200)]
Throw BinaryBlobException from RawParseUtils#lineMap.

This makes detection of binaries exact for ResolveMerger and
DiffFormatter: they will classify files as binary regardless of where
the '\0' occurs in the text.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: Id4342a199628d9406bfa04af1b023c27a47d4014

6 years agoAvoid loading and merging binary data in ResolveMerger 19/106519/14
Han-Wen Nienhuys [Tue, 10 Oct 2017 14:40:12 +0000 (16:40 +0200)]
Avoid loading and merging binary data in ResolveMerger

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: Ide4b68872d426aa262142f224acf636c776b35d3

6 years agoIntroduce ObjectLoader.Filter for delegation 12/110512/2
Han-Wen Nienhuys [Mon, 23 Oct 2017 12:41:00 +0000 (14:41 +0200)]
Introduce ObjectLoader.Filter for delegation

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I78ada3f4023c4304b19f94fb044024f0f0b2cbbe

6 years agoIntroduce RawText#load. 16/106516/12
Han-Wen Nienhuys [Mon, 9 Oct 2017 16:11:04 +0000 (18:11 +0200)]
Introduce RawText#load.

This method creates a RawText from a blob, but avoids reading the blob
if the start contains null bytes. This should reduce the amount of
garbage that Gerrit produces for changes with binaries.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: Idd202d20251f2d1653e5f1ca374fe644c2cf205f

6 years agoAdd missing @since tags for new API in ReceiveCommand 10/110510/1
Matthias Sohn [Mon, 23 Oct 2017 12:22:28 +0000 (14:22 +0200)]
Add missing @since tags for new API in ReceiveCommand

Change-Id: I6e5d29390b71a1c123bc90ec2e3435706ea9211c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge branch 'stable-4.9' 96/110496/1
David Pursehouse [Mon, 23 Oct 2017 03:08:54 +0000 (12:08 +0900)]
Merge branch 'stable-4.9'

* stable-4.9:
  Avoid bad rounding "1 year, 12 months" in date formatter
  Ensure that ~ in ssh config is replaced before Jsch sees it

Change-Id: If6ca55f9447aaea3d7c2d36c03520d5e6dd5193e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoAvoid bad rounding "1 year, 12 months" in date formatter 95/110495/1
Michael Keppler [Thu, 12 Oct 2017 07:38:31 +0000 (09:38 +0200)]
Avoid bad rounding "1 year, 12 months" in date formatter

Round first, then calculate the labels. This avoids "x years, 12 months"
and instead produces "x+1 years".

One test case has been added for the original example the bug was found
with, and one assertion has been moved from an existing test case to the
new test case, since it also triggered the bug.

Bug: 525907
Change-Id: I3270af3850c4fb7bae9123a0a6582f93055c9780
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoAlign PackStatistics and DfsPackDescription list length 73/110473/1
Masaya Suzuki [Fri, 20 Oct 2017 19:18:16 +0000 (12:18 -0700)]
Align PackStatistics and DfsPackDescription list length

Without this the caller cannot tell which PackStatistics is for which
pack file.

Change-Id: Ifa530f8bc82459611ae694c0a0d111daec3e08f3
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
7 years agodfs: Switch InMemoryRepository to DfsReftableDatabase 05/103205/16
Shawn Pearce [Sat, 12 Aug 2017 21:31:16 +0000 (14:31 -0700)]
dfs: Switch InMemoryRepository to DfsReftableDatabase

This ensure DfsReftableDatabase is tested by the same test suites that
use/test InMemoryRepository. It also simplifies the logic of
InMemoryRepository and brings its compatibility story closer to any
other DFS repository that uses reftables for its reference storage.

Change-Id: I881469fd77ed11a9239b477633510b8c482a19ca
Signed-off-by: Minh Thai <mthai@google.com>
Signed-off-by: Terry Parker <tparker@google.com>
7 years agoMerge changes from topic 'reftable'
Terry Parker [Thu, 19 Oct 2017 00:25:08 +0000 (20:25 -0400)]
Merge changes from topic 'reftable'

* changes:
  dfs: reftable backed DfsRefDatabase
  Support symbolic references in ReceiveCommand

7 years agodfs: reftable backed DfsRefDatabase 04/103204/16
Shawn Pearce [Sat, 12 Aug 2017 19:19:30 +0000 (12:19 -0700)]
dfs: reftable backed DfsRefDatabase

DfsReftableDatabase is a new alternative for DfsRefDatabase that
handles more operations for the implementor by delegating through
reftables. All reftable files are stored in sibling DfsObjDatabase
using PackExt.REFTABLE and PackSource.INSERT.

Its assumed the DfsObjDatabase periodically runs compactions and GCs
using DfsPackCompactor and DfsGarbageCollector. Those passes are
essential to collapsing the stack of reftables.

Change-Id: Ia03196ff6fd9ae2d0623c3747cfa84357c6d0c79
Signed-off-by: Minh Thai <mthai@google.com>
Signed-off-by: Terry Parker <tparker@google.com>
7 years agoEnsure that ~ in ssh config is replaced before Jsch sees it 45/110345/1
Thomas Wolf [Wed, 18 Oct 2017 20:45:36 +0000 (22:45 +0200)]
Ensure that ~ in ssh config is replaced before Jsch sees it

Do tilde replacement for values from the ssh config file that are
file names in all cases to make sure that they are already replaced
when Jsch tries to get the values.

Previously, OpenSshConfig did tilde replacement only for the
IdentityFile in the JGit-facing "Host" interface and left the
replacement in the Jsch-facing "Config" interface to Jsch.

But on Windows the JGit notion of what should be used to replace the
tilde differs from Jsch's replacement. Jsch always replaces the tilde
by the value of the system property "user.home", whereas JGit also
considers some environment variables like %HOME%. This can lead to
rather surprising failures as in the case of bug 526175 where
%HOME% != user.home.

Prior to commit 9d24470 (i.e.,prior to JGit 4.9.0) this problem never
occurred because Jsch was completely unaware of the ssh config file
and all host and IdentityFile handling happened exclusively in JGit.

Bug: 526175
Change-Id: I1511699664ffea07cb58ed751cfdb79b15e3a99e
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoSupport symbolic references in ReceiveCommand 17/103017/13
Shawn Pearce [Sat, 12 Aug 2017 15:25:16 +0000 (08:25 -0700)]
Support symbolic references in ReceiveCommand

Allow creating symbolic references with link, and deleting them or
switching to ObjectId with unlink.  How this happens is up to the
individual RefDatabase.

The default implementation detaches RefUpdate if a symbolic reference
is involved, supporting these command instances on RefDirectory.
Unfortunately the packed-refs file does not support storing symrefs,
so atomic transactions involving more than one symref command are
failed early.

Updating InMemoryRepository is deferred until reftable lands, as I
plan to switch InMemoryRepository to use reftable for its internal
storage representation.

Change-Id: Ibcae068b17a2fc6d958f767f402a570ad88d9151
Signed-off-by: Minh Thai <mthai@google.com>
Signed-off-by: Terry Parker <tparker@google.com>
7 years agoAvoid bad rounding "1 year, 12 months" in date formatter 95/109895/3
Michael Keppler [Thu, 12 Oct 2017 07:38:31 +0000 (09:38 +0200)]
Avoid bad rounding "1 year, 12 months" in date formatter

Round first, then calculate the labels. This avoids "x years, 12 months"
and instead produces "x+1 years".

One test case has been added for the original example the bug was found
with, and one assertion has been moved from an existing test case to the
new test case, since it also triggered the bug.

Bug: 525907
Change-Id: I3270af3850c4fb7bae9123a0a6582f93055c9780
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoMerge branch 'stable-4.9' 32/106432/2
David Pursehouse [Sat, 14 Oct 2017 07:31:52 +0000 (16:31 +0900)]
Merge branch 'stable-4.9'

* stable-4.9:
  Prepare 4.9.1-SNAPSHOT builds
  JGit v4.9.0.201710071750-r

Change-Id: Iac83a1d999ad66774d10de984a5b6dc581d43d0f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoSkip unreachable garbage packs in dfs fsck 78/106478/1
Zhen Chen [Mon, 9 Oct 2017 17:53:58 +0000 (10:53 -0700)]
Skip unreachable garbage packs in dfs fsck

Change-Id: I8899e0faf1e4e6386dfd57340dfa4f4fdebc3cf3
Signed-off-by: Zhen Chen <czhen@google.com>
7 years agoPrepare 4.10.0-SNAPSHOT builds 19/106419/1
Matthias Sohn [Sun, 8 Oct 2017 09:35:54 +0000 (11:35 +0200)]
Prepare 4.10.0-SNAPSHOT builds

Change-Id: I5ca462d1db18a2c5c9382cfb9c83972510fa2b88
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoPrepare 4.9.1-SNAPSHOT builds 16/106416/1
Matthias Sohn [Sun, 8 Oct 2017 09:25:06 +0000 (11:25 +0200)]
Prepare 4.9.1-SNAPSHOT builds

Change-Id: Ic49fd093d3fe4324c4d83aba74033040fcaa37a6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoJGit v4.9.0.201710071750-r 11/106411/1 v4.9.0.201710071750-r
Matthias Sohn [Sat, 7 Oct 2017 21:46:52 +0000 (23:46 +0200)]
JGit v4.9.0.201710071750-r

Change-Id: I487f6aa3d0c4ef1d57f91cdc36177d994ae24c51
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoTerminate StreamCopy threads in case of errors 85/106185/5
Till Brychcy [Wed, 4 Oct 2017 08:40:23 +0000 (10:40 +0200)]
Terminate StreamCopy threads in case of errors

- fix NPE: don't invoke close() if no exception happened.

Bug: 513554
Change-Id: I29f9b2ac1607ee26521e8aba334facd20e4ad79c
Signed-off-by: Till Brychcy <register.eclipse@brychcy.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoUse a new RevWalk for validating not advertised wants 46/106246/10
Zhen Chen [Wed, 4 Oct 2017 21:02:24 +0000 (14:02 -0700)]
Use a new RevWalk for validating not advertised wants

Shadow commits in the RevWalk in the UploadPack object may cause the
UNINTERESTING flag not being carried over to their parents commits since
they were marked NO_PARENTS during the assumeShallow or
initializeShallowCommits call.

A new RevWalk needs to be created for this reason, but instead of
creating a new RevWalk from Repository, we can reuse the ObjectReader in
the RevWalk of UploadPack to load objects.

Change-Id: Ic3fee0512d35b4f555c60e696a880f8b192e4439
Signed-off-by: Zhen Chen <czhen@google.com>
7 years agoAdd photon target platform jgit-4.8.target 57/106057/3
Matthias Sohn [Sat, 30 Sep 2017 23:17:11 +0000 (01:17 +0200)]
Add photon target platform jgit-4.8.target

Change-Id: I87f52f512db4c89fa4e3e550ff97fdec843b8469
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoCheckout now reports failures through exceptions. 92/105592/3
Ned Twigg [Fri, 18 Mar 2016 09:37:58 +0000 (02:37 -0700)]
Checkout now reports failures through exceptions.

Checkout sometimes throws an exception, and
other times it writes an error message to outw
and returns normally, even though the command
failed.  This commit now reports all failures
through a die() exception.

Change-Id: I038a5d976d95020fea3faac68e9178f923c25b28
Signed-off-by: Ned Twigg <ned.twigg@diffplug.com>
7 years agoTerminate StreamCopy threads in case of errors 03/92903/4
Dmitry Neverov [Mon, 13 Mar 2017 11:05:44 +0000 (12:05 +0100)]
Terminate StreamCopy threads in case of errors

Bug: 513554
Change-Id: I065836b8fc77ade6de92e4a809fcf770a4f793ec
Signed-off-by: Dmitry Neverov <dmitry.neverov@gmail.com>
7 years agoReflogWriter: Align auto-creation defaults with C git 97/102397/5
Dave Borowitz [Wed, 2 Aug 2017 14:39:27 +0000 (10:39 -0400)]
ReflogWriter: Align auto-creation defaults with C git

Per git-config(1), core.logAllRefUpdates auto-creates reflogs for HEAD
and for refs under heads, notes, tags, and for HEAD. Add notes and
remove stash from ReflogWriter#shouldAutoCreateLog. Explicitly force
writing reflogs for refs/stash at call sites, now that this is
supported.

Change-Id: I3a46d2c2703b7c243e0ee2bbf6948279800c485c

7 years agoSupport force writing reflog on a per-update basis 96/102396/5
Dave Borowitz [Tue, 1 Aug 2017 12:53:33 +0000 (08:53 -0400)]
Support force writing reflog on a per-update basis

Even if a repository has core.logAllRefUpdates=true, ReflogWriter does
not create reflog files unless the refs are under a hard-coded list of
prefixes, or unless the forceWrite bit is set. Expose the forceWrite bit
on a per-update basis in RefUpdate/BatchRefUpdate/ReceiveCommand,
creating RefLogWriters as necessary.

Change-Id: Ifc851fba00f76bf56d4134f821d0576b37810f80

7 years agoEnsure ReflogWriter only works with a RefDirectory 95/102395/5
Dave Borowitz [Tue, 1 Aug 2017 13:43:22 +0000 (09:43 -0400)]
Ensure ReflogWriter only works with a RefDirectory

The ReflogWriter constructor just took a Repository and called
getDirectory() on it to figure out the reflog dirs, but not all
Repository instances use this storage format for reflogs, so it's
incorrect to attempt to use ReflogWriter when there is not a
RefDirectory directly involved. In practice, ReflogWriter was mostly
only used by the implementation of RefDirectory, so enforcing this is
mostly just shuffling around calls in the same internal package.

The one exception is StashDropCommand, which writes to a reflog lock
file directly. This was a reasonable implementation decision, because
there is no general reflog interface in JGit beyond using
(Batch)RefUpdate to write new entries to the reflog. So to implement
"git stash drop <N>", which removes an arbitrary element from the
reflog, it's fair to fall back to the RefDirectory implementation.
Creating and using a more general interface is well beyond the scope of
this change.

That said, the old behavior of writing out the reflog file even if
that's not the reflog format used by the given Repository is clearly
wrong. Fail fast in this case instead.

Change-Id: I9bd4b047bc3e28a5607fd346ec2400dde9151730

7 years agoChangeIdUtilTest: Remove unused notestCommitDashV 49/106049/2
David Pursehouse [Sat, 30 Sep 2017 09:56:42 +0000 (10:56 +0100)]
ChangeIdUtilTest: Remove unused notestCommitDashV

This test was never being run. Since it was introduced it was
named "notest.." which meant it didn't run with JUnit3, and
since it is not annotated @Test it also doesn't run with JUnit4.

When compiling with Bazel 0.6.0, error-prone raises an error
that the public method is not annotated with @Ignore or @Test.

Given that the test has never been run anyway, we can just
remove it.

Bug: 525415
Change-Id: Ie9a54f89fe42e0c201f547ff54ff1d419ce37864
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoAdd the args4j jar 45/106045/2
Pepper Lebeck-Jobe [Sat, 30 Sep 2017 06:22:31 +0000 (08:22 +0200)]
Add the args4j jar

This allows the tests to all be built and run by bazel.

Bug: 525412
Change-Id: Ie9281d07462cd07200fadb4b0e7b7f88c44f7865
Signed-off-by: Pepper Lebeck-Jobe <eljobe@gmail.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoHttpConfig: load user config before reading values from it 10/105810/1
Thomas Wolf [Tue, 26 Sep 2017 21:54:45 +0000 (23:54 +0200)]
HttpConfig: load user config before reading values from it

Same problem as in commit c227268: openUserConfig() just creates the
FileBasedConfig object, but doesn't read the file yet. An explicit
load() is needed.

As HttpConfig is read-only this omission did not cause any bad effects,
but it simply ignored values from the user config. Most uses of
HttpConfig go through the two-argument constructor, though, where
HttpConfig is given an already loaded repo config.

Change-Id: Ibe7c562c17d6ef37de8b661ab7f6fa0246db01a2
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoLoad the user config before modifying it 52/105652/1
Thomas Wolf [Sat, 23 Sep 2017 09:15:27 +0000 (11:15 +0200)]
Load the user config before modifying it

SystemReader.openUserConfig() does not load the config yet; an
explicit StoredConfig.load() is needed.

Bug: 374703
Change-Id: I1c397e2fb1a07ac4d9de3675d996417734ff90e9
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoAdded API to TextBuiltin for piped usage. 50/104050/4
Ned Twigg [Fri, 18 Mar 2016 07:11:04 +0000 (00:11 -0700)]
Added API to TextBuiltin for piped usage.

Added a public method to TextBuiltin which makes it possible for
clients to initialize all of its state, including output and error
streams.  This gives clients the ability to customize the way in
which a command is run.

Change-Id: If718236964d2c5cf869e120c74f1a12965f4812e
Signed-off-by: Ned Twigg <ned.twigg@diffplug.com>
7 years agoSubmoduleUpdateCommand: Add fetch callback 69/105169/2
David Pursehouse [Fri, 15 Sep 2017 03:44:10 +0000 (12:44 +0900)]
SubmoduleUpdateCommand: Add fetch callback

When the submodule already exists, it is fetched instead of
cloned.

Use the fetch callback instead of clone callback in this case.

Change-Id: I170c21ab92b4117f25fdf940fe6807f214b04d39
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoFetch submodule repo before resolving commits 07/100307/5
Michael FIG [Wed, 28 Jun 2017 21:33:07 +0000 (15:33 -0600)]
Fetch submodule repo before resolving commits

By default, this is turned off unless cmd.setFetch(true) is given.  It
will default to true in a future release to mimic c-git behaviour.

This is needed to prevent Eclipse from crashing with "Missing unknown
[REF]" when cloning a repo with submodules.

Bug: 470318
Change-Id: I8ae37c7c5bd2408cead8d57dd13e93e01e0e9dc1
Signed-off-by: Michael FIG <michael@fig.org>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoHandle SSL handshake failures in TransportHttp 22/104222/7
Thomas Wolf [Sat, 2 Sep 2017 11:20:48 +0000 (13:20 +0200)]
Handle SSL handshake failures in TransportHttp

When a https connection could not be established because the SSL
handshake was unsuccessful, TransportHttp would unconditionally
throw a TransportException.

Other https clients like web browsers or also some SVN clients
handle this more gracefully. If there's a problem with the server
certificate, they inform the user and give him a possibility to
connect to the server all the same.

In git, this would correspond to dynamically setting http.sslVerify
to false for the server.

Implement this using the CredentialsProvider to inform and ask the
user. We offer three choices:

1. skip SSL verification for the current git operation, or
2. skip SSL verification for the server always from now on for
   requests originating from the current repository, or
3. always skip SSL verification for the server from now on.

For (1), we just suppress SSL verification for the current instance of
TransportHttp.

For (2), we store a http.<uri>.sslVerify = false setting for the
original URI in the repo config.

For (3), we store the http.<uri>.sslVerify setting in the git user
config.

Adapt the SmartClientSmartServerSslTest such that it uses this
mechanism instead of setting http.sslVerify up front.

Improve SimpleHttpServer to enable setting it up also with HTTPS
support in anticipation of an EGit SWTbot UI test verifying that
cloning via HTTPS from a server that has a certificate that doesn't
validate pops up the correct dialog, and that cloning subsequently
proceeds successfully if the user decides to skip SSL verification.

Bug: 374703
Change-Id: Ie1abada9a3d389ad4d8d52c2d5265d2764e3fb0e
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoSupport http.<url>.* configs 93/103993/5
Thomas Wolf [Wed, 30 Aug 2017 05:47:26 +0000 (07:47 +0200)]
Support http.<url>.* configs

Git has a rather elaborate mechanism to specify HTTP configuration
options per URL, based on pattern matching the URL against "http"
subsection names.[1] The URLs used for this matching are always the
original URLs; redirected URLs do not participate.

* Scheme and host must match exactly case-insensitively.
* An optional user name must match exactly.
* Ports must match exactly after default ports have been filled in.
* The path of a subsection, if any, must match a segment prefix of
  the path of the URL.
* Matches with user name take precedence over equal-length path
  matches without, but longer path matches are preferred over
  shorter matches with user name.

Implement this for JGit. Factor out the HttpConfig from TransportHttp
and implement the matching and override mechanism.

The set of supported settings is still the same; JGit currently
supports only followRedirects, postBuffer, and sslVerify, plus the
JGit-specific maxRedirects key.

Add tests for path normalization and prefix matching only on segment
separators, and use the new mechanism in SmartClientSmartServerSslTest
to disable sslVerify selectively for only the test server URLs.

Compare also bug 374703 and bug 465492. With this commit it would be
possible to set sslVerify to false for only the git server using a
self-signed certificate instead of having to switch it off globally
via http.sslVerify.

[1] https://git-scm.com/docs/git-config

Change-Id: I42a3c2399cb937cd7884116a2a32fcaa7a418fcb
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoAdd PushConfig class with PushRecurseSubmodulesMode 76/103676/11
David Pursehouse [Fri, 25 Aug 2017 06:55:44 +0000 (15:55 +0900)]
Add PushConfig class with PushRecurseSubmodulesMode

This will be used later when adding for support for recursing
submodules on push.

Change-Id: Ie2a183e5404a32046de9f6524e6ceeec37919671
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoImplement CommandRef.toString() to help debugging 85/104685/1
Matthias Sohn [Thu, 7 Sep 2017 23:47:56 +0000 (01:47 +0200)]
Implement CommandRef.toString() to help debugging

Change-Id: If3ebed08c8f4e2cc925a97dbdd4c84410bc7c4a5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoFix missing RefsChangedEvent when packed refs are used 30/104330/3
Thomas Wolf [Tue, 5 Sep 2017 09:09:27 +0000 (11:09 +0200)]
Fix missing RefsChangedEvent when packed refs are used

With atomic ref updates using packed refs, JGit did not fire a
RefsChangedEvent. This resulted in a user-visible regression in
EGit: the UI would not update after a "Fetch from upstream...".
Presumably it would also make Gerrit miss out on ref changes?

Strengthen the BatchRefUpdateTest by also asserting the expected
number of RefsChangedEvents, and ensure modCnt is incremented in
RefDirectory.commitPackedRefs() when refs really changed (as opposed
to some internal housekeeping operation, such as packing loose refs).

Bug: 521296
Change-Id: Ia985bda1d99f45a5f89c8020ca4845e7a66e743e
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoAdd FetchCommand#setRefSpecs(String...) variant 44/104644/1
Dave Borowitz [Thu, 7 Sep 2017 11:46:25 +0000 (07:46 -0400)]
Add FetchCommand#setRefSpecs(String...) variant

Much of the time the caller can specify a RefSpec succinctly using a
string, and doesn't care about calling setters. Add a convenience method
for this case, and use it where applicable in JGit core.

Change-Id: Ic3fac7fc568eee4759236a5264d2e7e5f9b9716d

7 years agoReceivePack: clear advertised .haves if application changes refs 18/104618/2
Shawn Pearce [Thu, 7 Sep 2017 02:09:42 +0000 (19:09 -0700)]
ReceivePack: clear advertised .haves if application changes refs

An application can choose to invoke setAdvertisedRefs multiple times,
for example several AdvertiseRefsHook installed in a chain. Each of
these invocations populates the advertisedHaves collection with the
unique set of ObjectIds.

This can lead to a server over-advertising with ".have" lines if the
first hook pushes in a lot of references, and the second hook filters
this to a subset.  ReceivePack will advertise the unique objects from
the first hook using ".have" lines, which may lead to a huge
advertisement sent to the client.

This can also contribute to a very slow connectivity check after the
pack is parsed as ReceivePack calls markUninteresting on every commit
in advertisedHaves.  This may require expanding a lot of subtrees to
mark all trees as uninteresting as well.  On a very big repository
this can lead to a many-second stall.

Clear the advertisedHaves collection any time the refs are updated.
Add a test to verify the correct set of objects was sent.

Change-Id: I97f6998d0597251444a2e846a3ea1f461bae96f9

7 years agoDfsGarbageCollector: support disabling conversion to reftable 17/104617/1
Shawn Pearce [Wed, 6 Sep 2017 23:37:54 +0000 (16:37 -0700)]
DfsGarbageCollector: support disabling conversion to reftable

When a repository is initially created using only reftable but doesn't
yet have a GC pack, the garbage collector shouldn't scan the ref
database. Support disabling the reftable conversion path.

Change-Id: Iaaf3a4375cd43760b7181c1bd10244de8b2c5d9e

7 years agoRemove dead warning about minUpdaeIndex and maxUpdateIndex affecting refresh 97/104597/1
Shawn Pearce [Wed, 6 Sep 2017 18:12:34 +0000 (11:12 -0700)]
Remove dead warning about minUpdaeIndex and maxUpdateIndex affecting refresh

DfsGarbageCollector always performs refreshes.  This warning was from
a prior iteration of the patch set and should have been removed before
the change was merged.

Change-Id: Id4750bb6c1c177e1ef040fd22912f434bbb5e992

7 years agoMerge "Remove no longer needed API problem filters"
David Pursehouse [Wed, 6 Sep 2017 05:33:05 +0000 (01:33 -0400)]
Merge "Remove no longer needed API problem filters"

7 years agoRemove no longer needed API problem filters 05/104405/1
Matthias Sohn [Tue, 5 Sep 2017 22:58:09 +0000 (00:58 +0200)]
Remove no longer needed API problem filters

Change-Id: I206682a60ad9228c89efa22f8db9e72e19f17f6d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoStop using deprecated CmdLineException constructors 45/104345/2
David Pursehouse [Tue, 5 Sep 2017 11:27:32 +0000 (20:27 +0900)]
Stop using deprecated CmdLineException constructors

Instead of taking a String, the constructors now take a Localizable
and a variable list of format arguments.

Introduce a new Format helper class in CLIText, which implements the
Localizable interface, and use it in place of raw Strings.

Change-Id: I241eda16e242293ceb17b3c85ae5df85bd37c658
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoUntrackedFilesHandler: Fix non-localized string 44/104344/2
David Pursehouse [Tue, 5 Sep 2017 11:26:21 +0000 (20:26 +0900)]
UntrackedFilesHandler: Fix non-localized string

Change-Id: Ida7b9ddc991515ab233763f2cb985853c9143a3c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoMain: Replace deprecated ExampleMode with OptionHandlerFilter 15/104315/2
David Pursehouse [Tue, 5 Sep 2017 07:43:23 +0000 (16:43 +0900)]
Main: Replace deprecated ExampleMode with OptionHandlerFilter

Change-Id: I1161a82269b7f093c00c9533ed8b99b7cca0a322
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoObjectCheckerTest: Factor duplicate instances out to constants 31/104131/3
David Pursehouse [Fri, 1 Sep 2017 04:33:57 +0000 (13:33 +0900)]
ObjectCheckerTest: Factor duplicate instances out to constants

The tests:

- testCheckBlobNotCorrupt
- testCheckBlobCorrupt

create instances of ObjectChecker that are the same.

The tests:

- testCheckBlobWithBlobObjectCheckerNotCorrupt
- testCheckBlobWithBlobObjectCheckerCorrupt

also create instances of ObjectChecker that are the same.

Factor these instances out to constants instead of creating them
in the tests.

The `checker` member is still created anew in each test, since some
of the tests change its state.

Change-Id: I2d90263829d01d208632185b1ec2f678ae1a3f4c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoSubmoduleConfigTest: Add additional tests in fetchRecurseToConfigValue 34/104234/3
David Pursehouse [Sun, 3 Sep 2017 10:10:19 +0000 (19:10 +0900)]
SubmoduleConfigTest: Add additional tests in fetchRecurseToConfigValue

Add tests for "true" and "false" matching to "YES" and "NO".

Change-Id: I58223855022871ac4b21bd34ff6a9cd00fce30a1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoSubmoduleConfig: Simplify #toConfigValue 44/103744/6
David Pursehouse [Sun, 27 Aug 2017 23:19:17 +0000 (08:19 +0900)]
SubmoduleConfig: Simplify #toConfigValue

Just return configValue instead of transforming name().

Change-Id: I7f94ab2e206e93d1370467e187c5e68e8f6a8836
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoMerge changes from topic 'dfs-reftable'
Shawn Pearce [Tue, 5 Sep 2017 16:39:53 +0000 (12:39 -0400)]
Merge changes from topic 'dfs-reftable'

* changes:
  dfs: write reftable from DfsGarbageCollector
  dfs: compact reftables during DfsPackCompactor

7 years agodfs: write reftable from DfsGarbageCollector 72/101472/18
Shawn Pearce [Thu, 10 Aug 2017 23:41:26 +0000 (16:41 -0700)]
dfs: write reftable from DfsGarbageCollector

If a ReftableConfig has been supplied by the caller, write out a
reftable as a sibling of the the GC pack, alongside the heads.

To bootstrap from a non-reftable system, the refs are read from the
DfsRefDatabase if no GC reftables are present.  Its assumed the
references are fully current, and do not need to be merged with any
other reftables.  Any non-GC reftables will be pruned at the end of
the GC cycle, just like any packs that were replaced.

If a GC reftable is present, all existing reftables are compacted, and
references from DfsRefDatabase are only used to seed the packer.  Its
assumed these are consistent with each other.

Change-Id: Ie397eb58aaaefb6865c816d9b39de3ac12998019

7 years agodfs: compact reftables during DfsPackCompactor 08/102608/10
Shawn Pearce [Tue, 25 Jul 2017 22:37:56 +0000 (15:37 -0700)]
dfs: compact reftables during DfsPackCompactor

Combine intermediate, non-GC reftables when combining pack files.
This shrinks the reftable stack, improving lookup times.

Change-Id: I5dbba41806f99af5ecaff3a3119f6630e9404256

7 years agoRemove final modifier on args4j option or argument fields 04/104304/2
Matthias Sohn [Mon, 4 Sep 2017 21:48:31 +0000 (23:48 +0200)]
Remove final modifier on args4j option or argument fields

Remove final field modifier since args4j does no longer allow use of
final fields [1].

[1] https://github.com/kohsuke/args4j/commit/6e11f89d40dcc518c0e5eb9eef5d74f05d58e6af

Change-Id: Ib3dee10828d87d6b558c2e90387eadd9aa2ce260
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoFix Daemon.stop() to actually stop the listener thread 64/104264/3
Thomas Wolf [Mon, 4 Sep 2017 09:02:37 +0000 (11:02 +0200)]
Fix Daemon.stop() to actually stop the listener thread

ServerSocket.accept() is not interruptible: a thread busy in accept()
may not react to Thread.interrupt() and may not return from accept()
via an InterruptedException. Close the socket instead to make the
daemon's listener thread terminate.

* Close the listening socket to get the listening thread to exit
  instead of interrupting it.
* Add a stopAndWait() method that stops the listening thread and
  then waits until it has indeed finished.
* Set SO_REUSE_ADDRESS on the listening socket.

Bug: 376369
Change-Id: I9d6014103e6dcb0173daea134feb44dc52c5c69a
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoMerge "Remove workaround for bug in Java's ReferenceQueue"
Shawn Pearce [Mon, 4 Sep 2017 18:35:58 +0000 (14:35 -0400)]
Merge "Remove workaround for bug in Java's ReferenceQueue"

7 years agoRemove workaround for bug in Java's ReferenceQueue 45/104245/2
Matthias Sohn [Sat, 2 Sep 2017 22:06:59 +0000 (00:06 +0200)]
Remove workaround for bug in Java's ReferenceQueue

Sun's Java 5, 6, 7 implementation had a bug [1] where a Reference can be
enqueued and dequeued twice on the same reference queue due to a race
condition within ReferenceQueue.enqueue(Reference).

This bug was fixed for Java 8 [2] hence remove the workaround.

[1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6837858
[2] http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/858c75eb83b5

Change-Id: I2deeb607e3d237f9f825a207533acdee305c7e73
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoUse Config.getEnum() to read the IgnoreSubmoduleMode 18/103818/7
Thomas Wolf [Tue, 29 Aug 2017 08:25:05 +0000 (10:25 +0200)]
Use Config.getEnum() to read the IgnoreSubmoduleMode

Doing so goes through the TypedConfigGetter and thus allows library
clients (for instance EGit) to warn about invalid configurations.

Change-Id: If1080ad90b8aff54a903d4d75637614faad6469b
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoDon't assume name = path in .gitmodules 58/62358/6
Thomas Wolf [Tue, 29 Aug 2017 07:37:30 +0000 (09:37 +0200)]
Don't assume name = path in .gitmodules

While parsing .gitmodules, the name of the submodule subsection is
purely arbitrary: it frequently is the path of the submodule, but
there's no requirement for it to be. By building a map of paths to
the section name in .gitmodules, we can more accurately return
the submodule URL.

Bug: 508801
Change-Id: I8399ccada1834d4cc5d023344b97dcf8d5869b16
Also-by: Doug Kelly <dougk.ff7@gmail.com>
Signed-off-by: Doug Kelly <dougk.ff7@gmail.com>
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoUpgrade Maven compiler plugins 30/104130/2
David Pursehouse [Fri, 1 Sep 2017 04:02:26 +0000 (13:02 +0900)]
Upgrade Maven compiler plugins

- error_prone_core to 2.1.1
- maven-compiler-plugin to 3.6.2
- plexus-compiler-javac{-error-prone} to 2.8.2

Change-Id: I20d864c869f2d03f623ea054b6d08e7ee0eb262a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoUpgrade args4j to 2.33 in the bazel build 29/104129/1
David Pursehouse [Fri, 1 Sep 2017 03:51:25 +0000 (12:51 +0900)]
Upgrade args4j to 2.33 in the bazel build

Change-Id: Ic440657e3da53b643f79fbcdde45d4e659bc166d