]> source.dussan.org Git - jgit.git/log
jgit.git
6 years agoPrepare 5.0.0-SNAPSHOT builds 14/123114/1
Matthias Sohn [Tue, 22 May 2018 23:54:32 +0000 (01:54 +0200)]
Prepare 5.0.0-SNAPSHOT builds

Change-Id: Ie343ccf37f46168041046500a2e19acc80814cfe
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoJGit v5.0.0.201805221745-rc1 08/123108/1 v5.0.0.201805221745-rc1
Matthias Sohn [Tue, 22 May 2018 21:43:43 +0000 (23:43 +0200)]
JGit v5.0.0.201805221745-rc1

Change-Id: Ie2c35fab87f294b00f9754b07b60a848bf256b10
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge branch 'master' into stable-5.0 04/123104/1
Matthias Sohn [Tue, 22 May 2018 21:00:37 +0000 (23:00 +0200)]
Merge branch 'master' into stable-5.0

* master:
  DescribeCommand: Refactor to not use deprecated Repository#peel
  Repository: Deprecate #peel method
  Repository: Make #exactRef and #findRef final
  Skip ignored directories in FileTreeIterator
  Repository: Deprecate getTags method
  InfoRefsServlet: Refactor to not use deprecated methods
  RefAdvertiser: Add send(Collection<Ref>) and deprecate send(Map<String, Ref>)
  Remove deprecated Repository#notifyIndexChanged
  Implementors should override Repository#notifyIndexChanged(boolean)
  Revive Repository#notifyIndexChanged()
  Remove further unnecessary 'final' keywords
  Execute AdvertiseRefsHook only for protocol v0 and v1
  Add protocol v2 support in "jgit daemon"
  Teach UploadPack "ofs-delta" in "fetch"
  Teach UploadPack "include-tag" in "fetch"
  Avoid using #refs in UploadPack#sendPack
  FileRepository: Don't use deprecated RefDatabase#getRefs(String)
  BatchRefUpdate: Don't use deprecated RefDatabase#getRefs(String)

Change-Id: I16c5da62d09262d3f4070aa0f466dd6c8352b5ea
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoDescribeCommand: Refactor to not use deprecated Repository#peel 36/123036/1
David Pursehouse [Tue, 22 May 2018 03:08:08 +0000 (12:08 +0900)]
DescribeCommand: Refactor to not use deprecated Repository#peel

Change-Id: I76073ad62d1bc4fc21d8a1f5fc7eb92060a73baa
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoRepository: Deprecate #peel method 35/123035/2
David Pursehouse [Tue, 22 May 2018 02:27:30 +0000 (11:27 +0900)]
Repository: Deprecate #peel method

Callers should use getRefDatabase().peel(ref) instead since it
doesn't swallow the IOException.

Adapt all trivial callers to user the alternative.

DescribeCommand still uses the deprecated method and is not adapted in
this change since it will require more refactoring to add handling of
the IOException.

Change-Id: I14d4a95a5e0570548753b9fc5c03d024dc3ff832
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoRepository: Make #exactRef and #findRef final 34/123034/3
David Pursehouse [Tue, 22 May 2018 00:47:16 +0000 (09:47 +0900)]
Repository: Make #exactRef and #findRef final

This means less cognitive overhead for both implementors and callers,
since this way we can guarantee that they are always synonyms for
RefDatabase#exactRef and RefDatabase#findRef, respectively.

Change-Id: Ic8aeb52fc7ed65672f3f6cd1da39a66908d88baa
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoSkip ignored directories in FileTreeIterator 37/120337/3
Thomas Wolf [Tue, 27 Mar 2018 20:22:09 +0000 (22:22 +0200)]
Skip ignored directories in FileTreeIterator

Make FileTreeIterator not enter ignored directories by default. We
only need to enter ignored directories if we do some operation against
git, and there is at least one tracked file underneath an ignored
directory.

Walking ignored directories should be avoided as much as possible as
it is a potential performance bottleneck. Some projects have a lot of
files or very deep hierarchies in ignored directories; walking those
may be costly (especially so on Windows). See for instance also bug
500106.

Provide a FileTreeIterator.setWalkIgnoredDirectories() operation to
force the iterator to iterate also through otherwise ignored
directories. Useful for tests (IgnoreNodeTest, CGitIgnoreTest), or
to implement things like "git ls-files --ignored".

Add tests in DirCacheCheckoutTest, and amend IndexDiffTest to test a
little bit more.

Bug: 388582
Change-Id: I6ff584a42c55a07120a4369fd308409431bdb94a
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
6 years agoRepository: Deprecate getTags method 17/123017/3
David Pursehouse [Mon, 21 May 2018 23:34:53 +0000 (08:34 +0900)]
Repository: Deprecate getTags method

Callers should use getRefDatabase().getRefsByPrefix(R_TAGS) instead.

Adjust the tests accordingly.

Bug: 534731
Change-Id: Ib28ae365e42720268996ff46e34cae1745ad545c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoMerge changes Ibf6ee80d,I721db0f4,I7d014890
David Pursehouse [Mon, 21 May 2018 23:15:22 +0000 (19:15 -0400)]
Merge changes Ibf6ee80d,I721db0f4,I7d014890

* changes:
  Remove deprecated Repository#notifyIndexChanged
  Implementors should override Repository#notifyIndexChanged(boolean)
  Revive Repository#notifyIndexChanged()

6 years agoInfoRefsServlet: Refactor to not use deprecated methods 28/122728/4
David Pursehouse [Wed, 16 May 2018 03:07:34 +0000 (12:07 +0900)]
InfoRefsServlet: Refactor to not use deprecated methods

- Replace RefDatabase#getRefs(String) with #getRefsByPrefix(String)
- Replace RefAdvertiser#send(Map<String, Ref>) with #send(Collection<Ref>)

Bug: 534731
Change-Id: I25b617c3b0c54793cf4ab5b62f002e17745a5377
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoRefAdvertiser: Add send(Collection<Ref>) and deprecate send(Map<String, Ref>) 27/122727/4
David Pursehouse [Wed, 16 May 2018 03:03:02 +0000 (12:03 +0900)]
RefAdvertiser: Add send(Collection<Ref>) and deprecate send(Map<String, Ref>)

Bug: 534731
Change-Id: If15032a34dc62f420569e2b2b6d8e14e2dfed522
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoRemove deprecated Repository#notifyIndexChanged 72/122972/1
Jonathan Nieder [Fri, 18 May 2018 16:23:03 +0000 (09:23 -0700)]
Remove deprecated Repository#notifyIndexChanged

It is no longer used.

Change-Id: Ibf6ee80d5b6cd554295f4e657e087302770621b6

6 years agoImplementors should override Repository#notifyIndexChanged(boolean) 71/122971/1
Jonathan Nieder [Fri, 18 May 2018 16:16:16 +0000 (09:16 -0700)]
Implementors should override Repository#notifyIndexChanged(boolean)

Declare Repository#notifyIndexChanged() final and
Repository#notifyIndexChanged(boolean) abstract to force implementors
to switch to overriding the latter method.  This makes Repository less
error-prone to extend since implementors no longer need to remember to
override one of those two methods.

