]> source.dussan.org Git - jgit.git/log
jgit.git
6 years agoMerge "Break down DfsBlockCache stats by pack file extension."
Shawn Pearce [Tue, 28 Nov 2017 20:37:30 +0000 (15:37 -0500)]
Merge "Break down DfsBlockCache stats by pack file extension."

6 years agoRepoCommand: Skip RemoteReader when encountering a full SHA-1 67/112467/1
Jonathan Nieder [Tue, 28 Nov 2017 16:16:56 +0000 (08:16 -0800)]
RepoCommand: Skip RemoteReader when encountering a full SHA-1

There is no point in calling back to the RemoteReader to resolve a
40-digit hex SHA-1 to itself.  We already skip that call when not
ignoring remote failures; skip it when ignoring remote failures, too.

This should simplify RemoteReader implementations.

Reported-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I7566968ed1f39b1ad73574fa903faf3ee308eb87

6 years agoBreak down DfsBlockCache stats by pack file extension. 91/112391/2
Minh Thai [Mon, 27 Nov 2017 22:28:11 +0000 (14:28 -0800)]
Break down DfsBlockCache stats by pack file extension.

Change-Id: Iaecf0580279b33e3e2439784528cae7b69fb28bc
Signed-off-by: Minh Thai <mthai@google.com>
6 years agoUpgrade spotbugs-maven-plugin to 3.1.0-RC8 30/112230/2
David Pursehouse [Fri, 24 Nov 2017 01:12:36 +0000 (10:12 +0900)]
Upgrade spotbugs-maven-plugin to 3.1.0-RC8

Change-Id: I650d1a527063204aa9696fe99b4f59bfa7e5fb97
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoPerformance improvement on writing a large index 67/112067/4
Stephen Lawson [Wed, 22 Nov 2017 12:41:05 +0000 (12:41 +0000)]
Performance improvement on writing a large index

The index header consists of a 4-byte version number. The current
supported version numbers are 2 and 3. The code checks if any entries
are extended. If it finds any entries that are extended it picks version
'3', otherwise it chooses version '2'.

DirCache.java
-Changed the 'extended' check to exit early when any entry is considered
'extended' in the index.

(Of course, I maybe missing a bitwise optimization that is made in
the Java bytecode.)

Change-Id: If70db9454befe683319b974ebd3774060be9445d
Signed-off-by: Stephen Lawson <slawson@ptc.com>
6 years agoUpgrade maven-compiler-plugin to 3.7.0 40/112040/2
David Pursehouse [Wed, 22 Nov 2017 07:55:11 +0000 (16:55 +0900)]
Upgrade maven-compiler-plugin to 3.7.0

Change-Id: I9c4a591b809cee702b2d064d74c9809c023c78c8
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoFix discouraged access warnings in RefsUnreadableInMemoryRepository 28/112228/1
Matthias Sohn [Fri, 24 Nov 2017 00:23:07 +0000 (01:23 +0100)]
Fix discouraged access warnings in RefsUnreadableInMemoryRepository

Change-Id: I16e291f533625c80b1d39f7cbaf40efbdfcc2c3c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge branch 'stable-4.9' 27/112227/1
Matthias Sohn [Fri, 24 Nov 2017 00:18:13 +0000 (01:18 +0100)]
Merge branch 'stable-4.9'

* stable-4.9:
  Ignore warning for minor version change without API change
  Silence boxing warning
  Prepare 4.5.5-SNAPSHOT builds
  JGit v4.5.4.201711221230-r
  Fix LockFile semantics when running on NFS
  Honor trustFolderStats also when reading packed-refs
  Prepare 4.5.4-SNAPSHOT builds
  JGit v4.5.3.201708160445-r

Change-Id: Icc33d2e36f140e8714fce088379673a8834ae9de

6 years agoIgnore warning for minor version change without API change 26/112226/1
Matthias Sohn [Fri, 24 Nov 2017 00:12:14 +0000 (01:12 +0100)]
Ignore warning for minor version change without API change

- this is a new warning option in Eclipse 4.7 and higher
- we always change version of all bundles in a release to keep release
engineering simple

Change-Id: Ic7523d77b67b2802f1bab3bc70af250d712a034f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge branch 'stable-4.8' into stable-4.9 29/112129/2
Matthias Sohn [Wed, 22 Nov 2017 22:46:39 +0000 (23:46 +0100)]
Merge branch 'stable-4.8' into stable-4.9

* stable-4.8:
  Silence boxing warning
  Prepare 4.5.5-SNAPSHOT builds
  JGit v4.5.4.201711221230-r
  Fix LockFile semantics when running on NFS
  Honor trustFolderStats also when reading packed-refs
  Prepare 4.5.4-SNAPSHOT builds
  JGit v4.5.3.201708160445-r

Change-Id: I7cf2e48934195430b3945b6d74b092f93a3ccd36
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge branch 'stable-4.7' into stable-4.8 28/112128/2
Matthias Sohn [Wed, 22 Nov 2017 22:25:49 +0000 (23:25 +0100)]
Merge branch 'stable-4.7' into stable-4.8

* stable-4.7:
  Silence boxing warning
  Prepare 4.5.5-SNAPSHOT builds
  JGit v4.5.4.201711221230-r
  Fix LockFile semantics when running on NFS
  Honor trustFolderStats also when reading packed-refs
  Prepare 4.5.4-SNAPSHOT builds
  JGit v4.5.3.201708160445-r

Change-Id: Iaa99ec84594baf733c993c2d6768281ff14f545a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge branch 'stable-4.6' into stable-4.7 26/112126/1
Matthias Sohn [Wed, 22 Nov 2017 22:06:50 +0000 (23:06 +0100)]
Merge branch 'stable-4.6' into stable-4.7

* stable-4.6:
  Silence boxing warning
  Prepare 4.5.5-SNAPSHOT builds
  JGit v4.5.4.201711221230-r
  Fix LockFile semantics when running on NFS
  Honor trustFolderStats also when reading packed-refs
  Prepare 4.5.4-SNAPSHOT builds
  JGit v4.5.3.201708160445-r

Change-Id: I8f6bc09540727c6273d22775a9f9ca382a729c9b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoSilence boxing warning 17/112117/1
Matthias Sohn [Wed, 22 Nov 2017 20:34:37 +0000 (21:34 +0100)]
Silence boxing warning

