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

7 years agoMerge "Fix default directory set when setDirectory wasn't called."
David Pursehouse [Sat, 26 Aug 2017 00:57:52 +0000 (20:57 -0400)]
Merge "Fix default directory set when setDirectory wasn't called."

7 years agoFileMode: Remove unnecessary @SuppressWarnings("synthetic-access") 78/103678/2
David Pursehouse [Fri, 25 Aug 2017 08:03:28 +0000 (17:03 +0900)]
FileMode: Remove unnecessary @SuppressWarnings("synthetic-access")

In Eclipse Oxygen, the following warning is emitted:

  At least one of the problems in category 'synthetic-access' is not
  analysed due to a compiler option being ignored

Removing the suppression gets rid of the warning.

Change-Id: Ibfe5cc1e347150b699f54e2f204ab5ee770da202
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoAdd toString() methods to OpenSshConfig to help debugging 26/103726/2
Matthias Sohn [Fri, 25 Aug 2017 22:48:59 +0000 (00:48 +0200)]
Add toString() methods to OpenSshConfig to help debugging

Change-Id: I81b60a13a97e78d5ccd593ba8e4aa614df19f925
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoDo most %-token substitutions in OpenSshConfig 68/99068/4
Thomas Wolf [Sat, 10 Jun 2017 12:26:32 +0000 (14:26 +0200)]
Do most %-token substitutions in OpenSshConfig

Except for %p and %r and partially %C, we can do token substitutions
as defined by OpenSSH inside the config file parser. %p and %r can
be replaced only if specified in the config; if not, it would be the
caller's responsibility to replace them with values obtained from the
URI to connect to.

Jsch doesn't know about token substitutions at all. By doing the
replacements as good as we can in the config file parser, we can
make Jsch support most of these tokens.

%i is not handled at all as Java has no concept of a "user ID".

Includes unit tests.

Bug: 496170
Change-Id: If9d324090707de5d50c740b0d4455aefa8db46ee
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoLet Jsch know about ~/.ssh/config 67/99067/4
Thomas Wolf [Wed, 7 Jun 2017 16:39:19 +0000 (18:39 +0200)]
Let Jsch know about ~/.ssh/config

Ensure the Jsch instance used knows about ~/.ssh/config. This
enables Jsch to honor more user configurations (see
com.jcraft.jsch.Session.applyConfig()), in particular also the
UserKnownHostsFile configuration, or additional identities given
via multiple IdentityFile entries.

Turn JGit's OpenSshConfig into a full parser that can be a
Jsch-compliant ConfigRepository. This avoids a few bugs
in Jsch's OpenSSHConfig and keeps the JGit-facing interface
unchanged. At the same time we can supply a JGit OpenSshConfig
instance as a ConfigRepository to Jsch. And since they'll both
work from the same object, we can also be sure that the parsing
behavior is identical.

The parser does not handle the "Match" and "Include" keys, and it
doesn't do %-token substitutions (yet).

Note that Jsch doesn't handle multi-valued UserKnownHostFile
entries as known by modern OpenSSH.[1]

[1] http://man.openbsd.org/OpenBSD-current/man5/ssh_config.5

Additional tests for new features are provided in OpenSshConfigTest.

Bug: 490939
Change-Id: Ic683bd412fa8c5632142aebba4a07fad4c64c637
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoMerge "Consume request body before flushing the buffer"
Jonathan Nieder [Fri, 25 Aug 2017 23:31:05 +0000 (19:31 -0400)]
Merge "Consume request body before flushing the buffer"

7 years agoShow error message for non-git clients 22/103722/1
Masaya Suzuki [Fri, 25 Aug 2017 22:51:03 +0000 (15:51 -0700)]
Show error message for non-git clients

Change-Id: I56435d955348eb9acef6603d868f9add1c8781c9
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
7 years agoConsume request body before flushing the buffer 21/103721/2
Masaya Suzuki [Fri, 25 Aug 2017 22:05:45 +0000 (15:05 -0700)]
Consume request body before flushing the buffer

This is continuation from https://git.eclipse.org/r/#/c/94249/. When an
error happens, we might not read the entire stream. Consume the request
body before we flush the buffer.

