Commit Graph

4625 Commits

Author SHA1 Message Date
Marco Miller 00db4ab06e Fix config value get to return last instead of 1st just like git
Before this fix, getting the value of 'key' below used to return
value1. This fix makes it so that value3 gets returned instead,
just like native git's get.

[section]
  key = value1
  key = value2
  key = value3

Change-Id: Iccb24de9b63c3ad8646c909494ca3f8c9ed6e29c
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-05-12 00:26:38 +02:00
Marco Miller e5a9915a92 Remove UTF-8 checking duplication in Config lib subclasses
Change-Id: Ib9f0ae8207000a36c5bf1a92fcc2c32efc4c0984
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-05-12 00:14:17 +02:00
Matthias Sohn 3bc46dfed5 Update Maven plugins
to the following versions:
build-helper-maven-plugin 1.10
eclipse-jarsigner-plugin 1.1.3
findbugs-maven-plugin 3.0.3
jacoco-maven-plugin 0.7.6.201602180812
maven-clean-plugin 3.0.0
maven-compiler-plugin 3.5.1
maven-javadoc-plugin 2.10.3
maven-pmd-plugin 3.6
maven-project-info-reports-plugin 2.9
maven-resources-plugin 2.7
maven-shade-plugin 2.4.3
maven-site-plugin 3.5.1
maven-source-plugin 3.0.0
maven-surefire-plugin 2.19.1
maven-surefire-report-plugin 2.19.1
tycho 0.25
tycho-extras 0.25
wagon-ssh 2.10

Change-Id: I4dc57de77ab7838964e8fe3de1d50f28d67fcf4b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-05-07 23:50:48 +02:00
Matthias Sohn 41b194c718 JGit v4.3.1.201605051710-r
Change-Id: I25fb72cc17d7a27b0b69746d907dac9ccd4d7997
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-05-05 23:08:18 +02:00
Matthias Sohn 0c72f60fbf Fix type parameter in javadoc in TestRepository.delete(String ref)
Type parameter T extends AnyObjectId in signature of update(String, T)

Change-Id: I9c13ddc572b8e94d5c7854f4de1f8206cb5e99ca
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-05-05 22:51:14 +02:00
Matthias Sohn 89db7e01fa Merge branch 'stable-4.3'
* stable-4.3:
  Scan loose ref before packed in case gc about to remove the loose
  Fix possible NPEs when reporting transport errors
  Fix calling of clean/smudge filters from Checkout,MergeCommands
  Fix ApplyCommand when result of patch is an empty file

Change-Id: I0dc76b7a8c87ce8e0386a1b9e0fa92a3aa62abf7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-05-05 01:13:45 +02:00
Marco Miller 05fd01656e Scan loose ref before packed in case gc about to remove the loose
Before this change, jgit used to read packed-refs before scanning
loose refs. That was not a problem if gc didn't run concurrently. When
gc did run concurrently with such refs reading, that order sometimes
broke the latter. This lead to reading an older version of a ref's
tip, which meant "losing" the real tip or commit. The specific
read-Vs-gc concurrency scenario which broke reading that way follows:

1. let ref R be in packed-refs and R' be in loose
2. jgit starts reading packed-refs
3. gc also starts its business around that very time
4. jgit still has the time to read R from packed-refs
5. as gc is not done yet updating packed-refs with R'
6. jgit then starts scanning loose refs (or is about to)
7. gc quickly ends up being done moving loose R' to packed-refs
8. so gc (quickly) removes loose refs
9. -while jgit is scanning loose refs, now gone
10. so jgit assumes no loose to consider => packed-refs winning
11. so jgit wrongfully returns R (from 4.) as the tip, instead of R'.

This fix switches the order so loose refs are scanned (secured) before
taking the time to read packed-refs. This way, knowledge of the
likelier tip is guaranteed for ref reading to return the true tip
- despite concurrent gc. If there is no loose ref to scan, jgit reads
packed-refs and lands on R' (or S), which it then returns, as
expected. The gerrit issue [1] should be solved by this fix.

[1] https://code.google.com/p/gerrit/issues/detail?id=2302

Change-Id: Ibd120120a361a3a6ed565f3836afc1db706fbcdd
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-05-05 00:49:44 +02:00
Jonathan Nieder bc9df9c63c TestRepository: Add delete() method
Change-Id: Ib4841397ceab44bd38cf2f154314ac36ded73ae0
2016-05-04 15:48:36 -07:00
Jonathan Nieder e89393ba3e Make BaseReceivePack.setAtomic public
This makes atomic more consistent with other properties like
allowNonFastForwards.