Change-Id: I36c40eb91ce0c51f89b47911fa14beffcbc0a7cd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge branch 'stable-4.5' into stable-4.6 16/112116/1
Matthias Sohn [Wed, 22 Nov 2017 20:34:08 +0000 (21:34 +0100)]
Merge branch 'stable-4.5' into stable-4.6

* stable-4.5:
  Prepare 4.5.5-SNAPSHOT builds
  JGit v4.5.4.201711221230-r
  Fix LockFile semantics when running on NFS
  Honor trustFolderStats also when reading packed-refs
  Prepare 4.5.4-SNAPSHOT builds
  JGit v4.5.3.201708160445-r

Change-Id: Ie9c8e0d9172c8d53f075c284bf2a9677980d8dfb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoPrepare 4.5.5-SNAPSHOT builds 06/112106/1
Matthias Sohn [Wed, 22 Nov 2017 18:27:22 +0000 (19:27 +0100)]
Prepare 4.5.5-SNAPSHOT builds

Change-Id: I71f946f2875716670a2d74c21a8ab38a1f53a25c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoJGit v4.5.4.201711221230-r 96/112096/1 v4.5.4.201711221230-r
Matthias Sohn [Wed, 22 Nov 2017 17:31:24 +0000 (18:31 +0100)]
JGit v4.5.4.201711221230-r

Change-Id: Ia1079da239c5b3fde1ba8d2acc4e465a46297b4d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoFix LockFile semantics when running on NFS 16/112016/9
Christian Halstrick [Tue, 14 Nov 2017 16:08:56 +0000 (17:08 +0100)]
Fix LockFile semantics when running on NFS

When running on NFS there was a chance that JGits LockFile
semantic is broken because File#createNewFile() may allow
multiple clients to create the same file in parallel. This
change provides a fix which is only used when the new config
option core.supportsAtomicCreateNewFile is set to false. The
default for this option is true. This option can only be set in the
global or the system config file. The repository config file is not
taken into account in this case.

If the config option core.supportsAtomicCreateNewFile is true
then File#createNewFile() is trusted and the behaviour doesn't
change.

But if core.supportsAtomicCreateNewFile is set to false then after
successful creation of the lock file a hardlink to that lock file is
created and the attribute nlink of the lock file is checked to be 2. If
multiple clients manage to create the same lock file nlink would be
greater than 2 showing the error.

This expensive workaround is described in
 https://www.time-travellers.org/shane/papers/NFS_considered_harmful.html
section III.d) "Exclusive File Creation"

Change-Id: I3d2cc48d8eb280d5f7039eb94da37804f903be6a

6 years agoMerge branch 'stable-4.9' 29/112029/1
David Pursehouse [Wed, 22 Nov 2017 02:31:20 +0000 (11:31 +0900)]
Merge branch 'stable-4.9'

* stable-4.9:
  Yet another work-around for a Jsch bug: timeouts

Change-Id: I7cf227c62a3c06f91cee1a6c61719b6fe50da883
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoHonor trustFolderStats also when reading packed-refs 15/112015/1
Christian Halstrick [Tue, 14 Nov 2017 16:20:02 +0000 (17:20 +0100)]
Honor trustFolderStats also when reading packed-refs

Then list of packed refs was cached in RefDirectory based on mtime of
the packed-refs file. This may fail on NFS when attributes are cached.
A cached mtime of the packed-refs file could cause JGit to trust the
cached content of this file and to overlook that the file is modified.

Honor the config option trustFolderStats and always read the packed-refs
content if the option is false. By default this option is set to true
and this fix is not active.

Change-Id: I2b65cfaa8f4aba2efbf8a5e865d3f09f927e2eec

6 years agoYet another work-around for a Jsch bug: timeouts 21/111421/2
Thomas Wolf [Sat, 11 Nov 2017 10:41:10 +0000 (11:41 +0100)]
Yet another work-around for a Jsch bug: timeouts

Jsch 0.1.54 passes on the values from ~/.ssh/config for
"ServerAliveInterval" and "ConnectTimeout" as read from
the config file to java.net.Socket.setSoTimeout(). That
method expects milliseconds, but the values in the config
file are seconds!

The missing conversion in Jsch means that the timeout is
set way too low, and if the server doesn't respond within
that very short time frame, Jsch kills the connection and
then throws an exception with a message such as "session is
down" or "timeout in waiting for rekeying process".

As a work-around, do the conversion to milliseconds in the
Jsch-facing Config interface of OpenSshConfig. That way Jsch
already gets these values as milliseconds.

Bug: 526867
Change-Id: Ibc9b93f7722fffe10f3e770dfe7fdabfb3b97e74
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
6 years agoConfig: Handle leading/trailing single whitespaces 20/111920/1
Dave Borowitz [Mon, 20 Nov 2017 18:55:25 +0000 (13:55 -0500)]
Config: Handle leading/trailing single whitespaces

Change-Id: I468106acd2006d0a174c76dfd4bce231f1c7a6f8

6 years agoMerge branch 'stable-4.9' 72/111872/2
David Pursehouse [Mon, 20 Nov 2017 06:38:43 +0000 (15:38 +0900)]
Merge branch 'stable-4.9'

* stable-4.9:
  Fix NPE in TransportGitSsh.ExtSession.exec()
  Add missing help text for rev-parse's --verify option
  Remove final modifier on args4j argument field in RevParse

Change-Id: I5ac9e2f185f2210ee76970501710b99b12e93e75
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoFix NPE in TransportGitSsh.ExtSession.exec() 28/111828/3
Matthias Sohn [Fri, 17 Nov 2017 21:16:31 +0000 (22:16 +0100)]
Fix NPE in TransportGitSsh.ExtSession.exec()

Bug: 527383
Change-Id: I965860b4e0e9aa1adf6a1bb0735940cbd22adced
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoAdd missing help text for rev-parse's --verify option 54/111854/1
Matthias Sohn [Sat, 18 Nov 2017 23:38:05 +0000 (00:38 +0100)]
Add missing help text for rev-parse's --verify option

Change-Id: I3345f52e0c2a555e4c5edb7effe4be4af4cca10a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoRemove final modifier on args4j argument field in RevParse 53/111853/1
Rüdiger Herrmann [Sat, 18 Nov 2017 19:23:57 +0000 (20:23 +0100)]
Remove final modifier on args4j argument field in RevParse

Args4J does no longer allow to use final fields to reference
arguments or options [1]. Change RevParse to be compatibel with this
change.

[1] https://github.com/kohsuke/args4j/commit/6e11f89d40dcc518c0e5eb9eef5d74f05d58e6af