Change-Id: I721db0f4a4865db3b35212ee0a2045d5b31c96af
Signed-off-by: Jonathan Nieder <jrn@google.com>
6 years agoRevive Repository#notifyIndexChanged() 70/122970/1
Jonathan Nieder [Fri, 18 May 2018 16:15:30 +0000 (09:15 -0700)]
Revive Repository#notifyIndexChanged()

e9e150fdd24d (Store in IndexChangedEvent if it was caused by JGit
itself, 2018-05-13) modified Repository#notifyIndexChanged to take a
boolean argument to indicate whether the index change happened under
the current process's control or externally, for use by EGit.  In
other words, the function signature changed from

public abstract void notifyIndexChanged();

to

public abstract void notifyIndexChanged(boolean internal);

Callers outside JGit itself notifying a Repository about index changes
are expected to be rare, so this is not very disruptive to them.  In
most cases they would be notifying about changes that they made
themselves, so treating their notifyIndexChanged() calls as
notifyIndexChanged(true) should be relatively safe.

Implementors have the opposite problem: adding the new "abstract void
notifyIndexChanged(boolean)" method means they are obligated to
override it.  Add a default implementation that calls their existing
override of notifyIndexChanged() to make their migration easier.

The main downside is that authors of new Repository subclasses that
do not realize they need to override notifyIndexChanged would end up
with a default implementation which calls notifyIndexChanged(true),
in turn calling notifyIndexChanged() again and so on, resulting in
StackOverflowException.  Add an implementors' note to the class
Javadoc to avoid this issue.  A followup commit will force
implementors to adapt to the new API by changing the methods to

@Deprecated
public final void notifyIndexChanged() {
notifyIndexChanged(true);
}

public abstract void notifyIndexChanged(boolean internal);

Change-Id: I7d014890ee19abf283ea824d9baa9044bfdde130
Signed-off-by: Jonathan Nieder <jrn@google.com>
6 years agoRemove further unnecessary 'final' keywords 88/122788/2
Han-Wen Nienhuys [Wed, 16 May 2018 14:34:16 +0000 (16:34 +0200)]
Remove further unnecessary 'final' keywords

Remove it from

 * package private functions.

 * try blocks

 * for loops

this was done with the following python script:

$ cat f.py
import sys
import re
import os

def replaceFinal(m):
  return m.group(1) + "(" +  m.group(2).replace('final ', '') + ")"

methodDecl = re.compile(r"^([\t ]*[a-zA-Z_ ]+)\(([^)]*)\)")

def subst(fn):
  input = open(fn)
  os.rename(fn, fn + "~")

  dest = open(fn, 'w')
  for l in input:
    l = methodDecl.sub(replaceFinal, l)
    dest.write(l)
  dest.close()

for root, dirs, files in os.walk(".", topdown=False):
  for f in files:
    if not f.endswith('.java'):
      continue

    full = os.path.join(root, f)
    print full
    subst(full)

Change-Id: If533a75a417594fc893e7c669d2c1f0f6caeb7ca
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
6 years agoExecute AdvertiseRefsHook only for protocol v0 and v1 26/122726/3
Masaya Suzuki [Mon, 14 May 2018 21:13:11 +0000 (14:13 -0700)]
Execute AdvertiseRefsHook only for protocol v0 and v1

Refs are not advertised as part of the protocol v2 capability
advertisement. Don't call AdvertiseRefsHook.

Noticed because many implementations of AdvertiseRefsHook read all
refs in order to call UploadPack#setAdvertisedRefs, causing the
capability advertisement to be as slow as a v0 ref advertisement with
some RefDatabase implementations.

Such an AdvertiseRefsHook is of dubious utility (a better place to
determine which refs are advertised is in the RefDatabase
implementation itself, as in Gerrit), but at any rate since it's not
bringing about any benefit here, we can skip the hook call.

