Commit Graph

4187 Commits

Author SHA1 Message Date
Matthias Sohn f389e18a28 Prepare 4.11.1-SNAPSHOT builds
Change-Id: Id9aa6b7e8f56de5183b6cd57ef0e790ec9debd4d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-08 21:10:08 +01:00
Matthias Sohn f944063517 JGit v4.11.0.201803080745-r
Change-Id: Ie24a33bc8a24c30db06fe7b175f405efb95776ec
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-08 13:43:46 +01:00
Thomas Wolf e00f59b7fe Remove useless for(;;) loop
Change-Id: Ic9a7824cc178e92f44126acc8e77b0304b20ef4f
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-03-07 23:56:35 +01:00
Thomas Wolf 7d3040368f Fix DiffFormatter for diffs against working tree with autocrlf=true
The WorkingTreeSource produced an ObjectLoader that returned
inconsistent sizes: the file size in getSize(), but then a
correctly filtered smaller stream in openStream(). This resulted
either in an IOE "short read of block" or in an EOFException
depending on the resulting filtered size.

Fix this by ensuring that getSize() does return the size of the
filtered stream.

Bug: 530106
Change-Id: I7c7c85036047dc10030ed29c1d5a6c7f34f2bdff
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-03-07 23:25:22 +01:00
Matthias Sohn 0d79bcf151 Merge branch 'stable-4.10'
* stable-4.10:
  Don't subclass ThreadLocal to avoid memory leak in NLS
  Set context classloader to null in WorkQueue

Change-Id: Idacf9a15a27f8e1d73357a80ed11a02237eea49e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-07 22:37:50 +01:00
Markus Duft 0f9ec9e406 LFS: Adjust some API to make integration into tools (EGit,...) easier
Make the install command accessible without requiring reflection.

Expose the isEnabled(Repository) API to be able to check if calling the
install command is required for a repository.

Change-Id: I17e6eaefb6afda17fea8162cbf0cb86a20506753
Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-07 22:02:02 +01:00
David Pursehouse 2c29af7867 MergeCommand: Open RevWalk in try-with-resource
Change-Id: I45ce481cc198b8dc78e9c46b433504840597e982
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-07 14:46:08 +09:00
David Pursehouse ee4dd50b3f JschConfigSessionFactory: Open FileInputStream in try-with-resource
Change-Id: I0f8f4629c93ed747f2f604538fccc52da3974b2e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-07 14:39:39 +09:00
David Pursehouse e53edce867 GC: Open auto-closeable resources in try-with-resource
Change-Id: If437e14636de7c5014ee2aa419d6518acd857792
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-06 17:24:29 +09:00
David Pursehouse d1356bf238 FileRepository: Open FileInputStream in try-with-resource
Change-Id: Ief8aa4834437d76f7e636598bf9861312475e64a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-06 17:18:23 +09:00
David Pursehouse 336add10c1 FetchProcess: Open OutputStreamWriter in try-with-resource
Change-Id: Ide7768882a95f9e9706e50ca0774edd428dd07c1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-06 17:14:19 +09:00
David Pursehouse fabd645fad FS: Open TemporaryBuffer in try-with-resource
Change-Id: I52e048e491e838b7f762a5b5f4d148e91049877c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-06 16:58:12 +09:00
David Pursehouse da63121b0d DirCacheIterator: Open InputStream in try-with-resource
Change-Id: I05d2d1de9a3d39466a6880f6e8107da8681876b1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-06 16:56:13 +09:00
David Pursehouse e6c456eeae Merge changes from topic 'try-with-resource'
* changes:
  DiffCommand: Open DiffFormatter in try-with-resource
  DiffAlgorithms: Open Repository in try-with-resource
  DescribeCommandTest: Open FileWriter in try-with-resource
  CommitCommand: Open InputStream in try-with-resource
  DefaultNoteMerger: Open UnionInputStream in try-with-resource