Change-Id: Ie3b41f14ffba1d0b206ffecc697377417daa6973
2016-05-04 15:04:55 -07:00
Jonathan Nieder 73b3c9c1d8 ReceivePack: Pass atomic setting from client to BatchRefUpdate
Change-Id: I0e4e6cef693e8138562f5ca345e0db61a8abef9c
2016-05-04 14:00:42 -07:00
Matthias Sohn b4c6a41adc Prepare 4.4.0-SNAPSHOT builds
Change-Id: Ib95be1300b1b95cc7e8153170d509282bdc4e328
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-05-04 22:00:58 +02:00
Matthias Sohn 1447159b92 JGit v4.4.0.201605041135-m1
Change-Id: Ic9b6d7dae293887c3ac3a11f92e153501abad1dc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-05-04 17:35:15 +02:00
Matthias Sohn e3b45f79b6 Run Maven build in release.sh concurrently to speedup release
Change-Id: Iad8696825bb81becab945cd9ed2c33bea3778e17
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-05-04 17:34:35 +02:00
Dave Borowitz c9b00288fd PersonIdent: Make appendSanitized public
Change-Id: I337c90fff3c013819a42a7622ac6bacc72828c07
2016-05-03 14:40:15 -07:00
Stefan Beller 0406290eb4 Config: Improve documentation for setStringList
Change-Id: Idccfa0dfd6db324236f7cb26ab28bdbd80581a8b
Signed-off-by: Stefan Beller <sbeller@google.com>
2016-05-03 11:22:11 -07:00
Matthias Sohn e8705a6e27 Prepare Neon target platform
also use the Neon target platform as the default target platform.

Neon Eclipse platform requires BREE 8 so we have to use Java 8 at least
for the JGit packaging build (for the compiler settings we still stick
to source and target 1.7 since we want to still support Java 7)
otherwise unpacking platform pack200 archives will fail since they are
built using Java 8 and hence cannot be unpacked using Java 7's
unpack200.

Update org.junit from 4.11 to 4.11 and org.apache.ant from from 1.9.2 to
1.9.6 since the older versions are not available in Neon orbit version

Ignore a couple of tests in ResourceUtilTest which now fail [1] since
bug 476585 was fixed in Neon M6.

CQ: 10694
CQ: 11308
Change-Id: I1a99a3ac2148693e21c57df5aeb848035b52b97b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-05-02 22:46:51 +02:00
Dave Borowitz 125a8959d2 PersonIdent: Strip some special chars from external strings
The special characters <> and '\n' interfere with parsing of
identities. C git strips these special characters, so we should too.

Rather than allocating extra strings by calling String#trim(), add a
few lines to our sanitization method to perform the same trimming as
described in String's Javadoc.

Change-Id: I96edcb93a2fc194ee354d60566d352299742a52f
2016-04-29 11:27:14 -04:00
Dave Borowitz 773f9661d0 PersonIdent: Document that name and email aren't trimmed
This might be somewhat surprising behavior to users who might
naturally assume the following invariant:
  ident.equals(parseIdent(ident.toExternalString()))

This invariant does not hold since whitespace is only trimmed during
serialization. We don't want to mess with the strings during
initialization, as this is called during the highly-optimized commit
parsing codepath.

Change-Id: I081a603f0ac0e33167462244779b0ff3ad51e80c
2016-04-29 11:27:06 -04:00
Christian Halstrick ddc0e9e84a Fix possible NPEs when reporting transport errors
There was a bug in JGit which caused NPEs being thrown when Transport
errors should be reported. Avoid the NPE to let the original error show
up.

Change-Id: I9e1e2b0195bd61b7e531a09d0fc7bce109bd6515
2016-04-27 10:07:51 +02:00
Dave Borowitz adff322a69 Expose the ObjectInserter that created an ObjectReader
We've found in Gerrit Code Review that it is common to pass around
both an ObjectReader (or more commonly a RevWalk wrapping one) and an
ObjectInserter. These code paths often assume that the ObjectReader
can read back any objects created by the ObjectInserter without
flushing. However, we previously had no way to enforce that constraint
programmatically, leading to hard-to-spot problems.

Provide a solution by exposing the ObjectInserter that created an
ObjectReader, when known. Callers can either continue passing both
objects and check:
  reader.getCreatedFromInserter() == inserter
or they can just pass around ObjectReader and extract the inserter
when it's needed (checking that it's not null at usage time).

