Commit Graph

3029 Commits

Author SHA1 Message Date
Jonathan Nieder e25a3076f7 Merge "Add missing javadoc @param for new method setObjectCountCallback()" 2015-06-09 19:47:03 -04:00
Jonathan Nieder e75bc4321a Merge "Revert "Config: Distinguish between empty and null strings"" 2015-06-09 19:45:34 -04:00
Matthias Sohn 65ceb23c81 Add missing javadoc @param for new method setObjectCountCallback()
Change-Id: I91acdc3680bde09ae5809c14460500223a410395
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-06-10 01:26:00 +02:00
Matthias Sohn 852cc71344 Remove no longer used API warning filter for FileUtil
Change-Id: Ic13943139f23cdb1eac840417de43796236d578f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-06-10 01:21:45 +02:00
Jonathan Nieder cd3d952ec6 Revert "Config: Distinguish between empty and null strings"
This reverts commit 96eb3ee397, which
broke Gerrit tests that set a config value to 'null', serialize the
result, deserialize, and expect 'null' from Config.getString[1].

The intent of that commit was to make it possible to distinguish between
an absent and an empty config value, which we'll have to do with a new
method.

Revert the behavior change.  Keep the tests from 428cb23f2de8, since
they test the behavior more precisely than the old tests did.

[1] https://gerrit-review.googlesource.com/68452

Change-Id: Ie8042f380ea0e34e3203e1991aa0feb2e6e44641
Signed-off-by: Jonathan Nieder <jrn@google.com>
2015-06-09 15:58:12 -07:00
Yuxuan 'fishy' Wang 03fce81be3 Fix a javadoc typo in RepoProject.
Change-Id: I3ea25c157b9e11a46a140d2c3ab9373d1596c163
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2015-06-09 14:24:36 -07:00
Yuxuan 'fishy' Wang 53be446f6a Callback in PackWriter & BundleWriter.
Added callback in PackWriter and BundleWriter for the caller to get the
count of objects to write, and a chance to abort the write operation.

Change-Id: I1baeedcc6946b1093652de4a707fe597a577e526
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2015-06-09 14:11:13 -07:00
Fredrik Medley 96f210f4b7 UploadPack: Use reachable-sha1-in-want configuration
C git 2.5 supports setting the equivalent of
RequestPolicy.REACHABLE_COMMIT with uploadpack.allowreachablesha1inwant.
Parse this into TransportConfig and use it from UploadPack. An explicitly
set RequestPolicy overrides the config, and the policy may still be
upgraded on a unidirectional connection to avoid races.

Change-Id: Id39771a6e42d8082099acde11249306828a053c0
Signed-off-by: Fredrik Medley <fredrik.medley@gmail.com>
2015-06-09 18:43:48 +02:00
Matthias Sohn 2dd4dc149c Prepare 4.0.1-SNAPSHOT builds
Change-Id: I51d03d1a47d1e3cd453701e397750749867028a2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-06-09 15:17:22 +02:00
Matthias Sohn 4f22185455 JGit v4.0.0.201506090130-r
Change-Id: I01ad84fc74555656c42934cd62a85269a7030557
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-06-09 07:29:27 +02:00
Jonathan Nieder c1fca6cb43 Add missing # to javadoc comment
Change-Id: I351cee0ba2e77e3360846ac0c5368da3a322725c
Reported-by: Markus Keller <markus_keller@ch.ibm.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
2015-06-08 10:47:15 -07:00
Jonathan Nieder 48b67012d6 Allow lookup of multiple exact refs in one shot
exactRef(ref1, ref2, ref3) requests multiple specific refs in a single
lookup, which may be faster in some backends than looking them up one by
one.

firstExactRef generalizes getRef by finding the first existing ref from
the list of refs named.  Its main purpose is for the default
implementation of getRef (finding the first existing ref in a search
path).  Hopefully it can be useful for other operations that look for
refs in a search path (e.g., git log --notes=<name>), too.

Change-Id: I5c6fcf1d3920f6968b8b97f3d4c3a267258c4b86
Signed-off-by: Jonathan Nieder <jrn@google.com>
2015-06-05 16:08:55 -07:00
Jonathan Nieder a04d1ad2f1 Introduce exactRef to read a ref whose exact name is known
Unlike getRef(name), the new exactRef method does not walk the search
path.  This should produce a less confusing result than getRef when the
exact ref name is known: it will not try to resolve refs/foo/bar to
refs/heads/refs/foo/bar even when refs/foo/bar does not exist.

It can be faster than both getRefs(ALL).get(name) and getRef(name)
because it only needs to examine a single ref.

A follow-up change will introduce a findRef synonym to getRef and
deprecate getRef to make the choice a caller is making more obvious
(exactRef or findRef, with the same semantics as getRefs(ALL).get and
getRefs(ALL).findRef).

Change-Id: If1bd09bcfc9919e7976a4d77f13184ea58dcda52
Signed-off-by: Jonathan Nieder <jrn@google.com>
2015-06-05 14:14:55 -07:00
Shawn Pearce 336092afa7 Merge "Restore checkObjectCollisions flag" 2015-06-04 16:35:51 -04:00
David Pletcher c06620882b Restore checkObjectCollisions flag
I am developing an offline pack verification feature based on
PackParser. The birthday collision check is a prohibitive obstacle
to performance at scale because it interacts with the repository
to perform collision checks. This CL restores the checkObjectCollisions
flag that was removed in 9638e0aa87,
while changing the flag getter and setter to protected from public as a
precaution against misuse.

Change-Id: I363cd0c9de57c5e8659cdfe2d51b17823f4fe793
Signed-off-by: David Pletcher <dpletcher@google.com>
2015-06-04 13:26:36 -07:00
Dave Borowitz b9f850a79b Config: Allow ending a file with "=" and no newline
This is a perfectly valid construction according to C git:

$ echo -en '[a]\nx =' > foo.config
$ git config -f foo.config a.x; echo $?

0

Change-Id: Icfcf8304adb43c79e2b8b998f8d651b2a94f6acb
2015-06-04 11:50:31 -07:00
Dave Borowitz 96eb3ee397 Config: Distinguish between empty and null strings
The C git API and command line tools distinguish between a key having
the empty string as a value and no key being present in the config
file:

$ echo -e '[a]\nx =' > foo.config
$ git config -f foo.config a.x; echo $?

0
$ git config -f foo.config a.y; echo $?
1

Make JGit make the same distinction. This is in line with the current
Javadoc of getString, which claims to return "a String value from the
config, null if not found". It is more reasonable to interpret "x ="
in the above example as "found" rather than "missing".

We need to maintain the special handling of a key name with no "="
resolving to a boolean true, but "=" with an empty string is still not
a valid boolean.

Change-Id: If0dbb7470c524259de0b167148db87f81be2d04a
2015-06-04 11:50:31 -07:00
Jonathan Nieder 6227b340d3 Merge branch 'stable-4.0'
* stable-4.0:
  Revert "Fix unchecked conversion warning in MergeFormatter"
  Delete deprecated TemporaryBuffer.LocalFile constructors
  Delete deprecated FileUtils.setExecute(File, boolean)
  Delete deprecated WorkingTreeIterator.isModified(DirCacheEntry, boolean)
  Delete deprecated UploadPackMayNotContinueException
  Delete deprecated TransferConfig.isFsckObjects()
  Delete deprecated TextBuiltin.out
  Delete deprecated Merger.getBaseCommit()

Change-Id: Id23a39cc6a3cd122ff1738cb85b7451bbfd8af5f
Signed-off-by: Jonathan Nieder <jrn@google.com>
2015-06-03 12:27:17 -07:00
Shawn Pearce fb21fb10fc Revert "Fix unchecked conversion warning in MergeFormatter"
This reverts commit 6d4ebd168d.