2018-03-06 02:55:50 -05:00
David Pursehouse e2d875ee30 DiffCommand: Open DiffFormatter in try-with-resource
Change-Id: I22bd1062d64b01bb98cdaf612482538114624b7f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-06 10:40:35 +09:00
David Pursehouse 3393f78210 CommitCommand: Open InputStream in try-with-resource
Change-Id: I800a2afae17f84636cae593be7f07628fb8476c1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-06 09:48:19 +09:00
David Pursehouse 1826341793 DefaultNoteMerger: Open UnionInputStream in try-with-resource
Change-Id: I035aa89cdbf235992f41e752f49d735be4e5df0a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-06 09:47:11 +09:00
Matthias Sohn e88f95146a Silence API error raised for new CONFIG_SECTION_LFS constant
Change-Id: I27e68d245c6b9c972ab9470c14d1f45d15d4c253
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-06 00:28:38 +01:00
David Pursehouse 9e4a455f9b ArchiveCommand: Create archive output stream in try-with-resource
Change-Id: I72f4d303945275d400723aa17212b302e051dc15
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-05 20:19:25 +09:00
David Pursehouse 40868386db ApplyCommand: Open FileWriter in try-with-resource
Change-Id: Ia473f74dc4608fc43edd57eda4f193c226e9004d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-05 20:17:32 +09:00
David Pursehouse f6dbc7d472 AmazonS3: Open InputStream/FileInputStream in try-with-resource
Change-Id: I71606e14d2b3cf085b8d1343c3858e7a729a173e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-05 20:11:59 +09:00
David Pursehouse fa9ee83697 WalkRemoteObjectDatabase: Open auto-closeable resources in try-with-resource
Change-Id: Ie4f67ca8cab1031089782f202588b08cc157dd79
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-05 17:15:04 +09:00
David Pursehouse 99c187a5da TransportSftp: Open BufferedReader in try-with-resource
Change-Id: Iab94cce80c11a5edeaf8f377001408cc53707c04
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-05 17:13:20 +09:00
David Pursehouse 4c2f613a5a TransportHttp: Open auto-closeable resources in try-with-resource
Change-Id: I2f713b79ff07f5759c189f384cd25adb9b9f5761
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-05 16:28:59 +09:00
David Pursehouse 20b750d2f5 LockFile: Open FileInputStream in try-with-resource
Change-Id: I0784266814225428a6a0070d1653c465d268b342
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-05 11:03:21 +09:00
David Pursehouse 60b43c03e2 Add ConfigConstants.CONFIG_SECTION_LFS
DirCacheCheckout has a warning about non-localised string "lfs". Other
classes use org.eclipse.jgit.lfs.lib.Constants but that is not visible
to DirCacheCheckout.

Add a new constant in ConfigConstants and use that in DirCacheCheckout.

Replace existing uses of org.eclipse.jgit.lfs.lib.Constants.LFS with
the new constant, except where it is referring to the folder name.

Change-Id: I0f21b951babff9a2e579d68c4de0c62ee4bc23d4
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-05 10:53:28 +09:00
David Pursehouse bc9e3a31b2 Add|RemoveNoteComand: Reduce duplicated code
The private method commitNoteMap is in both classes with the same
implementation.

Make it static in AddNoteCommand and reuse it from RemoveNoteCommand.

Change-Id: Ia037bf9efdd94ee7b8d33b41321e9cfd6ea4a6a5
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-03 23:58:50 +01:00
David Pursehouse cf489d36b9 TagBuilder: Open OutputStreamWriter in try-with-resource
Change-Id: Ic0e23039b0aec6171f192234c6b1474cd32eadff
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-03 23:58:49 +01:00
David Pursehouse a73f6c6009 DaemonService: Open Repository in try-with-resource
Change-Id: I8deec91d91e82c7cb186cfa9507eb443dd87aad3
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-03 23:58:49 +01:00
David Pursehouse 63be96f488 RefDirectory: Open BufferedReader in try-with-resource
Change-Id: I9239df3e381b141b48ad7ea1b706e5b5927946cd
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-03 23:58:48 +01:00
David Pursehouse db0b7911fe ObjectDirectory: Open BufferedReader in try-with-resource
Change-Id: I4a44954c61647af1e48eade19112697e79297f2e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-03 23:58:48 +01:00
David Pursehouse 86330ca2ad Patch: Open TemporaryBuffer in try-with-resource
Change-Id: I90bff8d49ecc37b8c10ce909cd3ac563205b641c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-03 23:58:48 +01:00
David Pursehouse a573dfc658 Enable warning for resources not managed by try-with-resource
Change-Id: Iefe97de6bdb62af558f1b0e77c9205a9186f9b4c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-03 23:58:47 +01:00
Markus Duft c0103bc59d LFS: Enable LFS support for the CLI, better error handling
Enable LFS support for the CLI by registering the according filters.

