]> source.dussan.org Git - jgit.git/log
jgit.git
7 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

7 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

7 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

7 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>
7 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>
7 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>
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

7 years agoAdd org.apache.commons.codec 1.9.0 to target platform 21/103921/3
Matthias Sohn [Wed, 30 Aug 2017 00:17:51 +0000 (02:17 +0200)]
Add org.apache.commons.codec 1.9.0 to target platform

This is needed to run tests in org.eclipse.jgit.http.test from Eclipse.
The change 7ac1bfc8 which added this dependency to
org.eclipse.jgit.http.test was already merged.

Restrict dependency to org.apache.commons.codec to the
version range [1.6.0,2.0.0).

CQ: 14048
Change-Id: I461a5f6bfc114757061d68992f9bc7ab38622328
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoMerge "Fix some tests for running in bazel"
David Pursehouse [Fri, 1 Sep 2017 02:02:21 +0000 (22:02 -0400)]
Merge "Fix some tests for running in bazel"

7 years agoMerge "Update args4j to 2.33"
David Pursehouse [Fri, 1 Sep 2017 02:01:04 +0000 (22:01 -0400)]
Merge "Update args4j to 2.33"

7 years agoFsckPackParser: Fix warning about int being boxed to Integer 73/104073/3
David Pursehouse [Thu, 31 Aug 2017 11:40:31 +0000 (20:40 +0900)]
FsckPackParser: Fix warning about int being boxed to Integer

Change-Id: I525164090e3990ce353bbb1627aaafaad2c903b6
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoFix some tests for running in bazel 90/104090/1
Thomas Wolf [Thu, 31 Aug 2017 13:48:10 +0000 (15:48 +0200)]
Fix some tests for running in bazel

Some tests call out to external cgit. Those tests all failed for me
locally on Mac. Turned out that the reason was that the system git
config used by the git in the bazel run contained paths with ~/ but
somehow $HOME was not set. As a result the external git returned
with exit code 128.

Fix this by passing along $HOME explicitly. Also improve assertions
to make sure we do get the stderr of the external command in the
test log.

I hadn't noticed that until now because apparently the maven build
does pass along $HOME.

Change-Id: I7069676d5cc7b23a71e79a4866fe8acab5a405f4
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoFsckPackParser: Fix "Empty block should be documented" warnings 71/104071/2
David Pursehouse [Thu, 31 Aug 2017 11:32:39 +0000 (20:32 +0900)]
FsckPackParser: Fix "Empty block should be documented" warnings

Add "Do nothing" comments, consistent with other empty methods in
the same class.

Change-Id: I27a13a402e94104af617be0e14d8982e75fa73bd
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoFsckPackParser: Fix warnings about variable hiding 70/104070/2
David Pursehouse [Thu, 31 Aug 2017 11:29:00 +0000 (20:29 +0900)]
FsckPackParser: Fix warnings about variable hiding

Change-Id: Id1ada1cedfad5671e79df303c6dbcb6017b777ce
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoSilence API errors caused by adding enum constants in 1baf86d4d2 69/104069/2
David Pursehouse [Thu, 31 Aug 2017 11:22:43 +0000 (20:22 +0900)]
Silence API errors caused by adding enum constants in 1baf86d4d2

Change-Id: I23338c04567f95aedd909ab310e01277e8f7db69
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoAdd dependency to jsch for OpenSshConfigTest to bazel build 78/104078/1
Thomas Wolf [Thu, 31 Aug 2017 12:14:05 +0000 (14:14 +0200)]
Add dependency to jsch for OpenSshConfigTest to bazel build

Make jsch visible to the test bundle and add the dependency.

Change-Id: I0c49ee9b8f64fe8a8c74d2f08865917eb33069b4
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoMerge changes from topic 'dfs-reftable'
Shawn Pearce [Thu, 31 Aug 2017 00:42:23 +0000 (20:42 -0400)]
Merge changes from topic 'dfs-reftable'