Change-Id: I01f0c7cd997b9b3577cc1e98ab1adb5cdc5b55e4
2015-06-03 14:31:41 -04:00
Matthias Sohn d19ce2435d Delete deprecated TemporaryBuffer.LocalFile constructors
Change-Id: I5fdbf997ebcbe48e86f4c41c6b2643f47054b0c3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-06-03 13:16:27 +02:00
Matthias Sohn f691106547 Delete deprecated FileUtils.setExecute(File, boolean)
Change-Id: Ifa63e3743fb4de25e074404c301f860a1ffb5e02
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-06-03 13:16:27 +02:00
Matthias Sohn ba51037a69 Delete deprecated WorkingTreeIterator.isModified(DirCacheEntry, boolean)
Change-Id: I687c392e5a625fd66c45998c94373aa59921b986
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-06-03 13:16:26 +02:00
Matthias Sohn 08c8cf027d Delete deprecated UploadPackMayNotContinueException
Change-Id: Id298fc860684d2a2288769282fd8ce4475009dc8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-06-03 13:16:26 +02:00
Matthias Sohn fa56e0deae Delete deprecated TransferConfig.isFsckObjects()
Change-Id: Ib7f36282d69a3298b1ac177ae17af0f80d64964f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-06-03 13:16:26 +02:00
Matthias Sohn 913095e39e Delete deprecated Merger.getBaseCommit()
Change-Id: I3b39a2c0d547110709b4c28b66c4694cdef943e8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-06-03 13:16:25 +02:00
Terry Parker dd22bc831a Update PackWriter.Statistics.getBitmapIndexMises()
Return -1 from PackWriter.Statistics.getBitmapIndexMises() when no
bitmap indices were found, to differentiate it from the case where
the bitmap indices contained all of the want/have commits.

Change-Id: I78d4600b462c19f62b347217a0b2c19eaaf3a14b
Signed-off-by: Terry Parker <tparker@google.com>
2015-06-02 22:49:55 -04:00
Jonathan Nieder 8c3fe215b4 Allow setting detail message and cause when constructing most exceptions
In particular, this means a RepositoryResolver, UploadPackFactory, or
ReceivePackFactory can set a detail message for
ServiceNotAuthorizedException or ServiceNotEnabledException with
information for the client about why access is not allowed.

Change-Id: I38e1798e1e9d09b5e75cefacd9d85f25729235a9
Signed-off-by: Jonathan Nieder <jrn@google.com>
2015-06-02 16:54:09 -07:00
Jonathan Nieder 54b195ad3e Clarify description of ServiceNotAuthorizedException
This exception's detail message states

	Service not permitted

and according to the Javadoc it indicates that the current user does not
have access to the service.  In practice, though, callers handle this
exception by presenting a '401 Unauthorized' response to the client,
meaning that the user is unauthenticated and should authenticate.

Clarify the documentation and detail message to match the practice.

The exception message is not used anywhere except logs.  No
client-visible effect intended.

Change-Id: I2c6be9cb74af932f0dcb121a381a64f2ad876766
Signed-off-by: Jonathan Nieder <jrn@google.com>
2015-06-02 16:54:07 -07:00
Matthias Sohn a79168bcbb Prepare 4.1.0-SNAPSHOT builds
Change-Id: I03d08b8e2d3400d4b5cdb4ab541b312870776843
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-06-03 00:52:00 +02:00
Matthias Sohn 72ecb5c8c7 Prepare post 4.0-RC3 builds
Change-Id: I74469f1243503098fb05b5ddec3fa609132debab
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-06-02 23:11:57 +02:00
Matthias Sohn d59fafc7ca JGit v4.0.0.201506020755-rc3
Change-Id: I31c6177d19cba228aa67b2b5c3e0d82c38395cda
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-06-02 13:55:16 +02:00
Christian Halstrick 6d09c486ed Fix CommitCommand.setOnly()
When CommitCommand.setOnly(path) is used a temporary index has to be
created containing only modifications for the specified pathes. The
process to fill this temporary index was broken because filling the
index was stopped when we reached the first untracked file. Instead the
process to fill the temporary index should continue until we processed
all pathes.

Bug: 451465
Change-Id: I22af50d70bd3b81e7c056358724956122b0d158d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-06-01 10:42:21 +02:00
Matthias Sohn efacad0fc8 Improve exception thrown when pull can't find advertised ref
- throw an API exception instead of an internal exception to allow
applications to handle this problem
- improve error message to give hints about possible root causes

Bug: 464660
Change-Id: Ib7d18bb2eeeac0fc218daea375b290ea5034bda1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-29 00:15:33 +02:00
Matthias Sohn 8787176ef1 Silence unchecked conversion warning in TransportSftp
Change-Id: I3dc8e0b483072bdf193ae4190a60d1867ebefd12
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-29 00:15:33 +02:00
Matthias Sohn e013bcdcc6 Silence deprecation warning in WindowCacheConfig
Change-Id: I923b65efeaacc5e9cc8aecc754ab8d8e63ccd2e5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-29 00:15:33 +02:00
Matthias Sohn 17307df3af Silence deprecation warning in DirCacheCheckout
Change-Id: I9e021ba2e0d1317bd98e86f832d55787ed6b0a63
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-29 00:15:33 +02:00
Matthias Sohn faae5cdb5b Fix hidden field warnings in bundle org.eclipse.jgit
Change-Id: I4e79cefe15037df0e1c520956bf2482240e31a7d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-29 00:15:32 +02:00
Matthias Sohn 6d4ebd168d Fix unchecked conversion warning in MergeFormatter
Change-Id: Id57ef8b2e80736652e4c5062364efa3ccd39c4c7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-29 00:15:32 +02:00
Hugo Arès 663ccd76f0 Close WindowCursor using try-with-resources in UnpackedObject
Change-Id: I187403ed432f7d6b1e84223918bd72d895e6bdfe
Signed-off-by: Hugo Arès <hugo.ares@ericsson.com>
2015-05-28 16:07:23 -04:00
Shawn Pearce a3468f87cb Merge changes I7b6d7be4,I63a74651,I39c2ea6b
* changes:
  Silence unused object warning in MyersDiff
  Silence resource leak warnings where caller is responsible to close
  Fix potential null pointer access in IndexDiffFilter
2015-05-28 15:39:08 -04:00
Shawn Pearce 5426ba2778 Merge "Silence false potential null pointer access warnings" 2015-05-28 15:37:11 -04:00
Shawn Pearce 10b99121b0 Merge "Fix WindowCursor memory leak." 2015-05-28 15:35:26 -04:00
Hugo Arès 27128b3e01 Fix WindowCursor memory leak.
ObjectReader release method was replaced by close method but
WindowCursor was still implementing release method.

To prevent the same mistake again, make ObjectReader close method
abstract to force sub classes to implement it.

Change-Id: I50d0d1d19a26e306fd0dba77b246a95a44fd6584
Signed-off-by: Hugo Arès <hugo.ares@ericsson.com>
2015-05-28 15:14:25 -04:00
Jonathan Nieder a5778b6f41 archive: Drop unnecessary empty comments and 'final' qualifiers on locals
Early JGit code used comments to inform the Eclipse formatter about
where to break lines and used final in the hope of making code faster.
The ArchiveCommand command implementation imitated that style.

Nowadays the project relies less on the Eclipse formatter and relies
more on Java having sane performance with local variables that are not
explicitly marked 'final'.  Removing the unnecessary empty comments and
'final' qualifiers makes this code more readable and more consistent
with recent JGit code.

Change-Id: I7a181432eda7e18bd32cf110d89c0efbe490c4f1
Signed-off-by: Jonathan Nieder <jrn@google.com>
2015-05-27 16:49:34 -07:00
Jonathan Nieder 1287cdaf33 Close 'out' consistently in ArchiveCommand.call
Whether the output stream specified with setOutputStream() is closed by
ArchiveCommand.call() is murky and inconsistent:

- on success, it is closed
- if an exception is encountered when writing the archive, it is closed
- if an exception is encountered when calling createArchiveStream to
  open the archive, we forget to close it

Close the output stream consistently to avoid leaks.

Now that the inner try-with-resources doesn't have its own finally
block, this allows us to merge the two try blocks.

It would be even better to never close the output stream.  That will
involve more API changes to avoid silently breaking callers, so it is
deferred to a later change.

Change-Id: I0185bdaa60ecee4a541eab5d8ff6c9c4dbe40bf1
Signed-off-by: Jonathan Nieder <jrn@google.com>
2015-05-27 16:49:12 -07:00
Christian Halstrick ebfd62433a Fix that exceptions in ReceivePack cause Invalid Channel 101 exceptions
When during a PushOperation the server hits an exception different from
UnpackException the JGit server behaved wrong. That kind of exceptions
are handled so late that the connection is already released and the
information whether to talk sideband to the client is lost. In detail:
ReceivePack.receive() will call release() and that will reset the
capabilities. But later on the stack in ReceivePackServlet.doPost() it
is tried to send a response to client now with reset capabilities (no
sideband!).

Change-Id: I0a609acc6152ab43b47a93d712deb65bb1105f75
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-27 23:52:53 +02:00
Christian Halstrick 261b514ceb Better report too large pack-files from PushCommand
JGits PushCommand and BasePackPushConnection were throwing generic
TransportExceptions when the pushed pack-file was rejected by the server
since it was too big. Let JGit better interprete the server's response
to detect this situation and throw a more specific exception.

This detection works by parsing the status line sent by the server. This
change only recognizes the response sent by a JGit based server. All
other servers which report such problems in a different way still lead
to a generic TransportExceptions.

Change-Id: Ic075764ea152939ce72c446252464620dd54edea
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-27 23:52:53 +02:00
Dave Borowitz b8c8008115 FS: Extract GobblerThread into a private static class
The primary goal is to improve exception readability. Since this is a
standalone thread, just logging the stack trace of the caught
exception is not very useful:

java.io.IOException: Stream closed
	at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:162)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:258)
	at org.eclipse.jgit.util.FS$2.run(FS.java:451)

Providing a named class eliminates the "FS$2", and including the
command name provides a little more context in the error message.
A future improvement might include the stack trace that created the
GobblerThread as well.

Change-Id: Ibf16d15b47a85b6f41844a177e398c2fc94f27b0
2015-05-27 10:04:35 -07:00
Terry Parker 0e8ac496cd Add bitmap index misses to PackWriter.Statistics
RevWalks to find commits that are not in bitmap indices are expensive.
Track the count of commits that are enumerated via RevWalks as "bitmap
index misses" in the PackWriter.Statistics class.

Change-Id: Ie0135a0a0aeba2dfb6df78839d545006629f16cb
Signed-off-by: Terry Parker <tparker@google.com>
2015-05-26 14:37:17 -07:00
Shawn Pearce 2ad2d85bcd Merge "Enable public access to SimilarityIndex scoring function" 2015-05-26 16:49:30 -04:00
David Pletcher 5e57cc9585 Enable public access to SimilarityIndex scoring function
The SimilarityIndex class implements the useful capability of scoring
the similarity between two files. That capability is required for a
feature that's being developed in another package, to detect files
derived from a set of potential sources.

This CL adds a public factory method to create a SimilarityIndex from
an ObjectLoader. It grants public access to the SimilarityIndex class,
the score method, an inner exception class and a special marker
instance of that exception class.

Change-Id: I3f72670da643be3bb8e261c5af5e9664bcd0401b
Signed-off-by: David Pletcher <dpletcher@google.com>
2015-05-26 13:27:33 -07:00
Shawn Pearce 5635d9e1af Merge "Add getters to RepoProject." 2015-05-26 13:14:00 -04:00
Yuxuan 'fishy' Wang 744c370c1b Add getters to RepoProject.
Change-Id: I74ded6c2c3f5985568cd77bd8799b45017fb1d09
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2015-05-26 09:58:38 -07:00
Matthias Sohn eea43de7a4 Silence unused object warning in MyersDiff
Change-Id: I7b6d7be4bb283c1f451bc58f29c71a8082580989
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-26 10:52:23 +02:00
Matthias Sohn 11a0dffd16 Silence resource leak warnings where caller is responsible to close
Change-Id: I63a74651689c10426d5f150ab2e027c6b63cab95
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-26 10:52:23 +02:00
Matthias Sohn bb48901ddf Silence false potential null pointer access warnings
Change-Id: I30c074a1b3436e47316b2eb2f083708161182d32
2015-05-26 10:52:22 +02:00
Matthias Sohn 746cf09b33 Silence non-externalized string warnings in org.eclipse.jgit
Change-Id: I7fa180db0c59e4a317a0c99ec48574cb0e5ac2f2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-26 10:52:22 +02:00
Matthias Sohn d5a34551d5 Fix potential null pointer access in IndexDiffFilter
Change-Id: I39c2ea6b3090d7028cc1e246af6e3cc4e7bc70c2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-26 10:52:22 +02:00
Matthias Sohn 2390531888 Externalize translatable texts in org.eclipse.jgit
Change-Id: Ibf4c299f9d203c78cae79e61f88d4bea60ea2795
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-26 10:52:20 +02:00
Saša Živkov d9062145b8 Don't invalidate pack file on InterruptedIOException
If the thread reading a pack file is interrupted don't invalidate that
pack file.

This could happen when Gerrit invoked JGit for computing a diff in one
thread and waited for the call to finish from another thread, with a
timeout. When the timeout was reached the "diff" thread was interrupted.
If it happened to be in an IO operation, reading a pack file, an
InterruptedIOException was thrown and the pack file was marked as
invalid and removed from the pack list.

Invalidating the pack in that case could cause the project disappearing in
Gerrit as discussed in [1] and [2].

[1] https://groups.google.com/forum/#!topic/repo-discuss/CYYoHfDxCfA
[2] https://groups.google.com/forum/#!topic/repo-discuss/ZeGWPyyJlrM

Change-Id: I2eb1f98370936b5be541d96d70c3973cbfc39238
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
2015-05-26 10:28:59 +02:00
Andrey Loskutov 4d565f0b5f Guard agains null ReflogReader if named ref does not exist
Follow up on egit bug 466973.

Change-Id: Idd83d87803e86b25f106dfd725214b5a3ec5171c
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-25 22:58:14 +02:00
Sebastian Schuberth 7ce6abe858 FS: Allow to manually set the path to the Git system config file
Now that d7a4473 removed the gitprefix property, we did not have a way to
specify the path to the Git system config file in case
discoverGitSystemConfig() fails. Fix that by introducing a member variable
that caches the result of discoverGitSystemConfig() as well as a setter
method to overwrite the content of that variable.

Change-Id: Icd965bffbe2f11b18c9505ee2ddd2afad5b64d70
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2015-05-25 21:23:21 +02:00
Sebastian Schuberth 9599f3f1a6 FS: Fix a minor typo in runInShell() docs
Change-Id: I5b1a5f3732aa97f83a4d39b42ba0f1e8eff9dec4
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2015-05-25 21:23:20 +02:00
Sebastian Schuberth 7ee351fb95 FS: Improve javadoc of some recently introduced methods
Change-Id: I31e788ee20ac3e8439559d9060d39e9792f6dc7d
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-25 21:23:20 +02:00
Andrey Loskutov 1773002a34 Cleanup code and Eclipse compile errors in new gitrepo API
Commit d3348e introduced few errors in Eclipse.

This commit cleans up the new API:
 - fixes API error in RepoCommand after moving IncludedFileReader type
 - fixes unused imports in RepoCommand & RepoCommandTest
 - fix javadoc errors in ManifestParser & RepoProject
 - makes three (implicitly final) fields in ManifestParser final.

