]> source.dussan.org Git - jgit.git/log
jgit.git
7 years agoCorrect the boolean logic for filtering paths 32/91432/6
Magnus Vigerlöf [Sat, 18 Feb 2017 18:28:39 +0000 (19:28 +0100)]
Correct the boolean logic for filtering paths

The TreeWalk filtering classes need to support the three different
meanings of the return value the path comparison generates.
A new path comparison method (isPathMatch) is created with
three distinct return values (isPathPrefix use value '0' to
encode two of these) which will makes it possible for the logical
operators (especially NOT) to aggregate a correct verdict.

A filter like: AND(Path("path"), NOT(Path("path/to/other")))
Should filter out 'path/to/other/file', but not 'path/to/my/file'.

The path-limiting feature when testing path/to/my/file, would
result to run test for the following paths:

    path
    path/to
    path/to/my
    path/to/my/file

isPathPrefix('path/to/other') will return '0' for the first two
and since there is no way for NOT to distinguish between an exact
match and a match indicating that the tested path is a 'parent',
it will incorrectly return false and thus remove everything below
'path' immediately.
isPathMatch has a distinguished value for 'parent' matches that
will be preserved through the logic operators and should not
cause an over-eager removal of paths.

The functionality of isPathPrefix is required by other parts
and is untouched.

Unit tests are included to ensure that the logical functionality
is correct and can be preserved.

Change-Id: Ice2ca9406f09f1b179569e99b86a0e5d77baa20d
Signed-off-by: Magnus Vigerlöf <magnus.vigerlof@gmail.com>
7 years agoMerge "SHA1: support reset() and reuse instances"
Jonathan Nieder [Mon, 27 Feb 2017 00:01:36 +0000 (19:01 -0500)]
Merge "SHA1: support reset() and reuse instances"

7 years agoSHA1: support reset() and reuse instances 72/91872/5
Shawn Pearce [Sun, 26 Feb 2017 19:44:51 +0000 (11:44 -0800)]
SHA1: support reset() and reuse instances

Allow SHA1 instances to be reused to compute another hash value, and
resume caching them in ObjectInserter and PackParser.  This shaves a
small amount of running time off parsing git.git's pack file:

  before   after
  ------   ------
  25.25s   25.55s
  25.48s   25.06s
  25.26s   24.94s

Almost noise (small difference), but recycling the instances reduces
some stress on the memory allocator finding two 80 word message block
arrays needed for hashing and collision detection.

Change-Id: I4af88a720e81460293bc5c5d1d3db1a831e7e228

7 years agoMerge changes from topic 'SHAttered'
Jonathan Nieder [Sun, 26 Feb 2017 23:17:02 +0000 (18:17 -0500)]
Merge changes from topic 'SHAttered'

* changes:
  Switch to pure Java SHA1 for ObjectId
  Pure Java SHA-1

7 years agoUpdate Jetty to 9.4.1.v20170120 in buck build 76/91876/2
Jonathan Nieder [Sun, 26 Feb 2017 23:09:04 +0000 (15:09 -0800)]
Update Jetty to 9.4.1.v20170120 in buck build

5e8e2179b218ede7d14b69dc5149b0691b5859cf (Update Jetty to
9.4.1.v201470120, 2017-01-26) updated Jetty in the maven build.
Update the buck build to match so buck builds work again.

The buck build will go away soon, but in the meantime (until the bazel
build gets the same level of support) it is convenient as a faster way
of running tests than using maven.

The bazel build doesn't need this change since it doesn't build or run
http tests yet.

Change-Id: Ibbdaf2880e76b32fc9f6b5605a2ff29e3deffda2

7 years agoSwitch to pure Java SHA1 for ObjectId 37/91837/4
Shawn Pearce [Sat, 25 Feb 2017 07:33:18 +0000 (23:33 -0800)]
Switch to pure Java SHA1 for ObjectId

Generate names for objects using only the pure Java SHA1
implementation, but continue using MessageDigest in tests.
This opens the possibility of changing the hashing function
to incorporate additional safety measures, such as those
used in sha1dc[1].

Since MessageDigest has higher throughput, continue using
MessageDigest for computing pack, idx and DirCache trailers.
These are less likely to be sensitive to SHAttered[2] types
of attacks, as Git uses them to detect random bit flips
during transfer, and not for content identity.

[1] https://github.com/cr-marcstevens/sha1collisiondetection
[2] https://shattered.it/

Change-Id: If6da98334201f7f20cb916e46f782c45f373784e

7 years agoPure Java SHA-1 36/91836/4
Shawn Pearce [Fri, 24 Feb 2017 22:57:20 +0000 (14:57 -0800)]
Pure Java SHA-1

This implementation is derived straight from the description written
in RFC 3174.  On Mac OS X with Java 1.8.0_91 it offers similar
throughput as MessageDigest SHA-1:

  system   239.75 MiB/s
  system   244.71 MiB/s
  system   245.00 MiB/s
  system   244.92 MiB/s

  sha1     234.08 MiB/s
  sha1     244.50 MiB/s
  sha1     242.99 MiB/s
  sha1     241.73 MiB/s

This is the fastest implementation I could come up with.  Common SHA-1
implementation tricks such as unrolling loops creates a method too
large for the JIT to effectively optimize, resulting in lower overall
hashing throughput. Using a preprocessor to perform the register
renaming of A-E also didn't help, as again the method was too large
for the JIT to effectively optimize.

Fortunately the fastest version is a naive, straight-forward
implementation very close to the description in RFC 3174.

Change-Id: I228b05c4a294ca2ad51386cf0e47978c68e1aa42

7 years agoRemove unused imported package in org.eclipse.jgit.ant.test 10/91510/1
David Pursehouse [Mon, 20 Feb 2017 23:46:10 +0000 (08:46 +0900)]
Remove unused imported package in org.eclipse.jgit.ant.test

Change-Id: Id8e31a4d7cc25c3b953c67674797dc575b65f6c5
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoEnable and fix warnings about redundant specification of type arguments 50/91450/3
David Pursehouse [Mon, 20 Feb 2017 04:17:27 +0000 (13:17 +0900)]
Enable and fix warnings about redundant specification of type arguments

Since the introduction of generic type parameter inference in Java 7,
it's not necessary to explicitly specify the type of generic parameters.

Enable the warning in Eclipse, and fix all occurrences.

Change-Id: I9158caf1beca5e4980b6240ac401f3868520aad0
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoFix hamcrest dependency in org.eclipse.jgit.ant.test 48/91448/2
David Pursehouse [Mon, 20 Feb 2017 04:05:25 +0000 (13:05 +0900)]
Fix hamcrest dependency in org.eclipse.jgit.ant.test