See-also: a0558b709448cea01cc0725fff73408d9b223c72
Signed-off-by: Rüdiger Herrmann <ruediger.herrmann@gmx.de>
Change-Id: I33b233f195c06855d9e094c8c9ba804fbe7b1438

6 years agoMerge changes from topic 'includeDeletes'
Shawn Pearce [Thu, 16 Nov 2017 15:45:57 +0000 (10:45 -0500)]
Merge changes from topic 'includeDeletes'

* changes:
  Add flag for keeping ref tombstones in GC reftable
  Preserve ref tombstone when compact top retable stack

6 years agoAdd flag for keeping ref tombstones in GC reftable 62/111662/7
Minh Thai [Thu, 16 Nov 2017 06:48:04 +0000 (22:48 -0800)]
Add flag for keeping ref tombstones in GC reftable

A tombstone will prevent a delayed reference update from resurrecting the
deleted reference.

Change-Id: Id9f4df43d435a299ff16cef614821439edef9b11
Signed-off-by: Minh Thai <mthai@google.com>
6 years agoPreserve ref tombstone when compact top retable stack 85/111685/1
Minh Thai [Thu, 16 Nov 2017 06:45:32 +0000 (22:45 -0800)]
Preserve ref tombstone when compact top retable stack

Change-Id: I07f5ad572b4642a7cdd76d92aa98f3b6c63d9fa2
Signed-off-by: Minh Thai <mthai@google.com>
6 years agoRemove unused import from ReftableCompactorTest 39/111639/1
Matthias Sohn [Wed, 15 Nov 2017 15:22:55 +0000 (16:22 +0100)]
Remove unused import from ReftableCompactorTest

Change-Id: Ib6d7fb6b56a94be307b07fefacf5d9c77fce0447
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoTreeWalk: Make getEolStreamType(OperationType) public 06/111206/5
David Pursehouse [Wed, 8 Nov 2017 11:20:45 +0000 (20:20 +0900)]
TreeWalk: Make getEolStreamType(OperationType) public

and deprecate getEolStreamType().

This resolves a TODO that was apparently supposed to be done in
version 4.4.

Change-Id: I5c9861aedabdc3f99dcf47519b3959a979e6a591

6 years agoTreeWalk: Fix indentation 05/111205/4
David Pursehouse [Wed, 8 Nov 2017 11:21:28 +0000 (20:21 +0900)]
TreeWalk: Fix indentation

Change-Id: I040aaaf4e3f1e3458e0ece52d1d046f501272fc2
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoMerge "ObjectDirectory: Add pack directory getter"
David Pursehouse [Wed, 15 Nov 2017 01:37:26 +0000 (20:37 -0500)]
Merge "ObjectDirectory: Add pack directory getter"

6 years agoMerge "Add return tag"
David Pursehouse [Wed, 15 Nov 2017 01:37:14 +0000 (20:37 -0500)]
Merge "Add return tag"

6 years agoMerge "ReftableCompactor should accept 0 for minUpdateIndex"
Jonathan Nieder [Tue, 14 Nov 2017 20:05:19 +0000 (15:05 -0500)]
Merge "ReftableCompactor should accept 0 for minUpdateIndex"

6 years agoReftableCompactor should accept 0 for minUpdateIndex 02/111502/5
Minh Thai [Tue, 14 Nov 2017 04:17:16 +0000 (20:17 -0800)]
ReftableCompactor should accept 0 for minUpdateIndex

Do not use 0 as the unset value for minUpdateIndex, as input reftables
may have minUpdateIndex starting at 0.

Change-Id: Ie040a6b73d4a5eba5521e51d0ee4580713c84a3e
Signed-off-by: Minh Thai <mthai@google.com>
6 years agoObjectDirectory: Add pack directory getter 74/111374/5
Hector Caballero [Sat, 4 Nov 2017 11:37:39 +0000 (07:37 -0400)]
ObjectDirectory: Add pack directory getter

So far, in order to get the pack directory it was necessary to resolve
it from the object directory. This resolution is already done when
creating the object directory, so simplify the call by just adding a
getter to the pack directory.

Change-Id: I69e783141dc6739024e8b3d5acc30843edd651a7
Signed-off-by: Hector Caballero <hector.caballero@ericsson.com>
6 years agoAdd return tag 48/111548/1
Hector Caballero [Tue, 14 Nov 2017 15:06:26 +0000 (10:06 -0500)]
Add return tag

Eclipse was complaining about the missing tag for the return type.

Change-Id: I43c7e823c3090b19dc8202c1e4d7968e1fa8e6bb
Signed-off-by: Hector Caballero <hector.caballero@ericsson.com>
6 years agoFileUtils.toPath to convert File to Path 93/110593/3
Marc Strapetz [Tue, 14 Nov 2017 09:02:07 +0000 (10:02 +0100)]
FileUtils.toPath to convert File to Path

When invoking File.toPath(), an (unchecked) InvalidPathException may be
thrown which should be converted to a checked IOException.

For now, we will replace File.toPath() by FileUtils.toPath() only for
code which can already handle IOExceptions.

Change-Id: I0f0c5fd2a11739e7a02071adae9a5550985d4df6
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
6 years agoSilence invalid @since 3.5 API warning on ResolveMerge#processEntry 95/111495/1
Matthias Sohn [Mon, 13 Nov 2017 21:41:57 +0000 (22:41 +0100)]
Silence invalid @since 3.5 API warning on ResolveMerge#processEntry

This method was removed in 4.9 and reintroduced in
I48ba4308dee73925fa32d6c2fd6b5fd89632c571 as deprecated in 4.9.1 in
order to help EMF Compare to avoid breakage.

Change-Id: Ia638517178313da42ae13ebcf88ad535d9a02723
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge changes I335587ee,I4182a174
David Pursehouse [Sat, 11 Nov 2017 03:05:50 +0000 (22:05 -0500)]
Merge changes I335587ee,I4182a174

* changes:
  Merge branch 'stable-4.9'
  Remove an unused import from PackParserTest

6 years agoAdd a setting for fsck to check connectivity only 17/111417/4
Zhen Chen [Sat, 11 Nov 2017 00:05:28 +0000 (16:05 -0800)]
Add a setting for fsck to check connectivity only

The object checks may take a long time and sometimes we are only
interested in connectivity check.

This is similar to 'git fsck --connectivity-only'.