Change-Id: Ibbf5d1968b506f6b47030ab1b046ffccb47352ea
2016-04-26 17:21:37 -04:00
Dave Borowitz 8a26d0577f Add ObjectReader.Filter, like in ObjectInserter
Change-Id: If34ad8185dc8192435e622995fdca598b86add7e
2016-04-25 13:36:38 -04:00
Christian Halstrick 22d7ec2971 Fix calling of clean/smudge filters from Checkout,MergeCommands
When CheckoutCommand or MergeCommand is called then not in all situation
the treewalks have been prepared to support clean/smudge filters. Fix
this

Bug: 491505
Change-Id: Iab5608049221c46d06812552ab97299e44d59e64
2016-04-22 09:32:34 +02:00
David Pursehouse 29e83d44ff Update buck to e64a2e2ada022f81e42be750b774024469551398
To align with the version used in Gerrit's master build.

Change-Id: I3b6e21bf367ad1fb3598dc06b968aee6187d5aed
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2016-04-21 16:31:24 +09:00
Dave Borowitz a37d85ccd6 Support per-BatchRefUpdate atomic transactions
Repurpose RefDatabase#performsAtomicTransactions() slightly, to
indicate that the backend _supports_ atomic transactions, rather than
the current definition, which is that the backend always _uses_ atomic
transactions regardless of whether or not the caller actually wants
them. Allow BatchRefUpdate callers to turn off atomic transactions by
calling setAtomic(false). Defaulting to true means this is backwards
compatible.

Change-Id: I6df78d7df65ab147b4cce7764bd3101db985491c
2016-04-19 10:01:57 -04:00
Dave Borowitz 32156fda0b Add .buckd to .gitignore
Change-Id: I527923e282808c905ae9acd128ecc8a5b33d34c7
2016-04-19 09:40:55 -04:00
Jon Schneider 80fa5f39f9 Fix ApplyCommand when result of patch is an empty file
Such hunks are identifiable by a zero value for "new start line". Prior
to the fix, JGit throws and ArrayIndexOutOfBoundsException on such
patches.

Change-Id: I4f3deb5e5f41a08af965fcc178d678c77270cddb
Signed-off-by: Jonathan Schneider <jkschneider@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-04-16 17:28:06 -05:00
Matthias Sohn 31d5404ed3 Fix RefsUnreadableInMemoryRepository
- fix classpath for Eclipse
- add missing license header
- remove unused import

Change-Id: If491fe60678f050f86319388170ac789085fcf5f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-04-16 15:59:31 +02:00
Mike Edgar 3b526f863a Fix Buck build broken by 4812fda.
Creates a source directory under org.eclipse.jgit.http.test
for the new support class.

Signed-off-by: Michael Edgar <adgar@google.com>
Change-Id: Ie49492c2bbe5c1db96ceb0dc06fa7cb9f927431a
2016-04-14 23:00:35 -04:00
Mike Edgar 4812fdab61 Make UploadPack observe exceptions reading refs
Now if refs are unreadable when serving an upload pack the handler
will fail due to the actual underlying failure. Previously all wants
would be rejected as invalid because Repository.getAllRefs() returned
an empty map.

Testing this required a new subclass of InMemoryRepository so that
an IOException could be injected at the correct time.

Signed-off-by: Michael Edgar <adgar@google.com>
Change-Id: Iac708b1db9d0ccce08c4ef5ace599ea0b57afdc0
2016-04-14 20:41:53 -04:00
Ned Twigg 32a5993227 Expose conflicting files in CheckoutConflictException
Change-Id: I5b3b7b0633354d5ccf0c6c320c0df9c93fdf8eeb
Signed-off-by: Ned Twigg <ned.twigg@diffplug.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-04-11 22:55:16 +02:00
Matthias Sohn eeeca8042f Merge "Fix CommitCommand to be able to skip writing to RefLog" 2016-04-11 16:50:11 -04:00
Christian Halstrick 36a53d1a3c Fix CommitCommand to be able to skip writing to RefLog
CommitCommand already provided a method to set the comment which should
be written into the reflog. The underlying RefUpdate class supported to
skip writing a reflog entry. But through the CommitCommand API it was
not possible to prevent writing a reflog entry. Fix this and allow
creating commits which don't occur in the reflog.

Change-Id: I193c53de71fb5958ea749c4bfa8360a51acc9b58
2016-04-11 08:58:48 +02:00
Matthias Sohn ccf8363693 Prepare 4.4.0-SNAPSHOT builds
Change-Id: If3162f4cc4ae6319b9f1e3293549485b039cfe7f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-04-08 17:59:59 +02:00
Matthias Sohn a485fb7aac Merge branch 'stable-4.3'
* stable-4.3:
  Add lfs libraries to scripts for upload to Maven central
  Prepare 4.3.1-SNAPSHOT versions