TODO:
- call an appropriate hook instead (https://bugs.eclipse.org/534847)
- add tests

[jn: fleshed out commit message; added TODO notes]

Change-Id: I6eb60ccfb251a45432954467a9ae9c1079a8c8b5
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
6 years agoAdd protocol v2 support in "jgit daemon" 54/119454/14
Jonathan Tan [Sat, 24 Feb 2018 00:55:03 +0000 (16:55 -0800)]
Add protocol v2 support in "jgit daemon"

With this patch, a server spawned by "jgit daemon" can be accessed using
protocol v2 from a Git client that supports it (for example, "git" with
the appropriate patches). This is only activated if the repository's
config has "protocol.version" be 2.

This required a change to the package-private #execute methods in
DaemonService to allow passing of extra parameters.

This has been tested with a patched Git.

Change-Id: Icf043efec7ce956d72b075fc6dc7a87d5a2da82a
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
6 years agoTeach UploadPack "ofs-delta" in "fetch" 53/119453/14
Jonathan Tan [Tue, 13 Mar 2018 20:29:46 +0000 (13:29 -0700)]
Teach UploadPack "ofs-delta" in "fetch"

Add support for the "ofs-delta" parameter in the "fetch" command in
the fetch-pack/upload-pack protocol v2.

Change-Id: I728cf986082fce4ddeb6a6435897692e15e60cc7
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
6 years agoTeach UploadPack "include-tag" in "fetch" 52/119452/14
Jonathan Tan [Tue, 13 Mar 2018 18:07:36 +0000 (11:07 -0700)]
Teach UploadPack "include-tag" in "fetch"

Add support for the "include-tag" parameter in the "fetch" command in
the fetch-pack/upload-pack protocol v2.

In order to determine which tags to include, only objects pointed to by
refs starting with "refs/tags/" are checked. This restriction is for
performance reasons and to match the behavior of Git (see add_ref_tag()
in builtin/pack-objects.c).

Change-Id: I7d70aa09bcc8a525218ff1559e286c2a610258ca
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
6 years agoAvoid using #refs in UploadPack#sendPack 04/121604/7
Jonathan Tan [Mon, 23 Apr 2018 20:03:04 +0000 (13:03 -0700)]
Avoid using #refs in UploadPack#sendPack

When OPTION_INCLUDE_TAG is set, UploadPack#sendPack uses the #refs
instance variable as a source of information of tags. A subsequent patch
will need to supply this information to #sendPack without
modifying #refs, so refactor #sendPack to take in this information
through a parameter instead.

Note that prior to this patch, #refs was used twice in #sendPack: once
to generate the argument to PackWriter#setTagTargets, and once to
determine if any tags need to be included in the packfile. This patch
only updates the latter use, since the former is meant not only for
"true" tag targets but any object that should be hoisted earlier during
packing (see the documentation of PackWriter#setTagTargets).

This patch does not introduce any functionality change.

Change-Id: I70ed65a1041334abeda8d4bac98cce7cae7efcdf
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
6 years agoPrepare 5.0.0-SNAPSHOT builds 24/122824/1
Matthias Sohn [Wed, 16 May 2018 20:23:51 +0000 (22:23 +0200)]
Prepare 5.0.0-SNAPSHOT builds

Change-Id: I65d7d74c6124507aa9cb2856c74db6a1a6935bab
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoJGit v5.0.0.201805151920-m7 23/122723/1 v5.0.0.201805151920-m7
Matthias Sohn [Tue, 15 May 2018 23:20:14 +0000 (01:20 +0200)]
JGit v5.0.0.201805151920-m7

Change-Id: I42eb046c8ac8537672010aabe21459293cb23838
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoFileRepository: Don't use deprecated RefDatabase#getRefs(String) 28/122628/2
David Pursehouse [Tue, 15 May 2018 04:41:15 +0000 (13:41 +0900)]
FileRepository: Don't use deprecated RefDatabase#getRefs(String)

Change-Id: Iec58c973537ddbe0f4e6b8b62fcda5cecc961661
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoBatchRefUpdate: Don't use deprecated RefDatabase#getRefs(String) 25/122625/3
David Pursehouse [Tue, 15 May 2018 00:56:32 +0000 (09:56 +0900)]
BatchRefUpdate: Don't use deprecated RefDatabase#getRefs(String)

Change-Id: I672c9cfe221ddc4acbde7a8040bd6ba83b16626e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoRemove 'final' in parameter lists 05/122605/3
Han-Wen Nienhuys [Mon, 14 May 2018 16:42:02 +0000 (18:42 +0200)]
Remove 'final' in parameter lists

Change-Id: Id924f79c8b2c720297ebc49bf9c5d4ddd6d52547
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
6 years agoFixup javadoc and formatting in RawText and RawParseUtils 97/122597/6
Han-Wen Nienhuys [Mon, 14 May 2018 15:21:39 +0000 (17:21 +0200)]
Fixup javadoc and formatting in RawText and RawParseUtils

Change-Id: I9d6002941a33ec204d29e4fd920dde965387bb24
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
6 years agoRawParseUtils#lineMap: Simplify by using null sentinel internally 00/122600/2
Jonathan Nieder [Mon, 14 May 2018 15:54:01 +0000 (08:54 -0700)]
RawParseUtils#lineMap: Simplify by using null sentinel internally

Add an internal lineMapOrNull helper that returns null when the file
is binary.

This is simpler than using an exception for control flow and avoids
having to override fillInStackTrace to avoid a performance regression.

Change-Id: Ib8bb8df6a6bbd60c62cfb3b4c484a962a98b7507

6 years agoStore in IndexChangedEvent if it was caused by JGit itself 48/122548/2
Matthias Sohn [Sun, 13 May 2018 19:37:21 +0000 (21:37 +0200)]
Store in IndexChangedEvent if it was caused by JGit itself

This allows to differentiate if index was changed by an external git
command or by JGit itself.

Change-Id: Iae692ba7d9bf01a288b3fb2dc2d07aec9891c712
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoIntroduce new RawText constructor and RawParseUtils.lineMapOrBinary 82/121382/6
Han-Wen Nienhuys [Wed, 18 Apr 2018 21:37:25 +0000 (23:37 +0200)]
Introduce new RawText constructor and RawParseUtils.lineMapOrBinary

This makes binary detection exact in ResolveMerger and DiffFormatter

This has the same intention as
Id4342a199628d9406bfa04af1b023c27a47d4014 but preserves backward
compatibility of the signature of RawParseUtils.lineMap.

Change-Id: Ia24a4e716592bab3363ae24e3a46315a7511154f
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoUse a secure random generator to seed nonce for digest authentication 76/122476/1
Matthias Sohn [Fri, 11 May 2018 12:06:53 +0000 (14:06 +0200)]
Use a secure random generator to seed nonce for digest authentication

https://tools.ietf.org/html/rfc7616 says:

5.12.  Parameter Randomness

The security of this protocol is critically dependent on the
randomness of the randomly chosen parameters, such as client and
server nonces.  These should be generated by a strong random or
properly seeded pseudorandom source (see [RFC4086]).

Change-Id: I4da5316cb1eb3f59ae06c070ce1c3335e9ee87d6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge branch 'stable-4.11' 94/122394/3
Matthias Sohn [Thu, 10 May 2018 11:41:45 +0000 (13:41 +0200)]
Merge branch 'stable-4.11'

* stable-4.11:
  Retry stale file handles on .git/config file

Change-Id: I4fe6152c3c40dde9cb88913cc9706852de0fd712
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge branch 'stable-4.10' into stable-4.11 11/122411/1
Matthias Sohn [Thu, 10 May 2018 10:55:30 +0000 (12:55 +0200)]
Merge branch 'stable-4.10' into stable-4.11

* stable-4.10:
  Retry stale file handles on .git/config file

Change-Id: Ice5c8ae8c2992243a81da77e166406bc1930fe0e

6 years agoMerge branch 'stable-4.9' into stable-4.10 01/122401/1
Matthias Sohn [Thu, 10 May 2018 10:51:57 +0000 (12:51 +0200)]
Merge branch 'stable-4.9' into stable-4.10

* stable-4.9:
  Retry stale file handles on .git/config file

Change-Id: I6db7256dbd1c71b23e1231809642ca21e996e066
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge branch 'stable-4.8' into stable-4.9 00/122400/1
Matthias Sohn [Thu, 10 May 2018 10:30:05 +0000 (12:30 +0200)]
Merge branch 'stable-4.8' into stable-4.9

* stable-4.8:
  Retry stale file handles on .git/config file

Change-Id: Ib029b5536c038190626e7a7ff43b70f0a5673721

6 years agoMerge branch 'stable-4.7' into stable-4.8 99/122399/1
Matthias Sohn [Thu, 10 May 2018 10:08:46 +0000 (12:08 +0200)]
Merge branch 'stable-4.7' into stable-4.8

* stable-4.7:
  Retry stale file handles on .git/config file

Change-Id: Ib665c094b28eefb8236752bb273de0c2d9bf9578

6 years agoMerge branch 'stable-4.6' into stable-4.7 98/122398/1
Matthias Sohn [Thu, 10 May 2018 09:59:56 +0000 (11:59 +0200)]
Merge branch 'stable-4.6' into stable-4.7

* stable-4.6:
  Retry stale file handles on .git/config file

Change-Id: If5a21d38224528edfc551b3216daca6a2582e3ac

6 years agoMerge branch 'stable-4.5' into stable-4.6 95/122395/1
Matthias Sohn [Thu, 10 May 2018 09:39:52 +0000 (11:39 +0200)]
Merge branch 'stable-4.5' into stable-4.6

* stable-4.5:
  Retry stale file handles on .git/config file

Change-Id: Ib6e6ec0846c3ef261ec1016bfa6d26d2eadc3f26

6 years agoRetry stale file handles on .git/config file 73/120973/4
Nasser Grainawi [Fri, 6 Apr 2018 20:05:37 +0000 (14:05 -0600)]
Retry stale file handles on .git/config file

On a local non-NFS filesystem the .git/config file will be orphaned if
it is replaced by a new process while the current process is reading the
old file. The current process successfully continues to read the
orphaned file until it closes the file handle.

Since NFS servers do not keep track of open files, instead of orphaning
the old .git/config file, such a replacement on an NFS filesystem will
instead cause the old file to be garbage collected (deleted).  A stale
file handle exception will be raised on NFS clients if the file is
garbage collected (deleted) on the server while it is being read.  Since
we no longer have access to the old file in these cases, the previous
code would just fail. However, in these cases, reopening the file and
rereading it will succeed (since it will open the new replacement file).
Since retrying the read is a viable strategy to deal with stale file
handles on the .git/config file, implement such a strategy.

Since it is possible that the .git/config file could be replaced again
while rereading it, loop on stale file handle exceptions, up to 5 extra
times, trying to read the .git/config file again, until we either read
the new file, or find that the file no longer exists. The limit of 5 is
arbitrary, and provides a safe upper bounds to prevent infinite loops
consuming resources in a potential unforeseen persistent error
condition.

Change-Id: I6901157b9dfdbd3013360ebe3eb40af147a8c626
Signed-off-by: Nasser Grainawi <nasser@codeaurora.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMark CrissCrossMergeTest as flaky 63/122063/4
Jonathan Nieder [Wed, 2 May 2018 22:23:31 +0000 (15:23 -0700)]
Mark CrissCrossMergeTest as flaky

It often fails on my machine, both in maven and bazel.

This patch marks the test flaky[1] in bazel so that "bazel test" can
run it a few times before declaring failure.

[1] https://docs.bazel.build/versions/master/be/common-definitions.html#test.flaky

Bug: 534285
Change-Id: Ibe5414fefbffe4e8f86af7047608d51cf5df5c47

6 years agoMerge "Add API filter for "non-API type FileRepository" in tests"
Matthias Sohn [Sat, 5 May 2018 23:44:26 +0000 (19:44 -0400)]
Merge "Add API filter for "non-API type FileRepository" in tests"

6 years agoAdd API filter for "non-API type FileRepository" in tests 35/121035/3
David Pursehouse [Thu, 12 Apr 2018 01:53:29 +0000 (10:53 +0900)]
Add API filter for "non-API type FileRepository" in tests

Change-Id: If805ad4a962e48dd16fbc7eff915fd6539839933
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoReplace http://errorprone.info with https://errorprone.info 13/122213/1
Jonathan Nieder [Fri, 4 May 2018 22:09:22 +0000 (15:09 -0700)]
Replace http://errorprone.info with https://errorprone.info

That site serves from https now.

Reported-by: Nicholas Glorioso <glorioso@google.com>
Change-Id: I2150a18425a1fe3ab5a022882ffe06ccbde17f16
Signed-off-by: Jonathan Nieder <jrn@google.com>
6 years agoBazel: Add a target to build jgit commandline tool 58/122058/2
Jonathan Nieder [Wed, 2 May 2018 21:34:21 +0000 (14:34 -0700)]
Bazel: Add a target to build jgit commandline tool

This works well enough for basic testing, especially the "jgit daemon"
command:

 $ bazel build org.eclipse.jgit.pgm:jgit
 INFO: Analysed target //org.eclipse.jgit.pgm:jgit (39 packages loaded).
 INFO: Found 1 target...
 Target //org.eclipse.jgit.pgm:jgit up-to-date:
   bazel-bin/org.eclipse.jgit.pgm/jgit.jar
   bazel-bin/org.eclipse.jgit.pgm/jgit
 INFO: Elapsed time: 15.862s, Critical Path: 14.74s
 INFO: 42 processes: 32 linux-sandbox, 1 local, 9 worker.
 INFO: Build completed successfully, 60 total actions
 $ bazel-bin/org.eclipse.jgit.pgm/jgit rev-list HEAD^..HEAD 2>/dev/null
 e5ed926e02dd29b5e970d421b63b6921cc1800f5

Still to do:

 - suppress "Failed to load class "org.slf4j.impl.StaticLoggerBinder"
   output
 - add org.eclipse.jgit.pgm.test tests to bazel build
 - supply package information so that "jgit version" can work

Change-Id: Ie89872839fa5aae974d5d39b6776b96332b0e83f

6 years agossh: Kill the external process when we're done instead of waiting forever 02/115802/7
Carsten Pfeiffer [Wed, 2 May 2018 15:40:30 +0000 (17:40 +0200)]
ssh: Kill the external process when we're done instead of waiting forever

Bug: 529463
Change-Id: Iaf6fe20a1c759ac5e91a2393d7bc40a94f859e84
Signed-off-by: Carsten Pfeiffer <carsten.pfeiffer@gebit.de>
6 years agoRename RefDatabase#getAllRefs to getRefs 16/121916/2
Jonathan Nieder [Mon, 30 Apr 2018 00:15:18 +0000 (17:15 -0700)]
Rename RefDatabase#getAllRefs to getRefs

This is easier to type and makes it clearer that it only returns refs
and not the pseudo-refs returned by getAdditionalRefs. It also puts us
in a better position to add a method to the Repository class later
that delegates to this one without colliding with the existing
Repository#getAllRefs method that returns a Map<String, Ref>.

While at it, clarify the javadoc of getRefs and hasRefs to make the
same point.

Suggested-by: David Pursehouse <david.pursehouse@gmail.com>
Change-Id: I23497c66ac7b5e0c987b91efbc9e9cc29924ca66
Signed-off-by: Jonathan Nieder <jrn@google.com>
6 years agoRefDatabase: add hasRefs convenience method 02/121902/2
David Pursehouse [Fri, 27 Apr 2018 12:49:08 +0000 (21:49 +0900)]
RefDatabase: add hasRefs convenience method

Callers can now say:

 db.getRefDatabase().hasRefs()

rather than the more verbose:

 !db.getRefDatabase().getAllRefs().isEmpty()

The default implementation simply uses getAllRefs().isEmpty(), but a
derived class could possibly override the method with a more efficient
implementation.

Change-Id: I5244520708a1a7d9adb351f10e43fc39d98e22a1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoFix comparison order in AnyObjectId 99/121899/1
David Turner [Fri, 27 Apr 2018 19:04:18 +0000 (15:04 -0400)]
Fix comparison order in AnyObjectId

The previous version suggested testing w2 first because w1 was used
for hashing, but in fact, hashCode returns w2.  The order (w3, w4, w5,
w1, w2) might be better on 64-bit processors too, since it allows
comparing 64 bits at a time, although perhaps on a modern SIMD
processor, the entire 160 bytes would be compared at once anyway.

Change-Id: Ieb69606d3c1456aeff36bffe99a71587ea76e977
Signed-off-by: David Turner <dturner@twosigma.com>
6 years agoRefDatabase: Introduce getAllRefs method 27/121827/2
David Pursehouse [Fri, 27 Apr 2018 01:42:53 +0000 (10:42 +0900)]
RefDatabase: Introduce getAllRefs method

Currently to get all refs, callers must use:

  getRefsByPrefix(ALL)

Introduce getAllRefs, which does this, and migrate all existing
callers of getRefsByPrefix(ALL).

Change-Id: I7b1687c162c8ae836dc7db3ccc7ac847863f691d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoRefDatabase: Update Javadoc for ALL constant 26/121826/1
David Pursehouse [Fri, 27 Apr 2018 01:12:32 +0000 (10:12 +0900)]
RefDatabase: Update Javadoc for ALL constant

The Javadoc refers to the deprecated getRefs method. Update it to refer
to getRefsByPrefix which is the recommended replacement of getRefs.

Change-Id: I61f2abcf1a3794f40a1746317dbc18aa0beb87a7
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoLargePackedWholeObject#openStream: Suppress resource warning 25/121825/1
David Pursehouse [Thu, 26 Apr 2018 23:27:30 +0000 (08:27 +0900)]
LargePackedWholeObject#openStream: Suppress resource warning

Eclipse warns that DfsReader should be managed by try-with-resource.

As described in 1484d6e (LargePackedWholeObject: Do not reuse released
inflater, 2018-04-26), the DfsReader is owned and closed by the
PackInputStream or explicitly closed in the try block's finally.

Suppress the warning with a brief explanatory comment.

Change-Id: I4187c935742072f3ee7f2d3551a6a98d40fc2702
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoLargePackedWholeObject: Do not reuse released inflater 24/121824/2
Jonathan Nieder [Thu, 26 Apr 2018 22:14:50 +0000 (15:14 -0700)]
LargePackedWholeObject: Do not reuse released inflater

LargePackedWholeObject.openStream produces a stream that allows
reading a large object.  This stream holds a DfsReader that takes care
of caching delta bases etc and in particular holds zlib Inflater for
use while reading the each delta in the packfile.

At DfsReader creation time, the Inflater is acquired from a global
InflaterCache to avoid initialization overhead in case there is an
existing Inflater available for reuse.  When done with the Inflater,
the DfsReader is responsible for returning it to the cache for reuse.
The DfsReader is AutoClosable to remind the caller to close it and
release the Inflater when finished with it.

b0ac5f9c8907a4034612543a92eb465e88a9c6f2 (LargePackedWholeObject:
Refactor to open DfsReader in try-with-resource, 2018-04-11) tried to
clarify the lifetime of the DfsReader but was too aggressive: when
this function returns, PackInputStream owns the DfsReader and is
already going to release it.  Worse, the returned InflaterInputStream
holds a reference to the DfsReader's inflater, making releasing the
DfsReader not only unnecessary but unsafe.

The Inflater gets released into the InflaterCache's pool, to be
acquired by another caller that uses it concurrently with the
InflaterInputStream.  This results in errors, such as

 java.util.zip.ZipException: incorrect header check
        at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164)
        at java.util.zip.InflaterInputStream.skip(InflaterInputStream.java:208)
        at java.io.BufferedInputStream.skip(BufferedInputStream.java:377)

and

 java.util.zip.DataFormatException: incorrect header check
        at java.util.zip.Inflater.inflateBytes(Native Method)
        at java.util.zip.Inflater.inflate(Inflater.java:259)
        at org.eclipse.jgit.internal.storage.dfs.DfsReader.inflate(DfsReader.java:783)
        at org.eclipse.jgit.internal.storage.dfs.DfsPackFile.decompress(DfsPackFile.java:420)
        at org.eclipse.jgit.internal.storage.dfs.DfsPackFile.load(DfsPackFile.java:767)

and

 Caused by: java.util.zip.ZipException: incorrect header check
        at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
        at org.eclipse.jgit.lib.ObjectStream$Filter.read(ObjectStream.java:219)
        at org.eclipse.jgit.util.IO.readFully(IO.java:233)
        at org.eclipse.jgit.transport.PackParser.checkObjectCollision(PackParser.java:1173)

Verified in production.  It should be possible to make a
straightforward unit test for this using the InflaterCache state but
that can wait for a followup commit.

Change-Id: Iaf1d6fd368b64f76c520d215fd270a6098a1f236

6 years agoUse eclipse compiler in Maven build 00/121700/5
Matthias Sohn [Wed, 25 Apr 2018 01:09:05 +0000 (03:09 +0200)]
Use eclipse compiler in Maven build

Found instructions for configuring maven-compiler-plugin with ecj in
[1]. Verified that ecj run in this way raises build errors when executed
on commit d3ef5213.

Define profiles "ecj" for using Eclipse compiler and "javac" for using
javac including errorprone. By default ecj will be used.

use ecj:
$ mvn -Pecj clean install

use javac:
$ mvn -Pjavac clean install

TODO: find out how to run ecj with errorprone from Maven.

[1] https://stackoverflow.com/questions/33164976/using-eclipse-java-compiler-ecj-in-maven-builds

Change-Id: I716b603b57612b953e603387c82fd01eb1b5ca97
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoRemove trivial cases of using deprecated RefDatabase.getRefs() 99/121699/2
Matthias Sohn [Tue, 24 Apr 2018 23:44:43 +0000 (01:44 +0200)]
Remove trivial cases of using deprecated RefDatabase.getRefs()

Change-Id: I2d3e426a3391923f8a690ac68fcc33851f3eb419
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoSuppress boxing warning 98/121698/1
Matthias Sohn [Tue, 24 Apr 2018 23:08:58 +0000 (01:08 +0200)]
Suppress boxing warning

Change-Id: I90226674320841774ad691c84609e3fe71bf7852
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoRemove unnecessary semicolon 97/121697/1
Matthias Sohn [Tue, 24 Apr 2018 23:05:33 +0000 (01:05 +0200)]
Remove unnecessary semicolon

Change-Id: I3677ecb106ade209e756cec2c6f4232a416bfb44
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoFix non-externalized String warnings 96/121696/1
Matthias Sohn [Tue, 24 Apr 2018 23:05:13 +0000 (01:05 +0200)]
Fix non-externalized String warnings

- suppress warning for non-translatable texts
- externalize error messages

Change-Id: Ieba42219b2c0b51a288f5a60438a6cc4f9dfe641
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoRemove unused code and link to deprecated code 88/121688/3
Jonathan Tan [Tue, 24 Apr 2018 20:05:16 +0000 (13:05 -0700)]
Remove unused code and link to deprecated code

Eclipse reports these as errors, so remove them.

Change-Id: Ic53d8003f9faef38fe776af5a73794e7bb1dfc49
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
6 years agoFile compile and API errors in JGit 02/121602/3
Michael Keppler [Mon, 23 Apr 2018 20:00:27 +0000 (22:00 +0200)]
File compile and API errors in JGit

* Photon throws null analysis errors on the repeated invocation of those
previously null checked methods. Extract them to a local variable to
avoid this. (the null analysis is configured in project properties)
* setUseProtocolV2() misses @since tag. Problem was introduced with
332bc611249d21f9b604f2c0207bf0bdfbfc3a78. Might be caused by the long
delay of 2 months from creation to merging.

Change-Id: Ibbb1a1580b604b8e7cd4bf7edc4643e292b6b4a8
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
6 years agoMerge "Upgrade error_prone_core to 2.3.1"
Matthias Sohn [Mon, 23 Apr 2018 23:18:34 +0000 (19:18 -0400)]
Merge "Upgrade error_prone_core to 2.3.1"

6 years agoTeach UploadPack "no-progress" in "fetch" 51/119451/10
Jonathan Tan [Thu, 1 Mar 2018 23:45:19 +0000 (15:45 -0800)]
Teach UploadPack "no-progress" in "fetch"

Add support for the "no-progress" parameter in the "fetch" command in
the fetch-pack/upload-pack protocol v2.

Change-Id: I6a6d6b1534f44845254b81d0e1f5c4ba2ac3d10b
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
6 years agoTeach UploadPack "thin-pack" in "fetch" 50/119450/10
Jonathan Tan [Thu, 1 Mar 2018 22:24:16 +0000 (14:24 -0800)]
Teach UploadPack "thin-pack" in "fetch"

Add support for the "thin-pack" parameter in the "fetch" command in
the fetch-pack/upload-pack protocol v2.

Change-Id: I39a37b2b66a16929137d35c718a3acf2afb6b0b5
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
6 years agoTeach UploadPack basic "fetch" command 49/119449/11
Jonathan Tan [Fri, 23 Feb 2018 22:07:02 +0000 (14:07 -0800)]
Teach UploadPack basic "fetch" command

Add basic support for the "fetch" command in the fetch-pack/upload-pack
protocol v2. This patch teaches "have" and "done".

The protocol specification (Documentation/technical/protocol-v2.txt in
the Git project) states:

    want <oid>
Indicates to the server an object which the client wants to
retrieve.  Wants can be anything and are not limited to
advertised objects.

It is unspecified whether the server should respect the
uploadpack.allowtipsha1inwant option etc. when serving packfiles. This
patch is conservative in that the server respects them.

Change-Id: I3dbec172239712ef9286a15b8407e86b87ea7863
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
6 years agoTeach UploadPack "ref-prefix" in "ls-refs" 48/119448/10
Jonathan Tan [Thu, 22 Feb 2018 21:58:29 +0000 (13:58 -0800)]
Teach UploadPack "ref-prefix" in "ls-refs"

Add support for the "ref-prefix" parameter in the "ls-refs" command in
the fetch-pack/upload-pack protocol v2.

Change-Id: If9cf93b2646f75d50a11b5f482594f014d59a836
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
6 years agoUploadPack: Don't buffer ls-refs output 09/121509/2
Jonathan Nieder [Fri, 20 Apr 2018 23:34:15 +0000 (16:34 -0700)]
UploadPack: Don't buffer ls-refs output

Once we have read the user's entire command, there is no more need to
buffer our response --- even the strictest servlet engine allows
writing output once the input has been consumed.  Noticed when the
analogous code in the "fetch" command (introduced in a later patch)
overflowed its buffer:

 java.lang.OutOfMemoryError
        at java.io.ByteArrayOutputStream.hugeCapacity(ByteArrayOutputStream.java:123)
 [...]
        at org.eclipse.jgit.transport.UploadPack.sendPack(UploadPack.java:1905)
        at org.eclipse.jgit.transport.UploadPack.sendPack(UploadPack.java:1741)
        at org.eclipse.jgit.transport.UploadPack.fetchV2(UploadPack.java:1001)
        at org.eclipse.jgit.transport.UploadPack.serviceV2(UploadPack.java:1030)
        at org.eclipse.jgit.transport.UploadPack.upload(UploadPack.java:726)
        at org.eclipse.jgit.http.server.UploadPackServlet.doPost(UploadPackServlet.java:195)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

Change-Id: I33df56f1cb1c6c2c25ee95426cb7ad665134ac6b

6 years agoImplement ls-refs in UploadPack 47/119447/10
Jonathan Tan [Thu, 22 Feb 2018 18:24:19 +0000 (10:24 -0800)]
Implement ls-refs in UploadPack

Implement support for Git protocol v2's "ls-refs" command and its
"symrefs" and "peel" parameters.

This adds support for this command to UploadPack but the git://,
ssh://, and git:// transports do not make use of it yet.  That will
have to wait for later patches.

Change-Id: I8abc6bcc6ed4a88c165677ff1245625aca01267b
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
6 years agoUpgrade error_prone_core to 2.3.1 00/121400/2
David Pursehouse [Thu, 19 Apr 2018 10:16:11 +0000 (12:16 +0200)]
Upgrade error_prone_core to 2.3.1

and plexus-compiler-javac-errorprone to 2.8.4.

Change-Id: I36487ce53e70b54d7a04292e666540224c107b43
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoImplement protocol v2 with no capabilities in UploadPack 06/121506/4
Jonathan Tan [Thu, 22 Feb 2018 18:24:19 +0000 (10:24 -0800)]
Implement protocol v2 with no capabilities in UploadPack

Add initial support for protocol v2 of the fetch-pack/upload-pack
protocol. This protocol is described in the Git project in
"Documentation/technical/protocol-v2.txt".

This patch adds support for protocol v2 (without any capabilities) to
UploadPack. Adaptations of callers to make use of this support will
come in subsequent patches.

[jn: split from a larger patch; tweaked the API to make UploadPack
 handle parsing the extra parameters and config instead of requiring
 each caller to do such parsing]

Change-Id: I79399fa0dce533fdc8c1dbb6756748818cee45b0
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
6 years agoPacketLineIn, PacketLineOut: Add support for delim-pkt 98/121498/2
Jonathan Tan [Thu, 22 Feb 2018 18:24:19 +0000 (10:24 -0800)]
PacketLineIn, PacketLineOut: Add support for delim-pkt

Most pkt-lines (data-pkts) have the form

pkt-len pkt-payload

where pkt-len is a string of 4 hexadecimal digits representing the
size in bytes of the pkt-line.  Since this size includes the size of
the pkt-len, no data-pkt has a length less than 4.

A pkt-line with a length field less than 4 can thus be used for
other purposes.  In Git protocol v1, the only such pkt-line was

flush-pkt = "0000"

which was used to mark the end of a stream.  Protocol v2 (see
Documentation/technical/protocol-v2.txt in git.git) introduces a
second special pkt-line type:

delim-pkt = "0001"

used to mark the end of a section within a stream, for example to
separate capabilities from the content of a command.

[jn: split out from a larger patch that made use of this support]

Change-Id: I10e7824fa24ed74c4f45624bd490bba978cf5c34
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
6 years agoAdd RefDatabase#getRefsByPrefix method 73/120873/4
Jonathan Tan [Fri, 6 Apr 2018 22:50:01 +0000 (15:50 -0700)]
Add RefDatabase#getRefsByPrefix method

The existing RefDatabase#getRefs abstract method (to be implemented by
ref database backends) has the following issues:

 - It returns a map with a key (the name of the ref with the prefix
   removed) which is potentially superfluous (it can be derived by the
   caller if need be) and confusing (in that the prefix is removed).
 - The prefix is required to end with a '/', but some backends (e.g.
   reftable) have fast search by prefix regardless of what the last
   character of the prefix is.