Change-Id: Ia473a04ace600653b2d1f2822e3023570d992410
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
7 years agoFix default directory set when setDirectory wasn't called. 81/101581/11
Joan Goyeau [Mon, 24 Jul 2017 10:59:33 +0000 (11:59 +0100)]
Fix default directory set when setDirectory wasn't called.

Bug: 519883
Change-Id: I46716e9626b4c4adc0806a7c8df6914309040b94
Signed-off-by: Joan Goyeau <joan@goyeau.com>
7 years agoObjectToPack: Add missing @Override annotation 94/103594/1
David Pursehouse [Thu, 24 Aug 2017 07:20:11 +0000 (16:20 +0900)]
ObjectToPack: Add missing @Override annotation

Change-Id: I65ed7b89312d58ea816b46d27707ff907df1c78b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoCleanup: message reporting for HTTP redirect handling 14/103514/1
Thomas Wolf [Wed, 23 Aug 2017 09:50:05 +0000 (11:50 +0200)]
Cleanup: message reporting for HTTP redirect handling

The addition of "tooManyRedirects" in commit 7ac1bfc ("Do
authentication re-tries on HTTP POST") was an error I didn't
catch after rebasing that change. That message had been renamed
in the earlier commit e17bfc9 ("Add support to follow HTTP
redirects") to "redirectLimitExceeded".

Also make sure we always use the TransportException(URIish, ...)
constructor; it'll prefix the message given with the sanitized URI.
Change messages to remove the explicit mention of that URI inside the
message. Adapt tests that check the expected exception message text.

For the info logging of redirects, remove a potentially present
password component in the URI to avoid leaking it into the log.

Change-Id: I517112404757a9a947e92aaace743c6541dce6aa
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoDo authentication re-tries on HTTP POST 42/99442/10
Thomas Wolf [Fri, 16 Jun 2017 08:25:53 +0000 (10:25 +0200)]
Do authentication re-tries on HTTP POST

There is at least one git server out there (GOGS) that does
not require authentication on the initial GET for
info/refs?service=git-receive-pack but that _does_ require
authentication for the subsequent POST to actually do the push.

This occurs on GOGS with public repositories; for private
repositories it wants authentication up front.

Handle this behavior by adding 401 handling to our POST request.
Note that this is suboptimal; we'll re-send the push data at
least twice if an authentication failure on POST occurs. It
would be much better if the server required authentication
up-front in the GET request.

Added authentication unit tests (using BASIC auth) to the
SmartClientSmartServerTest:

- clone with authentication
- clone with authentication but lacking CredentialsProvider
- clone with authentication and wrong password
- clone with authentication after redirect
- clone with authentication only on POST, but not on GET

Also tested manually in the wild using repositories at try.gogs.io.
That server offers only BASIC auth, so the other paths
(DIGEST, NEGOTIATE, fall back from DIGEST to BASIC) are untested
and I have no way to test them.

* public repository: GET unauthenticated, POST authenticated
  Also tested after clearing the credentials and then entering a
  wrong password: correctly asks three times during the HTTP
  POST for user name and password, then gives up.
* private repository: authentication already on GET; then gets
  applied correctly initially to the POST request, which succeeds.

Also fix the authentication to use the credentials for the redirected
URI if redirects had occurred. We must not present the credentials
for the original URI in that case. Consider a malicious redirect A->B:
this would allow server B to harvest the user credentials for server
A. The unit test for authentication after a redirect also tests for
this.

Bug: 513043
Change-Id: I97ee5058569efa1545a6c6f6edfd2b357c40592a
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoreftable: explicitly store update_index per ref 31/103331/2
Shawn Pearce [Sat, 19 Aug 2017 18:28:34 +0000 (11:28 -0700)]
reftable: explicitly store update_index per ref

Add an update_index to every reference in a reftable, storing the
exact transaction that last modified the reference.  This is necessary
to fix some merge race conditions.

Consider updates at T1, T3 are present in two reftables.  Compacting
these will create a table with range [T1,T3].  If T2 arrives during
or after the compaction its impossible for readers to know how to
merge the [T1,T3] table with the T2 table.

With an explicit update_index per reference, MergedReftable is able to
individually sort each reference, merging individual entries at T3
from [T1,T3] ahead of identically named entries appearing in T2.

Change-Id: Ie4065d4176a5a0207dcab9696ae05d086e042140

7 years agoMerge changes Id3994e2d,I5e2a2868,I255af794
David Pursehouse [Fri, 18 Aug 2017 21:05:41 +0000 (17:05 -0400)]
Merge changes Id3994e2d,I5e2a2868,I255af794

* changes:
  LongObjectIdTest: Add back self comparison test
  Format BUILD files with buildifier
  Bazel: Add missing dependency in org.eclipse.jgit.http.test

7 years agoLongObjectIdTest: Add back self comparison test 65/103265/2
David Pursehouse [Thu, 17 Aug 2017 22:15:30 +0000 (23:15 +0100)]
LongObjectIdTest: Add back self comparison test

The test was removed in 4886621 to prevent a warning from
error-prone.

Add it back but rewrite it in a way that does not cause the
warning.

This reverts commit 4886621261c3b5fa2d9c75fd72d19ac186c9f970.

Change-Id: Id3994e2d882a9d08bf548b7778406f8a80fbf830
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoFormat BUILD files with buildifier 64/103264/2
David Pursehouse [Thu, 17 Aug 2017 22:22:11 +0000 (23:22 +0100)]
Format BUILD files with buildifier

Change-Id: I5e2a286866b63a8fa2bd29cc2fe432fab2bbe0af
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoBazel: Add missing dependency in org.eclipse.jgit.http.test 63/103263/2
David Pursehouse [Thu, 17 Aug 2017 22:21:22 +0000 (23:21 +0100)]
Bazel: Add missing dependency in org.eclipse.jgit.http.test

Change-Id: I255af794856371fdf1a1eceb6bca50a35b71b519
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoreftable: reserve standard PackExt 65/101365/26
Shawn Pearce [Mon, 17 Jul 2017 15:40:23 +0000 (08:40 -0700)]
reftable: reserve standard PackExt

Reserve "ref" extension for reftable files.  This allows them to be
used in a DFS repository as a stream in a DfsPackDescription.

Change-Id: Ife781bb64d0bb063333183ad2be70a41a2482513

7 years agoreftable: resolve symbolic references 50/101850/21
Shawn Pearce [Mon, 24 Jul 2017 16:01:55 +0000 (09:01 -0700)]
reftable: resolve symbolic references

resolve(Ref) helps callers recursively chase symbolic references and
is a useful function when wrapping a Reftable inside a RefDatabase, as
RefCursor does not resolve symbolic references during iteration.

Change-Id: I1ba143f403773497972e225dc92c35ecb989e154

7 years agoreftable: support threshold based compaction 24/101224/27
Shawn Pearce [Thu, 13 Jul 2017 18:24:13 +0000 (11:24 -0700)]
reftable: support threshold based compaction

Transactions may wish to merge several tables together as part of an
operation.  Setting a byte limit allows the transaction to consider
only some recent tables, bounding the cost of the compaction.

Change-Id: If037f2cbdc174ff1a215d5917178b33cde4ddaba

7 years agoreftable: compact merged tables 23/101223/27
Shawn Pearce [Thu, 13 Jul 2017 18:04:20 +0000 (11:04 -0700)]
reftable: compact merged tables

A compaction of reftables is just copying the results of a
MergedReftable into a ReftableWriter.  Wrap this up into a utility.

Change-Id: I6f5677d923e9628993a2d8b4b007a9b8662c9045

7 years agoreftable: merge-join reftables 22/101222/27
Shawn Pearce [Thu, 13 Jul 2017 17:44:24 +0000 (10:44 -0700)]
reftable: merge-join reftables

MergedReftable combines multiple reference tables together in a stack,
allowing higher/later tables to shadow earlier/lower tables.  This
forms the basis of a transaction system, where each transaction writes
a new reftable containing only the modified references, and readers
perform a merge on the fly to get the latest value.

Change-Id: Ic2cb750141e8c61a8b2726b2eb95195acb6ddc83

7 years agoreftable: lookup by ObjectId unit tests 75/101775/17
Shawn Pearce [Fri, 21 Jul 2017 19:40:33 +0000 (12:40 -0700)]
reftable: lookup by ObjectId unit tests

Change-Id: Ic819a04e285094e271435dcd027d8006e5897785

7 years agoreftable: reflog unit tests 13/101313/22
Shawn Pearce [Sat, 15 Jul 2017 21:58:04 +0000 (14:58 -0700)]
reftable: reflog unit tests

Change-Id: If719a63ead54ecbcaf7cbe12c71f00435706bc2b

7 years agoreftable: namespace unit tests 52/101152/24
Shawn Pearce [Wed, 12 Jul 2017 23:15:56 +0000 (16:15 -0700)]
reftable: namespace unit tests

Add additional test cases for looking up entries within a namespace
such as refs/heads/ or refs/tags/, where the seek is passed a name
that ends with '/'.

Change-Id: I5f944de7518cd0090374bddba48d4dd3955a8d72

7 years agoreftable: bulk operation unit tests 51/101151/24
Shawn Pearce [Wed, 12 Jul 2017 23:09:39 +0000 (16:09 -0700)]
reftable: bulk operation unit tests

Add more test cases that cover larger collections of
references, verifying every reference is accessible
both by scan and by seek.

Change-Id: Icada59fdcfc92a4634f6df61baaebb1c37b75d98

7 years agoreftable: basic functionality unit tests 50/101150/24
Shawn Pearce [Wed, 12 Jul 2017 22:05:22 +0000 (15:05 -0700)]
reftable: basic functionality unit tests

This set of tests covers primitive storage of an empty
file, and each type of supported reference.

Change-Id: I3bdff35cae8ae27283051932f20608b3ac353559

7 years agoreftable: debug tools 49/101149/24
Shawn Pearce [Wed, 12 Jul 2017 19:44:03 +0000 (12:44 -0700)]
reftable: debug tools

Simple debug programs to experiment with the reftable file format:

  debug-read-reftable
  debug-write-reftable
  debug-verify-reftable
  debug-benchmark-reftable

Change-Id: I79db351d86900f1e58b17e922e195dff06ee71f1

7 years agoreftable: scan and lookup reftable files 48/101148/24
Shawn Pearce [Wed, 12 Jul 2017 21:01:50 +0000 (14:01 -0700)]
reftable: scan and lookup reftable files

ReftableReader provides sequential scanning support over all
references, a range of references within a subtree (such as
"refs/heads/"), and lookup of a single reference.  Reads can be
accelerated by an index block, if it was created by the writer.

The BlockSource interface provides an abstraction to read from the
reftable's backing storage, supporting a future commit to connect
to JGit DFS and the DfsBlockCache.

Change-Id: Ib0dc5fa937d0c735f2a9ff4439d55c457fea7aa8

7 years agoreftable: create and write reftable files 47/101147/24
Shawn Pearce [Sun, 9 Jul 2017 17:38:24 +0000 (10:38 -0700)]
reftable: create and write reftable files

This is a simple writer to create reftable formatted files.  Follow-up
commits will add support for reading from reftable, debugging
utilities, and tests.

Change-Id: I3d520c3515c580144490b0b45433ea175a3e6e11

7 years agoreftable: file format documentation 74/101774/16
Shawn Pearce [Sat, 22 Jul 2017 17:12:32 +0000 (10:12 -0700)]
reftable: file format documentation

Some repositories contain a lot of references (e.g. android at 866k,
rails at 31k). The reftable format provides:

- Near constant time lookup for any single reference, even when the
  repository is cold and not in process or kernel cache.
- Near constant time verification a SHA-1 is referred to by at least
  one reference (for allow-tip-sha1-in-want).
- Efficient lookup of an entire namespace, such as `refs/tags/`.
- Support atomic push `O(size_of_update)` operations.
- Combine reflog storage with ref storage.

Change-Id: I29d0ff1eee475845660ac9173413e1407adcfbf2

7 years agoAdd support to follow HTTP redirects 61/46261/19
Thomas Wolf [Wed, 22 Apr 2015 15:05:12 +0000 (17:05 +0200)]
Add support to follow HTTP redirects

git-core follows HTTP redirects so JGit should also provide this.

Implement config setting http.followRedirects with possible values
"false" (= never), "true" (= always), and "initial" (only on GET, but
not on POST).[1]

We must do our own redirect handling and cannot rely on the support
that the underlying real connection may offer. At least the JDK's
HttpURLConnection has two features that get in the way:

* it does not allow cross-protocol redirects and thus fails on
  http->https redirects (for instance, on Github).
* it translates a redirect after a POST to a GET unless the system
  property "http.strictPostRedirect" is set to true. We don't want
  to manipulate that system setting nor require it.

Additionally, git has its own rules about what redirects it accepts;[2]
for instance, it does not allow a redirect that adds query arguments.

We handle response codes 301, 302, 303, and 307 as per RFC 2616.[3]
On POST we do not handle 303, and we follow redirects only if
http.followRedirects == true.

Redirects are followed only a certain number of times. There are two
ways to control that limit:

* by default, the limit is given by the http.maxRedirects system
  property that is also used by the JDK. If the system property is
  not set, the default is 5. (This is much lower than the JDK default
  of 20, but I don't see the value of following so many redirects.)
* this can be overwritten by a http.maxRedirects git config setting.

The JGit http.* git config settings are currently all global; JGit has
no support yet for URI-specific settings "http.<pattern>.name". Adding
support for that is well beyond the scope of this change.

Like git-core, we log every redirect attempt (LOG.info) so that users
may know about the redirection having occurred.

Extends the test framework to configure an AppServer with HTTPS support
so that we can test cloning via HTTPS and redirections involving HTTPS.

[1] https://git-scm.com/docs/git-config
[2] https://kernel.googlesource.com/pub/scm/git/git/+/6628eb41db5189c0cdfdced6d8697e7c813c5f0f
[3] https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

CQ: 13987
Bug: 465167
Change-Id: I86518cb76842f7d326b51f8715e3bbf8ada89859
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoMerge "Fix off-by-one error in Strings.count()"
Christian Halstrick [Wed, 16 Aug 2017 10:24:43 +0000 (06:24 -0400)]
Merge "Fix off-by-one error in Strings.count()"

7 years agoMerge "Use relative paths for attribute rule matching"
Christian Halstrick [Wed, 16 Aug 2017 10:24:33 +0000 (06:24 -0400)]
Merge "Use relative paths for attribute rule matching"

7 years agoSend a detailed event on working tree modifications 16/100916/8
Thomas Wolf [Fri, 7 Jul 2017 09:26:02 +0000 (11:26 +0200)]
Send a detailed event on working tree modifications

Currently there is no way to determine the precise changes done
to the working tree by a JGit command. Only the CheckoutCommand
actually provides access to the lists of modified, deleted, and
to-be-deleted files, but those lists may be inaccurate (since they
are determined up-front before the working tree is modified) if
the actual checkout then fails halfway through. Moreover, other
JGit commands that modify the working tree do not offer any way to
figure out which files were changed.

This poses problems for EGit, which may need to refresh parts of the
Eclipse workspace when JGit has done java.io file operations.

Provide the foundations for better file change tracking: the working
tree is modified exclusively in DirCacheCheckout. Make it emit a new
type of RepositoryEvent that lists all files that were modified or
deleted, even if the checkout failed halfway through. We update the
'updated' and 'removed' lists determined up-front in case of file
system problems to reflect the actual state of changes made.

EGit thus can register a listener for these events and then knows
exactly which parts of the Eclipse workspace may need to be refreshed.

Two commands manage checking out individual DirCacheEntries themselves:
checkout specific paths, and applying a stash with untracked files.
Make those two also emit such a new WorkingTreeModifiedEvent.

Furthermore, merges may modify files, and clean, rm, and stash create
may delete files.

CQ: 13969
Bug: 500106
Change-Id: I7a100aee315791fa1201f43bbad61fbae60b35cb
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoMerge branch 'stable-4.8' 77/103077/2
Matthias Sohn [Mon, 14 Aug 2017 22:25:41 +0000 (00:25 +0200)]
Merge branch 'stable-4.8'

* stable-4.8:
  Update Oxygen Orbit p2 repository to R20170516192513
  Fix exception handling for opening bitmap index files

Change-Id: Ica20f5aa0d8a365fe3317765b93520b3abd5d342
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoMerge branch 'stable-4.7' into stable-4.8 76/103076/2
Matthias Sohn [Mon, 14 Aug 2017 22:07:23 +0000 (00:07 +0200)]
Merge branch 'stable-4.7' into stable-4.8

* stable-4.7:
  Update Oxygen Orbit p2 repository to R20170516192513
  Fix exception handling for opening bitmap index files

Change-Id: I1e4fcf84506ff4316567bbb1713e84d8d196c2a1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoMerge branch 'stable-4.6' into stable-4.7 75/103075/2
Matthias Sohn [Mon, 14 Aug 2017 21:50:52 +0000 (23:50 +0200)]
Merge branch 'stable-4.6' into stable-4.7

* stable-4.6:
  Update Oxygen Orbit p2 repository to R20170516192513
  Fix exception handling for opening bitmap index files

Change-Id: I669fe48ce0034f9ea1977d38ee39099497422c1c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoMerge branch 'stable-4.5' into stable-4.6 74/103074/2
Matthias Sohn [Mon, 14 Aug 2017 21:37:44 +0000 (23:37 +0200)]
Merge branch 'stable-4.5' into stable-4.6

* stable-4.5:
  Fix exception handling for opening bitmap index files

Change-Id: Ifb511238e3e98b1bc9f79a990807b940a17ebaa6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoUpdate Oxygen Orbit p2 repository to R20170516192513 80/103080/1
Matthias Sohn [Mon, 14 Aug 2017 21:37:21 +0000 (23:37 +0200)]
Update Oxygen Orbit p2 repository to R20170516192513

Change-Id: I7f1b733ca414d77c9df5572df02e742e0a84ba2f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoFix exception handling for opening bitmap index files 98/102598/3
Christian Halstrick [Mon, 7 Aug 2017 12:26:46 +0000 (14:26 +0200)]
Fix exception handling for opening bitmap index files

When creating a new PackFile instance it is specified whether this pack
has an associated bitmap index file or not. This information is cached
and the public method getBitmapIndex() will always assume a bitmap index
file must exist if the cached data tells so. But it may happen that the
packfiles are repacked during a gc in a different process causing the
packfile, bitmap-index and index file to be deleted. Since JGit still
has an open FileHandle on the packfile this file is not really deleted
and can still be accessed. But index and bitmap index file are deleted.
Fix getBitmapIndex() to invalidate the cached packfile instance if such
a situation occurs.

This problem showed up when a gerrit server was serving repositories
which where garbage collected with native git regularly. Fetch and
clone commands for certain repositories failed permanently after a
native git gc had deleted old bitmap index files.

Change-Id: I8e620bec74dd3f310ba42024f9a657062f868f0e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoDo not apply pushInsteadOf to existing pushUris 54/103054/2
Thomas Wolf [Mon, 14 Aug 2017 14:09:29 +0000 (16:09 +0200)]
Do not apply pushInsteadOf to existing pushUris

Per the git config documentation[1], pushInsteadOf is ignored when
a remote has explicit pushUris.

Implement this, and adapt tests.

Up to now JGit mistakenly applied pushInsteadOf also to existing
pushUris. If some repositories had relied on this mis-feature,
pushes may newly suddenly fail (the uncritical case; the config
just needs to be fixed) or even still succeed but push to unexpected
places, namely to the non-rewritten pushUrls (the critical case).

The release notes should point out this change.

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

Bug: 393170
Change-Id: I38c83204d2ac74f88f3d22d0550bf5ff7ee86daf
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoRecord submodule paths with untracked changes as FileMode.GITLINK 79/102879/4
Thomas Wolf [Thu, 10 Aug 2017 13:03:22 +0000 (15:03 +0200)]
Record submodule paths with untracked changes as FileMode.GITLINK

Bug: 520702
Change-Id: I9bb48af9e8f1f2ce7968a82297c7c16f1237f987
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoFix handling of pushInsteadOf 35/99735/2
Thomas Wolf [Wed, 21 Jun 2017 09:40:04 +0000 (11:40 +0200)]
Fix handling of pushInsteadOf

According to [1], pushInsteadOf is

1. applied to the uris, not to the pushUris
2. ignored if a remote has an explicit pushUri

JGit applied it only to the pushUris. As a result, pushInsteadOf was
ignored for remotes having only a uri, but no pushUri.

This commit implements (1) if there are no pushUris. I did not dare
implement (2) because:

* there are explicit tests for it that expect that pushInsteadOf gets
  applied to existing pushUrls, and
* people may actually use and rely on this JGit behavior.

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

Bug: 393170
Change-Id: I6dacbf1768a105190c2a8c5272e7880c1c9c943a
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoMerge "Ensure EOL stream type is DIRECT when -text attribute is present"
Christian Halstrick [Mon, 14 Aug 2017 07:34:57 +0000 (03:34 -0400)]
Merge "Ensure EOL stream type is DIRECT when -text attribute is present"

7 years agoFix off-by-one error in Strings.count() 35/103035/1
Thomas Wolf [Mon, 14 Aug 2017 06:04:56 +0000 (08:04 +0200)]
Fix off-by-one error in Strings.count()

Change-Id: I0667b1624827d1cf0cc1b81f86c7bb44eafd68a7
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoRename extensions.refsStorage to refStorage 78/102578/5
Shawn Pearce [Sun, 6 Aug 2017 19:35:17 +0000 (12:35 -0700)]
Rename extensions.refsStorage to refStorage

This matches the proposal that has been discussed at length on
git-core mailing list and seems to be the accepted convention.

Change-Id: I9f6ab15144826893d1e2a4b48a2d657d6dd445ec

7 years agoEnsure EOL stream type is DIRECT when -text attribute is present 97/102997/2
Thomas Wolf [Fri, 11 Aug 2017 20:48:50 +0000 (22:48 +0200)]
Ensure EOL stream type is DIRECT when -text attribute is present

Otherwise fancy combinations of attributes (binary or -text in
combination with crlf or eol) may result in the corruption of binary
data.

Bug: 520910
Change-Id: I3ffc666c13d1b9d2ed987b69a67bfc7f42ccdbfc
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoUse relative paths for attribute rule matching 94/102994/3
Thomas Wolf [Fri, 11 Aug 2017 19:16:54 +0000 (21:16 +0200)]
Use relative paths for attribute rule matching

Attribute rules must match against the entry path relative to the
attribute node containing the rule. The global entry path is to be
used only for the init and the global node (and of course the root
node).

Bug: 520677
Change-Id: I80389a2dc272a72312729ccd5358d7c75e1ea20a
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoExpose LongMap in util package 77/102577/3
Shawn Pearce [Sat, 5 Aug 2017 00:16:02 +0000 (17:16 -0700)]
Expose LongMap in util package

This is a useful primitive collection type like IntList.

Change-Id: I04b9b2ba25247df056eb3a1725602f1be6d3b440

7 years agoNB: encode and decode 24-bit ints 93/102393/3
Shawn Pearce [Tue, 1 Aug 2017 15:49:33 +0000 (08:49 -0700)]
NB: encode and decode 24-bit ints

Change-Id: Ie036dc46e5a88a4e87dc52e880505bbe34601ca7

7 years agoUpdate thread-safety warning about Repository 87/102687/1
Shawn Pearce [Tue, 8 Aug 2017 13:44:35 +0000 (06:44 -0700)]
Update thread-safety warning about Repository

Change-Id: I1026a77cc688467d5a89a41121146f1bd3d56fa5

7 years agoReflogWriter: Minor cleanup 94/102394/2
Dave Borowitz [Tue, 1 Aug 2017 13:00:50 +0000 (09:00 -0400)]
ReflogWriter: Minor cleanup

Remove unnecessary finals, use consistent punctuation in Javadoc, reflow
some lines, etc.

Change-Id: Ic64db41c86917725ac649022290621406156bcc4

7 years agoEliminate SectionParser construction boilerplate 21/102421/1
Dave Borowitz [Wed, 2 Aug 2017 20:50:57 +0000 (16:50 -0400)]
Eliminate SectionParser construction boilerplate

Happily, most anonymous SectionParser implementations can be replaced
with FooConfig::new, as long as the constructor takes a single Config
arg. Many of these, the non-public ones, can in turn be inlined. A few
remaining SectionParsers can be lambdas.

Change-Id: I3f563e752dfd2007dd3a48d6d313d20e2685943a

7 years agoMerge changes Ia6c3935c,I46a29eae
David Pursehouse [Wed, 2 Aug 2017 07:12:16 +0000 (03:12 -0400)]
Merge changes Ia6c3935c,I46a29eae

* changes:
  Remove unused import introduced in a551b64
  Silence API errors caused by adding enum constants in dbb137e

7 years agoMerge "git ignore .DS_Store"
Matthias Sohn [Tue, 1 Aug 2017 21:30:00 +0000 (17:30 -0400)]
Merge "git ignore .DS_Store"

7 years agoMerge "git ignore all bazel folders"
Matthias Sohn [Tue, 1 Aug 2017 21:28:48 +0000 (17:28 -0400)]
Merge "git ignore all bazel folders"