Change-Id: I3361dce600698048b73a70cd991ad1a6b093e1da
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoAdd API filter for usage of FileRepository in test classes 47/91447/3
David Pursehouse [Mon, 20 Feb 2017 03:51:42 +0000 (12:51 +0900)]
Add API filter for usage of FileRepository in test classes

FileRepository is in the package org.eclipse.jgit.internal, and is
thus non-API. This causes warnings in Eclipse when FileRepository is
used.

Add a filter to prevent the warnings.

Change-Id: I9a8ae106c085bb0e826031fa183b4c4bdabcc5fc
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoFix bad test fix from 0bff481 "Limit receive commands" 97/91497/1
Shawn Pearce [Mon, 20 Feb 2017 18:51:27 +0000 (10:51 -0800)]
Fix bad test fix from 0bff481 "Limit receive commands"

In 0bff481d45db74db81a3b1b86f7401443a60d970 to accurately use the two
limits it was necessary to move the LimitedInputStream out of the
PacketLineIn and further down to the PackParser. Unfortuantely this
didn't survive review, as a buggy test failed and the "fix" was to
drop this part of the code.

The maxPackSizeLimit should apply to the pack stream, not the pkt-line
framing used to send commands to control the ReceivePack instance. The
commands are controlled using a different limit. The failing test allowed
too many bytes in the pack and was only failing because it was including
the command framing. The correct fix for the test was simply to drop the
limit lower, to more closely match the actual pack size.

Change-Id: I47d3885b9d7d527e153df7ac9c62fc2865ceecf4

7 years agoFix timestamp in Zip archives 96/91496/1
Shawn Pearce [Mon, 20 Feb 2017 18:30:58 +0000 (10:30 -0800)]
Fix timestamp in Zip archives

RevCommit.getCommitTime returns time in seconds since the epoch.
ZipArchiveEntry.setTime expects time in milliseconds.

Add the missing unit conversion to get the correct result.
Correct formatting to be consistent with the rest of the code.

Change-Id: I990b92f1d996ec8538d4857755694d91b142eb53

7 years agoAdd some more missing @Override annotations 44/91444/1
David Pursehouse [Mon, 20 Feb 2017 02:32:22 +0000 (11:32 +0900)]
Add some more missing @Override annotations

Change-Id: Ic13160920b986edde87c928c473240cc9c034f50
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoEnable and fix 'Should be tagged with @Override' warning 32/88732/7
David Pursehouse [Mon, 16 Jan 2017 05:39:32 +0000 (14:39 +0900)]
Enable and fix 'Should be tagged with @Override' warning

Set missingOverrideAnnotation=warning in Eclipse compiler preferences
which enables the warning:

  The method <method> of type <type> should be tagged with @Override
  since it actually overrides a superclass method

Justification for this warning is described in:

  http://stackoverflow.com/a/94411/381622

Enabling this causes in excess of 1000 warnings across the entire
code-base. They are very easy to fix automatically with Eclipse's
"Quick Fix" tool.

Fix all of them except 2 which cause compilation failure when the
project is built with mvn; add TODO comments on those for further
investigation.

Change-Id: I5772061041fd361fe93137fd8b0ad356e748a29c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoUpdate Jetty to 9.4.1.v20170120 43/91443/2
Matthias Sohn [Thu, 26 Jan 2017 00:03:16 +0000 (01:03 +0100)]
Update Jetty to 9.4.1.v20170120

MappedLoginService is no longer available in Jetty 9.4 therefore base
TestLoginService on AbstractLoginService.

Apparently Jetty now uses slf4j hence adapt RecordingLogger accordingly
so we can log error messages containing slf4j style formatting anchors
"{}".

Change-Id: Ibb36aba8782882936849b6102001a88b699bb65c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoFix typo in @since 35/91435/1
Thomas Wolf [Sun, 19 Feb 2017 15:46:44 +0000 (16:46 +0100)]
Fix typo in @since

Change-Id: I266b0c72d2827bcf2b86ddc6c1892d1a46c548eb
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoPullCommand: Allow to set tag behavior 43/91243/2
David Pursehouse [Thu, 16 Feb 2017 06:57:54 +0000 (15:57 +0900)]
PullCommand: Allow to set tag behavior

Add a new method setTagOpt which sets the annotated tag behavior during
fetch. Pass the option to the fetch command.

No explicit tests are added; the fetch with tags functionality is already
covered by the tests of the fetch command.

Change-Id: I131e1f68d8fcced178d8fa48abf7ffab17f8e173
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoAdd missing @Override annotations in org.eclipse.jgit.archive 19/91419/1
Matthias Sohn [Sat, 18 Feb 2017 09:48:58 +0000 (10:48 +0100)]
Add missing @Override annotations in org.eclipse.jgit.archive

Change-Id: I51e37ca7643da6abadbd36e9187ccb58fe713833
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoSet commit time to ZipArchiveEntry 16/91116/6
Naoki Takezoe [Thu, 29 Dec 2016 04:47:17 +0000 (13:47 +0900)]
Set commit time to ZipArchiveEntry

Archived zip files for a same commit have different MD5 hash because
mdate and mdate in the header of zip entries are not specified. In
this case, Commons Compress sets an archived time.

In the original git implementation, it's set a commit time:
https://github.com/git/git/blob/e2b2d6a172b76d44cb7b1ddb12ea5bfac9613a44/archive.c#L378

By this fix, archive command sets the commit time to ZipArchiveEntry
when RevCommit is given as an archiving target.

Change-Id: I30dd8710e910cdf42d57742f8709e9803930a123
Signed-off-by: Naoki Takezoe <takezoe@gmail.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoGC: don't loosen doomed objects 27/91327/3
David Turner [Thu, 16 Feb 2017 18:43:49 +0000 (13:43 -0500)]
GC: don't loosen doomed objects

If the pruneexpire config is set to "now", then any unreferenced loose
objects are immediately eligible for gc.  So there is no need to
actually write the loose objects.

Users who run hosting services which sometimes accept large, entirely
garbage packs might set the following configurations:

gc.pruneExpire = now
gc.prunePackExpire = 2.weeks

Then garbage objects will be kept around in packs, but after two weeks
the packs themselves will get deleted.

For client-side users of jgit, the default settings will loosen
garbage objects, and, after an hour, delete the old packs in which
they resided.

Change-Id: I8f686ac60b40181b1ee92ac6c313c3f33b55c44c
Signed-off-by: David Turner <dturner@twosigma.com>
7 years agoMerge "Update name of InsecureCipherMode error-prone pattern"
Jonathan Nieder [Thu, 16 Feb 2017 00:14:15 +0000 (19:14 -0500)]
Merge "Update name of InsecureCipherMode error-prone pattern"

7 years agoMerge "Update build to use Tycho 1.0.0"
Jonathan Nieder [Thu, 16 Feb 2017 00:06:04 +0000 (19:06 -0500)]
Merge "Update build to use Tycho 1.0.0"