Add a new method #getRefsByPrefix that does not have these issues. This
is non-abstract with a default implementation that uses #getRefs (for
backwards compatibility), but ref database backends can reimplement it.

This also prepares for supporting "ref-prefix" in the "ls-refs" command
in the fetch-pack/upload-pack protocol v2, which does not require that
the prefix end with a '/'.

Change-Id: I4c92f852e8c1558095dd460b5fd7b602c1d82df1
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
6 years agoHandle Gerrit Change-Ids for merge commits 71/120871/4
Thomas Wolf [Fri, 6 Apr 2018 21:58:34 +0000 (23:58 +0200)]
Handle Gerrit Change-Ids for merge commits

Otherwise successful, non-conflicting merges will never get a
Gerrit Change-Id.

Bug: 358206
Change-Id: I9b599ad01d9f7332200c1d81a1ba6ce5ef990ab5
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
6 years agoPushProcess: Remove unused import of HashMap 08/121208/1
David Pursehouse [Mon, 16 Apr 2018 14:51:32 +0000 (16:51 +0200)]
PushProcess: Remove unused import of HashMap

Bug: 533621
Change-Id: Ie125818d5fc8fef5800108db2ca21151d8d3bfa3
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoConfigure WindowCache settings to use in JGit CLI 95/118595/3
Matthias Sohn [Sun, 4 Mar 2018 09:42:46 +0000 (10:42 +0100)]
Configure WindowCache settings to use in JGit CLI