* changes:
  dfs: helper to open multiple reftables
  dfs: expose DfsReftable from DfsObjDatabase
  dfs: support reading reftables through DfsBlockCache

7 years agoMerge changes from topic 'fsck'
Shawn Pearce [Wed, 30 Aug 2017 12:42:37 +0000 (08:42 -0400)]
Merge changes from topic 'fsck'

* changes:
  DfsFsck: reduce memory usage during verifyIndex
  DfsFsck: refactor pack verify into its own method
  DfsFsck: run connectivity check pass exactly once

7 years agoDfsFsck: reduce memory usage during verifyIndex 14/103914/2
Shawn Pearce [Wed, 30 Aug 2017 01:40:03 +0000 (18:40 -0700)]
DfsFsck: reduce memory usage during verifyIndex

Don't convert a lot of ObjectId to String stored in generic
java.util.HashSet.  This is a very expensive way to store objects.

Instead rely on "this" from the FsckPackParser to lookup information
about the objects in this pack file, which lets the verify code avoid
sorting the object list.

Use ObjectIdOwnerMap, which is the most efficient format JGit has
for storing lots of objects.

Change-Id: Ib68f93acb4d91b96d0a44c0612f704500d332ac1

7 years agoDfsFsck: refactor pack verify into its own method 13/103913/2
Shawn Pearce [Wed, 30 Aug 2017 01:26:29 +0000 (18:26 -0700)]
DfsFsck: refactor pack verify into its own method

This simplifies the logic about allocation of the DfsReader, and
clarifies the code considerably by using smaller scopes with less
indentation.

A few static imports from PackExt and slightly shorter variable names
make for a more understandable-at-glance implementation.

Change-Id: Iaf5a0e14fe0349215d9e44446f68d1129ad3bb3d

7 years agoDfsFsck: run connectivity check pass exactly once 11/103911/1
Shawn Pearce [Wed, 30 Aug 2017 01:14:51 +0000 (18:14 -0700)]
DfsFsck: run connectivity check pass exactly once

The simpler algorithm is to load all branch tips into an ObjectWalk
and run that walk exactly once.  This avoids redoing work related to
parsing and considering trees reused across side branches.

Move the connectivity check into its own helper method.  This moves it
left one level of identation, and makes it easier to fit the method's
logic with less line wrapping.

Add a "Counting objects..." progress monitor around this phase.  Its
what is used when a server receives a push and is also trying to
verify the client sent all required objects.

Change-Id: I4d53d75d0cdd1a13fff7d513a6ae0b2d14ea4090

7 years agoUpdate args4j to 2.33 45/85445/6
Matthias Sohn [Mon, 22 Aug 2016 08:25:30 +0000 (10:25 +0200)]
Update args4j to 2.33

CQ: 11068
Change-Id: I7d52cddacff05477f646fda5f7b9f2de844922f6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoFix compilation errors with args4j 2.0.23 and later 62/14662/3
Robin Stocker [Thu, 18 Jul 2013 17:08:29 +0000 (19:08 +0200)]
Fix compilation errors with args4j 2.0.23 and later

The multiValued attribute on @Option was removed. When the field is a
List, it's not actually needed (even with earlier versions of args4j),
see RmTest. In other cases, we have a custom handler, where it's also
not needed.

Bug: 413163
Change-Id: I4bb951e9fab5f4ae4271bd7e11be799dc234ab80

7 years agoCleanup: Remove redundant type arguments 06/103906/3
Matthias Sohn [Tue, 29 Aug 2017 23:21:40 +0000 (01:21 +0200)]
Cleanup: Remove redundant type arguments

Change-Id: I81ce2e25666f5acfce4d3ada6b71ae8c81a97a4d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoCleanup: Remove unnecessary $NON-NLS$ tags 05/103905/3
Matthias Sohn [Tue, 29 Aug 2017 23:19:44 +0000 (01:19 +0200)]
Cleanup: Remove unnecessary $NON-NLS$ tags