7 years agoUpdate name of InsecureCipherMode error-prone pattern 27/91227/1
Jonathan Nieder [Thu, 16 Feb 2017 00:00:34 +0000 (16:00 -0800)]
Update name of InsecureCipherMode error-prone pattern

Without this, using bazel 0.4.4 to build fails:

 ERROR: jgit/org.eclipse.jgit/BUILD:29:1: Java compilation in rule '//org.eclipse.jgit:insecure_cipher_factory' failed: Worker process sent response with exit code: 1.
 jgit/src/org/eclipse/jgit/transport/InsecureCipherFactory.java:63: error: [InsecureCryptoUsage] Insecure usage of a crypto API: the transformation is not a compile-time constant expression.
                return Cipher.getInstance(algo);
                                         ^
    (see http://errorprone.info/bugpattern/InsecureCryptoUsage)

Change-Id: I7f9a3a5117e42cb68544674f5312df0368aa3674

7 years agoAdd missing skip garbage pack logic in DfsReader 25/91225/1
Zhen Chen [Wed, 15 Feb 2017 23:35:20 +0000 (15:35 -0800)]
Add missing skip garbage pack logic in DfsReader

* Missing garbage pack check in getObjectSize(AnyObjectId, int)
* Missing `last` pack check in has(AnyObjectId) and open(AnyObjectId,
int)

Change-Id: Idd1b9dd8db34c92d7da546fef1936ec9b2728718
Signed-off-by: Zhen Chen <czhen@google.com>
7 years agoUpdate build to use Tycho 1.0.0 23/91223/1
Matthias Sohn [Wed, 15 Feb 2017 22:44:12 +0000 (23:44 +0100)]
Update build to use Tycho 1.0.0

Change-Id: I10f61962e1496f079a39e0f533506816be56e925
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoSkip first pack if avoid garbage is set and it is a garbage pack 89/90989/5
Zhen Chen [Mon, 13 Feb 2017 20:36:25 +0000 (12:36 -0800)]
Skip first pack if avoid garbage is set and it is a garbage pack

At beginning of the OBJECT_SCAN loop, it will first check if the object
exists in the last pack, however, it forgot to avoid garbage pack for
the first iteration.

Change-Id: I8a99c0f439218d19c49cd4dae891b8cc4a57099d
Signed-off-by: Zhen Chen <czhen@google.com>
7 years agoRefactor skip garbage pack logic into a method 09/91009/2
Zhen Chen [Mon, 13 Feb 2017 23:28:10 +0000 (15:28 -0800)]
Refactor skip garbage pack logic into a method

There are multiple places in DfsReader to skip garbage pack if both of
the following conditions satisfied:

* AvoidUnreachable flag is set
* The pack is a garabge pack

Refactor them into a shared private method.

Change-Id: I67d6bb601db55f904437c807c6a3c36f0a723265
Signed-off-by: Zhen Chen <czhen@google.com>
7 years agoUpdate .mailmap 99/90899/1
David Pursehouse [Mon, 13 Feb 2017 01:19:42 +0000 (10:19 +0900)]
Update .mailmap

Change-Id: I88b219a90a4fd3b8111182bb519db58786dbbe6d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoLimit receive commands 08/77108/7
Shawn Pearce [Tue, 5 Jul 2016 01:04:43 +0000 (18:04 -0700)]
Limit receive commands

Place a configurable upper bound on the amount of command data
received from clients during `git push`.  The limit is applied to the
encoded wire protocol format, not the JGit in-memory representation.
This allows clients to flexibly use the limit; shorter reference names
allow for more commands, longer reference names permit fewer commands
per batch.

Based on data gathered from many repositories at $DAY_JOB, the average
reference name is well under 200 bytes when encoded in UTF-8 (the wire
encoding).  The new 3 MiB default receive.maxCommandBytes allows about
11,155 references in a single `git push` invocation.  A Gerrit Code
Review system with six-digit change numbers could still encode 29,399
references in the 3 MiB maxCommandBytes limit.

Change-Id: I84317d396d25ab1b46820e43ae2b73943646032c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoUpdate minimum JDK version in README 95/90795/2
David Pursehouse [Fri, 10 Feb 2017 06:58:26 +0000 (15:58 +0900)]
Update minimum JDK version in README

Change-Id: I655d896b268e946e3492661b08add0ebac22c6f0
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoUpgrade jacoco-maven-plugin to 0.7.9 91/90791/2
David Pursehouse [Fri, 10 Feb 2017 01:39:42 +0000 (10:39 +0900)]
Upgrade jacoco-maven-plugin to 0.7.9

Change-Id: Ifc0b0f2899f4094f0525021236c3e73658138f7e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoUpgrade maven-build-helper-plugin to 3.0.0 90/90790/2
David Pursehouse [Fri, 10 Feb 2017 01:39:22 +0000 (10:39 +0900)]
Upgrade maven-build-helper-plugin to 3.0.0

Change-Id: Ib354bf3a1c064f54255dc05de9e89e79dbcc9182
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoUpgrade maven-shade-plugin to 3.0.0 89/90789/2
David Pursehouse [Fri, 10 Feb 2017 01:38:32 +0000 (10:38 +0900)]
Upgrade maven-shade-plugin to 3.0.0

Change-Id: I46bf48657eceefc65b710a054df14dea5b9f15f8
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoFix inconsistent versioning of findbugs-maven-plugin 88/90788/2
David Pursehouse [Fri, 10 Feb 2017 01:36:37 +0000 (10:36 +0900)]
Fix inconsistent versioning of findbugs-maven-plugin

In one place version 3.0.4 is used, and in another place 3.0.3 is
used.

Define the version (3.0.4) in a property and use that in both places,
so it doesn't get inconsistent again next time the version is bumped.

Change-Id: If3a2489cec78c0c9ef76aa6b941fda51b098e04b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoUpgrade maven-compiler-plugin to 3.6.1 87/90787/2
David Pursehouse [Fri, 10 Feb 2017 01:28:57 +0000 (10:28 +0900)]
Upgrade maven-compiler-plugin to 3.6.1

Change-Id: Ia1c21c17ed6cd17c7ee353aa6a0bf1f88de5c045
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoLocalDiskRepositoryTestCase: Add clarifying comment in call to createRepository 14/90814/2
David Pursehouse [Fri, 10 Feb 2017 10:51:52 +0000 (19:51 +0900)]
LocalDiskRepositoryTestCase: Add clarifying comment in call to createRepository

Clarify that 'true' means 'auto close'. This makes it consistent with
other calls that have a boolean argument for 'bare'. It also makes it a
bit easier to see what's going on while stepping in the debugger, because
it's not necessary to scroll around to find the method declaration.

Change-Id: Idacd749407dcfd258af3efaaf44d129069925dd3
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoIndexDiffSubmoduleTest: Fix negative use count 19/89719/4
David Pursehouse [Fri, 10 Feb 2017 10:48:52 +0000 (19:48 +0900)]
IndexDiffSubmoduleTest: Fix negative use count

submoduleStandalone is created by createWorkRepository() which adds
the created repository to the set of repositories to be closed in
the test teardown. It is therefore not necessary to explicitly close
it.

Change-Id: Ib6f525b644fdeaaf1934df39cc2d3583a0d883dc
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoBlameGenerator: Annotate #getRenameDetector as Nullable 23/89923/5
David Pursehouse [Tue, 31 Jan 2017 05:52:52 +0000 (14:52 +0900)]
BlameGenerator: Annotate #getRenameDetector as Nullable

The renameDetector member returned by this method will be null when
following file renames has been disabled by previously calling:

  setFollowFileRenames(false).

Annotate it as @Nullable and update the Javadoc to explicitly
document the null return.

Change-Id: I9bdf443a64cf3c45352d3ab023051a2e11f7426d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoFetchCommandTest: Don't declare specific exceptions in test methods 01/90601/2
David Pursehouse [Wed, 8 Feb 2017 02:12:28 +0000 (11:12 +0900)]
FetchCommandTest: Don't declare specific exceptions in test methods

Change-Id: Ie0f8a0f7a9c2c383be6ae8265353daac7f5a89fa
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoPushCommandTest: Remove unused variables to prevent errors in Eclipse 97/90697/1
David Pursehouse [Thu, 9 Feb 2017 06:09:39 +0000 (15:09 +0900)]
PushCommandTest: Remove unused variables to prevent errors in Eclipse

Change-Id: Ie656b18fb151bf1e3c2dcc0438a77e32102991c2
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoRefLeaseSpec: Fix Eclipse errors 96/90696/1
David Pursehouse [Thu, 9 Feb 2017 06:08:47 +0000 (15:08 +0900)]
RefLeaseSpec: Fix Eclipse errors

- Remove unused import

- Remove unused private constructor

- Add Javadoc for public constructor

Change-Id: I1253e9fe863ca0f63182461ee87357fbf726ea2e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoMerge "push: support per-ref force-with-lease"
Shawn Pearce [Thu, 9 Feb 2017 03:27:03 +0000 (22:27 -0500)]
Merge "push: support per-ref force-with-lease"

7 years agopush: support per-ref force-with-lease 27/88127/3
David Turner [Wed, 4 Jan 2017 04:56:08 +0000 (23:56 -0500)]
push: support per-ref force-with-lease

When rebasing, force-pushing has a race condition: someone else might
have pushed a commit since the one you just rewrote. The force-with-lease
option prevents this by ensuring that the ref's old value is the one
that you expected.

Change-Id: I97ca9f8395396c76332bdd07c486e60549ca4401
Signed-off-by: David Turner <dturner@twosigma.com>
7 years agoAssume GC_REST and GC_TXN also attempted deltas during packing 88/90688/1
Shawn Pearce [Wed, 8 Feb 2017 23:34:00 +0000 (15:34 -0800)]
Assume GC_REST and GC_TXN also attempted deltas during packing

In a DFS repository the DfsGarbageCollector will typically attempt
delta compression while creating the three main pack files: GC,
GC_REST and GC_TXN. Include all of these in the wasDeltaAttempted()
decision so that future packers can bypass delta compression of
non-delta objects.

Change-Id: Ic2330c69fab0c494b920b4df0a290f3c2e1a03d7

7 years agoPrefer smaller GC files during DFS garbage collection 82/90482/5
Shawn Pearce [Tue, 7 Feb 2017 00:04:29 +0000 (16:04 -0800)]
Prefer smaller GC files during DFS garbage collection

In 8ac65d33ed7a94f77cb066271669feebf9b882fc PackWriter changed its
behavior to always prefer the last object representation presented
to it by the ObjectReuseAsIs implementation. This was a fix to avoid
delta chain cycles.

Unfortunately it can lead to suboptimal compression when concurrent
GCs are run on the same repository. One case is automatic GC running
(with default settings) in parallel to a manual GC that has disabled
delta reuse in order to generate new smaller deltas for the entire
history of the repository.

Running GC with no-reuse generally requires more CPU time, which
also translates to a longer running time.  This can lead to a race
where the automatic GC completes before the no-reuse GC, leaving
the repository in a state such as:

  no-reuse GC:   size 1 GiB, mtime = 18:45
  auto GC:       size 8 GiB, mtime = 17:30

With the default sort ordering, the smaller no-reuse GC pack is
sorted earlier in the pack list, due to its more recent mtime.

During object reuse in a future GC, these smaller representations
are considered first by PackWriter, but are all discarded when the
auto GC file from 17:30 is examined second (due to its older mtime).

Work around this in two ways.

Well formed DFS repositories should have at most 1 GC pack. If
2 or more GC packs exist, break the sorting tie by selecting the
smaller file earlier in the pack list. This allows all normal read
code paths to favor the smaller file, which places less pressure
on the DfsBlockCache. If any GC race happens, readers serving clone
requests will prefer the file that is smaller.

During object reuse, flip this ordering so that the smaller file is
last. This allows PackWriter to see smaller deltas last, replacing
larger representations that were previously considered from other
pack files.

Change-Id: I0b7dc8bb9711c82abd6bd16643f518cfccc6d31a

7 years agoFix missing deltas near type boundaries 04/90604/3
Shawn Pearce [Wed, 8 Feb 2017 05:00:30 +0000 (21:00 -0800)]
Fix missing deltas near type boundaries

Delta search was discarding discovered deltas if an object appeared
near a type boundary in the delta search window. This has caused JGit
to produce larger pack files than other implementations of the packing
algorithm.

Delta search works by pushing prior objects into a search window, an
ordered list of objects to attempt to delta compress the next object
against. (The window size is bounded, avoiding O(N^2) behavior.)

For implementation reasons multiple object types can appear in the
input list, and the window. PackWriter commonly passes both trees and
blobs in the input list handed to the DeltaWindow algorithm. The pack
file format requires an object to only delta compress against the same
type, so the DeltaWindow algorithm must stop doing comparisions if a
blob would be compared to a tree.

Because the input list is sorted by object type and the window is
recently considered prior objects, once a wrong type is discovered in
the window the search algorithm stops and uses the current result.

Unfortunately the termination condition was discarding any found
delta by setting deltaBase and deltaBuf to null when it was trying
to break the window search.

When this bug occurs, the state of the DeltaWindow looks like this:

                                 current
                                  |
                                 \ /
  input list:  tree0 tree1 blob1 blob2

  window:      blob1 tree1 tree0
                / \
                 |
              res.prev

As the loop iterates to the right across the window, it first finds
that blob1 is a suitable delta base for blob2, and temporarily holds
this in the bestDelta/deltaBuf fields. It then considers tree1, but
tree1 has the wrong type (blob != tree), so the window loop must give
up and fall through the remaining code.

Moving the condition up and discarding the window contents allows
the bestDelta/deltaBuf to be kept, letting the final file delta
compress blob1 against blob0.

The impact of this bug (and its fix) on real world repositories is
likely minimal. The boundary from blob to tree happens approximately
once in the search, as the input list is sorted by type. Only the
first window size worth of blobs (e.g. 10 or 250) were failing to
produce a delta in the final file.

This bug fix does produce significantly different results for small
test repositories created in the unit test suite, such as when a pack
may contains 6 objects (2 commits, 2 trees, 2 blobs).  Packing test
cases can now better sample different output pack file sizes depending
on delta compression and object reuse flags in PackConfig.

Change-Id: Ibec09398d0305d4dbc0c66fce1daaf38eb71148f

7 years agoMerge "Reintroduce garbage pack coalescing when ttl > 0."
Shawn Pearce [Wed, 8 Feb 2017 05:23:32 +0000 (00:23 -0500)]
Merge "Reintroduce garbage pack coalescing when ttl > 0."

7 years agoReintroduce garbage pack coalescing when ttl > 0. 65/90465/4
Thirumala Reddy Mutchukota [Mon, 6 Feb 2017 22:08:27 +0000 (14:08 -0800)]
Reintroduce garbage pack coalescing when ttl > 0.

Disabling the garbage pack coalescing when garbageTtl > 0 can result in
lot of garbage packs if they are created within the garbageTtl time.

To avoid a large number of garbage packs, re-introducing garbage pack
coalescing for the packs that are created within a single calendar day
when the garbageTtl is more than one day or one third of the garbageTtl.

Change-Id: If969716aeb55fb4fd0ff71d75f41a07638cd5a69
Signed-off-by: Thirumala Reddy Mutchukota <thirumala@google.com>
7 years agoMerge "Branch normalizer should not normalize already valid branch names"
David Pursehouse [Tue, 7 Feb 2017 12:31:03 +0000 (07:31 -0500)]
Merge "Branch normalizer should not normalize already valid branch names"

7 years ago[infer] Fix ObjectWalk leak in PackWriter.preparePack() 27/90227/2
Matthias Sohn [Thu, 2 Feb 2017 23:47:14 +0000 (00:47 +0100)]
[infer] Fix ObjectWalk leak in PackWriter.preparePack()

Change-Id: I5d2455404e507faa717e9d916e9b6cd80aa91473
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoBranch normalizer should not normalize already valid branch names 74/90474/2
Matthias Sohn [Mon, 6 Feb 2017 23:22:57 +0000 (00:22 +0100)]
Branch normalizer should not normalize already valid branch names

Change-Id: Ib746655e32a37c4ad323f1d12ac0817de8fa56cf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoFollow redirects in transport 11/88811/6
Bo Zhang [Mon, 16 Jan 2017 06:19:17 +0000 (14:19 +0800)]
Follow redirects in transport

Bug: 465167
Change-Id: I6da19c8106201c2a1ac69002bd633b7387f25d96
Signed-off-by: Bo Zhang <zhangbodut@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoMerge branch 'stable-4.6' 22/90222/1
Matthias Sohn [Thu, 2 Feb 2017 22:36:28 +0000 (23:36 +0100)]
Merge branch 'stable-4.6'

* stable-4.6:
  GC: delete empty directories after purging loose objects
  GC.prune(Set<ObjectId>): return early if objects directory is empty

Change-Id: I3d6cacf80d3b4c69ba108e970855963bd9f6ee78
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoGC: delete empty directories after purging loose objects 24/89824/3
Matthias Sohn [Mon, 30 Jan 2017 00:24:45 +0000 (01:24 +0100)]
GC: delete empty directories after purging loose objects

In order to limit the number of directories we check for emptiness only
consider fanout directories which contained unreferenced loose objects
we deleted in the same gc run.

Change-Id: Idf8d512867ee1c8ed40bd55752122ce83a98ffa2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoOrganize imports 28/90028/1
David Pursehouse [Wed, 1 Feb 2017 05:31:44 +0000 (14:31 +0900)]
Organize imports

Change-Id: I97044f69d220fc2d3f9fe890fdfec542454f02d2
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoDetect stale-file-handle error in causal chain 89/89589/5
Hongkai Liu [Tue, 24 Jan 2017 19:08:25 +0000 (14:08 -0500)]
Detect stale-file-handle error in causal chain

Cover the case where the exception is wrapped up as a
cause, e.g., PackIndex#open(File).

Change-Id: I0df5b1e9c2ff886bdd84dee3658b6a50866699d1
Signed-off-by: Hongkai Liu <hongkai.liu@ericsson.com>
7 years agoMerge branch 'stable-4.6' 20/89920/2
David Pursehouse [Tue, 31 Jan 2017 00:30:32 +0000 (09:30 +0900)]
Merge branch 'stable-4.6'

* stable-4.6:
  Clean up orphan files in GC

Change-Id: I4fb6b4cd03d032535a9c04ede784bea880b4536b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoMerge "Don't rely on default locale when using toUpperCase() and toLowerCase()"
David Pursehouse [Mon, 30 Jan 2017 12:32:30 +0000 (07:32 -0500)]
Merge "Don't rely on default locale when using toUpperCase() and toLowerCase()"

7 years agoMerge FileTreeIteratorJava7Test into FileTreeIteratorTest 70/89570/4
David Pursehouse [Thu, 26 Jan 2017 04:38:50 +0000 (13:38 +0900)]
Merge FileTreeIteratorJava7Test into FileTreeIteratorTest

JGit now requires Java 8, so it is no longer necessary to have a
separate class for Java 7 specific tests. Remove it and merge its
tests into the existing FileTreeIteratorTest.

FileTreeIteratorTest has an @Before annotated method that sets up
some files in the git, which breaks the tests which have assumptions
on the file names. Add adjustments.

Change-Id: I14f88d8e079e1677c8dfbc1fcbf4444ea8265365
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoRename FileUtilTest to FileUtilsTest and merge in FileUtils7Test 23/89523/4
Hongkai Liu [Tue, 24 Jan 2017 20:14:40 +0000 (15:14 -0500)]
Rename FileUtilTest to FileUtilsTest and merge in FileUtils7Test

Rename the test class to match the name of the class under test.

JGit now requires Java 8 so it is no longer necessary to have a
separate class (FileUtils7Test) for Java 7 tests. Merge those into
FileUtilsTest.

Change-Id: I39dd7e76a2e4ce97319c7d52261b0a1546879788
Signed-off-by: Hongkai Liu <hongkai.liu@ericsson.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoMake GC cancellable when called programmatically 00/89600/6
Hector Caballero [Thu, 26 Jan 2017 16:24:49 +0000 (11:24 -0500)]
Make GC cancellable when called programmatically

Sometimes, it is necessary to cancel a garbage collection operation.
When GC is called using the standalone executable, i.e., from a command
line, Control-Cing the process does the trick. When calling GC
programmatically, though, there is no mechanism to do it.

Add checks in the GC process so that a custom cancellable progress
monitor could be passed in order to cancel the operation at specific
points. In this case, the calling process set the cancel flag in the
progress monitor and the GC process will throw an exception that can
be caught and handled by the caller accordingly.

Change-Id: Ieaecf3dbdf244539ec734939c065735f6785aacf
Signed-off-by: Hector Caballero <hector.caballero@ericsson.com>
7 years agoGC.prune(Set<ObjectId>): return early if objects directory is empty 23/89823/1
Matthias Sohn [Sun, 29 Jan 2017 23:52:33 +0000 (00:52 +0100)]
GC.prune(Set<ObjectId>): return early if objects directory is empty

Change-Id: Id56b102604c4e0437230e3e7c59c0a3a1b676256
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoClean up orphan files in GC 95/89395/8
Hongkai Liu [Mon, 23 Jan 2017 16:33:40 +0000 (11:33 -0500)]
Clean up orphan files in GC

An orphan file is either a bitmap or an idx file in pack folder,
and its corresponding pack file is missing.

Change-Id: I3c4cb1f7aa99dd7b398bdb8d513f528d7761edff
Signed-off-by: Hongkai Liu <hongkai.liu@ericsson.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoRepositoryCacheTest: avoid to close already closed repository 11/89811/1
Matthias Sohn [Sat, 28 Jan 2017 20:19:55 +0000 (21:19 +0100)]
RepositoryCacheTest: avoid to close already closed repository

The tearDown() of the superclass closed the repository once more which
led to a negative use count warning logged by Repository.close().

Change-Id: I331f85a540c68264a53456276c32f72b79113d61
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoRefUpdateTest: Don't call createBareRepository in try-with-resource 23/89723/2
David Pursehouse [Fri, 27 Jan 2017 10:33:20 +0000 (19:33 +0900)]
RefUpdateTest: Don't call createBareRepository in try-with-resource

createBareRepository adds the created repo to the list of repos to be
closed in the superclass's teardown. Wrapping it in try-with-resource
causes it to be closed too many times, resulting in a corrupt use
count.

Change-Id: I4c70630bf6008544324dda453deb141f4f89472c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoReceivePackAdvertiseRefsHookTest: Don't close repositories in teardown 68/89668/2
David Pursehouse [Fri, 27 Jan 2017 08:08:09 +0000 (17:08 +0900)]
ReceivePackAdvertiseRefsHookTest: Don't close repositories in teardown

The repositories get added to the "toClose" set by createBareRepository,
and are then closed in the superclass's tearDown method.

Explicitly closing them in this test class's teardown causes the use
count to go negative when subsequently closed again by the superclass.

Change-Id: Idcbb16b4cf4bf0640d7e4ac15d1926d8a27c1251
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoRepoCommand#readFile: Don't call Git#getRepository() in try-with-resource 66/89666/2
David Pursehouse [Fri, 27 Jan 2017 05:44:14 +0000 (14:44 +0900)]
RepoCommand#readFile: Don't call Git#getRepository() in try-with-resource

Using try-with-resource means that close() will automatically be
called on the Repository object. However, according to the javadoc
of Git#close():

  If the repository was opened by a static factory method in this class,
  then this method calls Repository#close() on the underlying repository
  instance.

This means that Repository#close() is called twice, by Git.close()
and in the outer try-with-resource, leading to a corrupt use count.

Change-Id: I37ba517eb2cc67d1cd36813598772c70208d0bc9
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoRepoCommandTest: Don't wrap create{Bare,Work}Directory in t-w-r 65/89665/2
David Pursehouse [Fri, 27 Jan 2017 06:51:55 +0000 (15:51 +0900)]
RepoCommandTest: Don't wrap create{Bare,Work}Directory in t-w-r

These methods add the created Repository into "toClose", and they are
then closed by LocalDiskRepositoryTestCase's tearDown method.

Calling them in try-with-resource causes them to first be closed in
the test method, and then again in tearDown, which results in the use
count going negative and a log message on the console.

While this is not a serious problem, having so many false positives
in the logs will potentially drown out real cases of Repository being
closed too many times.

Change-Id: Ib374445e101dc11cb840957b8b19ee1caf777392
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoLocalDiskRepositoryTestCase: Only add to toClose through access method 63/89663/2
David Pursehouse [Fri, 27 Jan 2017 03:05:12 +0000 (12:05 +0900)]
LocalDiskRepositoryTestCase: Only add to toClose through access method

Only using the access method means we only have one place where the
toClose set is modified, making it easier to debug either by adding
log statements or by setting a breakpoint.

Change-Id: I4f9f1774d5f2e10bcab381edfd84bb6ee0499a11
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoGitConstructionTest: Remove unnecessary calls to Repository.close() 62/89662/2
David Pursehouse [Fri, 27 Jan 2017 01:08:11 +0000 (10:08 +0900)]
GitConstructionTest: Remove unnecessary calls to Repository.close()

The repositories are already closed in the superclass teardown due
to being added to the "toClose" set.

Change-Id: I768ba8a02fc585907687caf37e2e283434016c04
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoMerge "LocalDiskRepositoryTestCase: Prevent duplicates in list of repos to close"
Matthias Sohn [Sat, 28 Jan 2017 16:45:19 +0000 (11:45 -0500)]
Merge "LocalDiskRepositoryTestCase: Prevent duplicates in list of repos to close"

7 years agoMerge "Remove unused org.apache.http.impl.client.cache requirement"
Andrey Loskutov [Sat, 28 Jan 2017 15:04:28 +0000 (10:04 -0500)]
Merge "Remove unused org.apache.http.impl.client.cache requirement"

7 years agoDon't rely on default locale when using toUpperCase() and toLowerCase() 04/89804/1
Matthias Sohn [Sat, 28 Jan 2017 14:06:15 +0000 (15:06 +0100)]
Don't rely on default locale when using toUpperCase() and toLowerCase()

Otherwise these methods may produce unexpected results if used for
strings that are intended to be interpreted locale independently.
Examples are programming language identifiers, protocol keys, and HTML
tags. For instance, "TITLE".toLowerCase() in a Turkish locale returns
"t\u0131tle", where '\u0131' is the LATIN SMALL LETTER DOTLESS I
character.

See
https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#toLowerCase--
http://blog.thetaphi.de/2012/07/default-locales-default-charsets-and.html

Bug: 511238
Change-Id: Id8d8f37d84d62239c918b81f8d883ed798d87656
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoLocalDiskRepositoryTestCase: Prevent duplicates in list of repos to close 61/89661/1
David Pursehouse [Fri, 27 Jan 2017 02:32:18 +0000 (11:32 +0900)]
LocalDiskRepositoryTestCase: Prevent duplicates in list of repos to close

Change the "toClose" list to a set, which will not allow duplicate
entries. This reduces the number of false positive logs about corrupt
use count due to the same repository being closed more than once during
teardown.

Change-Id: I5ab0ff8b56e7f2b2c7aab5274d957708d26f42c5
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoRepository: Include repository name when logging corrupt use count 60/89660/1
David Pursehouse [Fri, 27 Jan 2017 02:23:22 +0000 (11:23 +0900)]
Repository: Include repository name when logging corrupt use count

Logging the repository name makes it easier to track down what is
incorrectly closing a repository.

Change-Id: I42a8bdf766c0e67f100adbf76d9616584e367ac2
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoRecord the estimated size of the pack files. 59/89259/8
Thirumala Reddy Mutchukota [Fri, 20 Jan 2017 22:31:01 +0000 (14:31 -0800)]
Record the estimated size of the pack files.

The Compacter and Garbage Collector will record the estimated size of
the newly going to be created compact, gc or garbage packs. This
information can be used by the clients to better make a call on how to
actually store the pack based on the approximated expected size.

Added a new protected method DfsObjDatabase.newPack(PackSource
packSource, long estimatedPackSize), so that the clients can override
this method to make use of the estimatedPackSize while creating a new
PackDescription object. The default implementation of this method is
equivalent to
newPack(packSource).setEstimatedPackSize(estimatedPackSize). I didn't
make it abstract because that would force all the existing sub classes
of DfsObjDatabase to implement this method. Due to this default
implementation, the estimatedPackSize is added to DfsPackDescription
using a setter instead of a constructor parameter (even though
constructor parameter would be a better choice as this value is set only
during the object creation).

Change-Id: Iade1122633ea774c2e842178a6a6cbb4a57b598b
Signed-off-by: Thirumala Reddy Mutchukota <thirumala@google.com>
7 years agoRemove unused org.apache.http.impl.client.cache requirement 93/89593/2
Andrey Loskutov [Thu, 26 Jan 2017 15:35:42 +0000 (16:35 +0100)]
Remove unused org.apache.http.impl.client.cache requirement

The package is not used by the plugin and seems to be missing in the
platform anyway under some conditions, see bug 508321 (newer
org.apache.httpcomponents.httpclient_4.5.2 does NOT include the package,
org.apache.httpcomponents.httpclient_4.3.6 does).

Change-Id: Ida5d926a611812b5177af651b3cf22f1b2519e02
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
7 years agoMerge branch 'stable-4.6' 69/89569/1
David Pursehouse [Thu, 26 Jan 2017 02:01:26 +0000 (11:01 +0900)]
Merge branch 'stable-4.6'

* stable-4.6:
  Update Orbit to S20170120205402 and com.jcraft.jsch to 0.1.54
  Fix preparation of 4.6.1-SNAPSHOT builds

Change-Id: Ifd1f81cb199a0b5bd35e8652cac116e377136b2d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoFixes Javadoc error in org.eclipse.jgit created with I59539ac 29/89529/4
Lars Vogel [Wed, 25 Jan 2017 16:05:19 +0000 (17:05 +0100)]
Fixes Javadoc error in org.eclipse.jgit created with I59539ac

Adds the param information to the private method. These are generated
via tooltip to resolve the compile errors.

Bug: 511043
Change-Id: I9ba551978eab750326d1a067b296e3ae93925871
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
7 years agoRemove @since tags from internal packages 62/89462/3
Jonathan Nieder [Tue, 24 Jan 2017 18:16:19 +0000 (10:16 -0800)]
Remove @since tags from internal packages

These packages don't use @since tags because they are not part of the
stable public API.  Some @since tags snuck in, though.  Remove them to
make the convention easier to find for new contributors and the
expectations clearer for users.

Change-Id: I6c17d3cfc93657f1b33cf5c5708f2b1c712b0d31

7 years agogc: loosen unreferenced objects 55/89455/4
David Turner [Tue, 24 Jan 2017 16:31:22 +0000 (11:31 -0500)]
gc: loosen unreferenced objects

An unreferenced object might appear in a pack.  This could only happen
because it was previously referenced, and then later that reference
was removed.  When we gc, we copy the referenced objects into a new
pack, and delete the old pack.  This would remove the unreferenced
object.  Now we first create a loose object from any unreferenced
object in the doomed pack.  This kicks off the two-week grace period
for that object, after which it will be collected if it's not
referenced.

This matches the behavior of regular git.

Change-Id: I59539aca1d0d83622c41aa9bfbdd72fa868ee9fb
Signed-off-by: David Turner <dturner@twosigma.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
7 years agoUpdate Orbit to S20170120205402 and com.jcraft.jsch to 0.1.54 60/89560/1
Matthias Sohn [Sat, 21 Jan 2017 08:32:00 +0000 (09:32 +0100)]
Update Orbit to S20170120205402 and com.jcraft.jsch to 0.1.54

CQ: 12553
Change-Id: Ie72b48d00f363e3dc05b9733018a6ddca32c3e6e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoFix preparation of 4.6.1-SNAPSHOT builds 59/89559/1
Matthias Sohn [Mon, 23 Jan 2017 19:29:20 +0000 (20:29 +0100)]
Fix preparation of 4.6.1-SNAPSHOT builds

Change-Id: Ib241c4f45192672712526599898c0bd0bd356436
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years ago[infer] Mark ManifestParse.getFilteredProjects non-null 87/89387/2
Matthias Sohn [Mon, 23 Jan 2017 00:06:30 +0000 (01:06 +0100)]
[infer] Mark ManifestParse.getFilteredProjects non-null

Change-Id: I05653df7a0337443d2c8e53f47f4e95ec9ca1a9c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years ago[infer] Fix potential NPE in DiffFormatter 86/89386/2
Matthias Sohn [Sun, 22 Jan 2017 23:53:50 +0000 (00:53 +0100)]
[infer] Fix potential NPE in DiffFormatter

Change-Id: Ia33e2af9ce3393d9173ca0dc7efefd86c965d8c8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years ago[infer] Fix potential NPE in CloneCommand 85/89385/2
Matthias Sohn [Sun, 22 Jan 2017 23:15:28 +0000 (00:15 +0100)]
[infer] Fix potential NPE in CloneCommand

Change-Id: Ie7eeba3ae719ff207c7535d535a9e0bd6c9e99e6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoImplement Bazel build for http-apache, lfs, lfs-server 64/89164/2
David Pursehouse [Fri, 20 Jan 2017 03:58:46 +0000 (12:58 +0900)]
Implement Bazel build for http-apache, lfs, lfs-server

Test plan:

  $ bazel build all

  $ unzip -t bazel-genfiles/all.zip
    Archive:  bazel-genfiles/all.zip
      testing: libhttp-apache.jar       OK
      testing: libjgit-archive.jar      OK
      testing: libjgit-lfs-server.jar   OK
      testing: libjgit-lfs.jar          OK
      testing: libjgit-servlet.jar      OK
      testing: libjgit.jar              OK
      testing: libjunit.jar             OK
    No errors detected in compressed data of bazel-genfiles/all.zip.

Change-Id: I9e6c60898ccc6d2a4557ec7544c297442a9702b4
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoFormat Bazel files with buildifier 63/89163/2
David Pursehouse [Fri, 20 Jan 2017 04:03:03 +0000 (13:03 +0900)]
Format Bazel files with buildifier

Change-Id: I934114315d2c7cab917f1011b8e55c52367d429f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoChange StreamGobbler to Runnable to avoid unused Future 40/89240/2
Shawn Pearce [Fri, 20 Jan 2017 16:41:29 +0000 (08:41 -0800)]
Change StreamGobbler to Runnable to avoid unused Future

It can be considered a programming error to create a Future<T>
but do nothing with that object. There is an async computation
happening and without holding and checking the Future for done
or exception the caller has no idea if it has completed.

FS doesn't really care about these StreamGobblers finishing.
Instead use Runnable with execute(Runnable), which doesn't
return a Future.

Change-Id: I93b66d1f6c869e66be5c1169d8edafe781e601f6

7 years agoAdd missing @since tags on new API constants 51/89151/1
Matthias Sohn [Thu, 19 Jan 2017 22:56:25 +0000 (23:56 +0100)]
Add missing @since tags on new API constants

Change-Id: Ia8b861da07fba99644ccc9eb5578a46cc39600a1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agogc: Add options to preserve and prune old pack files 69/87969/5
James Melvin [Tue, 3 Jan 2017 18:41:56 +0000 (11:41 -0700)]
gc: Add options to preserve and prune old pack files

The new --preserve-oldpacks option moves old pack files into the
preserved subdirectory instead of deleting them after repacking.

The new --prune-preserved option prunes old pack files from the
preserved subdirectory after repacking, but before potentially
moving the latest old packfiles to this subdirectory.

These options are designed to prevent stale file handle exceptions
during git operations which can happen on users of NFS repos when
repacking is done on them. The strategy is to preserve old pack files
around until the next repack with the hopes that they will become
unreferenced by then and not cause any exceptions to running processes
when they are finally deleted (pruned).

Change-Id: If3f729f0d9ce920ee2c3e6acdde46f2068be61d2
Signed-off-by: James Melvin <jmelvin@codeaurora.org>
7 years agoMake ObjectDownloadListener public 70/89070/1
David Pursehouse [Thu, 19 Jan 2017 04:42:14 +0000 (13:42 +0900)]
Make ObjectDownloadListener public

The same was already done for ObjectUploadListener in I5b0fb1220.

Change-Id: Ie8a79f715fe69bed9331962fb478f7e35acf8680
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoImplement initial framework of Bazel build 27/84527/10
David Ostrovsky [Sun, 6 Nov 2016 08:06:54 +0000 (09:06 +0100)]
Implement initial framework of Bazel build

The initial implementation only builds the packages consumed by
Gerrit Code Review.

Test build and execution is not implemented.

We prefer to consume maven_jar custom rule from bazlets repository,
for the same reasons as in the Gerrit project:

* Caching artifacts across different clones and projects
* Exposing source classifiers and neverlink artifact

TEST PLAN:

  $ bazel build :all
  $ unzip -t bazel-genfiles/all.zip
  Archive: bazel-genfiles/all.zip
    testing: libjgit-archive.jar      OK
    testing: libjgit-servlet.jar      OK
    testing: libjgit.jar              OK
    testing: libjunit.jar             OK
  No errors detected in compressed data of bazel-genfiles/all.zip.

Change-Id: Ia837ce95d9829fe2515f37b7a04a71a4598672a0
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoNormalizer creating a valid branch name from a string 31/88131/9
Wim Jongman [Fri, 6 Jan 2017 01:27:43 +0000 (02:27 +0100)]
Normalizer creating a valid branch name from a string

Generic normalization method for a possible invalid branch name.
The method compresses dividers between spaces, then replaces spaces
and non word characters with underscores.

This method is needed in preparation for subsequent EGit changes.

Bug: 509878
Change-Id: Ic0d12f098f90f912a45bcc5693d6accf751d4e58
Signed-off-by: Wim Jongman <wim.jongman@remainsoftware.com>
7 years agoMerge "Fix StashApplyCommand for stashes containing untracked changes."
Christian Halstrick [Mon, 16 Jan 2017 08:44:57 +0000 (03:44 -0500)]
Merge "Fix StashApplyCommand for stashes containing untracked changes."

7 years agoFix StashApplyCommand for stashes containing untracked changes. 26/88726/3
Thomas Wolf [Sun, 15 Jan 2017 20:35:50 +0000 (21:35 +0100)]
Fix StashApplyCommand for stashes containing untracked changes.

If there are untracked changes, apply only the untracked tree
after a successful merge. The merge tree from merging untracked
with HEAD would also contain files already reset before (changes
in tracked files) and try to reset those again,leading to false
checkout conflicts.

Bug: 505804
Change-Id: Iaced4d277623334d11e3d1cca5969590d7c5093e
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoFix possible InvalidObjectIdException in ObjectDirectory 78/88378/4
Marc Strapetz [Tue, 10 Jan 2017 15:28:54 +0000 (16:28 +0100)]
Fix possible InvalidObjectIdException in ObjectDirectory

ObjectDirectory.getShallowCommits should throw an IOException
instead of an InvalidArgumentException if invalid SHAs are present
in .git/shallow (as this file is usually edited by a human).

Change-Id: Ia3a39d38f7aec4282109c7698438f0795fbec905
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoAdd missing slf4j dependency in BUCK file for jgit-lfs-server 93/88693/2
Zhen Chen [Sat, 14 Jan 2017 06:27:36 +0000 (22:27 -0800)]
Add missing slf4j dependency in BUCK file for jgit-lfs-server

Change-Id: I0c7fcae123f94ebd8e5eb2700e3d601a1b199be9
Signed-off-by: Zhen Chen <czhen@google.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoSkip pack header bytes in DfsPackFile 92/88692/1
Zhen Chen [Sat, 14 Jan 2017 06:02:37 +0000 (22:02 -0800)]
Skip pack header bytes in DfsPackFile

The 12 bytes `PACK...` header is written in PackWriter before reading
CachedPack files. In DfsPackFile#copyPackBypassCache, the header was not
skipped when the first block is not in cache.

Change-Id: Ibbe2e564d36b79922a936657f286addb1044d237
Signed-off-by: Zhen Chen <czhen@google.com>