Errors during filter creation must be propagated up the call stack, as a
failure to create a filter should be treated as fatal if the filter is
required.

Change-Id: I3833757839bdda97cd01b6c21c1613d199e2692d
Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
2018-03-03 11:44:01 +01:00
Markus Duft a3f8edbf6a Cleanup stream usage WRT filters
As it is right now some streams leak out of the filter construct. This
change clarifies responsibilities and fixes stream leaks

Change-Id: Ib9717d43a701a06a502434d64214d13a392de5ab
Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-03 11:40:55 +01:00
Markus Duft d3ed64bcd4 LFS: support merge/rebase/cherry-pick/diff/compare with LFS files
Respect merge=lfs and diff=lfs attributes where required to replace (in
memory) the content of LFS pointers with the actual blob content from
the LFS storage (and vice versa when staging/merging).

Does not implement general support for merge/diff attributes for any
other use case apart from LFS.

Change-Id: Ibad8875de1e0bee8fe3a1dffb1add93111534cae
Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-03-03 11:39:43 +01:00
Terry Parker 5a74b586b3 Correctly exit fetch negotiation for stateless RPC connections
Commit 9530c10192 (2018-02-11)
"Add a minimum negotiation feature for fetch" made fetch
negotiation cheaper for repos with huge numbers of
references (we are seeing a 15x reduction in maximum fetch
times for chromium/chromium/src on trans-Pacific links).
But it inadvertently broke the handling of stateless RPC
connections, so fix that here.

Change-Id: I0090aa76ffecc55801ebb833ac2e0c933a4a7c54
Signed-off-by: Terry Parker <tparker@google.com>
2018-02-28 15:32:57 -08:00
Markus Duft c0bb992845 LFS: pre-push upload support
If JGit built in LFS support is enabled for the current repository (or
user/system), any existing pre-push hook will cause an exception for the
time beeing, as only a single pre-push hook is supported.

Thus either native pre-push hooks OR JGit built-in LFS support may be
enabled currently, but not both.

Change-Id: Ie7d2b90e26e948d9cca3d05a7a19489488c75895
Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-02-27 18:32:45 +01:00
David Pursehouse 12a589fb57 AmazonS3: Open OutputStream in try-with-resource
Change-Id: I0685a298a0f9fec465973cc718ae3bff373318a4
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-02-26 20:38:12 +09:00
David Pursehouse f0b46e1db4 Add ObjectIdSerializer
This is based on the ObjectIdSerialization class written by Shawn Pearce
for the Gerrit Code Review project in 2009 [1]. As mentioned in the
commit message there, it should be part of core JGit.

This implementation is slightly different to Shawn's version. Rather
than having separate methods for null/non-null ids, single methods are
implemented with @Nullable annotations.

[1] https://gerrit-review.googlesource.com/c/gerrit/+/9792

Change-Id: I7599cf8bd1ecd546e2252783d6d672eb76804060
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-02-25 23:15:01 +01:00
David Pursehouse c9e3921fbb Fix warnings about boxing/unboxing Boolean
Change-Id: I9d81d510282e9181267750fe3f9c571c35b61407
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-02-25 17:35:12 +09:00
David Pursehouse e8c69fa5fd WorkingTreeIterator: Fix warnings about variable hiding
Change-Id: I78ed3ae7aa30a7e7f146d0bd2e9feff74554da78
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-02-25 17:32:33 +09:00
David Pursehouse 6ea21b454c WorkingTreeIterator: Add NON-NLS suppressions
Change-Id: I369b8f68912134fc3880c162e9a2c5a1669bb4ac
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-02-25 17:30:16 +09:00
Marc Strapetz 78420b7d0a Fix processing of gitignore negations
Processing of negated rules, like !bin/ was not working correctly: they
were interpreted too broad, resulting in unexpected untracked files
which should actually be ignored

Bug: 409664
Change-Id: I0a422fd6607941461bf2175c9105a0311612efa0
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
2018-02-23 13:36:48 +01:00
Dave Borowitz 879372eb72 DfsReaderIoStats: Clarify that "blocks" are really cache misses
The previous wording was ambiguous as to whether these were blocks
requested from the cache (hits + misses) or read from underlying storage
(misses only).

They are in fact recording only misses:
Accumulator#{readBlock,readBlockBytes,readBlockMicros} are only
incremented from BlockBasedFile#readOneBlock, which is only called from
the cache miss path in DfsBlockCache#getOrLoad (line 391).