Change-Id: I143c9d62b89322509123d4e06a221dd4dc158c55
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoCleanup: Organize imports 04/103904/2
Matthias Sohn [Tue, 29 Aug 2017 22:30:34 +0000 (00:30 +0200)]
Cleanup: Organize imports

Change-Id: I6065e59519bc42bd18f5cc5ee3ec5210764ab03c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoPartially revert c0ad77d8 "Enhance Eclipse save actions" 10/103910/1
Matthias Sohn [Wed, 30 Aug 2017 01:07:18 +0000 (03:07 +0200)]
Partially revert c0ad77d8 "Enhance Eclipse save actions"

Do not automatically organize imports using a save action since this
seems to be buggy and removed some annotations org.eclipse.jgit.pgm
needs to use args4j.

Change-Id: I5a91292c3b9241ce2dde3e4ecce14ad460097129
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoCleanup: Remove trailing whitespace 03/103903/1
Matthias Sohn [Tue, 29 Aug 2017 22:27:16 +0000 (00:27 +0200)]
Cleanup: Remove trailing whitespace

Change-Id: I7c08b60fb6afafd1874210320da3da7519632e08
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoPartially revert c0ad77d8 "Enhance Eclipse save actions" 02/103902/1
Matthias Sohn [Tue, 29 Aug 2017 21:41:16 +0000 (23:41 +0200)]
Partially revert c0ad77d8 "Enhance Eclipse save actions"

Revert the following save actions which were introduced in c0ad77d8:
- always use braces around blocks
- remove unused imports

Other than I expected save actions are run globally on edited files -
and not only on edited code lines only.

Hence revert the save action "Convert control statement bodies to
blocks" which would affect a large number of code lines not affected by
the change editing some small part of a class. This would generate a
large number of changes which may lead to many unnecessary conflicts.
Total number of affected lines across jgit would be around 10k lines.

Also revert "Remove unused imports" since it erroneously removes imports
of some annotations needed by pgm classes using args4j.

Change-Id: I879a47f68e664129e6124cf25c1ae1f6a2d7a5aa
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoPass along the original exception when an ssh connection fails 70/103870/2
Thomas Wolf [Tue, 29 Aug 2017 14:55:00 +0000 (16:55 +0200)]
Pass along the original exception when an ssh connection fails

Otherwise, the stack trace doesn't really tell anything.
See for instance [1].

[1] https://www.eclipse.org/forums/index.php/t/1088535/

Change-Id: If22f2c63c36fec6b32818d2c2acecf20531b4185
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agodfs: helper to open multiple reftables 07/102607/8
Shawn Pearce [Fri, 28 Jul 2017 18:27:18 +0000 (11:27 -0700)]
dfs: helper to open multiple reftables

ReftableStack maintains multiple open reftables
in an AutoCloseable format, making it easier for
higher level code to handle multiple files.

Change-Id: I7ac35c18e67b7e771fb3de29169d1ee50fab62ca

7 years agodfs: expose DfsReftable from DfsObjDatabase 51/101851/10
Shawn Pearce [Mon, 24 Jul 2017 16:38:36 +0000 (09:38 -0700)]
dfs: expose DfsReftable from DfsObjDatabase

Reftable storage in DFS is related to pack storage.  Reftables are
stored in the same namespace, but with PackExt.REFTABLE.  Include
the set of DfsReftable instances in the PackList and export some
helpers to access the tables.

Change-Id: I6a4f5f953ed6b0ff80a7780f4c6cbcc5eda0da3e

7 years agodfs: support reading reftables through DfsBlockCache 66/101366/17
Shawn Pearce [Mon, 17 Jul 2017 16:35:14 +0000 (09:35 -0700)]
dfs: support reading reftables through DfsBlockCache

