]> source.dussan.org Git - jgit.git/log
jgit.git
8 years agoAdd the new class Attributes holding multiple Attribute(s) 01/60601/10
Ivan Motsch [Tue, 17 Nov 2015 12:32:20 +0000 (13:32 +0100)]
Add the new class Attributes holding multiple Attribute(s)

Attributes represents a semantic collector of Attribute(s) and replaces
the anonymous Map<String,Attribute>. This class will be returned by
TreeWalk.getAttributes(). It offers convenient access to the attributes
wrapped in the Attributes object. Adds preparations for a future
Attribute Macro Expansion

Change-Id: I8348c8c457a2a7f1f0c48050e10399b0fa1cdbe1
Signed-off-by: Ivan Motsch <ivan.motsch@bsiag.com>
8 years agoFix unit tests on Windows 03/61203/2
Christian Halstrick [Tue, 24 Nov 2015 14:16:42 +0000 (15:16 +0100)]
Fix unit tests on Windows

PushCommandTest and RunExternalScriptTest didn't succeed on Windows.
Fix this by expecting a simple line-feed as line ending (instead of the
platform dependent line separator. Additionally correct the computation
of expected URLs in PushCommandTest.

Change-Id: Idcdc41cd7e535ff88df33ea0a249333ed8fc91b0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoAdd missing @since tags and missing javadoc 00/61300/2
Matthias Sohn [Wed, 25 Nov 2015 23:32:37 +0000 (00:32 +0100)]
Add missing @since tags and missing javadoc

Change-Id: I8575797127fc96abea8af56f019ca39f5897486f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoFix HookTest when running on Win32_Cygwin 18/60918/3
Christian Halstrick [Fri, 20 Nov 2015 13:38:24 +0000 (14:38 +0100)]
Fix HookTest when running on Win32_Cygwin

This test expected that the test scripts emit a platform-dependent
newline (crlf on windows, lf on linux). But that's not true. Expected
result should always be a trailing "\n" because the test scripts
explicitly echo a "\n" in the end.

Change-Id: I604e08cda8cebe276b5214ba0f618b6112c3441f

8 years agoFix FS.runProcess() to close the InputStream 65/61165/2
Christian Halstrick [Tue, 24 Nov 2015 10:18:59 +0000 (11:18 +0100)]
Fix FS.runProcess() to close the InputStream

When FS.runProcess was called and an InputStream was given the method
tried to pump the whole InputStream to the process. When the method
ended the InputStream was not giving any data anymore. Consequently
close the InputStream inside the method.

Change-Id: I0ed738a775e5c977b21447d195acee1ecf5e2cb9

8 years agorepo: Do not use search path to find refs/remotes/origin/<branch> 53/60853/5
Jonathan Nieder [Thu, 19 Nov 2015 20:47:18 +0000 (12:47 -0800)]
repo: Do not use search path to find refs/remotes/origin/<branch>

When running from a non-bare repository, "jgit repo" checks whether
the rev passed in is a sha1 or branch name and in the latter case will
check out origin/<branch>.

We are expecting refs/remotes/origin/<branch>, but as a side effect of
using getRef we also end up looking for refs/origin/<branch>,
refs/heads/origin/<branch>, and so on.  Avoid that by using exactRef
instead.

Signed-off-by: Jonathan Nieder <jrn@google.com>
Change-Id: I670b2e48a88138a1f2104ea201baa958e9edbddb

8 years agoRepository: Introduce exactRef and findRef, deprecate getRef 74/49574/7
Jonathan Nieder [Fri, 5 Jun 2015 22:20:24 +0000 (15:20 -0700)]
Repository: Introduce exactRef and findRef, deprecate getRef

The Repository class provides only one method to look up a ref by
name, getRef.  If I request refs/heads/master and that ref does not
exist, getRef will look further in the search path:

 ref/refs/heads/master
 refs/heads/refs/heads/master
 refs/remotes/refs/heads/master

This behavior is counterintuitive, needlessly inexpensive, and usually
not what the caller expects.

Allow callers to specify whether to use the search path by providing
two separate methods:

- exactRef, which looks up a ref when its exact name is known
- findRef, which looks for a ref along the search path

For backward compatibility, keep getRef as a deprecated synonym for
findRef.

This change introduces findRef and exactRef but does not update
callers outside tests to use them yet.

Change-Id: I35375d942baeb3ded15520388f8ebb9c0cc86f8c
Signed-off-by: Jonathan Nieder <jrn@google.com>
8 years agoNull-annotated RefDatabase class 90/61290/1
Andrey Loskutov [Wed, 25 Nov 2015 20:19:05 +0000 (21:19 +0100)]
Null-annotated RefDatabase class

No other code changes except adding nullness annotations.

Change-Id: If2606fb208f6690bd4fd7ad953e709a3ebd6398c
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoNull-annotated Repository class and fixed related compiler errors 42/60442/7
Andrey Loskutov [Sun, 15 Nov 2015 22:59:41 +0000 (23:59 +0100)]
Null-annotated Repository class and fixed related compiler errors

org.eclipse.jgit.lib.Repository class is an example of the API which
should be written with Java 8 java.util.Optional<T> type. Unfortunately
this API is already released and widely used. The good clients are
currently doing their best with checking return values for null and bad
clients do not know how bad their code is.

I've tried not to change any logic and to be as less intrusive as
possible. Most of the JGit code was well prepared to this, only few
classes needed some smaller fixes.

This change fixes all compiler errors in JGit and replaces possible
NPE's with either appropriate exceptions, avoiding multiple "Nullable
return" method calls or early returning from the method.

Because annotating getDirectory() and getFS() as Nullable would cause
lot of additional changes in JGit and EGit they are postponed.

Change-Id: Ie8369d2c9c5fac5ce83b3b1b9bc217d7b55502a3
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoRaise error if FileNotFoundException is caught for an existing file 39/60939/5
Matthias Sohn [Fri, 20 Nov 2015 13:40:41 +0000 (14:40 +0100)]
Raise error if FileNotFoundException is caught for an existing file

File, FileInputStream and friends may throw FileNotFoundException even
if the file is existing e.g. when file permissions don't allow to access
the file content. In most cases this is a severe error we should not
suppress hence rethrow the FileNotFoundException in this case.

This may also fix bug 451508.

Bug: 451508
Change-Id: If4a94217fb5b7cfd4c04d881902f3e86193c7008
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoMerge "RefDirectory.getRef: Treat fake missing symrefs like real ones"
Jonathan Nieder [Tue, 24 Nov 2015 20:43:05 +0000 (15:43 -0500)]
Merge "RefDirectory.getRef: Treat fake missing symrefs like real ones"

8 years agoLet FS_Win32_Cygwin detect symlink support by creating temporary symlink 17/60917/2
Christian Halstrick [Fri, 20 Nov 2015 13:33:15 +0000 (14:33 +0100)]
Let FS_Win32_Cygwin detect symlink support by creating temporary symlink

The class FS_Win32 was always trying out to create a temporary symlink
in order to find out whether symlinks are supported. FS_Win32_Cygwin was
overwriting this method and always returned true. But when the user
running JGit does not have administrative rights then the creation of
symlinks is forbidden even if he is running on FS_Win32_Cygwin. A lot of
tests failed only on the Windows platform because of this. It was
correctly detected that FS_Win32_Cygwin is the filesystem abstraction to
be used but creation of symlinks always failed because of lacking
privileges of the user running the tests.

This fix teaches FS_Win32_Cygwin to behave like FS_Win32 and to test
whether symlinks can be created in order to find out whether symlinks
are supported.

Change-Id: Ie2394631ffc4c489bd37c3ec142ed44bbfcac726
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoFix classpath of test launch configurations 62/60762/3
Matthias Sohn [Wed, 18 Nov 2015 23:47:05 +0000 (00:47 +0100)]
Fix classpath of test launch configurations

Remove references to the bundle org.eclipse.jgit.java7 which was removed
in 4.0.

Change-Id: I85527eb2a34bb94979fdab1311043ae77a2b5ecd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoAvoid UnknownHostException in WalkEncryptionTest 87/60187/4
Matthias Sohn [Thu, 12 Nov 2015 10:28:01 +0000 (11:28 +0100)]
Avoid UnknownHostException in WalkEncryptionTest

Prevent that WalkEncryptionTest fails when it can't determine the public
IP address using http://checkip.amazonws.com. Also set timeouts when
determining IP address in order to prevent long wait times during tests.

Change-Id: I1d2fe09f99df2a5f75f8077811a72fb2271cdddb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoRemove no longer needed outdated API warning filter 57/60957/2
Matthias Sohn [Fri, 20 Nov 2015 23:18:14 +0000 (00:18 +0100)]
Remove no longer needed outdated API warning filter

This fixes a warning saying this filter isn't needed anymore.

Change-Id: If77056378befe86c1773950dbe48a82c833fd532
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoRefDirectory.getRef: Treat fake missing symrefs like real ones 07/60107/3
Jonathan Nieder [Wed, 11 Nov 2015 00:34:00 +0000 (16:34 -0800)]
RefDirectory.getRef: Treat fake missing symrefs like real ones

getRef() loops over its search path to find a ref:

Ref ref = null;
for (String prefix : SEARCH_PATH) {
ref = readRef(prefix + needle, packed);
if (ref != null) {
ref = resolve(ref, 0, null, null, packed);
break;
}
}
fireRefsChanged();
return ref;

If readRef returns null (indicating that the ref does not exist), the
loop continues so we can find the ref later in the search path.  And
resolve should never return null, so if we return null it should mean
we exhausted the entire search path and didn't find the ref.

... except that resolve can return null: it does so when it has
followed too many symrefs and concluded that there is a symref loop:

if (MAX_SYMBOLIC_REF_DEPTH <= depth)
return null; // claim it doesn't exist

Continue the loop instead of returning null immediately.  This makes
the behavior more consistent.

Arguably getRef should throw an exception when a symref loop is
detected.  That would be a more invasive change, so if it's a good
idea it will have to wait for another patch.

Change-Id: Icb1c7fafd4f1e34c9b43538e27ab5bbc17ad9eef
Signed-off-by: Jonathan Nieder <jrn@google.com>
8 years agoMerge "git rev-parse: Add --verify option"
Jonathan Nieder [Thu, 19 Nov 2015 22:49:17 +0000 (17:49 -0500)]
Merge "git rev-parse: Add --verify option"

8 years agogit rev-parse: Add --verify option 36/60836/4
Thomas Meyer [Thu, 19 Nov 2015 22:14:03 +0000 (23:14 +0100)]
git rev-parse: Add --verify option

Add the --verify option to be more compatible with git

Change-Id: I225a36ecc4711fd2eb9af67ca8fb79681d94c587
Signed-off-by: Thomas Meyer <thomas.mey@web.de>
8 years agoThrow IndexReadException if existing index can't be read 99/60799/2
Christian Halstrick [Thu, 19 Nov 2015 16:21:46 +0000 (17:21 +0100)]
Throw IndexReadException if existing index can't be read

If the index file exists but can't be read for example because of wrong
filesystem permissions we should throw a specific exception. This allows
EGit to handle this error situation.

Bug: 482607
Change-Id: I50bfcb719c45caac3cb5550a8b16307c2ea9def4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoFix pre-push hook to not set null remoteName as first argument 32/60632/3
Matthias Sohn [Tue, 17 Nov 2015 16:26:53 +0000 (17:26 +0100)]
Fix pre-push hook to not set null remoteName as first argument

According to [1] the pre-push hook expects two parameters which provide
the name and location of the destination remote, if a named remote is
not being used both values should be the same.

We did set the first parameter to null in that case which caused
ProcessBuilder to throw a NullPointerException since its start() method
doesn't accept null arguments.

[1] https://git-scm.com/docs/githooks#_pre_push

Bug: 482393
Change-Id: Idb9b0a48cefac01abfcfdf00f6d173f8fa1d9a7b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoIntroduce FS.execute() to execute a command defined by a ProcessBuilder 02/59102/13
Christian Halstrick [Wed, 28 Oct 2015 12:24:28 +0000 (13:24 +0100)]
Introduce FS.execute() to execute a command defined by a ProcessBuilder

Change-Id: I2ad2c71ad30b969455bdea89637b8e996b1dad8c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoAdd an attribute accessor to CanonicalTreeParser and use it in Treewalk 68/60068/6
Christian Halstrick [Tue, 10 Nov 2015 15:21:00 +0000 (16:21 +0100)]
Add an attribute accessor to CanonicalTreeParser and use it in Treewalk

When checking out a branch we need to access the attributes stored
in the tree to be checked out. E.g. directly after a clone we checkout
the remote HEAD. In this case index and workingtree are still empty.
So we have to search the tree to be checked out for attributes.

Change-Id: I6d96f5d095ed2e3c259d4b12124e404f5215bd9f

8 years agoAdds the git attributes computation on the treewalk 77/35377/22
Arthur Daussy [Fri, 31 Oct 2014 16:46:36 +0000 (17:46 +0100)]
Adds the git attributes computation on the treewalk

Adds the getAttributes feature to the tree walk. The computation of
attributes needs to be done by the TreeWalk since it needs both a
WorkingTreeIterator and a DirCacheIterator.

Bug: 342372
CQ: 9120
Change-Id: I5e33257fd8c9895869a128bad3fd1e720409d361
Signed-off-by: Arthur Daussy <arthur.daussy@obeo.fr>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
8 years agoMake jgit annotations accessible to other plugins 38/60638/2
Andrey Loskutov [Mon, 16 Nov 2015 22:41:38 +0000 (23:41 +0100)]
Make jgit annotations accessible to other plugins

Other plugins which want to use JGit nullness annotations in their code
cannot do this if the annotations aren't part of the published API.

Unfortunately it looks like although Eclipse JDT allows to use custom
nullness annotation types per project, it does not understand if those
annotations are used mixed with other nullness annotations in other
projects. E.g. EGit can either configure JGit annotations for NPE
analysis and so "understand" nullness from JGit API but so it loses the
ability to use any other nullness annotations to annotate its own code.

Change-Id: Ieeeb578c2fe35223a7561d668dce8e767dc89ef0
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoFixed typo in preferences: NonByDefault -> NonNullByDefault 39/60439/3
Andrey Loskutov [Sun, 15 Nov 2015 21:59:14 +0000 (22:59 +0100)]
Fixed typo in preferences: NonByDefault -> NonNullByDefault

Change-Id: I6ef5fbdb57e7cba010ad23cb3f6af02891e7fe78
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoAdded jgit own NonNull annotation type 37/60437/4
Andrey Loskutov [Sun, 15 Nov 2015 21:55:58 +0000 (22:55 +0100)]
Added jgit own NonNull annotation type

The annotation is required for example in Repository case (patch
follows), where almost all non-void return methods return Nullable
except few returning NonNull. I definitely do not favor this style, but
it is a nightmare to clients to guess if the null check is needed or
not.

Change-Id: Ib2a778a246c6d84b7c32565f54df2385b59f6498
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoMerge "Fix MissingObjectException in RenameDetector"
Christian Halstrick [Tue, 17 Nov 2015 08:27:53 +0000 (03:27 -0500)]
Merge "Fix MissingObjectException in RenameDetector"

8 years agoHandle InternalError during symlink support detection on Windows 38/60438/1
Matthias Sohn [Sun, 15 Nov 2015 21:56:55 +0000 (22:56 +0100)]
Handle InternalError during symlink support detection on Windows

When JGit tries to detect symlink support the attempt to create a
symlink may fail with a java.lang.InternalError. This was reported for a
case where the application using JGit runs in Windows XP compatibility
mode using Oracle JDK 1.8. Handle this by assuming symlinks are not
supported in this case.

Bug: 471027
Change-Id: I978288754dea0c6fffd3457fad7d4d971e27c6c2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoMerge branch 'stable-4.1' 08/60408/1
Matthias Sohn [Fri, 13 Nov 2015 23:59:36 +0000 (00:59 +0100)]
Merge branch 'stable-4.1'

* stable-4.1:
  Prepare 4.1.2-SNAPSHOT builds
  JGit v4.1.1.201511131810-r
  Fallback exactRef: Do not ignore symrefs to unborn branch
  RefDirectory.exactRef: Do not ignore symrefs to unborn branch

Change-Id: I66afb303f355aad8a7eaa7a6dff06de70ae9c490
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoPrepare 4.1.2-SNAPSHOT builds 06/60406/1
Matthias Sohn [Fri, 13 Nov 2015 23:53:45 +0000 (00:53 +0100)]
Prepare 4.1.2-SNAPSHOT builds

Change-Id: I1d1c4d918f2260c866c4392c1abea1e40a1de962
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoJGit v4.1.1.201511131810-r 91/60391/1 v4.1.1.201511131810-r
Matthias Sohn [Fri, 13 Nov 2015 23:09:54 +0000 (00:09 +0100)]
JGit v4.1.1.201511131810-r

Change-Id: If0246daab39fa279c30874549b198e7aa917bc62
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoFallback exactRef: Do not ignore symrefs to unborn branch 50/60150/2
Jonathan Nieder [Wed, 11 Nov 2015 18:42:46 +0000 (10:42 -0800)]
Fallback exactRef: Do not ignore symrefs to unborn branch

When asked to read a symref pointing to a branch-yet-to-be-born (such
as HEAD in a newly initialized repository), getRef and getRefs provide
different results.

getRef: SymbolicRef[HEAD -> refs/heads/master=00000000]
getRefs and getAdditionalRefs: nothing

exactRef should match the getRef behavior: it is meant to be a
simpler, faster version of getRef that lets you search for a ref
without resolving it using the search path without other semantic
changes.  But the fallback implementation of exactRef relies on getRefs
and produces null for this case.

Luckily the in-tree RefDatabase implementations override exactRef and
get the correct behavior.  But any out-of-tree storage backend that
doesn't inherit from DfsRefDatabase or RefDirectory would still return
null when it shouldn't.

Let the fallback implementation use getRef instead to avoid this.
This means that exactRef would waste some effort traversing the ref
search path when the named ref is not found --- but subclasses tend to
override exactRef for performance already, so in the default
implementation correctness is more important.

Bug: 478865
Change-Id: I60f04e3ce3bf4731640ffd2433d329e621330029

8 years agoFix MissingObjectException in RenameDetector 26/60226/2
Rüdiger Herrmann [Thu, 12 Nov 2015 14:54:13 +0000 (15:54 +0100)]
Fix MissingObjectException in RenameDetector

When attempting to determine the size of a blob that does not exist,
the RenameDetector throws a MissingObjectException.

The fix is to return a size of zero if the size is requested for a blob
id that doesn't exist.

Bug: 481577
Change-Id: I4e86276039c630617610cc51d0eefa56d7d3952f
Signed-off-by: Rüdiger Herrmann <ruediger.herrmann@gmx.de>
8 years agoMerge "Merge branch 'stable-4.2'"
Matthias Sohn [Thu, 12 Nov 2015 10:38:03 +0000 (05:38 -0500)]
Merge "Merge branch 'stable-4.2'"

8 years agoMerge branch 'stable-4.2' 86/60186/1
Matthias Sohn [Thu, 12 Nov 2015 07:52:41 +0000 (08:52 +0100)]
Merge branch 'stable-4.2'

* stable-4.2:
  Prepare post 4.2-m1 builds
  JGit v4.2.0.201511101648-m1

Change-Id: Idef8f81a82e2625e4b46141fae74975227f3ab7d

8 years agoRefDirectory.exactRef: Do not ignore symrefs to unborn branch 06/60106/2
Jonathan Nieder [Tue, 10 Nov 2015 23:11:04 +0000 (15:11 -0800)]
RefDirectory.exactRef: Do not ignore symrefs to unborn branch

When asked to read a symref pointing to a branch-yet-to-be-born (such
as HEAD in a newly initialized repository), DfsRepository and
FileRepository return different results.

FileRepository:

exactRef("HEAD") => null

DfsRepository:

exactRef("HEAD") => SymbolicRef[HEAD -> refs/heads/master=00000000]

getRef("HEAD") returns the same as DfsRepository's exactRef in both
backends.

The intended behavior is the DfsRepository one: exactRef() is supposed
to be like getRef(), but more exact because it doesn't need to
traverse the search path.

The discrepancy is because DfsRefDatabase implements exactRef()
directly with the intended semantics, while RefDirectory uses a
fallback implementation built on top of getRefs().  getRefs() skips
symrefs to an unborn branch.

Override the fallback implementation with a correct implementation
that is similar to getRef() to avoid this.  A followup change will fix
the fallback.

Change-Id: Ic138a5564a099ebf32248d86b93e2de9ab3c94ee
Reported-by: David Pursehouse <david.pursehouse@sonymobile.com>
Improved-by: Christian Halstrick <christian.halstrick@sap.com>
Bug: 478865

8 years agoMerge "Revert "Remove PackWriter.Statistics and other deprecated classes""
Jonathan Nieder [Wed, 11 Nov 2015 01:20:43 +0000 (20:20 -0500)]
Merge "Revert "Remove PackWriter.Statistics and other deprecated classes""

8 years agoRevert "Remove PackWriter.Statistics and other deprecated classes" 11/60111/1
Jonathan Nieder [Wed, 11 Nov 2015 01:14:01 +0000 (20:14 -0500)]
Revert "Remove PackWriter.Statistics and other deprecated classes"

This reverts commit bbcbcab8d39dd4bdf194cdba02c97a9eb70b2379.
These classes were part of the public API and should not be removed
until JGit 5.0.

Change-Id: Ife4bee69f82151de6ef8ea1a4c6c146d91bbf0d5

8 years agoPrepare post 4.2-m1 builds 05/60105/1
Matthias Sohn [Tue, 10 Nov 2015 23:30:53 +0000 (00:30 +0100)]
Prepare post 4.2-m1 builds

Change-Id: I20e5eadc243ea375948ceca8c99441605c45ad95
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoJGit v4.2.0.201511101648-m1 97/60097/1 v4.2.0.201511101648-m1
Matthias Sohn [Tue, 10 Nov 2015 21:48:00 +0000 (22:48 +0100)]
JGit v4.2.0.201511101648-m1

Change-Id: I659e9e95a96797f78f23669cfc5946c6b2d9c088
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoMerge "Remove PackWriter.Statistics and other deprecated classes"
Jonathan Nieder [Tue, 10 Nov 2015 20:57:29 +0000 (15:57 -0500)]
Merge "Remove PackWriter.Statistics and other deprecated classes"

8 years agoRemove PackWriter.Statistics and other deprecated classes 03/60003/1
Terry Parker [Tue, 10 Nov 2015 02:55:18 +0000 (18:55 -0800)]
Remove PackWriter.Statistics and other deprecated classes

These classes make improper use of internal classes in the public API
and were replaced by corresponding classes in the JGit 4.1 release.

Change-Id: I3d474210e49089aa788314b4e08f505f0d26619b
Signed-off-by: Terry Parker <tparker@google.com>
8 years agoSilence API errors for new methods added to BitmapBuilder 00/60000/1
Matthias Sohn [Mon, 9 Nov 2015 23:59:40 +0000 (00:59 +0100)]
Silence API errors for new methods added to BitmapBuilder

These API changes were introduced in f523f21e and 73474466.

BitmapBuilder is an interface to be implemented by implementors of this
interface. According to OSGi semantic versioning rules breaking API
changes require update of the minor version only if implementors of the
API have to be adapted and the changes do not affect clients of the API.

Change-Id: If45d204181ea9bc788b6b57693ca17b1847564c7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoAdd missing javadoc to bitmap index classes 99/59999/1
Matthias Sohn [Mon, 9 Nov 2015 23:50:55 +0000 (00:50 +0100)]
Add missing javadoc to bitmap index classes

Change-Id: Ib9fd230c9465a719df53cfcb314d8b5015743928
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoMerge changes from topic 'nullable'
Jonathan Nieder [Mon, 9 Nov 2015 23:04:22 +0000 (18:04 -0500)]
Merge changes from topic 'nullable'

* changes:
  Update dependencies to use the JGit-internal @Nullable
  Use the JGit-internal @Nullable annotation
  Add a JGit-internal Nullable type

8 years agoMake BitmapIndexImpl.CompressedBitmap public 14/59914/6
Jonathan Nieder [Mon, 9 Nov 2015 16:48:46 +0000 (08:48 -0800)]
Make BitmapIndexImpl.CompressedBitmap public

PackWriterBitmapPreparer (which is in another package) is already well
aware of the mapping between EWAHCompressedBitmaps and the
higher-level CompressedBitmap objects of the BitmapIndexImpl API.
Making the CompressedBitmap type public makes the translation more
obvious and wouldn't break any abstractions that aren't already
broken.  So expose it.

This is all under org.eclipse.jgit.internal so there are no API
stability guarantees --- we can change the API if internals change
(for example if some day there are bitmaps spanning multiple packs).

In particular this means the confusing toBitmap helper can be removed.

Change-Id: Ifb2e8804a6d5ee46e82a76d276c4f8507eaa2a4c

8 years agoUpdate dependencies to use the JGit-internal @Nullable 95/59995/2
Terry Parker [Mon, 9 Nov 2015 22:19:11 +0000 (14:19 -0800)]
Update dependencies to use the JGit-internal @Nullable

Update the project-specific Eclipse settings to replace the use of the
org.eclipse.jdt.annotation.Nullable class the new JGit-specific
@Nullable annotation. I verified that Eclipse reports errors when the
return value of a method annotated with
@org.eclipse.jgit.annotations.Nullable is dereferenced without a null
check.

Also remove the Maven and MANIFEST.MF dependencies on
org.eclipse.jdt.annotation.

Eclipse null analysis uses three annotations: @Nullable, @NonNull and
@NonNullByDefault. All three are updated in this patch because it is
invalid to set the Eclipse preferences to empty values. So far only
@Nullable has been introduced in org.eclipse.jgit.annotations.

My personal preference is to follow the advice in Effective Java and
avoid the null-return idiom, and to avoid passing null values in
general. This sets the expectation is that arguments and return types
are assumed non-null unless otherwise documented. If that is the
expectation, then consistent application of @NonNull is redundant and
hurts readability by cluttering the code, obscuring the occasional
@Nullable annotation that really requires attention.

If the JGit community decides there is value in using the @NonNull and
@NonNullByDefault annotations we can add them--this change configures
Eclipse to use them.

Change-Id: I9af1b786d1b44b9b0d9c609480dc842df79bf698
Signed-off-by: Terry Parker <tparker@google.com>
8 years agoUse the JGit-internal @Nullable annotation 94/59994/2
Terry Parker [Mon, 9 Nov 2015 21:42:20 +0000 (13:42 -0800)]
Use the JGit-internal @Nullable annotation

Update existing @Nullable uses to use the JGit-internal version of the
annotation.

Change-Id: I95234ffad4c3110f9597fbd3a2760f653e22ecf7
Signed-off-by: Terry Parker <tparker@google.com>
8 years agoAdd a JGit-internal Nullable type 93/59993/2
Terry Parker [Mon, 9 Nov 2015 21:40:39 +0000 (13:40 -0800)]
Add a JGit-internal Nullable type

Commit 847b3d1 enabled annotation-based NPE analysis to JGit.

In so doing, it introduced a new dependency on the org.eclipse.jdt that
is undesirable. Follow Gerrit's lead by adding an internal Nullable type
(see
https://gerrit.googlesource.com/gerrit/+/stable-2.11/gerrit-common/src/main/java/com/google/gerrit/common/Nullable.java).

The javax.annotations.Nullable class uses a retention policy of RUNTIME,
whereas the org.eclipse.jdt.annotation.Nullable class used a policy of
CLASS. Since I'm not aware of tools that make use of the annotation at
runtime I chose the CLASS policy. If in the future there is a benefit to
retaining the annotations in the running binary we can update this
class.

Change-Id: I63dc8f9a6dc46b517cbde211bb5e2f8521a54d04
Signed-off-by: Terry Parker <tparker@google.com>
8 years agoMake BitmapIndexImpl.CompressedBitmap, CompressedBitmapBuilder static 89/59989/3
Jonathan Nieder [Mon, 9 Nov 2015 21:14:13 +0000 (13:14 -0800)]
Make BitmapIndexImpl.CompressedBitmap, CompressedBitmapBuilder static

A CompressedBitmap represents a pair (EWAH bit vector, PackIndex
assigning bit positions to git objects).  The bit vector is a member
field and the PackIndex is implicit via the 'this' reference to the
outer class.

Make this clearer by making CompressedBitmap a static class and
replacing the 'this' reference by an explicit field.

Likewise for CompressedBitmapBuilder.

Change-Id: Id85659fc4fc3ad82034db3370cce4cdbe0c5492c
Suggested-by: Terry Parker <tparker@google.com>
8 years agoSkip redundant 'OR-reuse' step in tip commit bitmap setup 98/59898/2
Jonathan Nieder [Sat, 7 Nov 2015 19:53:25 +0000 (11:53 -0800)]
Skip redundant 'OR-reuse' step in tip commit bitmap setup

When creating bitmaps during gc, the bitmaps in tipCommitBitmaps are
built in setupTipCommitBitmaps using the following procedure:

 0. create a bitmap ('reuse') that lists all ancestors of commits
    whose existing bitmaps will be reused.  I will call this the
    reused part of history.

 1. initialize a bitmap for each of the pack's "want"s by taking
    a copy of the 'reuse' bitmap and setting the bit corresponding
    to the one wanted commit.

 2. walk through ancestors of wants, excluding the reused part of
    history.  Add parents of visited commits to bitmaps that have
    those commits.

 3. AND-NOT each tipCommitBitmap against the 'reuse' bitmap

 4. Sort the bitmaps and AND-NOT each against the previous so they
    partition the new commits.

The OR against 'reuse' in step 1 and the AND-NOT against 'reuse'
cancel each other out, except when commits from the reused part of
history are added to a bitmap in step 2.  So avoid adding commits from
the reused part of history in step 2 and skip the OR and AND-NOT.

Performance impact (thanks to Terry for measuring):

The initial "selecting bitmaps" phase of garbage collection decreased
from (83 + 81 + 85) / 3 = 83 to (56 + 57 + 56) / 3 = 56.3, meaning
nearly a ~50% speedup of that phase.

Tested-by: Terry Parker <tparker@google.com>
Change-Id: I26ea695809594347575d14a1d8e6721b8608eb9c

8 years agoAvoid repeated sort of tipCommitBitmaps 99/59899/3
Jonathan Nieder [Sat, 7 Nov 2015 20:01:41 +0000 (12:01 -0800)]
Avoid repeated sort of tipCommitBitmaps

Change-Id: I0feb2003f58776d50fab2d31d46ac98ae863bea8

8 years ago[style] Shorten line lengths and import order in bitmap code 95/59895/1
Terry Parker [Sat, 7 Nov 2015 18:31:15 +0000 (10:31 -0800)]
[style] Shorten line lengths and import order in bitmap code

Change-Id: I420fcd308a97e30b8c74026d74b93ed3ec74bb3f
Signed-off-by: Terry Parker <tparker@google.com>
8 years agoInline PackWriterBitmapWalker.newRevFilter into callers 33/59633/3
Jonathan Nieder [Wed, 4 Nov 2015 06:29:31 +0000 (22:29 -0800)]
Inline PackWriterBitmapWalker.newRevFilter into callers

Instead of using the newRevFilter helper, call the appropriate
RevFilter constructor directly.  This means one less hop to find
documentation about what the RevFilter will do.

Change-Id: Ida6ff1c0457a47a1bd1e4ed0fd1dd42a616d214f

8 years agoConvert remaining callers of BitmapBuilder.add to use .addObject 32/59632/3
Jonathan Nieder [Wed, 4 Nov 2015 06:43:45 +0000 (22:43 -0800)]
Convert remaining callers of BitmapBuilder.add to use .addObject

When setupTipCommitBitmaps is called, writeBitmaps does not have any
bitmaps saved, so these calls to .add always add a single commit and
do not OR in a bitmap.

The objects returned by nextObject after a commit walk is finished
are trees and blobs.  Non-commit objects do not have bitmaps
associated so the call to .add also can only add a single object.

Change-Id: I7b816145251a7fa4f1fffe0d03644257ea7f5440

8 years agoMerge changes I57b1d7c1,I590ac460
Jonathan Nieder [Thu, 5 Nov 2015 22:51:14 +0000 (17:51 -0500)]
Merge changes I57b1d7c1,I590ac460

* changes:
  Use .addObject and .or instead of .add in AddToBitmapFilter
  Replace anonymous BitmapRevFilter subclasses with explicit classes

8 years agoMerge "Fix imports in DfsInserterTest"
Matthias Sohn [Thu, 5 Nov 2015 22:48:55 +0000 (17:48 -0500)]
Merge "Fix imports in DfsInserterTest"

8 years agoMerge changes Ia95da478,I2773aa94,Ib745645f,I92c65f34,Ibb714002, ...
Jonathan Nieder [Thu, 5 Nov 2015 22:08:25 +0000 (17:08 -0500)]
Merge changes Ia95da478,I2773aa94,Ib745645f,I92c65f34,Ibb714002, ...

* changes:
  Remove BitmapRevFilter.getCountOfLoadedCommits
  Make BitmapBuilder.getBitmapIndex public
  Deprecate BitmapBuilder.add and introduce simpler addObject method
  Add @Override annotations to BitmapIndexImpl
  Rely on bitmap RevFilter to filter walk during bitmap selection
  Use 'reused' bitmap to filter walk during bitmap selection
  Rely on bitmap RevFilter to filter tip commit setup walk
  Use 'reused' bitmap to filter tip commit setup walk
  Include ancestors of reused bitmap commits in reuse bitmap again

8 years agoFix imports in DfsInserterTest 87/59787/1
Matthias Sohn [Thu, 5 Nov 2015 21:47:54 +0000 (22:47 +0100)]
Fix imports in DfsInserterTest

- remove unused import of AnyObjectId
- auto-sort import statements

Change-Id: I1c7cec2734bd58370a7dfae70a6a4ccbe3e304ce
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoUse .addObject and .or instead of .add in AddToBitmapFilter 31/59631/2
Jonathan Nieder [Wed, 4 Nov 2015 06:33:05 +0000 (22:33 -0800)]
Use .addObject and .or instead of .add in AddToBitmapFilter

This is the caller that the BitmapBuilder.add method was designed
around.  Moving away from .add makes it more verbose but hopefully
clearer.

Change-Id: I57b1d7c1dc8fb800b242b76c606922b5aa36b9b2

8 years agoReplace anonymous BitmapRevFilter subclasses with explicit classes 30/59630/2
Jonathan Nieder [Wed, 4 Nov 2015 05:54:48 +0000 (21:54 -0800)]
Replace anonymous BitmapRevFilter subclasses with explicit classes

This puts the code for include() in each RevFilter returned by
newRevFilter in one place and should make the code easier to
understand and modify.

Change-Id: I590ac4604b61fc1ffe7aba2ed89f8139847ccac3

8 years agoRemove BitmapRevFilter.getCountOfLoadedCommits 29/59629/2
Jonathan Nieder [Wed, 4 Nov 2015 05:42:28 +0000 (21:42 -0800)]
Remove BitmapRevFilter.getCountOfLoadedCommits

The count of loaded commits is equal to the number of commits returned
by the walk.  Simplify BitmapRevFilter by counting them in the caller.

Change-Id: Ia95da47831d9e89d6f8068470ec4529aaabfa7dd

8 years agoMake BitmapBuilder.getBitmapIndex public 28/59628/2
Jonathan Nieder [Wed, 4 Nov 2015 07:20:14 +0000 (23:20 -0800)]
Make BitmapBuilder.getBitmapIndex public

Every Bitmap in current JGit code has an associated BitmapIndex.  Make
it public in BitmapBuilder to make retrieving bitmaps to OR in from
that index easier.

Change-Id: I2773aa94d8b67f12194608e6317c0792a5de21e2

8 years agoDeprecate BitmapBuilder.add and introduce simpler addObject method 25/59625/5
Jonathan Nieder [Wed, 4 Nov 2015 02:54:25 +0000 (18:54 -0800)]
Deprecate BitmapBuilder.add and introduce simpler addObject method

The BitmapIndex.BitmapBuilder.add API is subtle:

/**
 * Adds the id and the existing bitmap for the id, if one
 * exists, to the bitmap.
 *
 * @return true if the value was not contained or able to be
 * loaded.
 */
boolean add(AnyObjectId objectId, int type);

Reading the name of the method does not make it obvious what it will
do.  Does it add the named object to the bitmap, or all objects
reachable from it?  It depends on whether the BitmapIndex owns an
existing bitmap for that object.  I did not notice this subtlety when
skimming the javadoc, either.  This resulted in enough confusion to
subtly break the bitmap building code (see change
I30844134bfde0cbabdfaab884c84b9809dd8bdb8 for details).

So discourage use of the add() API by deprecating it.

To replace it, provide a addObject() method that adds a single object.
This way, callers can decide whether to use addObject() or or() based
on the context.

For example,

if (bitmap.add(c, OBJ_COMMIT)) {
for (RevCommit p : c.getParents()) {
rememberToAlsoHandle(p);
}
}

can be replaced with

if (bitmap.contains(c)) {
// already included
} else if (index.getBitmap(c) != null) {
bitmap.or(index.getBitmap(c));
} else {
bitmap.addObject(c, OBJ_COMMIT);
for (RevCommit p : c.getParents()) {
rememberToAlsoHandle(p);
}
}

which is more verbose but makes it clearer that the behavior
depends on the content of index.getBitmaps().

Change-Id: Ib745645f187e1b1483f8587e99501dfcb7b867a5

8 years agoAdd @Override annotations to BitmapIndexImpl 24/59624/3
Jonathan Nieder [Wed, 4 Nov 2015 02:38:18 +0000 (18:38 -0800)]
Add @Override annotations to BitmapIndexImpl

This makes it easier to distinguish between implementations of methods
from the interface from helpers internal to org.eclipse.jgit.internal.storage.*.

This was illegal in Java 5 but JGit requires newer Java these days.

Change-Id: I92c65f3407a334acddd32ec9e09ab7d1d39c4dc6

8 years agoRely on bitmap RevFilter to filter walk during bitmap selection 98/59598/4
Jonathan Nieder [Tue, 3 Nov 2015 19:31:21 +0000 (11:31 -0800)]
Rely on bitmap RevFilter to filter walk during bitmap selection

This RevWalk filters out reused bitmap commits via the 'reuse' bitmap.
Avoid possible wasted time and complexity by not also redundantly
marking them UNINTERESTING.

Change-Id: Ibb714002ddac599963d148a9aab90645fcc73141

8 years agoUse 'reused' bitmap to filter walk during bitmap selection 97/59597/4
Jonathan Nieder [Tue, 3 Nov 2015 19:24:02 +0000 (11:24 -0800)]
Use 'reused' bitmap to filter walk during bitmap selection

When building fullBitmap in order to determine which ancestor chain to
add this commit to, we were excluding the ancestors of reusedCommits
using markUninteresting.  This use of markUninteresting is a bit
wasteful because we already have a bitmap indicating exactly which
commits should be excluded (which can save some walking).  Use it.

A separate commit will remove the now-redundant markUninteresting
call.

No behavior change intended (except for performance improvement).

Change-Id: I1112641852d72aa05c9a8bd08a552c70342ccedb

8 years agoRely on bitmap RevFilter to filter tip commit setup walk 96/59596/4
Jonathan Nieder [Tue, 3 Nov 2015 19:16:22 +0000 (11:16 -0800)]
Rely on bitmap RevFilter to filter tip commit setup walk

This RevWalk filters out reused bitmap commits via the 'reuse' bitmap.
Avoid possible wasted time and complexity by not redundantly marking
them UNINTERESTING any more.

Change-Id: If467ccd1d75e17cf9367b2a0399fca3f9d52adf9

8 years agoUse 'reused' bitmap to filter tip commit setup walk 95/59595/4
Jonathan Nieder [Tue, 3 Nov 2015 19:15:36 +0000 (11:15 -0800)]
Use 'reused' bitmap to filter tip commit setup walk

When garbage collecting, we decide to reuse some bitmaps in older
history from the previous pack to save time.  The remainder of commit
selection only involves commits not covered by those bitmaps.

Currently we carry that out in two ways:

1. by building a bitmap representing the already-covered commits,
   for easy containment checks and AND-NOT-ing against
2. by marking the reused bitmap commits as uninteresting in the
   RevWalk that finds new commits

The mechanism in (2) is less efficient than (1): rw.next() will walk
back from reused bitmap commits to check whether the commit it is
about to emit is an ancestor of them, when using the bitmap from (1)
would let us perform the same check with a single contains() call.
Add a RevFilter teaching the RevWalk to perform that same check
directly using the bitmap from (1).

The next time the RevWalk is used, a different RevFilter is installed
so this does not break that.

A later commit will drop the markUninteresting calls.

No functional change intended except a possible speedup.

Change-Id: Ic375210fa69330948be488bf9dbbe4cb0d069ae6

8 years agoInsert duplicate objects to prevent race during garbage collection. 82/59282/3
Mike Williams [Wed, 21 Oct 2015 20:09:58 +0000 (16:09 -0400)]
Insert duplicate objects to prevent race during garbage collection.

Prior to this change, DfsInserter would not insert an object into a pack
if it already existed in another pack in the repository, even if that
pack was unreachable. Consider this sequence of events:

- Object FOO is pushed to a repository.
- Subsequent ref changes make FOO UNREACHABLE_GARBAGE.
- FOO is subsequently re-inserted using a DfsInserter, but skipped
  due to existing in UNREACHABLE_GARBAGE.
- The repository is repacked; FOO will not be written into a new pack
  because it is not yet reachable from a reference. If the
  UNREACHABLE_GARBAGE packs are deleted, FOO disappears.
- A reference is updated to reference FOO. This reference is now broken
  as FOO was removed when the repacking process deleted the
  UNREACHABLE_GARBAGE pack that stored the only copy of FOO.

The garbage collector can't safely delete the UNREACHABLE_GARBAGE
pack because FOO might be in the middle of being re-inserted/re-packed.

This change writes a duplicate copy of an object if it only exists in
UNREACHABLE_GARBAGE. This "freshens" the object to give it a chance to
survive long enough to be made reachable through a reference.

Change-Id: I20f2062230f3af3bccd6f21d3b7342f1152a5532
Signed-off-by: Mike Williams <miwilliams@google.com>
8 years agoMerge "Delta compression: reuse DeltaTask.getAdjustedWeight()"
Jonathan Nieder [Wed, 4 Nov 2015 17:56:42 +0000 (12:56 -0500)]
Merge "Delta compression: reuse DeltaTask.getAdjustedWeight()"

8 years agoMerge "[performance] Speed up delta packing"
Shawn Pearce [Wed, 4 Nov 2015 17:55:20 +0000 (12:55 -0500)]
Merge "[performance] Speed up delta packing"

8 years agoInclude ancestors of reused bitmap commits in reuse bitmap again 22/59622/1
Jonathan Nieder [Wed, 4 Nov 2015 01:45:06 +0000 (17:45 -0800)]
Include ancestors of reused bitmap commits in reuse bitmap again

Until 320a4142 (Update bitmap selection throttling to fully span
active branches, 2015-10-20), setupTipCommitBitmaps contained code
along the following lines:

for (PackBitmapIndexRemapper.Entry entry : bitmapRemapper) {
if (!reuse(entry))
continue;
RevCommit rc = (RevCommit) rw.peel(rw.parseAny(entry));

reuseCommits.add(new BitmapCommit(rc));
EWAHCompressedBitmap bitmap =
remap.ofObjectType(remap.getBitmap(rc), OBJ_COMMIT);
writeBitmaps.addBitmap(rc, bitmap, 0);
reuse.add(rc, OBJ_COMMIT);
}
writeBitmaps.clearBitmaps(); // Remove temporary bitmaps

This loop OR-ed together bitmaps for commits whose bitmaps would be
reused.  A subtle point is the use of the add() method, which ORs in a
bitmap from the BitmapIndex when it exists and falls back to OR-ing in
a single bit when that bitmap does not exist in the BitmapIndex.

Commit 320a4142 removed the addBitmap step, so the bitmap does not
exist in the BitmapIndex and the fallback behavior is triggered.

Simplify and restore the intended behavior by avoiding use of the
subtle use of the add() method --- use or() directly instead.

Change-Id: I30844134bfde0cbabdfaab884c84b9809dd8bdb8

8 years agoMerge "Decrease indentation in setupTipCommitBitmaps"
Jonathan Nieder [Wed, 4 Nov 2015 00:41:22 +0000 (19:41 -0500)]
Merge "Decrease indentation in setupTipCommitBitmaps"

8 years agoMerge "[style] Add braces to DeltaTask"
Jonathan Nieder [Tue, 3 Nov 2015 23:33:26 +0000 (18:33 -0500)]
Merge "[style] Add braces to DeltaTask"

8 years agoDelta compression: reuse DeltaTask.getAdjustedWeight() 14/59614/1
Terry Parker [Tue, 3 Nov 2015 23:08:32 +0000 (15:08 -0800)]
Delta compression: reuse DeltaTask.getAdjustedWeight()

Change-Id: I07ed5207b175735b4e2c46edf652cc35908dad02
Signed-off-by: Terry Parker <tparker@google.com>
8 years ago[performance] Speed up delta packing 16/59416/4
Terry Parker [Sat, 31 Oct 2015 00:47:06 +0000 (17:47 -0700)]
[performance] Speed up delta packing

When packing is able to reuse lots of deltas from existing packs, those
objects are marked as "doNotAttemptDelta" and do not contribute to
DeltaTask's computeTopPaths() "totalWeight" calculation.

In the extreme case when all packs are reusable, "totalWeight" will be
zero. DeltaTask.partitionTasks() uses "totalWeight" to determine a
"weightPerThread" size it uses to set up DeltaTasks. When "totalWeight"
is small, partitionTasks() ends up creating a DeltaTask for every
unique path.

For a large repository, the small "weightPerThread" can result in the
creation of >100k tasks (for the MSM 3.10 Linux repository, the count
was ~150k). This makes the "task stealing" mechanism in DeltaTask very
inefficient, because every attempt to steal work does a linear walk
through all tasks, searching for the one with the most work remaining,
which is O(N^2) comparisons. For the MSM 3.10 repository when all
deltas were reusable, PackWriter.parallelDeltaSearch() took
(1615+1633+1458)/3 = 1568 seconds.

The error is that DeltaTask treats the weights of objects marked as
"doNotAttemptDelta" inconsistently. It ignores the weights when
calculating "totalWeight" but uses them when partitioning the tasks.
The fix is to also ignore them when partitioning the tasks.

With this patch applied, PackWriter.parallelDeltaSearch() on the
MSM 3.10 repository when all deltas are reused went from taking
1568 seconds to 62ms (>25k speedup).

This patch also fixes a totalWeight initialization error in
DeltaTask.computeTopPaths().

Change-Id: I2ae37efa83bca42b0e716266ae6aa9d182e76d9c
Signed-off-by: Terry Parker <tparker@google.com>
8 years ago[style] Add braces to DeltaTask 13/59613/1
Terry Parker [Sat, 31 Oct 2015 00:47:06 +0000 (17:47 -0700)]
[style] Add braces to DeltaTask

Change-Id: I3306cc77544dec6d9273b2c35b8db0ed43799992
Signed-off-by: Terry Parker <tparker@google.com>
8 years agoDecrease indentation in setupTipCommitBitmaps 94/59594/1
Jonathan Nieder [Tue, 3 Nov 2015 19:42:53 +0000 (11:42 -0800)]
Decrease indentation in setupTipCommitBitmaps

Avoid leaving the reader in suspense by handling the unusual
(!RevCommit) case first.  As a nice side effect, there is less nesting
to keep track of in the rest of the loop body.

No functional change intended.

Change-Id: I1580de444fccde08070f696218c12041151a924a

8 years agoAdd support for pre-push hooks 18/59318/3
Christian Halstrick [Tue, 30 Jun 2015 14:43:20 +0000 (16:43 +0200)]
Add support for pre-push hooks

When the file <git-dir>/hooks/pre-push exists make sure that is is
executing during a push. The pre-push hook runs during git push, after
the remote refs have been updated but before any objects have been
transferred.

Change-Id: Ibbb58ee3227742d1a2f913134ce11e7a135c7f4c

8 years agoEnhance FS.runProcess() to support stdin-redirection and binary data 71/50371/10
Christian Halstrick [Wed, 17 Jun 2015 12:54:11 +0000 (14:54 +0200)]
Enhance FS.runProcess() to support stdin-redirection and binary data

In order to support filters in gitattributes FS.runProcess() is made
public. Support for stdin redirection has been added. Support for binary
data on stdin/stdout (as used be clean/smudge filters) has been added.

Change-Id: Ice2c152e9391368dc5748d7b825a838e3eb755f9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoCleaned up various readPipe() threading issues 34/59434/2
Andrey Loskutov [Sun, 1 Nov 2015 12:40:02 +0000 (13:40 +0100)]
Cleaned up various readPipe() threading issues

Fixed random errors in discoverGitSystemConfig() on Linux where the
process error stream was closed by readPipe() before or while
GobblerThread was reading from it.

Marked readPipe() as @Nullable and fixed potential NPE in
discoverGitSystemConfig() on readPipe() return value.

Fixed process error output randomly mixed with other threads log
messages.

Change-Id: Id882af2762cfb75f010f693b2e1c46eb6968ee82
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoDon't report errors logged by FS with "debug" level 92/59392/1
Andrey Loskutov [Fri, 30 Oct 2015 23:06:27 +0000 (00:06 +0100)]
Don't report errors logged by FS with "debug" level

Change-Id: I6a10116cd2e6b58d2300a9e741afe2eeac719b03
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoBuilding bitmaps: Simplify the logic to sort by chains 81/59281/5
Terry Parker [Thu, 29 Oct 2015 18:02:01 +0000 (11:02 -0700)]
Building bitmaps: Simplify the logic to sort by chains

Change-Id: I3da98e85107154c159093c138893f54dfa7ef435
Signed-off-by: Terry Parker <tparker@google.com>
8 years agoMerge "Pack bitmaps: improve readability"
Jonathan Nieder [Thu, 29 Oct 2015 18:11:40 +0000 (14:11 -0400)]
Merge "Pack bitmaps: improve readability"

8 years agoMerge "Bitmap generation: Add a test of ordering commits by "chains""
Jonathan Nieder [Thu, 29 Oct 2015 18:09:02 +0000 (14:09 -0400)]
Merge "Bitmap generation: Add a test of ordering commits by "chains""

8 years agoMerge "reset command should support the -- <paths> parameters"
Christian Halstrick [Thu, 29 Oct 2015 12:26:51 +0000 (08:26 -0400)]
Merge "reset command should support the -- <paths> parameters"

8 years agoreset command should support the -- <paths> parameters 60/59060/2
Kaloyan Raev [Fri, 25 Sep 2015 11:39:52 +0000 (14:39 +0300)]
reset command should support the -- <paths> parameters

Bug: 480750
Change-Id: Ia85b1aead03dcf2fcb50ce0391b656f7c60a08d4
Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
8 years agoJGit CLI should check if calling itself when invoking native git exe 12/59012/2
Kaloyan Raev [Tue, 27 Oct 2015 14:14:54 +0000 (16:14 +0200)]
JGit CLI should check if calling itself when invoking native git exe

Bug: 480782
Change-Id: I0d7f7a648671e7ff678f2b19fe39b85f8835c061
Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
8 years agoBitmap generation: Add a test of ordering commits by "chains" 91/59191/1
Terry Parker [Thu, 29 Oct 2015 04:59:10 +0000 (21:59 -0700)]
Bitmap generation: Add a test of ordering commits by "chains"

When commits are selected for bitmap generation, they are reordered
so that related "chains" of commits are grouped together. Chains are
"subbranches" of commits that may branch off of and re-merge with the
main line. Grouping by chains means that the XOR difference between
consecutive selected commits will be smaller, resulting in better
run-length compression of the XORed bitmaps.

Add a new testSelectionOrderingWithChains() test in a new
GcCommitSelectionTest test class. Also move related GC commit selection
tests out of GcBasicPackingTest and into GcCommitSelectionTest.

Change-Id: I8e80cac29c4ca8193b41c9898e5436c22a659f11
Signed-off-by: Terry Parker <tparker@google.com>
8 years agoPack bitmaps: improve readability 77/59077/2
Terry Parker [Wed, 28 Oct 2015 05:33:24 +0000 (22:33 -0700)]
Pack bitmaps: improve readability

Add comments and rename variables in PackWriterBitmapPreparer to improve
readability.

Change-Id: I49e7a1c35307298f7bc32ebfc46ab08e94290125
Signed-off-by: Terry Parker <tparker@google.com>
8 years ago[performance] Remove synthetic access$ methods in dfs, diff and merge 74/59174/1
Andrey Loskutov [Wed, 28 Oct 2015 20:17:43 +0000 (21:17 +0100)]
[performance] Remove synthetic access$ methods in dfs, diff and merge

Java compiler must generate synthetic access methods for private methods
and fields of the enclosing class if they are accessed from inner
classes and vice versa.

While invisible in the code, those synthetic access methods exist in the
bytecode and seem to produce some extra execution overhead at runtime
(compared with the direct access to this fields or methods), see
https://git.eclipse.org/r/58948/.

By removing the "private" access modifier from affected methods and
fields we help compiler to avoid generation of synthetic access methods
and hope to improve execution performance.

To validate changes, one can either use javap or use Bytecode Outline
plugin in Eclipse. In both cases one should look for "synthetic
access$<number>" methods at the end of the class and inner class files
in question - there should be none.

NB: don't mix this "synthetic access$" methods up with "public synthetic
bridge" methods generated to allow generic method override return types.

Change-Id: I94fb481b68c84841c1db1a5ebe678b13e13c962b
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years ago[performance] Remove synthetic access$ methods in lib, util and dircache 72/59172/1
Andrey Loskutov [Wed, 28 Oct 2015 19:52:43 +0000 (20:52 +0100)]
[performance] Remove synthetic access$ methods in lib, util and dircache

Java compiler must generate synthetic access methods for private methods
and fields of the enclosing class if they are accessed from inner
classes and vice versa.

While invisible in the code, those synthetic access methods exist in the
bytecode and seem to produce some extra execution overhead at runtime
(compared with the direct access to this fields or methods), see
https://git.eclipse.org/r/58948/.

By removing the "private" access modifier from affected methods and
fields we help compiler to avoid generation of synthetic access methods
and hope to improve execution performance.

To validate changes, one can either use javap or use Bytecode Outline
plugin in Eclipse. In both cases one should look for "synthetic
access$<number>" methods at the end of the class and inner class files
in question - there should be none.

NB: don't mix this "synthetic access$" methods up with "public synthetic
bridge" methods generated to allow generic method override return types.

Change-Id: Ie7b65f251ec4452d5a5ed48aa0f272cf49a9aecd
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years ago[performance] Remove synthetic access$ methods in transport package 70/59170/1
Andrey Loskutov [Wed, 28 Oct 2015 19:24:12 +0000 (20:24 +0100)]
[performance] Remove synthetic access$ methods in transport package

Java compiler must generate synthetic access methods for private methods
and fields of the enclosing class if they are accessed from inner
classes and vice versa.

While invisible in the code, those synthetic access methods exist in the
bytecode and seem to produce some extra execution overhead at runtime
(compared with the direct access to this fields or methods), see
https://git.eclipse.org/r/58948/.

By removing the "private" access modifier from affected methods and
fields we help compiler to avoid generation of synthetic access methods
and hope to improve execution performance.

To validate changes, one can either use javap or use Bytecode Outline
plugin in Eclipse. In both cases one should look for "synthetic
access$<number>" methods at the end of the class and inner class files
in question - there should be none.

NB: don't mix this "synthetic access$" methods up with "public synthetic
bridge" methods generated to allow generic method override return types.

Change-Id: I0ebaeb2bc454cd8051b901addb102c1a6688688b
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years ago[performance] Remove synthetic access$ methods in pack and file packages 73/59073/2
Andrey Loskutov [Tue, 27 Oct 2015 22:51:21 +0000 (23:51 +0100)]
[performance] Remove synthetic access$ methods in pack and file packages

Java compiler must generate synthetic access methods for private methods
and fields of the enclosing class if they are accessed from inner
classes and vice versa.

While invisible in the code, those synthetic access methods exist in the
bytecode and seem to produce some extra execution overhead at runtime
(compared with the direct access to this fields or methods), see
https://git.eclipse.org/r/58948/.

By removing the "private" access modifier from affected methods and
fields we help compiler to avoid generation of synthetic access methods
and hope to improve execution performance.

To validate changes, one can either use javap or use Bytecode Outline
plugin in Eclipse. In both cases one should look for "synthetic
access$<number>" methods at the end of the class and inner class files
in question - there should be none.

NB: don't mix this "synthetic access$" methods up with "public synthetic
bridge" methods generated to allow generic method override return types.

Change-Id: If53ec94145bae47b74e2561305afe6098012715c
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
8 years agoAdd missing dependency to org.slf4j for org.eclipse.jgit.test bundle 84/58884/1
Matthias Sohn [Sat, 24 Oct 2015 19:18:01 +0000 (21:18 +0200)]
Add missing dependency to org.slf4j for org.eclipse.jgit.test bundle

This OSGi dependency was missed in 6c424d32.

Change-Id: I5bad895896194ad468c260d6c0810132a358f152
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
8 years agoMerge "WalkEncryptionTest: get rid of Log4J dependency"
Matthias Sohn [Fri, 23 Oct 2015 17:56:18 +0000 (13:56 -0400)]
Merge "WalkEncryptionTest: get rid of Log4J dependency"

8 years agoRestore TestRepository.getClock(), it is used by Gerrit/Gitiles 70/58770/1
Terry Parker [Thu, 22 Oct 2015 22:29:04 +0000 (15:29 -0700)]
Restore TestRepository.getClock(), it is used by Gerrit/Gitiles

Change-Id: I88880f18998e33377c0c684cbd8007b5d27d76e7
Signed-off-by: Terry Parker <tparker@google.com>
8 years agoAdd best-effort variant of File.getCanonicalFile() 60/58760/2
Thomas Wolf [Thu, 22 Oct 2015 19:23:18 +0000 (21:23 +0200)]
Add best-effort variant of File.getCanonicalFile()

See https://git.eclipse.org/r/#/c/58405/.

Change-Id: I097c4b1369754f59137eb8848a680c61b06510ad
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
8 years agoExpose bitmap selection parameters via PackConfig 84/58684/2
Terry Parker [Mon, 19 Oct 2015 22:59:47 +0000 (15:59 -0700)]
Expose bitmap selection parameters via PackConfig

Expose the following bitmap selection parameters via PackConfig:
"bitmapContiguousCommitCount", "bitmapRecentCommitCount",
"bitmapRecentCommitSpan", "bitmapDistantCommitSpan",
"bitmapExcessiveBranchCount", and "bitmapInactiveBranchAge".

The value of bitmapContiguousCommitCount, whereby bitmaps are
created for the most recent N commits in a branch, has never
been verified. If experiments show that they are not valuable,
then we can simplify the implementation so that there is only
a concept of recent and distant commit history (defined by
"bitmapRecentCommitCount"), and the only controls we need are
"bitmapRecentCommitSpan" and "bitmapDistantCommitSpan".

Change-Id: I288bf3f97d6fbfdfcd5dde2699eff433a7307fb9
Signed-off-by: Terry Parker <tparker@google.com>