Change-Id: Ieba46a2b12c893d6c626194310ab8dde5a2f1e6a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-04-08 17:31:43 +02:00
Matthias Sohn 24b6c080d7 Add lfs libraries to scripts for upload to Maven central
Change-Id: I13d78fd57421cca32a965af37cc9571e77448e31
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-04-08 17:24:44 +02:00
Matthias Sohn ac5d1bc37b Prepare 4.3.1-SNAPSHOT versions
Change-Id: I985828fd379e4596ae7f1c30a87e55df06a7924e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-04-08 17:24:30 +02:00
Matthias Sohn 08fc807780 Merge "Prepare 4.3.1-SNAPSHOT versions" 2016-04-08 11:01:18 -04:00
Terry Parker 2708b11b6c Filter corrupt objects from DfsReader.selectObjectRepresentation()
PackWriter.writeObject() can get into an infinite loop when corrupt
packs are present. When it finds a pack file with an object that can be
reused it calls DfsPackFile.copyAsIs(). If that method sees an invalid
CRC, it adds the object to the DfsPackFile's corrupt object list and
throws a CorruptObjectException, which it later catches as an
IOException and wraps in a
StoredObjectRepresentationNotAvailableException.
PackWriter.writeObjectImpl() catches that SORNAE and retries the
operation by calling DfsReader.selectObjectRepresentation(). But
currently that method returns the same object which was just seen to
be corrupt.

Change DfsPackFile.isCorrupt() from private to package private, and use
that method in DfsReader.selectObjectRepresentation() to filter out
corrupt objects.

The stack traces that show the problem are:
  org.eclipse.jgit.errors.CorruptObjectException.<init>(CorruptObjectException.java:113)
  org.eclipse.jgit.internal.storage.dfs.DfsPackFile.copyAsIs(DfsPackFile.java:624)
  org.eclipse.jgit.internal.storage.dfs.DfsReader.copyObjectAsIs(DfsReader.java:491)
  org.eclipse.jgit.internal.storage.pack.PackWriter.writeObjectImpl(PackWriter.java:1478)
  org.eclipse.jgit.internal.storage.pack.PackWriter.writeObject(PackWriter.java:1455)

  org.eclipse.jgit.internal.storage.dfs.DfsPackFile.getPackIndex(DfsPackFile.java:228)
  org.eclipse.jgit.internal.storage.dfs.DfsReader.findAllFromPack(DfsReader.java:476)
  org.eclipse.jgit.internal.storage.dfs.DfsReader.selectObjectRepresentation(DfsReader.java:455)
  org.eclipse.jgit.internal.storage.pack.PackWriter.writeObjectImpl(PackWriter.java:1492)
  org.eclipse.jgit.internal.storage.pack.PackWriter.writeObject(PackWriter.java:1455)

Change-Id: Iad7bbcaed1f11a6aa3b4f5af911a73a34c0fabfd
Signed-off-by: Terry Parker <tparker@google.com>
2016-04-07 16:25:05 -07:00
Matthias Sohn f2ee537d55 Prepare 4.3.1-SNAPSHOT versions
Change-Id: I52c98ba8fb3a303269a1f9380af114b6dd8c5009
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-04-08 00:56:43 +02:00
Matthias Sohn 4f0daa3bb2 JGit v4.3.0.201604071810-r
Change-Id: I902cdf1ff92ce8c6e9d80c4965d8d5bd8b9ac6c1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-04-08 00:10:10 +02:00
Matthias Sohn 57e6274bcf JGit v4.3.0.201604071045-r
Change-Id: Iafab78d6be34d31a13f979b7be67611135c0f8bd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-04-07 16:41:24 +02:00
Matthias Sohn 27d06cb8d5 Merge branch 'master' into stable-4.3
* master:
  Remove repository from cache when it's closed
  Fix RefDirectory not closing resources
  Fix repository cache never closing repository

Change-Id: I9dc9d017806cba25125f69b53812cc3e062ef975
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-04-07 13:06:23 +02:00
Hugo Arès 7d2b3b9e25 Remove repository from cache when it's closed
RepositoryCache has 2 methods to remove a repository from the cache but
they are never called when a repository is closed. Users of the cache
were expected to call one of those 2 methods but how could they have
called them at proper time without having visibility of the repository
usage count.

Ideally, I would have reworked the RepositoryCache to wrap any
repository it opens in a class that would be responsible to unregister
them from the cache when it's really closed, i.e. when usage counter
reaches 0. The problem preventing the wrapping solution is the
RepositoryCache.register method that allows to register an already
opened repository in the cache. Such repositories cannot be wrapped
because callers are still holding a reference on the unwrapped
repository.