DfsBlockCache directly shares its internal byte[] with ReftableReader,
avoding copying between the DfsBlockCache and the BlockReader
instances used by ReftableReader.

Change-Id: Icaa4f40052b26f952681414653a8b5314b7c2c23

7 years agoMerge "reftable: explicitly store update_index per ref"
Shawn Pearce [Mon, 28 Aug 2017 21:57:13 +0000 (17:57 -0400)]
Merge "reftable: explicitly store update_index per ref"

7 years agoMerge "Enhance Eclipse save actions"
David Pursehouse [Mon, 28 Aug 2017 16:08:01 +0000 (12:08 -0400)]
Merge "Enhance Eclipse save actions"

7 years agoMerge "Add BlobObjectChecker"
Terry Parker [Mon, 28 Aug 2017 16:00:52 +0000 (12:00 -0400)]
Merge "Add BlobObjectChecker"

7 years agoEnhance Eclipse save actions 35/103735/2
Matthias Sohn [Sat, 26 Aug 2017 20:19:30 +0000 (22:19 +0200)]
Enhance Eclipse save actions

Add the following Eclipse save actions executed when saving modified
lines. This should help to reduce manual work needed to maintain a clean
and consistent code style:
- organize imports
- always use braces around blocks
- add missing annotations
  - @Override including implementation of interface methods
  - @Deprecated
- remove
  - unused imports
  - unnecessary $NON-NLS$ tags
  - redundant type arguments

Also add default values for new settings that were introduced in recent
Eclipse versions up to Neon since we updated save rules the last time.

Change-Id: Idc90b249df044d0552f04edf01a5f607c4846f50
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoAdd BlobObjectChecker 30/102830/4
Masaya Suzuki [Thu, 10 Aug 2017 06:30:03 +0000 (23:30 -0700)]
Add BlobObjectChecker

Some repositories can have a policy that do not accept certain blobs. To
check if the incoming pack file contains such blobs, ObjectChecker can
be used. However, this ObjectChecker is not called by PackParser if the
blob is stored as a whole. This is because the object can be so large
that it doesn't fit in memory.

This change introduces BlobObjectChecker. This interface takes chunks of
a blob instead of the entire object. ObjectChecker can optionally return
a BlobObjectChecker. This won't change existing ObjectChecker
implementation; existing implementation continues to receive deltified
blob objects only.

Change-Id: Ic33a92c2de42bd7a89786a4da26b7a648b25218d
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
7 years agoFetchCommand: pass on CredentialsProvider to submodule fetches 37/103737/2
Thomas Wolf [Sun, 27 Aug 2017 13:35:35 +0000 (15:35 +0200)]
FetchCommand: pass on CredentialsProvider to submodule fetches

When a JGit API command is implemented in terms of other API
commands, the child command must "inherit" all relevant settings.
Calling configure() ensures that the CredentialsProvider and the
connection timeout are propagated correctly.

Bug: 515325
Change-Id: I948e306693a9edb7b199a735877413b6eddcfba4
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoExclude file matching: fix backtracking on match failures after ** 27/103027/6
Thomas Wolf [Sun, 13 Aug 2017 13:08:16 +0000 (15:08 +0200)]
Exclude file matching: fix backtracking on match failures after **

** matching always tries the empty match first. If a mismatch occurs
later, the ** must be extended by exactly one segment and matching must
resume with the matcher following the ** matcher.

Bug: 520920
Change-Id: Id019ad1c773bd645ae92e398021952f8e961f45c
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoFix path pattern matching to work also for gitattributes 21/103021/9
Thomas Wolf [Sat, 12 Aug 2017 19:51:52 +0000 (21:51 +0200)]
Fix path pattern matching to work also for gitattributes

Path pattern matching for attribute rules is different than matching
for excluded files.

The first difference concerns patterns without slashes. For
gitattributes those must match on the last component only, not on
any earlier segment. This is true also for directory-only patterns.