Change-Id: I0135cd1e76d09c1e28e0f1833b34c312511c66ce
2018-02-22 16:27:09 +09:00
Marc Strapetz 49cb6ba5dd PathMatcher: fix handling of **/
**/ should match only directories, but not files

Change-Id: I885c83e5912cac5bff338ba657faf6bb9ec94064
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
2018-02-22 14:39:23 +09:00
David Pursehouse 0e20df710a Merge changes Id616611e,Ib6509e81,I52f5d3f2
* changes:
  RepoCommand: generate relative submodule URLs from absolute URLs.
  RepoCommand: don't record new commit if tree did not change
  RepoCommand: persist unreadable submodules in .gitmodules
2018-02-22 00:37:48 -05:00
Shawn Pearce d0fbaf502e dfs: Try to avoid searching UNREACHABLE_GARBAGE during packing
If an object can be found in a non-garbage pack, favor that pack over
paging in the garbage pack's idx and pack content.

Only fall back to garbage packs if an object cannot be found and there
are garbage packs present in the repository.  This fallback is
required to correct race conditions during GC.

Change-Id: Ia7c123975bc069b8e6e713eda2d357303b71e329
2018-02-21 14:46:57 -05:00
Han-Wen Nienhuys 6a420613f7 RepoCommand: generate relative submodule URLs from absolute URLs.
If a manifest file specifies an absolute URL on the same host on which
the superproject resides, rewrite the URLs to be relative.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: Id616611e5195998fb665c8e7806539a3a02e219a
2018-02-21 13:41:50 +01:00
Han-Wen Nienhuys 3214171dec RepoCommand: don't record new commit if tree did not change
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: Ib6509e816684256d723558d5e8f3c37de58a2ff8
2018-02-19 20:24:07 +09:00
Han-Wen Nienhuys 446a7096ef RepoCommand: persist unreadable submodules in .gitmodules
In cases where a manifest file mixes different remotes, a Gerrit
server process may not have access to all remotes, and won't be able
to produce a full submodule tree.

Preserving this information in .gitmodules will let downstream clients
reconstruct the full tree.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I52f5d3f288e771dca0af2b4dd3f3fa0f940dcf15
2018-02-19 20:24:07 +09:00
Matthias Sohn 44f0a01f24 Silence API error for new constant in ConfigConstants
Change-Id: Ic4bd10b67caf6b2a2cc0c23bb4e7c717e4ccd6d5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-02-18 22:23:00 +01:00
Matthias Sohn 33d5c0fe4a Silence API errors raised for new public fields in PackStatistics
Change-Id: I8e118282a833361b676aa3cc90cbe774ccd42ed0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-02-18 22:08:47 +01:00
Markus Duft 94bcde663c LFS: Add remote download to SmudgeFilter
Transfer data in chunks of 8k Transferring data byte per byte is slow,
running checkout with CleanFilter on a 2.9MB file takes 20 seconds.
Using a buffer of 8k shrinks this time to 70ms.

Also register the filter commands in a way that the native GIT LFS can
be used alongside with JGit.

Implements auto-discovery of LFS server URL when cloning from a Gerrit
LFS server.

Change-Id: I452a5aa177dcb346d92af08b27c2e35200f246fd
Also-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
2018-02-16 18:27:25 +01:00
David Pursehouse 9bebb1eae7 RepoCommand: Don't leave Git open
When the command is run on a non-bare repository, an instance of
Git is created to execute the commit, and is left open when the
command has finished.

Refactor to not use a class scope Git instance, and make sure it
gets closed before returning.

Change-Id: Ic623ae0fd8b9e264b5dfd434da0de6bb4f910984
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-02-15 16:59:42 +09:00
Matthias Sohn 282dc592da Merge "Merge branch 'stable-4.10'" 2018-02-14 18:18:43 -05:00
David Pursehouse 184ddc5afa Merge "InitCommand: Don't leave Repository open after Git is closed" 2018-02-14 18:18:35 -05:00
Matthias Sohn d2d22e1471 Merge branch 'stable-4.10'
* stable-4.10:
  Fix ssh host name handling for Jsch
  Jsch overrides the port in the URI with the one in ~/.ssh/config