Change-Id: I4185f451d97039d155391f62815bb9d3afe39fa6
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
2015-05-24 10:27:20 +02:00
Shawn Pearce a990cce776 Merge "Refactor to expose ManifestParser." 2015-05-22 14:24:46 -04:00
Yuxuan 'fishy' Wang d3348e5623 Refactor to expose ManifestParser.
The repo xml manifest parser used in RepoCommand could also be useful for
others, so refactor to make it public.

Also this breaks backward compatibility slightly.

Change-Id: I5001bd2fe77541109fe32dbe2597a065e6ad585e
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2015-05-22 11:08:52 -07:00
Sebastian Schuberth d7a44736ce FS: Remove the gitprefix logic
The only purpose of the gitprefix logic was to determine the path to the
system-wide config file. This is now done by discoverGitSystemConfig()
independent of the gitprefix, so get rid of this unused code.

Change-Id: Iaa88df9bd066dc1ed4067c18618af809e49876b3
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2015-05-22 09:37:35 +02:00
Sebastian Schuberth d9ffc03837 SystemReader: Use discoverGitSystemConfig() in openSystemConfig()
Bug: 410568
Change-Id: Id768294e83f374f50ae5e6486f4e757515c8262d
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-22 09:37:34 +02:00
Sebastian Schuberth cb12f4f0ad FS: Add a method to discover the system-wide config file
Change-Id: I969e26a5ab5f8ca3ab29024f405c1e34afdba493
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-22 09:37:26 +02:00
Sebastian Schuberth b8b6357fe6 FS: Extend readPipe() to optionally take additional environment
Change-Id: I4db7763826e4ada92074317d4d1c9a32299f3af8
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-21 23:42:13 +02:00
Sebastian Schuberth 8ed6b745bb FS: Document readpipe()'s encoding parameter
Change-Id: I36f0edf0f9d0bfa26448e25355c6d78dea524079
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2015-05-21 23:39:26 +02:00
Sebastian Schuberth 6fdd214349 Split discoverGitPrefix() code out into discoverGitExe()
Change-Id: I700540eec06efb24eeb09bfcb40420820c32d156
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-21 23:37:42 +02:00
Sebastian Schuberth 4ca2fc5ce7 Equalize discoverGitPrefix() implementations between POSIX and Win32
Change-Id: I936df151890d4bba9079d79c65b75a69c209523b
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2015-05-21 23:32:07 +02:00
Sebastian Schuberth 8025443db4 Move resolveGrandparentFile() to the base class for wider use
Change-Id: I67ec732ea2e5345a6946783f0c5ef60c07ce254e
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-21 23:29:28 +02:00
Matthias Sohn 686124bec3 Replace deprecated release() methods by close()
See the discussion [1] in the Gerrit mailing list.

[1] https://groups.google.com/forum/#!topic/repo-discuss/RRQT_xCqz4o

Change-Id: I2c67384309c5c2e8511a7d0d4e088b4e95f819ff
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-21 02:05:45 +02:00
Matthias Sohn 0e73d39506 Use AutoClosable to close resources in bundle org.eclipse.jgit
- use try-with-resource where possible
- replace use of deprecated release() by close()

Change-Id: I0f139c3535679087b7fa09649166bca514750b81
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-21 00:01:36 +02:00
Shawn Pearce 0419f8128b ReceivePack: support quiet capability
git-core has supported this for a long time; allowing clients to
avoid progress messages from the server if they are dumping to a
pipe instead of a tty.

Avoid the two progress monitors going on side-band and expose
isQuiet() method to allow hooks to also reduce their output if
this is sensible for them.

Change-Id: I1df7e38d16765446b441366500b017a90b8ff958
2015-05-20 08:23:47 -07:00
Shawn Pearce faf0a8f61d Merge "Fix ObjectReader resources leak" 2015-05-20 02:02:26 -04:00
Matthias Sohn 4cbe66af47 Fix warnings in ObjectFilter
- add missing tags in JavaDoc of ObjectFilter.include()
- remove unnecessary import

Change-Id: I24b9dcc49f66380f77345d704df70c05f7f74db8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-15 23:20:46 +02:00
Matthias Sohn 0243da320e Fix typo in reflog message written by RebaseCommand.tryFastForward()
Change-Id: I1ad544f2b5673ed3b4a2206b5eb4ce20fd3c86d2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-15 23:00:53 +02:00
Hugo Arès 9d6507ba4d Fix ObjectReader resources leak
In 77030a5e, AutoClosable was implemented on classes that use release().
This caused a resource leak because the ObjectReader.close method  was
not calling the now deprecated release method, which is the method that
sub classes implements to release resources.

Change-Id: I247651ec8fd7ca9941d256ca46d14cc43cc35c6e
Signed-off-by: Hugo Arès <hugo.ares@ericsson.com>
2015-05-15 16:10:49 -04:00
Jonathan Nieder b35b09d09a Correct @since tags for ObjectFilter
Although the stable-4.0 branch already exists, 4.0 development is
still happening on master until IP logs are sent for review, which
will happen at the end of May.

Change-Id: I863ba85c6303f8ef2eb13bca5e2d30e5d3c58b29
Signed-off-by: Jonathan Nieder <jrn@google.com>
2015-05-15 11:37:57 -07:00
Jonathan Nieder f91f4e5ed6 Fix typo in ObjectWalk#getObjectFilter javadoc
While trying to decide between "which matches every object" and "as it
matches every object", I became distracted and wrote both.

Change-Id: I867ce29664e661a81a9d441e59ffd0b72270dd98
Signed-off-by: Jonathan Nieder <jrn@google.com>
2015-05-15 11:23:55 -07:00
Jonathan Nieder f2be5bca04 Allow ObjectWalk to be filtered by an arbitrary predicate
This will make it possible to declare a collection of objects as
ineligible for the walk en masse, for example if they are known to be
uninteresting via a bitmap.

Change-Id: I637008b25bf9fb57df60ebb2133a70214930546a
Signed-off-by: Jonathan Nieder <jrn@google.com>
2015-05-14 18:43:38 -07:00
Shawn Pearce 2eb16aa6ca Remove SoftReference from dfs.DeltaBaseCache
The Java GC doesn't always clear these before running out of memory
and failing allocations. In practice OpenJDK 7 is leaving these live,
removing any advantage of the SoftReference to attempt to shed memory
when the GC is unable to continue allocating.

Instead follow the pattern of the DfsBlockCache and use hard refs
to the object data. Require applications to configure the cache
size more accurately given expected memory usage.

Change-Id: I87586b3e71b1cba0308a6a278d42e971be4bccd3
2015-05-11 11:39:28 -07:00
Shawn Pearce 8ff08455f6 Fix memory leak in dfs.DeltaBaseCase
The LRU chain management code was broken leading to situations where
the chain was incomplete.  This prevented the cache from removing
items when it exceeded its memory target, causing a leak.

One case was repeated hit on the head of the chain. moveToHead(e)
was invoked linking the head back to itself in a cycle orphaning
the rest of the table.

Add some unit tests to cover this and a few other paths.

Change-Id: Ib27486eaa1b1d2bf1c745a56d0a5832bfb029322
2015-05-11 11:39:28 -07:00
Shawn Pearce 3852a085bd Merge "FS_POSIX: Rework umask detection to make it settable" 2015-05-11 14:17:49 -04:00
Christian Halstrick 446fa0e480 Merge "Fix possible AIOOB in DirCacheTree.contains()" 2015-05-11 04:09:55 -04:00
Matthias Sohn 8b9623511f Use ANY_DIFF filter in ResolveMerger only for bare repositories
As Chris pointed out change I822721c76c64e614f87a080ced2457941f53adcd
slowed down merge since ANY_DIFF filter is much less efficient than the
manual detection of diffs done in ResolveMerger.processEntry() since it
avoids unnecessary filesystem calls using the git index. Hence only set
the ANY_DIFF filter on bare repositories which don't have a working tree
to scan.