Document that RepositoryCache.close method is removing the repository
from the cache as well as closing it and rework
RepositoryCache.unregister method to only remove the repository from the
cache. Use the latter to unregister repository when Repository.doClose
is getting executed.

Change-Id: Ia364816e4da8d7b6cfa72f10758ca31aa8a1f9db
Signed-off-by: Hugo Arès <hugo.ares@ericsson.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-04-07 13:00:50 +02:00
Hugo Arès 53ea86cd7b Fix RefDirectory not closing resources
When repositories are opened using the RepositoryCache, they are kept in
memory and when the repository usage counter reaches 0, the
Repository.close method is called which then calls close method on its
reference and object databases.

The problem is that RefDirectory.close method was a no-op and the
reference database was kept in memory. This problem is only happening
when opening a repository using the RepositoryCache because it never
evicts repositories, it's just calling the close method.

Change-Id: Iacb961de8e8b1f5b37824bf0d1a4caf4c6f1233f
Signed-off-by: Hugo Arès <hugo.ares@ericsson.com>
2016-04-07 11:32:57 +02:00
Hugo Arès 83235432e7 Fix repository cache never closing repository
Repository has a usage counter that is initialized to 1 at
instantiation and this counter is decremented when Repository.close
method is called. There is also a Repository.incrementOpen method that
RepositoryCache uses to increment the usage count when it's returning a
repository that is already opened.

The problem was that RepositoryCache was incrementing the usage count
for repositories that it just opened or registered. The usage count was
2 when it should have been 1.

Incrementing usage count is now only be done for repository that are
served from the cache.

This bug is causing slow memory increase of our Gerrit server until the
server become slow. Even if the RepositoryCache is using SoftReference,
it seems that the JVM is not garbage collecting the repositories because
it's not yet on the edge of being out of memory.

To test this change, I replicated all repositories(11k) from Gerrit
master to one slave. The Gerrit master used memory after this test was
10GB without this change and 3.5GB with.

Change-Id: I86c7b36174e384f106b51fe92f306018fd1dbdf0
Signed-off-by: Hugo Arès <hugo.ares@ericsson.com>
2016-04-07 11:32:57 +02:00
Matthias Sohn f56b9001fc Merge branch 'master' into stable-4.3
* master:
  Add config parameter gc.prunePackExpire for packfile expiration
  In TestRepository, use a consistent clock

Change-Id: I7ac568e650fbd191e48a8f1a4068af72deb242e8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-04-06 16:05:14 +02:00
Christian Halstrick 47dd98e362 Enable calling of smudge filters when checking out paths
When checking out commits/branches JGit was triggering correctly
configured smudge filters. But when checking out paths (either from
index or from commits) JGit was not triggering smudge filters. Fix
CheckoutCommand to properly call filters.

Bug: 486560
Also-by: Pascal Krause <pascal.krausek@sap.com>
Change-Id: I5ff893054defe57ab12e201d901fe74e1376efea
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-04-06 00:06:53 +02:00
Matthias Sohn 46bef2bcb6 Prepare 4.3-SNAPSHOT builds
Change-Id: Ib831f8870938113bd5338763f90a07d5c108b1de
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-04-05 23:10:06 +02:00
Preben Ingvaldsen 403f04d8dd Implement DIR_NO_GITLINKS
Implement the DIR_NO_GITLINKS setting with the same functionality
it provides in cGit.

Bug: 436200
Change-Id: I8304e42df2d7e8d7925f515805e075a92ff6ce28
Signed-off-by: Preben Ingvaldsen <preben@puppetlabs.com>
2016-04-05 10:43:40 +02:00
Christian Halstrick 74743bc547 Add config parameter gc.prunePackExpire for packfile expiration
JGit's Garbage Collector is repacking relevant objects into new
packfiles and is afterwards deleting the now obsolete packfiles. But to
prevent problems caused by race conditions JGit was not deleting
packfiles when they are too young. The same mechanism as for loose
objects and the config parameter gc.pruneExpire was used.
But JGit was reusing the parameter gc.pruneExpire also for packfiles
which may cause a lot of filesystem consumption if gc.pruneExpire was
set to the default of 2 weeks. Only two weeks after packfile creation gc
was allowed to delete this packfile.

This change introduces a new config paramter gc.prunePackExpire with a
default of "1.hour". This parameter is used when packfiles are deleted.
Only packfiles older than the specified time can be deleted.

For loose objects the behaviour is not changed and only the old
parameter gc.pruneExpire is relevant. 

Change-Id: I6209efb05678b15153bd22479dc13486907a44f8
2016-03-31 16:11:02 +02:00