Change-Id: I860fc61ceb12ae792b1ee7421046ecd32373b9f8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-02-14 23:28:28 +01:00
Matthias Sohn 95fc2b210f Don't subclass ThreadLocal to avoid memory leak in NLS
These problem usually occur when you subclass ThreadLocal (usually to
implement initialValue). Those classes reference the webapp's
classloader. The ThreadLocal subclass in turn is referenced by each
Thread instance (that's how ThreadLocals are implemented, they have a
"helper-Map" in each Thread instance, so the leak is actually not a tiny
Random instance but the whole webapp's classloader with a bunch of class
definitions and statically referenced parts of the webapp.

Bug: 449321
Change-Id: Ie7a8b0b90e40229e2471202f2a12637b9e0b1d11
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-02-14 21:39:25 +01:00
Matthias Sohn 95f868f246 Set context classloader to null in WorkQueue
If threads created by the executor have a reference to the context
classloader this may cause a leak.

See: https://wiki.apache.org/tomcat/MemoryLeakProtection#cclThreadSpawnedByWebApp
Bug: 517107
Change-Id: If79c1ebd3f9cf733fd88a5fce38fd46ff0d08d10
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-02-14 21:39:24 +01:00
Matthias Sohn 6e0f8bacd4 Merge branch 'stable-4.9' into stable-4.10
* stable-4.9:
  Fix ssh host name handling for Jsch
  Jsch overrides the port in the URI with the one in ~/.ssh/config

Change-Id: Iff9076f65e767bbe8df016337b631bdaeb40ad98
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-02-14 21:25:16 +01:00
Matthias Sohn 105bfd9b56 Merge "TransportLocal should reuse FS from source repo" 2018-02-14 15:02:22 -05:00
Thomas Wolf 185e53bce4 Fix ssh host name handling for Jsch
If we give Jsch access to the ssh config file, we must _not_ resolve
the host name from the alias. Instead we must give the alias (i.e.,
the host name as is in the URI) to Jsch, so that it finds the same
ssh config entry.

Otherwise if the hostname in the URI, which is taken as an alias in
ssh config ("Host" line), is unequal to the "Hostname" line, and
there happens to be another ssh config entry with that translated
host name as alias, Jsch will pick up that second entry, and we end
up with a strange mixture of both.

Add tests for this case.

Bug: 531118
Change-Id: I249d8c073b0190ed110a69dca5b9be2a749822c3
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-02-14 13:39:28 +01:00
Thomas Wolf 891103609d Jsch overrides the port in the URI with the one in ~/.ssh/config
Jsch unconditionally overwrites the port from the ssh config
file (if a port is specified there), even if the URI explicitly does
give a different port.

Fix this, and add tests.

Change-Id: I7b014543c7ece26270e366db39d7647f82d64f0d
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-02-14 13:32:37 +01:00
David Pursehouse f527d4548f InitCommand: Don't leave Repository open after Git is closed
The InitCommand returns a Git that is instantiated with the newly
created Repository, but the Repository is not closed with the Git
resulting in resource leaks.

Create the Git with `closeRepo` set to true, such that the Repository
is also closed when the Git is closed.

Adjust the tests to use try-with-resource on the Git instance.

Change-Id: Ib26e7428c7d8840956d1edb09e53b93e23e6fe5a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-02-14 14:09:40 +09:00
Terry Parker 9530c10192 Add a minimum negotiation feature for fetch
Android an Chrome have several repos with >300k refs. We sometimes see
negotiations of >100k rounds. This change provides a "minimal negotiation"
feature on the client side that limits how many "have" lines the client
sends. The client extracts the current SHA-1 values for the refs in its
wants set, and terminates negotiation early when all of those values have
been sent as haves. If a new branch is being fetched then that set will
be empty and the client will terminate after current default minimum
of two rounds.

This feature is gated behind a "fetch.useminimalnegotiation" configuration
flag, which defaults to false.

Change-Id: Ib12b095cac76a59da6e8f72773c4129e3b32ff2b
Signed-off-by: Terry Parker <tparker@google.com>
2018-02-12 14:03:11 -08:00
Terry Parker 302596cc67 Add negotiation statistics to PackStatistics
Add fetch statistics for the counts of advertised refs, wants and haves.
Also add the duration in milliseconds for the negotiation phase. For
non-bidirectional transports like HTTP, this is the time for the final
round that sends the pack back to the user.

Change-Id: I1af7ffd3cb7b62182340682e2a243691ea24ec2e
Signed-off-by: Terry Parker <tparker@google.com>
2018-02-12 13:59:42 -08:00
Minh Thai 5efc3dcc6c MergedReftable to skip shadowed refs in same reftable
This would allow compact and GC process to clean up duplicate ref names in the reftables.

Change-Id: I2b9df0bf72dba63cc3525e374982e60559a776c2
Signed-off-by: Minh Thai <mthai@google.com>
2018-02-09 09:49:24 -08:00
Christian Halstrick 4d5231f001 Fix CleanCommand not to throw FileNotFoundExceptions
When CleanCommand is collecting the files and folders to be deleted
it may happen that the list of directories contains obsolete entries.
E.g. a folder and its parent folder may be in the list. Only the
parent folder would be sufficient.

This was a reason for hitting FileNotFoundExceptions when finally
trying to delete the files and folders. Improve CleanCommand
to ignore files to be deleted which are already gone.

Bug: 514434
Change-Id: I10caa01bfb9cec5967dfdaea50c6e4a713eeeabd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-02-08 10:27:21 +01:00
Hector Caballero 93654f75a2 GC: Remove empty references folders
After packaging references, the folders containing these references are
not deleted. In a busy repository, this causes operations to slow down
as traversing the references tree becomes longer.

Delete empty reference folders after the loose references have been
packed.
To avoid deleting a folder that was just created by another concurrent
operation, only delete folders that were not modified in the last 30
seconds.

Signed-off-by: Hector Oswaldo Caballero <hector.caballero@ericsson.com>
Change-Id: Ie79447d6121271cf5e25171be377ea396c7028e0
2018-02-07 18:37:12 -05:00
David Ostrovsky ab1b97234d Bazel: Support building with Java 9
Bazel@HEAD supports Java 9.

The current code has one single issue with Java 9 compliance: the usage
of javax.xml.bind.DatatypeConverter class for printHexBinary() method.
This class is not available on Java 9. One alternative is to use guava
library. Something similar was done here: [1]. But unlike the case with
checkstyle library, JGit currently doesn't use guava. Instead, we add
java.xml.bind module with --add-modules compiler option.

To build (or test) with Java 9, build custom bazel version and issue:

  $ bazel --host_javabase=/usr/lib64/jvm/java-9-openjdk build \
    --javacopt='--release 9' \
    --java_toolchain=@bazel_tools//tools/jdk:toolchain_jdk9 :all

The Java 9 support is backwards compatible.

* [1] https://github.com/checkstyle/checkstyle/issues/5027

Change-Id: I2c5203fc4e65885ce7b210f824fda85ba6d6c51d
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
2018-02-07 17:51:35 -05:00
Hector Caballero 6766fc85d0 GC: Merge if statement with the enclosing one
Reported by Sonar.

Signed-off-by: Hector Oswaldo Caballero <hector.caballero@ericsson.com>
Change-Id: Ib6fe6c67d6f7697e6d60693d5cee7e9c6a227767
2018-02-06 08:41:41 -05:00
Hector Caballero 4644d15bc5 GC: Replace Files methods with File alternatives
The Files.exists method has noticeably poor performance in JDK 8 and can
slow an application significantly when used to check files that do not
actually exist. The same goes for Files.notExists, Files.isDirectory and
Files.isRegularFile [1].

Replace them with their File counterpart.

[1] https://rules.sonarsource.com/java/tag/performance/RSPEC-3725

Signed-off-by: Hector Oswaldo Caballero <hector.caballero@ericsson.com>
Change-Id: I89d23b9cc74bec8e05f6b7f3e49bfd967dbb6373
2018-02-06 08:39:43 -05:00
Hector Caballero 66127d4284 GC: Replace anonymous classes with lambdas
Signed-off-by: Hector Oswaldo Caballero <hector.caballero@ericsson.com>
Change-Id: Ic9725bdb1a281c80055a5438a02d961b1d1875f4
2018-02-06 06:29:29 -05:00
Hector Caballero 54053389ef GC: Simplify lambda
filter() stream operation also accepts a lambda expression.

Signed-off-by: Hector Oswaldo Caballero <hector.caballero@ericsson.com>
Change-Id: Ie0b7fe43d39593172969fd16c3e44b49bac27306
2018-02-06 06:28:10 -05:00
Hector Caballero e00a12f5a2 GC: Simplify reference equals() method
Signed-off-by: Hector Oswaldo Caballero <hector.caballero@ericsson.com>
Change-Id: I5b2e12e012d5423e9b84c1c66a478960121ea212
2018-02-06 06:26:14 -05:00
Hector Caballero f58c3fce90 GC: Simplify boolean expression
Signed-off-by: Hector Oswaldo Caballero <hector.caballero@ericsson.com>
Change-Id: I0e7a365c26b2333627fcc26b9ea9f4fcd65e8746
2018-02-06 06:25:57 -05:00
Hector Caballero 6ca4c79063 GC: Simplify expression
Avoid converting path to file to then reconvert it to path.

Signed-off-by: Hector Oswaldo Caballero <hector.caballero@ericsson.com>
Change-Id: I6a8c3ca9b83bf9b0eead9506938f5d68b27a76f5
2018-02-06 06:25:32 -05:00
Hector Caballero 049417d504 GC: Remove redundant type arguments
Signed-off-by: Hector Oswaldo Caballero <hector.caballero@ericsson.com>
Change-Id: Id3281a744b08f9d7b2b60f69b4e461b053ac5d02
2018-02-06 06:25:17 -05:00
Hector Caballero e3b73d889c GC: Remove unnecessary continue statement
continue is unnecessary when it is the last statement in a loop

Signed-off-by: Hector Oswaldo Caballero <hector.caballero@ericsson.com>
Change-Id: I12af9f9a0bb2fd7fc0239f1f3b59fb8e64e1f351
2018-02-06 06:24:40 -05:00
Matthias Sohn f7244b81cc Close RevWalk in BranchTrackingStatus.of()
Bug: 530757
Change-Id: I985ee5395e1468981c28ae0a80797732e2f528d2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-02-06 01:10:26 +01:00
David Turner be2a8ed63b Basic submodule merge handling
This doesn't handle the really hard thing, which is merging spurious
conflicts inside .gitmodules files.  That's OK: git.git doesn't
either.  Users can resolve the conflict themselves and then commit
the merge.

Previously, jgit would crash when attempting to merge conflicting
submodule changes.  Even if there was no conflict, after a merge which
adds submodules, the repository would have been missing empty
directories for newly-added submodules.

This patch fixes the crash, and adds the empty directories where
necessary. It ensures that the index is in a conflicted state when
submodule changes conflict.

Reported-by: Alexey Korobkov
Bug: 494551
Change-Id: I79db6798c2bdcc1159b5b2589b02da198dc906a1
Signed-off-by: David Turner <dturner@twosigma.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-02-04 15:33:24 +01:00
David Pursehouse 595f968b6d Add class to access WindowCache statistics
Change-Id: Iacb5b65539efd92a6b45afc307ebf246e8b8fccf
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-02-03 22:30:41 +01:00
Thomas Wolf f22a162c47 Use a TemporaryBuffer to do a content merge
This avoids having to re-read the merged file (twice even!) to
update the index.

Change-Id: Id13e0fd38906ed6f859604f86ca352761dca9ffe
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-02-02 10:50:12 +01:00
Thomas Wolf 9ac415aa95 Fix index blob for merges with CRLF translations
Commit fc7d407 corrected line endings for working tree files resulting
from merges when CRLF translations are to be done. However, that also
resulted in the file content being put as-is into the index, which is
wrong. The index must contain the file content with reverse CRLF
translations applied.

With core.autocrlf=true, the working tree file should have CR-LF, but
the index blob must still contain only LF.

Fix this oversight and apply the inverse translation when updating the
index, similar to what is done in AddCommand.

Bug: 499615
Change-Id: I3a33931318bdb580b2390f3450f91ea8f258a6a4
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-02-02 08:16:13 +01:00
Thomas Wolf fc7d407d0b Honor CRLF settings when writing merge results
Merges are performed using the raw text as stored in the git
repository. When we write the merge result, we must apply the
correct CRLF settings. Otherwise the line endings in the result
will be wrong.

Bug: 499615
Change-Id: I37a9b987e9404c97645d2720cd1c7c04c076a96b
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-02-02 00:45:32 +01:00
David Pursehouse 9ce7e8e767 Merge branch 'stable-4.9' into stable-4.10
* stable-4.9:
  Minor fixes in three error messages

Change-Id: Ibd6bcecb40a6d97c46c66360020dca7453876298
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-02-01 17:36:10 +09:00
Thomas Wolf 3d6455331d Minor fixes in three error messages
* Fix "can not" -> "cannot" in two messages
* Re-word "Cannot mkdir" to "Cannot create directory"

Change-Id: Ide0cec55eeeebd23bccc136257c80f47638ba858
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-01-31 14:29:49 +09:00
Thomas Wolf 6eb053734d Minor fixes in three error messages
* Fix "can not" -> "cannot" in two messages
* Re-word "Cannot mkdir" to "Cannot create directory"

Change-Id: Ide0cec55eeeebd23bccc136257c80f47638ba858
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-01-30 07:36:37 +01:00
Thomas Wolf e12c6b58ee Minor improvements in git config file inclusions
* Section and key names in git config files are case-insensitive.
* If an include directive is invalid, include the line in the
  exception message.
* If inclusion of the included file fails, put the file name into
  the exception message so that the user knows in which file the
  problem is.

Change-Id: If920943af7ff93f5321b3d315dfec5222091256c
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-01-28 16:13:04 +01:00
Markus Duft 1c43af8b97 Progress reporting for checkout
The reason for the change is LFS: when using a lot of LFS files,
checkout can take quite some time on larger repositories. To avoid
"hanging" UI, provide progress reporting.

Also implement (partial) progress reporting for cherry-pick, reset,
revert which are using checkout internally.

The feature is also useful without LFS, so it is independent of it.

Change-Id: I021e764241f3c107eaf2771f6b5785245b146b42
Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-01-23 00:48:00 +01:00
Dave Borowitz 14167272c2 Enforce DFS blockLimit is a multiple of blockSize
Change-Id: I2821124ff88d7d1812a846ed20f3828fc9123b38
2018-01-22 10:36:58 -05:00
David Pursehouse bd96feab24 Revert usage of TYPE_USE in Nullable and NonNull annotations
Using TYPE_USE causes compilation errors in Eclipse Neon.3 (JDT 3.12.3)
and Eclipse Oxygen.2 (JDT 3.13.2).

This reverts commit 8e217517e2.
This reverts commit 55eba8d0f5.

Reported-by: Thomas Wolf <thomas.wolf@paranor.ch>
Change-Id: I96869f80dd11ee238911706581b224bca4fb12cd
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-01-19 22:42:38 +09:00
David Pursehouse 8e217517e2 Nullable: Switch to TYPE_USE
Since JGit now requires Java 8, we can switch to TYPE_USE instead
of explicitly specifying the target type.

Some of the existing uses of Nullable need to be reworked slightly
as described in [1] to prevent the compilation error:

  scoping construct cannot be annotated with type-use annotation

[1] https://stackoverflow.com/a/21385939/381622

Change-Id: Idba48f67a09353b5237685996ce828c8ca398168
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-01-18 13:35:44 +09:00
David Pursehouse 55eba8d0f5 NonNull: Switch to TYPE_USE
Since JGit now requires Java 8, we can switch to TYPE_USE instead
of explicitly specifying the target type.

Change-Id: I373d47c3d92507459685789df1fad0933d5625ff
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-01-18 13:23:34 +09:00
David Pursehouse cd2489423d NonNull: Fix typo in javadoc
Change-Id: Ia8e6559047a12391223645e2768f46666f198f6d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-01-18 13:19:52 +09:00
David Pursehouse 94cf82dbc5 RevWalk: Annotate methods documented to return "Never null" as @NonNull
Change-Id: If1a1bed4b04dd48c9573fd3c4eacbf73de40622f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-01-18 10:45:07 +09:00
Zhen Chen 5452ac1dea Skip broken symbolic ref in DfsReftableDatabase
We skipped the broken symbolic reference in other implementation like
DfsRefDatabase, RefDirectory. The broken symbolic reference may cause
NPE when caller forget to have a null check against the object id before
calling parse it.

Change-Id: If5e07202e9ee329d0bd9488936d79c98143c7ad9
Signed-off-by: Zhen Chen <czhen@google.com>
2018-01-17 15:19:05 -08:00
Han-Wen Nienhuys f40ebed124 Make SideBandInputStream public
This mirrors SideBandOutputStream which is also public

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: Ic0983af663f0c4c85bf5486b195108c45cddc4c2
2018-01-17 11:20:09 +01:00
Matthias Sohn 28aa3be21b Merge branch 'stable-4.10'
* stable-4.10:
  Revert handling of ssh IdentityFile to pre-4.9 behavior
  Prepare 4.10.1-SNAPSHOT builds
  JGit v4.10.0.201712302008-r

Change-Id: I13797f064de919c257feb8e96da226d7b1faaf7a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-01-13 01:06:42 +01:00