Set the same defaults as in EGit.
Use mmap to map git packfiles into memory.

Change-Id: I7997b9123448a762192d7eeb55e01432549fba98
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge "Push: Ensure ref updates are processed in input order"
David Pursehouse [Fri, 13 Apr 2018 21:43:12 +0000 (17:43 -0400)]
Merge "Push: Ensure ref updates are processed in input order"

6 years agoMerge "Allow '@' as last character of ref"
Christian Halstrick [Fri, 13 Apr 2018 09:14:43 +0000 (05:14 -0400)]
Merge "Allow '@' as last character of ref"

6 years agoPush: Ensure ref updates are processed in input order 87/121087/4
Dave Borowitz [Thu, 12 Apr 2018 15:43:50 +0000 (11:43 -0400)]
Push: Ensure ref updates are processed in input order

Various places on the client side of the push were creating unordered
maps and sets of ref names, resulting in ReceivePack processing commands
in an order other than what the client provided. This is normally not
problematic for clients, who don't typically care about the order in
which ref updates are applied to the storage layer.

However, it does make it difficult to write deterministic tests of
ReceivePack or hooks whose output depends on the order in which commands
are processed, for example if informational per-ref messages are written
to a sideband.[1]

Add a test that ensures the ordering of commands both internally in
ReceivePack and in the output PushResult.