To test performance I used the setup described in Chris' comment on
change I822721c76c64e614f87a080ced2457941f53adcd and modified
ResolveMerger.mergeTrees() to not add the working tree in order to
simulate merging in a bare repository.

At least on Mac I couldn't detect a speedup, with and without the
ANY_DIFF filter merge test takes an average 0.67sec.

Change-Id: I17b3a06f369cee009490f54ad1a2deb6c145c7cf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-10 23:17:36 +02:00
Shawn Pearce bfdd963083 FS_POSIX: Rework umask detection to make it settable
Avoid always calling `sh -c umask` on startup, instead deferring
the invocation until the first time a working tree file needs to
use the execute bit. This allows servers using bare repos to avoid
a costly fork+exec for a value that is never used.

Store the umask as an int instead of two Boolean. This is slightly
smaller memory (one int vs. two references) and makes it easier for
an application to force setting the umask to a value that overrides
whatever the shell told JGit.

Simplify the code to bail by returning early when canExecute is
false, which is the common case for working tree files.

Change-Id: Ie713647615bc5bdf5d71b731a6748c28ea21c900
2015-05-10 12:36:18 -07:00
Shawn Pearce 4ac7cf003b Merge "Fix IllegalArgumentException in AmazonS3" 2015-05-10 14:44:16 -04:00
Shawn Pearce e4e947049f Expose disposeBody() on RevCommit and RevTag
Applications that use a commit message once and do not
need it again can free the body to save memory. Expose
the disposeBody() methods to support this and use it in
pgm.Log which only visits each commit once.

Change-Id: I4142a0749c24f15386ee7fb119934a0432234de3
2015-05-10 10:56:34 -07:00
Shawn Pearce ca7daa5226 ObjectReader: remove the walkAdvice API
This was added a very long time ago to support the failed
DHT storage implementation. Since then no storage system
was able to make use of this API, but it pollutes internals
of the walkers.

Kill the API on ObjectReader and drop the invocations from
the walker code.

Change-Id: I36608afdac13a6c3084d7c7e0af5e0cb22900332
2015-05-10 10:47:10 -07:00
Shawn Pearce af7dcd6e1b RevWalk: Discard uninteresting commits unless RevSort.BOUNDARY
Previously using an ObjectWalk meant uninteresting commits may keep
their commit message buffers in memory just in case they were found to
be on the boundary and were output as UNINTERESTING for the caller.

This was incorrect inside StartGenerator. ObjectWalk hides these
internal UNINTERESTING cases from its caller unless RevSort.BOUNDARY
was explicitly set, and its false by default. Callers never see one
of these saved uninteresting commits.

Change the test to allow early dispose unless the application has
explicitly asked for RevSort.BOUNDARY. This allows uninteresting
commit buffers to be discarded and garbage collected in ObjectWalks
when the caller will never be given the RevCommit.

Change-Id: Ic1419cc1d9ee95f4d09386dd0730d54c12dcc157
2015-05-10 10:47:09 -07:00
Shawn Pearce 53e39094bf ObjectWalk: make setRetainBody(false) the default
Despite being the primary author of RevWalk and ObjectWalk I still
fail to remember to setRetainBody(false) in application code using
an ObjectWalk to examine the graph.

Document the default for RevWalk is setRetainBody(true), where the
application usually wants the commit bodies to display or inspect.

Change the default for ObjectWalk to setRetainBody(false), as nearly
all callers want only the graph shape and do not need the larger text
inside a commit body. This allows some code in JGit to be simplified.

Change-Id: I367e42209e805bd5e1f41b4072aeb2fa98ec9d99
2015-05-10 10:45:34 -07:00
Shawn Pearce 3d06349ff2 Merge changes I62befa4a,Ia9c3d123,I7fcf6534
* changes:
  Delete deprecated PackWriter.preparePack() methods
  Delete deprecated class IgnoreRule
  Delete deprecated checkoutEntry() methods in DirCacheCheckout
2015-05-09 23:00:56 -04:00
Sebastian Schuberth 11c393a1d4 Do not concatenate strings as arguments to StringBuilder.append()
That more or less defeats the purpose of using a StringBuilder.

Change-Id: I519f7bf1c9b6670e63c3714210f834ee845dc69f
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2015-05-08 11:26:25 +02:00
Sebastian Schuberth 926ad4296e IndexDiffFilter: Simplify a boolean expression
Change-Id: Ibdd0338b638b864d6572045b084b08a04471ecf7
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2015-05-08 11:26:20 +02:00
Sebastian Schuberth 3d231bd95e GroupHead: Remove a redundant call to String.format()
Change-Id: I8f5fc09469b56d73d3838e7bcfecfd21140429eb
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2015-05-08 11:26:07 +02:00
Sebastian Schuberth ec6ec3b10f FS_Win32: Avoid an IOException on Windows if bash is not in PATH
Change-Id: I3145f74ecee9f5b368e7f4b9fd7cb906f407eff5
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-07 10:54:43 +02:00
Shawn Pearce ae592cc655 Add repository name to failures in HTTP server log
If UploadPack or ReceivePack has an exception record an identifier
associated with the repository as part of the log message. This can
help the HTTP admin track down the offending repository and take
action to repair the root cause.

Change-Id: I58f22b33cdb40994f044a26fba9fe965b45be51d
2015-05-06 15:47:34 -07:00
Matthias Sohn c2ce3a60e0 Merge "Revert "ResolveMerge only needs to visit differing TreeEntries"" 2015-05-04 09:33:30 -04:00
Christian Halstrick 6f71301404 Fix possible AIOOB in DirCacheTree.contains()
When DirCacheTree.contains() is called and 'aOff' is greater than 'aLen'
an ArrayIndexOutOfBoundsException was thrown. This fix makes
DirCacheTree.contains() more robust and allows parsing such index files
without throwing AIOOB.

I couldn't create a test case leading to this situation but I have seen
such situations while inspecting Bug: 465393. It seems that such
situations are created on Windows when there are invalid pathes in the
index. There may be a not yet known bug leading to such situations in
combination with invalid pathes.

Bug: 465393
Change-Id: I6535d924a22cba9a05df0ccd7e6dc2c9ddc42375
2015-05-04 11:07:23 +02:00
Shawn Pearce 4a984e2033 Support agent= capability in wire protocol
Since git-core ff5effd (v1.7.12.1) the native wire protocol transmits
the server and client implementation and version strings using
capability "agent=git/1.7.12.1" or similar.

Support this in JGit and hang the implementation data off UploadPack
and ReceivePack.  On HTTP transports default to the User-Agent HTTP
header until the client overrides this with the optional capability
string in the first line.

Extract the user agent string into a UserAgent class under transport
where it can be specified to a different value if the application's
build process has broken the Implementation-Version header in the
JGit package.

Change-Id: Icfc6524d84a787386d1786310b421b2f92ae9e65
2015-04-30 14:40:35 -07:00
Matthias Sohn 7e0ebb8e29 Merge changes I368af61a,I2400fe5f
* changes:
  Remove pack from list when file handle is stale
  Lower log level to warn for handled pack errors
2015-04-30 10:43:48 -04:00
Shawn Pearce 4feffb3bf5 Add fsck.allowInvalidPersonIdent to accept invalid author/committers
A larger than expected number of real-world repositories found on
the Internet contain invalid author, committer and tagger lines
in their history. Many of these seem to be caused by users misusing
the user.name and user.email fields, e.g.:

  [user]
    name = Au Thor <author@example.com>
    email = author@example.com

that some version of Git (or a reimplementation thereof) copied
directly into the object header. These headers are not valid and
are rejected by a strict fsck, making it impossible to transfer
the repository with JGit/EGit.

Another form is an invalid committer line with double negative for
the time zone, e.g.

  committer Au Thor <a@b> 1288373970 --700