The second difference concerns directory-only patterns. Those also
must not match on a prefix or segment except the last one. They do
not apply recursively to all files beneath.

And third, matches only on a prefix must match for gitattributes
only if the last matcher was "/**".

Add a new parameter for such path matching to IMatcher.matches() and
pass it through as appropriate (false for gitignore, true for
gitattributes). As far as gitignore is concerned, there is no change.

New tests have been added, and some existing attribute matching tests
have been fixed since they operated on wrong assumptions.

Bug: 508568
Change-Id: Ie825dc2cac8a85a72a7eeb0abb888f3193d21dd2
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoAdd new tests for gitignore/gitattribute pattern matching 36/103036/3
Thomas Wolf [Mon, 14 Aug 2017 06:16:04 +0000 (08:16 +0200)]
Add new tests for gitignore/gitattribute pattern matching

These tests verify that JGit matches the same as C git, for
both attribute matching (.gitattributes) and file exclusion matching
(.gitignore). These tests work by setting up a test repository and
test rules, and then determine excluded files or attributes both with
JGit and with the native C git, and then compare the results.

For .gitignore tests, we run

  git ls-files --ignored --exclude-standard -o

and for attribute tests we use

  git check-attr --stdin --all

and pass the list of all files in the repository via stdin.

Change-Id: I5b40946e04ff4a97456be7dffe09374323b7c89d
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoIgnore invalid TagOpt values 47/103447/4
Thomas Wolf [Tue, 22 Aug 2017 11:23:10 +0000 (13:23 +0200)]
Ignore invalid TagOpt values

C git silently ignores invalid tagopt values; so make JGit behave the
same way.

Bug: 429625
Change-Id: I99587cc46c7e0c19348bcc63f602038fa9a7f378
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoAdd a getter for a list of RefSpecs to Config 23/103423/3
Thomas Wolf [Tue, 22 Aug 2017 07:02:31 +0000 (09:02 +0200)]
Add a getter for a list of RefSpecs to Config

Reading RefSpecs from a Config can be seen as another typed value
conversion, so add a getter to Config and to TypedConfigGetter. Use
it in RemoteConfig.

Doing this allows clients of the JGit library to customize the
handling of invalid RefSpecs in git config files by installing a
custom TypedConfigGetter.

Bug: 517314
Change-Id: I0ebc0f073fabc85c2a693b43f5ba5962d8a795ff
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoImprove getting typed values from a Config 02/103102/4
Thomas Wolf [Tue, 15 Aug 2017 12:52:44 +0000 (14:52 +0200)]
Improve getting typed values from a Config

Make the handling of typed values somewhat configurable by using
a separate converter. The default converter is the same as before;
just the implementations of the getters were moved. They also still
raise IllegalArgumentException on invalid values as before.

The converter can be set globally via Config.setTypedConfigGetter(),
which EGit can use in its core Activator to plug in a variant that
catches the IllegalArgumentException, logs the problem, and then
returns the default value.

In this way the behavior for other users of the JGit library is
unchanged, while EGit can deal gracefully with invalid git configs.

Bug: 520978
Change-Id: Ie8f81d206e358b6cc57aa29b9d7ad2a5d34b86a1
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoFix unthrown exception errors in CloneCommandTest 28/103728/1
Matthias Sohn [Sat, 26 Aug 2017 07:08:16 +0000 (09:08 +0200)]
Fix unthrown exception errors in CloneCommandTest

The Eclipse compiler raises errors for unthrown exceptions declared to
be thrown by test methods introduced in 88e45399.

Change-Id: I0d91c89e1b20ceff52c38b759abf906cc94e9902
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoMerge "Fix JGit set core.fileMode to false by default instead of true for non Windows...
David Pursehouse [Sat, 26 Aug 2017 00:58:07 +0000 (20:58 -0400)]
Merge "Fix JGit set core.fileMode to false by default instead of true for non Windows OS."