[1] Real-world example:
    https://gerrit-review.googlesource.com/c/gerrit/+/171871/1/javatests/com/google/gerrit/acceptance/git/PushPermissionsIT.java#149

Change-Id: I7f1254b4ebf202d4dcfc8e59d7120427542d0d9e

6 years agoAllow '@' as last character of ref 42/121042/1
Christian Halstrick [Thu, 12 Apr 2018 06:39:29 +0000 (08:39 +0200)]
Allow '@' as last character of ref

Previously @ was allowed e.g. in branch names, but not as the last
character. The case that @ is the last character was not handled.

Change-Id: Ic33870b22236f7a5ec7b54007f1b0cefd9354bfb

6 years agoDirCache: Use constant from StandardCharsets 96/120996/2
David Pursehouse [Wed, 11 Apr 2018 12:31:07 +0000 (21:31 +0900)]
DirCache: Use constant from StandardCharsets

Instead of hard-coding the encoding name, use the constant from
StandardCharsets. As a result it is no longer necessary to catch
the UnsupportedEncodingException.

Change-Id: I3cb6de921a78e05e2a894c220e0d5a5c85e172cc
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoUse Constants.CHARACTER_ENCODING in tests 82/120982/2
David Pursehouse [Wed, 11 Apr 2018 05:10:02 +0000 (14:10 +0900)]
Use Constants.CHARACTER_ENCODING in tests