Change-Id: I654e8fdccdb16d796f920088429d188cc96734bc
Signed-off-by: Zhen Chen <czhen@google.com>
6 years agoMerge branch 'stable-4.9' 01/111401/2
Matthias Sohn [Fri, 10 Nov 2017 18:01:14 +0000 (19:01 +0100)]
Merge branch 'stable-4.9'

* stable-4.9:
  Work around a Jsch bug: ensure the user name is set from URI
  Reintroduce protected method which removal broke EMF Compare

Change-Id: I335587eee279f91bd36c9ba9fc149b17a6db6110
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoRemove an unused import from PackParserTest 00/111400/2
Matthias Sohn [Fri, 10 Nov 2017 18:00:55 +0000 (19:00 +0100)]
Remove an unused import from PackParserTest

Change-Id: I4182a1746b09dedab648e457d1ece6d667a01f12
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge changes I22a8874b,I68ed4abd,I740bc4bf,Icbd17d15
Jonathan Nieder [Fri, 10 Nov 2017 23:52:53 +0000 (18:52 -0500)]
Merge changes I22a8874b,I68ed4abd,I740bc4bf,Icbd17d15

* changes:
  BitmapWalker: do not revisit objects in bitmap
  Use bitmaps for non-commit reachability checks
  Make PackWriterBitmapWalker public
  UploadPackTest: construct commits in test method

6 years agoBitmapWalker: do not revisit objects in bitmap 86/111086/8
Jonathan Tan [Thu, 2 Nov 2017 01:20:54 +0000 (18:20 -0700)]
BitmapWalker: do not revisit objects in bitmap

Currently, BitmapWalker walks through every object returned by the
internal ObjectWalk, regardless of whether that object has already
been marked in the bitmap. Set an object filter to ensure that only
bitmap-unmarked objects are walked through.

Change-Id: I22a8874b1e571df3c33643b365036d95f52fe7c7
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
6 years agoUse bitmaps for non-commit reachability checks 85/111085/8
Jonathan Tan [Thu, 2 Nov 2017 00:36:18 +0000 (17:36 -0700)]
Use bitmaps for non-commit reachability checks