The real world is messy. :(

Allow callers and users to weaken the fsck settings to accept these
sorts of breakages if they really want to work on a repo that has
broken history.  Most routines will still function fine, however
commit timestamp sorting in RevWalk may become confused by a corrupt
committer line and sort commits out of order. This is mostly fine if
the corrupted chain is shorter than the slop window.

Change-Id: I6d529542c765c131de590f4f7ef8e7c1c8cb9db9
2015-04-30 10:27:03 -04:00
Hugo Arès ae4b72d50e Remove pack from list when file handle is stale
This error happens on nfs file system when you try to read a file that
was deleted or replaced.

When the error happens because the file was deleted, removing it from
the list is the proper way to handle the error, same use case as
FileNotFoundException. When the error happens because the file was
replaced, removing the file from the list will cause the file to be
re-read so it will get the latest version of the file.

Bug: 462868
Change-Id: I368af61a6cf73706601a3e4df4ef24f0aa0465c5
Signed-off-by: Hugo Arès <hugo.ares@ericsson.com>
2015-04-30 16:21:05 +02:00
Hugo Arès d3a73c1407 Lower log level to warn for handled pack errors
Pack not found and pack corrupted/invalid are handled by the code (pack
is removed from the list) so logging an error and the stacktrace is
misleading because it implies that there is an action to take to fix the
error.

Lower the log level to warn and remove the stacktrace for those 2 types
of errors and keep the error log statement for any other.

Change-Id: I2400fe5fec07ac6d6c244b852cce615663774e6e
Signed-off-by: Hugo Arès <hugo.ares@ericsson.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-30 16:21:03 +02:00
Matthias Sohn 65423ea1b1 Merge branch 'stable-3.7'
* stable-3.7:
  Prepare 3.7.2-SNAPSHOT builds
  JGit v3.7.1.201504261725-r
  Revert "Let ObjectWalk.markUninteresting also mark the root tree as"

Change-Id: If1b62ff695e063d797c3d13c43e488ca56f29cbe
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-27 23:59:26 +02:00
Matthias Sohn 720adcebb5 Prepare 3.7.2-SNAPSHOT builds
Change-Id: Ia42a665e76953b643a080b58d2cd4526575ddf2e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-27 00:33:14 +02:00
Matthias Sohn 2383cccf12 JGit v3.7.1.201504261725-r
Change-Id: I80639e317df80c103aef5cad75ad9079d43fb9d0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-26 23:23:20 +02:00
Matthias Sohn f02e4a6188 Merge "Revert "Let ObjectWalk.markUninteresting also mark the root tree as"" into stable-3.7 2015-04-26 16:26:54 -04:00
David Ostrovsky d1da2780c2 Revert "Let ObjectWalk.markUninteresting also mark the root tree as"
The Iff2de881 tried to fix missing tree ..." but introduced severe
performance degradation (>10x in some cases) when acting as server
(git push) and as client (replication). IOW cure is worse than the
disease.

This reverts commit c4797fe986.

Change-Id: I4e6056eb352d51277867f857a0cab380eca153ac
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
2015-04-26 17:52:24 +02:00
Matthias Sohn 10412ddfed Delete deprecated PackWriter.preparePack() methods
Change-Id: I62befa4a933c9ffd42d14519f555554cc513ddd9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-25 00:51:02 +02:00
Matthias Sohn ffdacc2bbb Delete deprecated class IgnoreRule
Was replaced by FastIgnoreRule in 3.6

Change-Id: Ia9c3d1231a5d97f3f5bddc81113954c9f9d8ee1e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-25 00:43:20 +02:00
Matthias Sohn 5362e1d41c Delete deprecated checkoutEntry() methods in DirCacheCheckout
Change-Id: I7fcf6534e6092ba87360ccd68a7dd7466c5c8911
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-25 00:22:59 +02:00
Shawn Pearce 6e5c71b358 Remove validate support when reusing cached pack
Cached packs are only used when writing over the network or to
a bundle file and reuse validation is always disabled in these
two contexts. The client/consumer of the stream will be SHA-1
checksumming every object.

Reuse validation is most critical during local GC to avoid silently
ignoring corruption by stopping as soon as a problem is found and
leaving everything alone for the end-user to debug and salvage.
Cached packs are not supported during local GC as the bitmap rebuild
logic does not support including a cached pack in the result.

Strip out the validation and force PackWriter to always disable the
cached pack feature if reuseValidation is enabled.

Change-Id: If0d7baf2ae1bf1f7e71bf773151302c9f7887039
2015-04-24 11:31:22 -07:00
Shawn Pearce a3476ced1f Rename copyThroughCache to shouldCopyThroughCache
Sensible suggestion from Terry Parker as a late comment on
commit f2efcdc6f769d59722b17e9274932d585035cfb6.

Change-Id: I225775bfb6d3d91ae066ff00f9d80a9c02a422c2
2015-04-24 11:07:22 -07:00
Shawn Pearce 1553a6ff55 Add readAheadBuffer hint to ReadableChannel
This hint allows an underlying implementation to read more bytes when
possible and buffer them locally for future read calls to consume.

Change-Id: Ia986a1bb8640eecb91cfbd515c61fa1ff1574a6f
2015-04-24 11:06:56 -07:00
Shawn Pearce c761c8bb5c Avoid storing large packs in block cache during reuse
When a large pack (> 30% of the block cache) is being reused by
copying it pollutes the block cache with noise by storing blocks
that are never referenced again.

Avoid this by streaming the file directly from its channel onto
the output stream.

Change-Id: I2e53de27f3dcfb93de68b1fad45f75ab23e79fe7
2015-04-23 20:22:13 -07:00
David Pletcher 12e38d7275 Expose public getDepth method
The clone or fetch depth is a valuable bit of information
for access logging. Create a public getter to faciliate access.
A precondition check prevents unintentional misuse when the
data isn't valid yet.

Change-Id: I4603d5fd3bd4a767e3e2419b0f2da3664cfbd7f8
Signed-off-by: David Pletcher <dpletcher@google.com>
2015-04-16 15:50:43 -07:00
Matthias Sohn 41c4f9cb2a Fix error message to include cause if ResetCommand fails
Bug: 464048
Change-Id: I6e7d9262b94cb168c84faef1dea22c1e082fe5ad
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-16 14:28:39 +02:00
Christian Halstrick 510aed1493 Revert "ResolveMerge only needs to visit differing TreeEntries"
This reverts commit bda5e76420. This reduces
performance at least for non-bare repositories.

Change-Id: Ib26cf8372f210798e104112edf14e91bfeaf23ec
2015-04-10 17:06:36 -04:00
Matthias Sohn 017032c465 Fix IllegalArgumentException in AmazonS3
JGit hit IllegalArgumentException: invalid content length
when pushing large packs to S3.

Bug: 463015
Change-Id: Iddf50d90c7e3ccb15b9ff71233338c6b204b3648
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-09 11:12:01 +02:00
Shawn Pearce 300a55dcba Merge "FS.readPipe() shouldn't log IOException as an error" 2015-04-08 21:08:51 -04:00
Shawn Pearce 9fb6d217b5 Merge "Remove obsolete API warning filters to silence warnings" 2015-04-08 21:08:31 -04:00
Shawn Pearce e0d95ab577 Merge "Use try-with-resources to fix warnings in AddCommand" 2015-04-08 21:08:01 -04:00
Shawn Pearce 481405f770 Merge changes Iad4d4127,I0211bcf0
* changes:
  Silence warning for non-translatable String in AddNoteCommand
  Use try-with-resources to fix warnings in AddNoteCommand
2015-04-08 21:07:06 -04:00
Shawn Pearce a0bc9560aa Merge changes I28a5c7e2,If90a6cca
* changes:
  Replace use of deprecated release() in BasePackPushConnection
  Replace use of deprecated release() in BasePackFetchConnection
2015-04-08 21:05:33 -04:00
Shawn Pearce 5ef9c1709e Merge changes I184945ee,Iacaad1a7
* changes:
  Remove unnecessary $NON-NLS comment in BaseReceivePack
  Use try-with-resources to close resources in BaseReceivePack
2015-04-08 21:04:08 -04:00
Shawn Pearce 9b9087d47d Merge changes Ic555e6e0,Id4cb9a23
* changes:
  Replace use of deprecated release() method in BlameResult
  Use try-with-resource to close BlameGenerator
2015-04-08 20:59:05 -04:00
Shawn Pearce f96e15b1e6 Merge "Use try-with-resource to close resources in BlobBasedConfig" 2015-04-08 20:58:32 -04:00
Shawn Pearce 32cc3c3096 Merge "Use try-with-resource to close resources in BundleFetchConnection" 2015-04-08 20:57:53 -04:00
Shawn Pearce 7810d9bc42 Merge "Use try-with-resource to close resources in BundleWriter" 2015-04-08 20:56:24 -04:00
Matthias Sohn d726f0c1e0 Use try-with-resource to close resources in CommitCommand
Change-Id: Ibbbc74acfd050f28e68f318970660b5959caf7e3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-08 22:53:20 +02:00
Matthias Sohn bb2ca576ff Externalize error message used in CheckoutCommand
Change-Id: Ifbc469b07e63218107157ffbf23ae55c52a55ef4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-08 22:52:06 +02:00
Matthias Sohn 7343c7a10f Use try-with-resource to close resources in CheckoutCommand
Change-Id: Ia4d4f9bff03a03d116b80022d7691df67bf8b51b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-08 22:52:05 +02:00
Shawn Pearce f4ded63880 Merge "Fix resource leak in ChangeIdUtil" 2015-04-08 16:08:43 -04:00
Shawn Pearce 2b2cd4ba53 Merge changes I11631afb,Iaa51a46a
* changes:
  Externalize error messages used in DfsGarbageCollector
  Use try-with-resource to close resources in DfsGarbageCollector
2015-04-08 15:53:48 -04:00
Shawn Pearce 297600f7c2 Merge changes I8c06635c,I62d6de7d
* changes:
  Silence non-externalized string warning in CherryPickCommand
  Use try-with-resource to close resources in CherryPickCommand
2015-04-08 15:30:50 -04:00
Shawn Pearce ba8b275ac5 Merge "Silence non-externalized string warnings in CherryPickResult" 2015-04-08 15:30:17 -04:00
Shawn Pearce b2bba1419f Merge "Use try-with-resource to close resources in CloneCommand" 2015-04-08 15:29:53 -04:00
Shawn Pearce 881dfc0147 Merge "Replace call to deprecated RevWalk.release() in DescribeCommand" 2015-04-08 15:26:21 -04:00
Shawn Pearce 15a95e3911 Merge "Use try-with-resource to close resources in DiffCommand" 2015-04-08 15:26:07 -04:00
Shawn Pearce e0477d3fe0 Merge "Fix resource leak in DiffFormatter" 2015-04-08 15:25:30 -04:00
Shawn Pearce f3a44db491 Merge "Use try-with-resource to close resources in DirCache" 2015-04-08 15:22:58 -04:00
Matthias Sohn 842ae868cf Externalize error messages used in DfsGarbageCollector
Change-Id: I11631afb33a2bb29d994551a0be8775bbe277300
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-08 12:22:31 -07:00
Matthias Sohn 13cfc83b2b Use try-with-resource to close resources in DfsGarbageCollector
Change-Id: Iaa51a46a9dde13d6f5c0f9ff54a68cea0ef1fde3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-08 12:22:31 -07:00
Shawn Pearce 429e96eab6 Merge "Reduce visibility of DirCacheCheckout.checkValidPath()" 2015-04-08 15:21:17 -04:00
Shawn Pearce ad1aa922de Merge "Use try-with-resource to close resources in FetchProcess" 2015-04-08 15:20:37 -04:00
Shawn Pearce a80adfbf9c Merge "Use try-with-resource to close resources in GC" 2015-04-08 15:20:15 -04:00
Shawn Pearce 66a95621a3 Merge "Replace deprecated release() methods by close() in Merger" 2015-04-08 15:19:19 -04:00
Shawn Pearce 6e1dc98672 Merge "Ensure that NameRevCommand.call() closes RevWalk" 2015-04-08 15:18:13 -04:00
Shawn Pearce 754b855f73 Merge "Replace deprecated release() methods by close() in NoteMapMerger" 2015-04-08 15:17:29 -04:00
Shawn Pearce 67568ee630 Merge "Use try-with-resource to close resources in ObjectDatabase" 2015-04-08 15:17:13 -04:00
Shawn Pearce aa94e3f3ae Merge changes Ia3908555,I3bc26847
* changes:
  Silence false null pointer access warnings in PackFile
  Externalize error messages used in ObjectDirectoryInserter
2015-04-08 15:16:53 -04:00
Shawn Pearce 96a5ec43fa Merge "Silence non-externalized string warning in PackIndexV2" 2015-04-08 15:15:47 -04:00
Matthias Sohn 8d41c783c0 Silence non-externalized string warning in PackParser
Change-Id: I1a4181fc292c42157c69479f71c7674b2e00d2ce
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-04 00:54:24 +02:00
Matthias Sohn e5a6290ac9 Replace call to deprecated release() by close() in PackParser
Change-Id: Ic2db051130059cce89486f55ecca32a7ce6715fd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-04 00:53:47 +02:00
Matthias Sohn 6feb7bc9dd Silence non-externalized string warning in PackIndexV2
Change-Id: I8c94811972c593c898f6375178f250a2123d01c6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-04 00:51:05 +02:00
Matthias Sohn 4dd4d7e12a Silence false null pointer access warnings in PackFile
Change-Id: Ia39085557b38840dfaa9b4995e6f6c40e19042cb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-04 00:49:05 +02:00
Matthias Sohn fc2d723dd9 Externalize error messages used in ObjectDirectoryInserter
Change-Id: I3bc26847071fbc31267a4a4cf5a10b428bcf229d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-04 00:45:33 +02:00
Matthias Sohn 1728d1d760 Use try-with-resource to close resources in ObjectDatabase
Change-Id: Ib410bf0d3c300c25b615bb6a51488b3d88aeb3bd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-04 00:38:39 +02:00
Matthias Sohn f777ed1d24 Replace deprecated release() methods by close() in NoteMapMerger
Change-Id: Iaa76f0e853bb82cd7f231fd2f462a319f4196d8c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-04 00:36:28 +02:00
Matthias Sohn f434f29fd9 Ensure that NameRevCommand.call() closes RevWalk
Change-Id: Icc35a81081759d664fe9e2b05e962ff3cd9aad92
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-04 00:32:59 +02:00
Matthias Sohn 8e332f1057 Replace deprecated release() methods by close() in Merger
Change-Id: I80ce98511a6e9048f1eea93288d6960dcbf3326f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-04 00:19:39 +02:00
Matthias Sohn ed42bad1c6 Use try-with-resource to close resources in GC
Change-Id: I62a755a4ce839a252a5e80abf3f0d21243862376
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-04 00:17:03 +02:00
Matthias Sohn 2693d6075d Use try-with-resource to close resources in FetchProcess
Change-Id: If489d530ca39ae279c8da848f870b561c38eac3c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-04 00:05:14 +02:00
Matthias Sohn 787ca168a9 Reduce visibility of DirCacheCheckout.checkValidPath()
This was deprecated and should only be used by DirCacheCheckout and
friends. Other classes should use SystemReader.checkPath() instead.

Change-Id: I37cf753b1f081602dee9f0f47979eff39d735f92
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 02:03:00 +02:00
Matthias Sohn b84623ac64 Use try-with-resource to close resources in DirCache
Change-Id: I7dd3fd38784689816a1a8e9d8ccb499ae2138a8a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 01:25:45 +02:00
Matthias Sohn ff0a7b719e Fix resource leak in DiffFormatter
- close RevWalk allocated in scan()
- replace use of deprecated ObjectReader.release() method

Change-Id: I41b2b10a1a44270a6ceaa1741e996c0921439852
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 01:23:31 +02:00
Matthias Sohn b8658e486c Use try-with-resource to close resources in DiffCommand
Change-Id: I13d7c8bd0eb049aa69effd8b74384746226414cb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 01:15:37 +02:00
Matthias Sohn 5f8308bdb9 Replace call to deprecated RevWalk.release() in DescribeCommand
Change-Id: Ie4bfdeb37d345d6ff1525a737f3b7653b2f8e23e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 00:58:50 +02:00
Matthias Sohn 4bae608e84 Use try-with-resource to close resources in CloneCommand
Change-Id: I9536bc208a5f3ec34f0a82fb565b4253be38e074
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 00:38:42 +02:00
Matthias Sohn b53e2a99b3 Silence non-externalized string warnings in CherryPickResult
Change-Id: I515abbcb4319b744c5074de5a0c56caed13c2fb5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 00:36:36 +02:00
Matthias Sohn 588965c6da Silence non-externalized string warning in CherryPickCommand
Change-Id: I8c06635ce655470b5b650fa5c0c546e64445420c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 00:33:01 +02:00
Matthias Sohn 58c2c52219 Use try-with-resource to close resources in CherryPickCommand
Change-Id: I62d6de7d67c7de2460f4cbe918ad2bb8109650b9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-03 00:32:08 +02:00
Matthias Sohn 3f79182081 Fix resource leak in ChangeIdUtil
Change-Id: I5cb3e9c7e167248697932933eef925c446514683
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:30:14 +02:00
Matthias Sohn d4380a9c81 Use try-with-resource to close resources in BundleWriter
Change-Id: I5341973737f6d21c04982bcbefc2ed672ac9bcff
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:25:46 +02:00
Matthias Sohn 9e37f6d144 Use try-with-resource to close resources in BundleFetchConnection
Change-Id: Id79c01133b835e278d5b494b5bc5972d7aeed9a9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:24:05 +02:00
Matthias Sohn d6692d54a9 Use try-with-resource to close resources in BlobBasedConfig
Change-Id: Idb890788a88049d07326cd48e7c5534148f18e32
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:21:55 +02:00
Matthias Sohn 48622e0ec2 Replace use of deprecated release() method in BlameResult
Change-Id: Ic555e6e0443337aed694bc6445a60abe08e07ad2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:18:42 +02:00
Matthias Sohn e03b6c5cf8 Use try-with-resource to close BlameGenerator
Change-Id: Id4cb9a236dddfc674b55e9e7037329a885455288
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:15:59 +02:00
Matthias Sohn 21eee62f7d Remove unnecessary $NON-NLS comment in BaseReceivePack
Change-Id: I184945ee29fb9a6b1f30aec88958375e7b5239b3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:12:22 +02:00
Matthias Sohn c1edc1a07e Use try-with-resources to close resources in BaseReceivePack
Change-Id: Iacaad1a7e0719541e5616d231422ea6fd4c95161
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:11:22 +02:00
Matthias Sohn 6691c20bc2 Replace use of deprecated release() in BasePackPushConnection
Change-Id: I28a5c7e222daf35e3d1a1a6fda8ed6ef9b960f78
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:06:08 +02:00
Matthias Sohn b61be2cf3e Replace use of deprecated release() in BasePackFetchConnection
Change-Id: If90a6cca9a2ae80474f5ad023cb2a0a8905010be
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 01:02:21 +02:00
Matthias Sohn 81c84c088f Use try-with-resources to close walks in ArchiveCommand
Change-Id: I77120d77a12f1bab5c918a23b0e3eac90e320b2b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 00:58:13 +02:00
Matthias Sohn 114dee6770 Silence warning for non-translatable String in AddNoteCommand
Change-Id: Iad4d41271eff4e8744efece5bc777c1cb06dead7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 00:51:02 +02:00
Matthias Sohn 3206f37cc3 Use try-with-resources to fix warnings in AddNoteCommand
Replaces use of deprecated release() methods.

Change-Id: I0211bcf0a76a2fccc2c85fa74778e20c256984ba
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 00:46:59 +02:00
Matthias Sohn e5b81e49e8 Use try-with-resources to fix warnings in AddCommand
- replaces use of deprecated ObjectInserter.release()
- auto-close TreeWalk

Change-Id: I540ee711b8c3430a71fdff07add506b7d9c039dc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 00:41:19 +02:00
Matthias Sohn 5d22a7b108 Remove obsolete API warning filters to silence warnings
Change-Id: I958d540a6afb1462a3fbb3d76c8f51f386ac068e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-04-02 00:29:34 +02:00
Shawn Pearce d94ce9c754 Buffer overflow output stream
Most callers/users of TemporaryBuffer are sizing the in-memory
portion large enough that most outputs fit into RAM. With this
assumption they don't pay close attention to the size of IOs
being written, as it "should" just be a copy from one byte array
to another.

Overflow sets up a local file handle, which is costly to write to
for small IO units. Wrap the local file in a BufferedOutputStream
to combine small writes together. Larger writes can still bypass the
buffer as BOS automatically avoids copying for larger writes.

Change-Id: I09f4136dd65c48830cfda86d9101bc647581018a
2015-04-01 13:02:09 -07:00
Shawn Pearce e4433e5e37 Fix overflow stream leak during merge conflicts
When reading back from an overflowed TemporaryBuffer the InputStream
must be closed to close the FileInputStream that is reading from
the backing file.

Change-Id: Id83d8f16f5b2c2618a9f841ec3508508455a6ae1
2015-04-01 13:02:09 -07:00
Shawn Pearce 6884ea24cd Use local GIT_DIR for overflow during merge conflicts
By writing the temporary overflow merge result to $GIT_DIR JGit
can ensure the same filesystem permissions apply to protect the
file contents.

If no directory is available from the repository (e.g. DfsRepository)
null will be passed and the system temporary directory will be used
instead.

Change-Id: I95532aa092676d18f1dc1e3fdbe6dcb1f91b782e
2015-04-01 13:02:08 -07:00
Shawn Pearce 835955fc5b Use try-with-resources and BufferedOutputStream for local merge conflicts
Change-Id: If5539aab1de19bb22400c862bbe2cdf7c3e85535
2015-04-01 13:02:08 -07:00
Shawn Pearce 1b63323212 Optimize EolAwareOutputStream for bulk output
Formatting merge conflicts one byte at a time is going to be very
slow when the final OutputStream is a FileOutputStream and the JVM
is making system calls for each byte output.

When outputting a range of bytes from a byte[] the bol (beginning
of line) value only depends on the value of the last byte written.
Other bytes in the array can be passed directly to the lower stream
for more efficient output.

Change-Id: I3415f9a390ee215210a17bb5bf39164d197e1348
2015-04-01 13:02:07 -07:00
Matthias Sohn bda5e76420 ResolveMerge only needs to visit differing TreeEntries
This should considerably speed up the treewalk on larger repositories.

Found by discussing new EGit API to support model merge in change
eda23bb556d342f421f03b93c7faa160998598aa

Change-Id: I822721c76c64e614f87a080ced2457941f53adcd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
cc: Laurent Delaigue <laurent.delaigue@obeo.fr>
2015-03-31 17:33:31 +02:00
Matthias Sohn 6e653aef1d FS.readPipe() shouldn't log IOException as an error
This unintentionally was changed from severity debug to error which is
causing unexpected log entries.

Bug: 463349
Change-Id: I4b6d42a1420652ab6824e237bd231ba86896acbf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-03-28 10:10:47 +01:00