Change-Id: Iba9fc991aee54fcb8b0dc5e5841da24c2d54dfc2
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoLargePackedWholeObject: Refactor to open DfsReader in try-with-resource 81/120981/2
David Pursehouse [Wed, 11 Apr 2018 04:59:00 +0000 (13:59 +0900)]
LargePackedWholeObject: Refactor to open DfsReader in try-with-resource

Change-Id: Ia9557e6c1ab230dbe2e94e025a49e93159d8658c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoDon't throw if a pre-push hook is ignored. 38/120438/3
Markus Duft [Thu, 29 Mar 2018 13:28:07 +0000 (15:28 +0200)]
Don't throw if a pre-push hook is ignored.

This breaks any scenario where native git (with LFS) clones a repository
(and thus installs the hook) and later on JGit is used to push changes.

Change-Id: I2a17753377265a0b612ba3451b9df63a577a1c38
Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
6 years agoMerge branch 'stable-4.11' 87/120887/1
David Pursehouse [Mon, 9 Apr 2018 07:40:37 +0000 (16:40 +0900)]
Merge branch 'stable-4.11'

* stable-4.11:
  LFS: Fix potential NPE in LfsPrePushHook

Change-Id: If721bd18035870541d216d2dcd9d47484e9af3e5
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoLFS: Fix potential NPE in LfsPrePushHook 54/119754/2
Markus Duft [Tue, 20 Mar 2018 07:40:14 +0000 (08:40 +0100)]
LFS: Fix potential NPE in LfsPrePushHook

The NPE occurred in conjunction with a symbolic ref (origin/HEAD).

Change-Id: I291636818a121ca00e0df25de5b6fc71a48d447f
Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
6 years agoSilence API error for ObjectIdSerializer.readWithoutMarker() 03/120303/2
Thomas Wolf [Tue, 27 Mar 2018 20:11:57 +0000 (22:11 +0200)]
Silence API error for ObjectIdSerializer.readWithoutMarker()

Change-Id: I99111797253b04148c42c83e1ef3d2cc383cc627
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
6 years agoMerge branch 'stable-4.11' 21/120221/2
Matthias Sohn [Mon, 26 Mar 2018 22:51:05 +0000 (00:51 +0200)]
Merge branch 'stable-4.11'

* stable-4.11:
  Remove package import for javax.servlet.http from org.eclipse.jgit
  Add missing @since tag and silence API error

Change-Id: I2783a15ead26ab19de31a8fb3bfb148ef19de91a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoRemove package import for javax.servlet.http from org.eclipse.jgit 20/120220/1
Matthias Sohn [Mon, 26 Mar 2018 22:33:00 +0000 (00:33 +0200)]
Remove package import for javax.servlet.http from org.eclipse.jgit

This package import is unused.

Change-Id: I9f202bb3162736a1ef8054516f1a3145d3a7bb9b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoAdd missing @since tag and silence API error 19/120219/1
Matthias Sohn [Mon, 26 Mar 2018 22:35:40 +0000 (00:35 +0200)]
Add missing @since tag and silence API error

These methods were introduced for 4.11.1 so we have to silence the API
error adding API in a service release raises.

Change-Id: Ic847cebbed439912d3979ec2ec1809f77a28f61e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoSignificantly speed up FileTreeIterator on Windows 18/120118/4
Thomas Wolf [Sun, 18 Mar 2018 22:29:59 +0000 (23:29 +0100)]
Significantly speed up FileTreeIterator on Windows

Getting attributes of files on Windows is an expensive operation.
Windows stores file attributes in the directory, so they are
basically available "for free" when a directory is listed. The
implementation of Java's Files.walkFileTree() takes advantage of
that (at least in the OpenJDK implementation for Windows) and
provides the attributes from the directory to a FileVisitor.