Currently, unless RequestPolicy#ANY is used, UploadPack rejects all
non-commit "want" lines unless they were advertized. This is fine,
except when "uploadpack.allowreachablesha1inwant" is true
(corresponding to RequestPolicy#REACHABLE_COMMIT), in which case one
would expect that "want"-ing anything reachable would work.

(There is no restriction that "want" lines must only contain commits -
it is allowed for refs to directly point to trees and blobs, and
requesting for them using "want" lines works.)

This commit has been written to avoid performance regressions as much
as possible. In the usual (and currently working) case where the only
unadvertized things requested are commits, we do a standard RevWalk in
order to avoid incurring the cost of loading bitmaps. However, if
unadvertized non-commits are requested, bitmaps are used instead, and
if there are no bitmaps, a WantNotValidException is thrown (as is
currently done).

Change-Id: I68ed4abd0e477ff415c696c7544ccaa234df7f99
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
6 years agoMake PackWriterBitmapWalker public 84/111084/7
Jonathan Tan [Wed, 25 Oct 2017 21:09:17 +0000 (14:09 -0700)]
Make PackWriterBitmapWalker public

Make PackWriterBitmapWriter class public and move it to a more central
location, in preparation for its use by another class (in a subsequent
commit).

One of its inner static classes, AddUnseenToBitmapFilter, previously
package-private, is also used directly in its former package. Therefore,
AddUnseenToBitmapFilter and its sibling class have been moved to an
internal package instead.

Change-Id: I740bc4bfc4e4e3c857d1ee7d25fe45e90cd22a75
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
6 years agoWork around a Jsch bug: ensure the user name is set from URI 59/111359/1
Thomas Wolf [Tue, 7 Nov 2017 07:19:56 +0000 (08:19 +0100)]
Work around a Jsch bug: ensure the user name is set from URI

JSch unconditionally overrides the user name given in the connection
URI by the one found in ~/.ssh/config (if that does specify one for
the used host). If the SSH config file has a different user name,
we'll end up using the wrong name, which typically results in an
authentication failure or in Eclipse/EGit asking for a password for
the wrong user.

Unfortunately there is no way to prevent or circumvent this Jsch
behavior up front; it occurs already in the Session constructor at
com.jcraft.jsch.Session() and the Session.applyConfig() method. And
while there is a Session.setUserName() that would enable us to correct
this, that latter method has package visibility only.

So resort to reflection to invoke that setUserName() method to ensure
that Jsch uses the user name from the URI, if there is one.

Bug: 526778
Change-Id: Ia327099b5210a037380b2750a7fd76ff25c41a5a
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
6 years agoReject pack if delta exceeds array size limit 12/111312/3
Shawn Pearce [Thu, 9 Nov 2017 17:12:59 +0000 (09:12 -0800)]
Reject pack if delta exceeds array size limit

JGit's delta handling code requires the target to be a single byte
array. Any attempt to inflate a delta larger than fits in the 2GiB
limit will fail with some form of array index exceptions. Check for
this overflow early and abort pack parsing.

Change-Id: I5bb3a71f1e4f4e0e89b8a177c7019a74ee6194da

6 years agoCheck non-flushed packs for existence of object 76/111176/4
Zhen Chen [Tue, 7 Nov 2017 20:48:47 +0000 (12:48 -0800)]
Check non-flushed packs for existence of object

Change-Id: Id466909d70ec6f828c904692139891dec880305e
Signed-off-by: Zhen Chen <czhen@google.com>
6 years agoSuppress "Unlikely argument type for equals()" warnings in tests 61/106061/4
David Pursehouse [Sun, 1 Oct 2017 05:08:17 +0000 (06:08 +0100)]
Suppress "Unlikely argument type for equals()" warnings in tests

This new warning was introduced in Eclipse 4.7 Oxygen [1].

The only instances of the warning are in test code that is asserting
that some class does not compare equal to Strings. As in the Gerrit
project [2] these asserts are arguably overkill, but arguably also
a reasonable test of an equals implementation. Ignore the warning in
these cases.

Note that if the project is opened in an earlier version of Eclipse,
a warning "Unsupported @SuppressWarnings" will be emitted.

[1] https://www.eclipse.org/eclipse/news/4.7/M6/
[2] https://gerrit-review.googlesource.com/#/c/gerrit/+/110339/

Change-Id: I08ea33d71e6009cf0f37e6492a475931f447256b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoUpdate spotbugs-maven-plugin to 3.1.0-RC7 48/110948/2
Matthias Sohn [Thu, 2 Nov 2017 21:48:00 +0000 (22:48 +0100)]
Update spotbugs-maven-plugin to 3.1.0-RC7

Change-Id: Ic1c2c5b6e3955a1404780e51206513d226600e4b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge "Reintroduce protected method which removal broke EMF Compare" into stable-4.9
Matthias Sohn [Thu, 2 Nov 2017 16:59:11 +0000 (12:59 -0400)]
Merge "Reintroduce protected method which removal broke EMF Compare" into stable-4.9

6 years agoUploadPackTest: construct commits in test method 83/111083/1
Jonathan Tan [Wed, 1 Nov 2017 23:23:32 +0000 (16:23 -0700)]
UploadPackTest: construct commits in test method

In a subsequent commit, more tests will be added. This commit allows
those tests to reuse fields.

Change-Id: Icbd17d158cfe3ba4dacbd8a11a67f9e7607b41b3
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
6 years agoMerge branch 'stable-4.9' 90/110890/1
David Pursehouse [Wed, 1 Nov 2017 23:29:56 +0000 (08:29 +0900)]
Merge branch 'stable-4.9'

* stable-4.9:
  PackInserter: Implement newReader()
  Move some strings from DfsText to JGitText
  FileRepository: Add pack-based inserter implementation
  ObjectDirectory: Factor a method to close open pack handles
  ObjectDirectory: Remove last modified check in insertPack

Change-Id: Ifc9ed6f5d8336bc978818a64eae122bceb933e5d

6 years agoPackInserter: Implement newReader() 66/110866/3
Dave Borowitz [Wed, 1 Nov 2017 15:46:48 +0000 (11:46 -0400)]
PackInserter: Implement newReader()

Change-Id: Ib9e7f6439332eaed3d936f895a5271a7d514d3e9

6 years agoMove some strings from DfsText to JGitText 65/110865/2
Dave Borowitz [Wed, 1 Nov 2017 15:45:22 +0000 (11:45 -0400)]
Move some strings from DfsText to JGitText

Change-Id: I60050e5127d12b6139d81859dba929fcfaabe504

6 years agoFileRepository: Add pack-based inserter implementation 64/110864/2
Dave Borowitz [Tue, 31 Oct 2017 14:05:29 +0000 (10:05 -0400)]
FileRepository: Add pack-based inserter implementation

Applications that use ObjectInserters to create lots of individual
objects may prefer to avoid cluttering up the object directory with
loose objects. Add a specialized inserter implementation that produces a
single pack file no matter how many objects. This inserter is loosely
based on the existing DfsInserter implementation, but is simpler since
we don't need to buffer blocks in memory before writing to storage.

An alternative for such applications would be to write out the loose
objects and then repack just those objects later. This operation is not
currently supported with the GC class, which always repacks existing
packs when compacting loose objects. This in turn requires more
CPU-intensive reachability checks and extra I/O to copy objects from old
packs to new packs.

So, the choice was between implementing a new variant of repack, or not
writing loose objects in the first place. The latter approach is likely
less code overall, and avoids unnecessary I/O at runtime.

The current implementation does not yet support newReader() for reading
back objects.

Change-Id: I2074418f4e65853b7113de5eaced3a6b037d1a17

6 years agoObjectDirectory: Factor a method to close open pack handles 63/110863/2
Dave Borowitz [Wed, 1 Nov 2017 14:42:46 +0000 (10:42 -0400)]
ObjectDirectory: Factor a method to close open pack handles

Change-Id: I9490c4583fdf801de9c0bb09595ebb8fb4926988

6 years agoObjectDirectory: Remove last modified check in insertPack 62/110862/1
Dave Borowitz [Wed, 1 Nov 2017 14:19:38 +0000 (10:19 -0400)]
ObjectDirectory: Remove last modified check in insertPack

GC explicitly handles the case where a new pack has the same name as an
existing pack due to it containing the exact same set of objects. In
this case, the pack passed to insertPack will have the same name as an
existing pack, but it will also almost certainly have a later mtime than
the existing pack.

The loop in insertPack tried to short-circuit when inserting a new pack,
to avoid walking more of the pack list than necessary. Unfortunately,
this means it will never get to the check for an identical name,
resulting in a duplicate entry for the same PackFile in the pack list.
Remove the short-circuit so that insertPack does not insert a duplicate
entry.

Change-Id: I00711b28594622ad3bd104332334e8a3592cda7f

6 years agoUpgrade error_prone_core to 2.1.2 23/110623/2
David Pursehouse [Thu, 26 Oct 2017 05:30:45 +0000 (14:30 +0900)]
Upgrade error_prone_core to 2.1.2

Change-Id: I2e6ea106ed5e6568eaf421ce5794bfe446c6cadb
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoMove loggers to the top of their class 74/110674/2
Saša Živkov [Fri, 27 Oct 2017 10:29:52 +0000 (12:29 +0200)]
Move loggers to the top of their class

There is a possibility of hitting NPE on a logger if it is not the first
statically initialized member. For example, if another static
initializer creates an instance of its class and the logger is used
from the constructor.

Change-Id: I51fa855a8883c107f2e4ef5ac039dc12a571a7ae

6 years agoMerge "Align PackStatistics and DfsPackDescription list length"
Terry Parker [Thu, 26 Oct 2017 22:22:49 +0000 (18:22 -0400)]
Merge "Align PackStatistics and DfsPackDescription list length"

6 years agoUpdate .mailmap 86/110586/1
David Pursehouse [Wed, 25 Oct 2017 01:56:00 +0000 (10:56 +0900)]
Update .mailmap

Before:

$ git shortlog -n -s | grep Han
    14    Han-Wen Nienhuys
     1    Han-Wen NIenhuys

After:

$ git shortlog -n -s | grep Han
    15    Han-Wen Nienhuys

Change-Id: I2874713f120f09bcbd33a1c48645e25fb5bf9259
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoReintroduce protected method which removal broke EMF Compare 79/110579/1
Matthias Sohn [Tue, 24 Oct 2017 21:13:37 +0000 (23:13 +0200)]
Reintroduce protected method which removal broke EMF Compare

So far we follow OSGi semantic versioning [1] which says the following:

"A change in the second (minor) part of the version signals that the
change is backward compatible with consumers of the API package but not
with the providers of that API. That is, when the API package goes from
version 1.5 to 1.6 it is no longer compatible with a provider of that
API but consumers of that API are backward compatible with that API
package."

The change Ib5fbf17bdaf727bc5d0e106ce88f2620d9f87a6f broke EMF Compare
which subclasses ResolveMerger since we added a new parameter to the
protected ResolveMerger.processEntry() method. According to the above
cited OSGi semantic versioning this is ok, implementers should expect
that they break on minor version changes of the API they implement.

This change reintroduces the old processEntry() method in order to help
avoid breakage for existing EMF Compare versions which expect breakage
also for the implementer case only for major version change (in this
case from JGit 4.x to 5.x).

[1] http://www.osgi.org/wp-content/uploads/SemanticVersioning1.pdf

See: https://dev.eclipse.org/mhonarc/lists/jgit-dev/msg03431.html
Change-Id: I48ba4308dee73925fa32d6c2fd6b5fd89632c571
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoRevert "Throw BinaryBlobException from RawParseUtils#lineMap." 67/110567/2
Han-Wen NIenhuys [Tue, 24 Oct 2017 15:25:50 +0000 (11:25 -0400)]
Revert "Throw BinaryBlobException from RawParseUtils#lineMap."

This reverts commit f2e64cd895a6aa4f18ab3b876f13b7814fb98f04.

The newly added throws clause breaks backward compatibility.

Change-Id: Ifa76a1b95935e52640b81cd53c171eb17da175c2
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
6 years agoFix typo in comment 57/110557/2
Han-Wen Nienhuys [Tue, 24 Oct 2017 13:13:10 +0000 (15:13 +0200)]
Fix typo in comment

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I04912b32b55dd61ad2d2e7ccb5d688655b1dc335

6 years agoThrow BinaryBlobException from RawParseUtils#lineMap. 09/110209/7
Han-Wen Nienhuys [Tue, 17 Oct 2017 13:17:34 +0000 (15:17 +0200)]
Throw BinaryBlobException from RawParseUtils#lineMap.

This makes detection of binaries exact for ResolveMerger and
DiffFormatter: they will classify files as binary regardless of where
the '\0' occurs in the text.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: Id4342a199628d9406bfa04af1b023c27a47d4014

6 years agoAvoid loading and merging binary data in ResolveMerger 19/106519/14
Han-Wen Nienhuys [Tue, 10 Oct 2017 14:40:12 +0000 (16:40 +0200)]
Avoid loading and merging binary data in ResolveMerger

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: Ide4b68872d426aa262142f224acf636c776b35d3

6 years agoIntroduce ObjectLoader.Filter for delegation 12/110512/2
Han-Wen Nienhuys [Mon, 23 Oct 2017 12:41:00 +0000 (14:41 +0200)]
Introduce ObjectLoader.Filter for delegation

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I78ada3f4023c4304b19f94fb044024f0f0b2cbbe

6 years agoIntroduce RawText#load. 16/106516/12
Han-Wen Nienhuys [Mon, 9 Oct 2017 16:11:04 +0000 (18:11 +0200)]
Introduce RawText#load.

This method creates a RawText from a blob, but avoids reading the blob
if the start contains null bytes. This should reduce the amount of
garbage that Gerrit produces for changes with binaries.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: Idd202d20251f2d1653e5f1ca374fe644c2cf205f

6 years agoAdd missing @since tags for new API in ReceiveCommand 10/110510/1
Matthias Sohn [Mon, 23 Oct 2017 12:22:28 +0000 (14:22 +0200)]
Add missing @since tags for new API in ReceiveCommand

Change-Id: I6e5d29390b71a1c123bc90ec2e3435706ea9211c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoMerge branch 'stable-4.9' 96/110496/1
David Pursehouse [Mon, 23 Oct 2017 03:08:54 +0000 (12:08 +0900)]
Merge branch 'stable-4.9'

* stable-4.9:
  Avoid bad rounding "1 year, 12 months" in date formatter
  Ensure that ~ in ssh config is replaced before Jsch sees it

Change-Id: If6ca55f9447aaea3d7c2d36c03520d5e6dd5193e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 years agoAvoid bad rounding "1 year, 12 months" in date formatter 95/110495/1
Michael Keppler [Thu, 12 Oct 2017 07:38:31 +0000 (09:38 +0200)]
Avoid bad rounding "1 year, 12 months" in date formatter

Round first, then calculate the labels. This avoids "x years, 12 months"
and instead produces "x+1 years".

One test case has been added for the original example the bug was found
with, and one assertion has been moved from an existing test case to the
new test case, since it also triggered the bug.

Bug: 525907
Change-Id: I3270af3850c4fb7bae9123a0a6582f93055c9780
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 years agoAlign PackStatistics and DfsPackDescription list length 73/110473/1
Masaya Suzuki [Fri, 20 Oct 2017 19:18:16 +0000 (12:18 -0700)]
Align PackStatistics and DfsPackDescription list length

Without this the caller cannot tell which PackStatistics is for which
pack file.

Change-Id: Ifa530f8bc82459611ae694c0a0d111daec3e08f3
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
7 years agodfs: Switch InMemoryRepository to DfsReftableDatabase 05/103205/16
Shawn Pearce [Sat, 12 Aug 2017 21:31:16 +0000 (14:31 -0700)]
dfs: Switch InMemoryRepository to DfsReftableDatabase

This ensure DfsReftableDatabase is tested by the same test suites that
use/test InMemoryRepository. It also simplifies the logic of
InMemoryRepository and brings its compatibility story closer to any
other DFS repository that uses reftables for its reference storage.

Change-Id: I881469fd77ed11a9239b477633510b8c482a19ca
Signed-off-by: Minh Thai <mthai@google.com>
Signed-off-by: Terry Parker <tparker@google.com>
7 years agoMerge changes from topic 'reftable'
Terry Parker [Thu, 19 Oct 2017 00:25:08 +0000 (20:25 -0400)]
Merge changes from topic 'reftable'

* changes:
  dfs: reftable backed DfsRefDatabase
  Support symbolic references in ReceiveCommand

7 years agodfs: reftable backed DfsRefDatabase 04/103204/16
Shawn Pearce [Sat, 12 Aug 2017 19:19:30 +0000 (12:19 -0700)]
dfs: reftable backed DfsRefDatabase

DfsReftableDatabase is a new alternative for DfsRefDatabase that
handles more operations for the implementor by delegating through
reftables. All reftable files are stored in sibling DfsObjDatabase
using PackExt.REFTABLE and PackSource.INSERT.

Its assumed the DfsObjDatabase periodically runs compactions and GCs
using DfsPackCompactor and DfsGarbageCollector. Those passes are
essential to collapsing the stack of reftables.

Change-Id: Ia03196ff6fd9ae2d0623c3747cfa84357c6d0c79
Signed-off-by: Minh Thai <mthai@google.com>
Signed-off-by: Terry Parker <tparker@google.com>
7 years agoEnsure that ~ in ssh config is replaced before Jsch sees it 45/110345/1
Thomas Wolf [Wed, 18 Oct 2017 20:45:36 +0000 (22:45 +0200)]
Ensure that ~ in ssh config is replaced before Jsch sees it

Do tilde replacement for values from the ssh config file that are
file names in all cases to make sure that they are already replaced
when Jsch tries to get the values.

Previously, OpenSshConfig did tilde replacement only for the
IdentityFile in the JGit-facing "Host" interface and left the
replacement in the Jsch-facing "Config" interface to Jsch.

But on Windows the JGit notion of what should be used to replace the
tilde differs from Jsch's replacement. Jsch always replaces the tilde
by the value of the system property "user.home", whereas JGit also
considers some environment variables like %HOME%. This can lead to
rather surprising failures as in the case of bug 526175 where
%HOME% != user.home.

Prior to commit 9d24470 (i.e.,prior to JGit 4.9.0) this problem never
occurred because Jsch was completely unaware of the ssh config file
and all host and IdentityFile handling happened exclusively in JGit.

Bug: 526175
Change-Id: I1511699664ffea07cb58ed751cfdb79b15e3a99e
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoSupport symbolic references in ReceiveCommand 17/103017/13
Shawn Pearce [Sat, 12 Aug 2017 15:25:16 +0000 (08:25 -0700)]
Support symbolic references in ReceiveCommand

Allow creating symbolic references with link, and deleting them or
switching to ObjectId with unlink.  How this happens is up to the
individual RefDatabase.

The default implementation detaches RefUpdate if a symbolic reference
is involved, supporting these command instances on RefDirectory.
Unfortunately the packed-refs file does not support storing symrefs,
so atomic transactions involving more than one symref command are
failed early.

Updating InMemoryRepository is deferred until reftable lands, as I
plan to switch InMemoryRepository to use reftable for its internal
storage representation.

Change-Id: Ibcae068b17a2fc6d958f767f402a570ad88d9151
Signed-off-by: Minh Thai <mthai@google.com>
Signed-off-by: Terry Parker <tparker@google.com>
7 years agoAvoid bad rounding "1 year, 12 months" in date formatter 95/109895/3
Michael Keppler [Thu, 12 Oct 2017 07:38:31 +0000 (09:38 +0200)]
Avoid bad rounding "1 year, 12 months" in date formatter

Round first, then calculate the labels. This avoids "x years, 12 months"
and instead produces "x+1 years".

One test case has been added for the original example the bug was found
with, and one assertion has been moved from an existing test case to the
new test case, since it also triggered the bug.

Bug: 525907
Change-Id: I3270af3850c4fb7bae9123a0a6582f93055c9780
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoMerge branch 'stable-4.9' 32/106432/2
David Pursehouse [Sat, 14 Oct 2017 07:31:52 +0000 (16:31 +0900)]
Merge branch 'stable-4.9'

* stable-4.9:
  Prepare 4.9.1-SNAPSHOT builds
  JGit v4.9.0.201710071750-r

Change-Id: Iac83a1d999ad66774d10de984a5b6dc581d43d0f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoSkip unreachable garbage packs in dfs fsck 78/106478/1
Zhen Chen [Mon, 9 Oct 2017 17:53:58 +0000 (10:53 -0700)]
Skip unreachable garbage packs in dfs fsck

Change-Id: I8899e0faf1e4e6386dfd57340dfa4f4fdebc3cf3
Signed-off-by: Zhen Chen <czhen@google.com>
7 years agoPrepare 4.10.0-SNAPSHOT builds 19/106419/1
Matthias Sohn [Sun, 8 Oct 2017 09:35:54 +0000 (11:35 +0200)]
Prepare 4.10.0-SNAPSHOT builds

Change-Id: I5ca462d1db18a2c5c9382cfb9c83972510fa2b88
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoPrepare 4.9.1-SNAPSHOT builds 16/106416/1
Matthias Sohn [Sun, 8 Oct 2017 09:25:06 +0000 (11:25 +0200)]
Prepare 4.9.1-SNAPSHOT builds

Change-Id: Ic49fd093d3fe4324c4d83aba74033040fcaa37a6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoJGit v4.9.0.201710071750-r 11/106411/1 v4.9.0.201710071750-r
Matthias Sohn [Sat, 7 Oct 2017 21:46:52 +0000 (23:46 +0200)]
JGit v4.9.0.201710071750-r

Change-Id: I487f6aa3d0c4ef1d57f91cdc36177d994ae24c51
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoTerminate StreamCopy threads in case of errors 85/106185/5
Till Brychcy [Wed, 4 Oct 2017 08:40:23 +0000 (10:40 +0200)]
Terminate StreamCopy threads in case of errors

- fix NPE: don't invoke close() if no exception happened.

Bug: 513554
Change-Id: I29f9b2ac1607ee26521e8aba334facd20e4ad79c
Signed-off-by: Till Brychcy <register.eclipse@brychcy.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoUse a new RevWalk for validating not advertised wants 46/106246/10
Zhen Chen [Wed, 4 Oct 2017 21:02:24 +0000 (14:02 -0700)]
Use a new RevWalk for validating not advertised wants

Shadow commits in the RevWalk in the UploadPack object may cause the
UNINTERESTING flag not being carried over to their parents commits since
they were marked NO_PARENTS during the assumeShallow or
initializeShallowCommits call.

A new RevWalk needs to be created for this reason, but instead of
creating a new RevWalk from Repository, we can reuse the ObjectReader in
the RevWalk of UploadPack to load objects.

Change-Id: Ic3fee0512d35b4f555c60e696a880f8b192e4439
Signed-off-by: Zhen Chen <czhen@google.com>
7 years agoAdd photon target platform jgit-4.8.target 57/106057/3
Matthias Sohn [Sat, 30 Sep 2017 23:17:11 +0000 (01:17 +0200)]
Add photon target platform jgit-4.8.target

Change-Id: I87f52f512db4c89fa4e3e550ff97fdec843b8469
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
7 years agoCheckout now reports failures through exceptions. 92/105592/3
Ned Twigg [Fri, 18 Mar 2016 09:37:58 +0000 (02:37 -0700)]
Checkout now reports failures through exceptions.

Checkout sometimes throws an exception, and
other times it writes an error message to outw
and returns normally, even though the command
failed.  This commit now reports all failures
through a die() exception.

Change-Id: I038a5d976d95020fea3faac68e9178f923c25b28
Signed-off-by: Ned Twigg <ned.twigg@diffplug.com>
7 years agoTerminate StreamCopy threads in case of errors 03/92903/4
Dmitry Neverov [Mon, 13 Mar 2017 11:05:44 +0000 (12:05 +0100)]
Terminate StreamCopy threads in case of errors

Bug: 513554
Change-Id: I065836b8fc77ade6de92e4a809fcf770a4f793ec
Signed-off-by: Dmitry Neverov <dmitry.neverov@gmail.com>
7 years agoReflogWriter: Align auto-creation defaults with C git 97/102397/5
Dave Borowitz [Wed, 2 Aug 2017 14:39:27 +0000 (10:39 -0400)]
ReflogWriter: Align auto-creation defaults with C git

Per git-config(1), core.logAllRefUpdates auto-creates reflogs for HEAD
and for refs under heads, notes, tags, and for HEAD. Add notes and
remove stash from ReflogWriter#shouldAutoCreateLog. Explicitly force
writing reflogs for refs/stash at call sites, now that this is
supported.

Change-Id: I3a46d2c2703b7c243e0ee2bbf6948279800c485c

7 years agoSupport force writing reflog on a per-update basis 96/102396/5
Dave Borowitz [Tue, 1 Aug 2017 12:53:33 +0000 (08:53 -0400)]
Support force writing reflog on a per-update basis

Even if a repository has core.logAllRefUpdates=true, ReflogWriter does
not create reflog files unless the refs are under a hard-coded list of
prefixes, or unless the forceWrite bit is set. Expose the forceWrite bit
on a per-update basis in RefUpdate/BatchRefUpdate/ReceiveCommand,
creating RefLogWriters as necessary.

Change-Id: Ifc851fba00f76bf56d4134f821d0576b37810f80

7 years agoEnsure ReflogWriter only works with a RefDirectory 95/102395/5
Dave Borowitz [Tue, 1 Aug 2017 13:43:22 +0000 (09:43 -0400)]
Ensure ReflogWriter only works with a RefDirectory

The ReflogWriter constructor just took a Repository and called
getDirectory() on it to figure out the reflog dirs, but not all
Repository instances use this storage format for reflogs, so it's
incorrect to attempt to use ReflogWriter when there is not a
RefDirectory directly involved. In practice, ReflogWriter was mostly
only used by the implementation of RefDirectory, so enforcing this is
mostly just shuffling around calls in the same internal package.

The one exception is StashDropCommand, which writes to a reflog lock
file directly. This was a reasonable implementation decision, because
there is no general reflog interface in JGit beyond using
(Batch)RefUpdate to write new entries to the reflog. So to implement
"git stash drop <N>", which removes an arbitrary element from the
reflog, it's fair to fall back to the RefDirectory implementation.
Creating and using a more general interface is well beyond the scope of
this change.

That said, the old behavior of writing out the reflog file even if
that's not the reflog format used by the given Repository is clearly
wrong. Fail fast in this case instead.

Change-Id: I9bd4b047bc3e28a5607fd346ec2400dde9151730

7 years agoChangeIdUtilTest: Remove unused notestCommitDashV 49/106049/2
David Pursehouse [Sat, 30 Sep 2017 09:56:42 +0000 (10:56 +0100)]
ChangeIdUtilTest: Remove unused notestCommitDashV

This test was never being run. Since it was introduced it was
named "notest.." which meant it didn't run with JUnit3, and
since it is not annotated @Test it also doesn't run with JUnit4.

When compiling with Bazel 0.6.0, error-prone raises an error
that the public method is not annotated with @Ignore or @Test.

Given that the test has never been run anyway, we can just
remove it.

Bug: 525415
Change-Id: Ie9a54f89fe42e0c201f547ff54ff1d419ce37864
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoAdd the args4j jar 45/106045/2
Pepper Lebeck-Jobe [Sat, 30 Sep 2017 06:22:31 +0000 (08:22 +0200)]
Add the args4j jar

This allows the tests to all be built and run by bazel.

Bug: 525412
Change-Id: Ie9281d07462cd07200fadb4b0e7b7f88c44f7865
Signed-off-by: Pepper Lebeck-Jobe <eljobe@gmail.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
7 years agoHttpConfig: load user config before reading values from it 10/105810/1
Thomas Wolf [Tue, 26 Sep 2017 21:54:45 +0000 (23:54 +0200)]
HttpConfig: load user config before reading values from it

Same problem as in commit c227268: openUserConfig() just creates the
FileBasedConfig object, but doesn't read the file yet. An explicit
load() is needed.

As HttpConfig is read-only this omission did not cause any bad effects,
but it simply ignored values from the user config. Most uses of
HttpConfig go through the two-argument constructor, though, where
HttpConfig is given an already loaded repo config.

Change-Id: Ibe7c562c17d6ef37de8b661ab7f6fa0246db01a2
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoLoad the user config before modifying it 52/105652/1
Thomas Wolf [Sat, 23 Sep 2017 09:15:27 +0000 (11:15 +0200)]
Load the user config before modifying it

SystemReader.openUserConfig() does not load the config yet; an
explicit StoredConfig.load() is needed.

Bug: 374703
Change-Id: I1c397e2fb1a07ac4d9de3675d996417734ff90e9
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
7 years agoAdded API to TextBuiltin for piped usage. 50/104050/4
Ned Twigg [Fri, 18 Mar 2016 07:11:04 +0000 (00:11 -0700)]
Added API to TextBuiltin for piped usage.

Added a public method to TextBuiltin which makes it possible for
clients to initialize all of its state, including output and error
streams.  This gives clients the ability to customize the way in
which a command is run.

Change-Id: If718236964d2c5cf869e120c74f1a12965f4812e
Signed-off-by: Ned Twigg <ned.twigg@diffplug.com>
7 years agoSubmoduleUpdateCommand: Add fetch callback 69/105169/2
David Pursehouse [Fri, 15 Sep 2017 03:44:10 +0000 (12:44 +0900)]
SubmoduleUpdateCommand: Add fetch callback

When the submodule already exists, it is fetched instead of
cloned.

Use the fetch callback instead of clone callback in this case.

Change-Id: I170c21ab92b4117f25fdf940fe6807f214b04d39
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>