Using Files.walkFileTree() with a maximum depth of 1 is thus a
good approach on Windows to get both the file names and the
attributes in one go.

In my tests, this gives a significant speed-up of FileTreeIterator
over the "normal" way: using File.listFiles() and then reading the
attributes of each file individually. The speed-up is hard to
quantify exactly, but in my tests I've observed consistently 30-40%
for staging 500 files one after another, each individually, and up
to 50% for individual TreeWalks with a FileTreeIterator.

On Unix, this technique is detrimental. Unix stores file attributes
differently, and getting attributes of individual files is not costly.
On Unix, the old way of doing a listFiles() and getting individual
attributes (both native operations) is about three times faster than
using walkFileTree, which is implemented in Java.

Therefore, move the operation to FS/FS_Win32 and call it from
FileTreeIterator, so that we can have different implementations
depending on the file system.

A little performance test program is included as a JUnit test (to be
run manually).

While this does speed up things on Windows, it doesn't solve the basic
problem of bug 532300: the iterator always gets the full directory
listing and the attributes of all files, and the more files there are
the longer that takes.

Bug: 532300
Change-Id: Ic5facb871c725256c2324b0d97b95e6efc33282a
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
6 years agoTransportHttp: Refactor to use try-with-resource and suppress resource warning 37/119737/3
David Pursehouse [Tue, 20 Mar 2018 02:37:30 +0000 (11:37 +0900)]
TransportHttp: Refactor to use try-with-resource and suppress resource warning

Change-Id: I130269e7c5e46aea2152dea6b02539529208eea2
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoAdd missing @since tags for new API 36/120136/3
Matthias Sohn [Sat, 24 Mar 2018 21:05:53 +0000 (22:05 +0100)]
Add missing @since tags for new API

These methods were added after 4.11 so strictly speaking they violate
semantic versioning since new API requires increasing the minor version
number. Hence pretend these methods were introduced in 5.0

Change-Id: I7793ead16577dc1f2ddea09ba6b055103c783555
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoFix API problem filter warnings 37/120137/3
Matthias Sohn [Sat, 24 Mar 2018 21:14:15 +0000 (22:14 +0100)]
Fix API problem filter warnings

Silence warnings for bundles which haven't broken API since 4.11 but
we increased major version to 5 since we always use the same version
for all jgit bundles

Change-Id: If4f9a6aa4ef21f9b511946c5fc4bd7c0af6094c4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoRemove unused API problem filters 68/119468/2
David Pursehouse [Thu, 15 Mar 2018 06:46:54 +0000 (15:46 +0900)]
Remove unused API problem filters

Change-Id: I414ebba1db831686fd378dadcb7c4882eb323115
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoDfsInserter#openStream: Suppress resource warning about DfsReader 38/119738/3
David Pursehouse [Tue, 20 Mar 2018 02:43:15 +0000 (11:43 +0900)]
DfsInserter#openStream: Suppress resource warning about DfsReader

DfsReader is not opened in a try-with-resource because in the case where
the method returns an ObjectStream.Filter, the DfsReader should only be
closed from within the Filter's close() method.

Suppress the resource warning.

Change-Id: Ifcaf5e4a326bd1d03c6331b476c645ca43943b34
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoCloneCommand: Suppress resource warning about Repository 36/119736/2
David Pursehouse [Tue, 20 Mar 2018 02:28:18 +0000 (11:28 +0900)]
CloneCommand: Suppress resource warning about Repository

Repository is not opened in try-with-resource because it is wrapped
in a Git instance which should be closed by the caller. On exeptions
during fetch, it is explicitly closed in the catch blocks.

Suppress the warning with an explanatory comment.

Change-Id: Ib32c74ce39bb810077ab84db33002bdde806f3b6
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoRename RecursiveMergerTest and ResolveMergerTest to reduce confusion 60/119660/3
David Pursehouse [Mon, 19 Mar 2018 12:13:53 +0000 (21:13 +0900)]
Rename RecursiveMergerTest and ResolveMergerTest to reduce confusion

The class names imply that RecursiveMergerTest tests the RecursiveMerger
and ResolveMergerTest tests the ResolveMerger.

In fact, both of them include coverage of both strategies; the difference
is that RecursiveMergerTest is only testing criss-cross merges.

The tests cannot be combined into a single class because the criss-cross
test methods have additional data points.

Instead, rename the classes to more meaningful names.

Change-Id: I7ca8a03a3b7e351e2d4fcaca3b3186c098a3ca66
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoResolveMergerTest: Use @DataPoints instead of @DataPoint 59/119659/3
David Pursehouse [Mon, 19 Mar 2018 12:10:04 +0000 (21:10 +0900)]
ResolveMergerTest: Use @DataPoints instead of @DataPoint

Define strategiesUnderTest as an array of MergeStrategy using the
@DataPoints annotation, rather than two separate variables each
annotated as @DataPoint.

This makes the implementation consistent with RecursiveMergerTest.

Change-Id: I9f1d525b38cb59634ba054c7779dc4af1fc46e25
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoSubmoduleSyncCommand: Refactor to open Repository in try-with-resource 67/119467/5
David Pursehouse [Thu, 15 Mar 2018 06:43:13 +0000 (15:43 +0900)]
SubmoduleSyncCommand: Refactor to open Repository in try-with-resource

Change-Id: I502904ff7dbe074f7bbcb2a56a17bf4729f4f4d3
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoSubmoduleUpdateCommand: Refactor to open Repository in try-with-resource 66/119466/5
David Pursehouse [Thu, 15 Mar 2018 05:27:01 +0000 (14:27 +0900)]
SubmoduleUpdateCommand: Refactor to open Repository in try-with-resource

Change-Id: I1a303fdfdb6823043fa6751c43eaeaf678f2e64f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoTransportGitAnon: Suppress resource warning about Socket 64/119464/5
David Pursehouse [Thu, 15 Mar 2018 05:09:50 +0000 (14:09 +0900)]
TransportGitAnon: Suppress resource warning about Socket

Change-Id: Id1f5c0db4273324748a0ead2e6dac58d9114cf86
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoFS#runProcess: Fix OutputStream left unclosed after IOException 63/119463/6
David Pursehouse [Thu, 15 Mar 2018 04:44:00 +0000 (13:44 +0900)]
FS#runProcess: Fix OutputStream left unclosed after IOException

The runProcess method creates an OutputStream that is not managed by
a try-with-resource because it's manually closed and any IOException
raised by the close() method is explicitly ignored.

Suppress the resource warning with an explanatory comment.

Enclose the call to StreamGobbler#copy in an inner try-block, and move
the call to close() inside its finally block. This prevents the stream
from being left unclosed if StreamGobbler#copy raises IOException.

Change-Id: Idca9adfc4d87e0989d787ad8239c055c0c849814
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoMerge changes from topic 'If72b4b422-cleanup'
Jonathan Nieder [Fri, 23 Mar 2018 01:01:31 +0000 (21:01 -0400)]
Merge changes from topic 'If72b4b422-cleanup'

* changes:
  UploadPackTest: Fix name hiding introduced by If72b4b422
  Suppress non-localized string warnings introduced by If72b4b422