]> source.dussan.org Git - jgit.git/log
jgit.git
2 years agoAdd GetRefsBenchmark for testing refs lookups 83/185683/17
Luca Milanesio [Tue, 21 Sep 2021 23:38:24 +0000 (00:38 +0100)]
Add GetRefsBenchmark for testing refs lookups

Introduce a new benchmark that shows a typical use-case
of opening a cached repository and fetching one ref from
a repository with a high number of refs.

This specific benchmark is tailored to the Gerrit use-case
of reading frequently individual refs SHA1s and by ref-name
prefix from the All-Users repository.

Include the following variables for the benchmark:
- numBranches (from 100 up to 50000)
- trustFolderStat (true or false)
- useRefTable (true or false)

The benchmark needs to be evaluated on a local high-perf SSD
and on a slower NFS network disk.

Bug: 576165
Change-Id: Ie59a87ca9f0191ff30229688e3430332e2f59a4f

2 years ago[pgm tests] Relax version constraints for hamcrest 01/192201/2
Matthias Sohn [Wed, 16 Mar 2022 15:32:06 +0000 (16:32 +0100)]
[pgm tests] Relax version constraints for hamcrest

We updated hamcrest to 2.2. but there is no need to prevent that
older versions of hamcrest can be used. Hence relax the lower bound
to 1.1 like in other bundles.

Change-Id: I3f2f270d2aabc7d742a585d2fc7f0bce283e2a64

2 years agoUse git config core.commentChar 64/192064/2
Thomas Wolf [Sun, 23 Jan 2022 14:43:24 +0000 (15:43 +0100)]
Use git config core.commentChar

This concerns committing, creating merge conflict messages and creating
and editing squash messages. In a squash message, once the comment
character has been determined initially is always the first character.
Note that if core.commentChar=auto and there is a sequence of squashes,
it may be necessary to change the comment character when a new message
is added.

Bug: 579325
Change-Id: Idca19284a0240cd322e7512ea299a03658e1b2c1
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoCommitConfig: add support for core.commentChar 63/192063/2
Thomas Wolf [Sat, 22 Jan 2022 16:00:32 +0000 (17:00 +0100)]
CommitConfig: add support for core.commentChar

Provide  access to the core.commentChar git config, and provide a
utility method to determine an unused comment character if the setting
is "auto".

Bug: 579325
Change-Id: I1ec7e4deffea6ac5929a8538a624d73bb59e4ecc
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years ago[push, lfs] Tell the pre-push hook whether the push is a dry run 30/191930/3
Thomas Wolf [Sun, 20 Feb 2022 23:20:52 +0000 (00:20 +0100)]
[push, lfs] Tell the pre-push hook whether the push is a dry run

This is a feature that does not exist in C git: an external pre-push
hook doesn't know whether the push is run as a dry run. But for
internal hooks written in Java it is entirely possible to give a hook
this information.

In JGit with its internal LFS implementation, this enables us to not
perform LFS uploads in a dry run. This is kind of important because
EGit frequently does a dry-run before doing the actual push to give the
user a way to review what would be pushed before it actually happens.

Doing an LFS upload of potentially huge files during a dry-run is
wasteful, makes the dry run not actually a dry run, and leads to
uploading the same file twice if followed by a real push.

Use the information in the LfsPrePushHook to only do the initial call
to the LFS server, but then skipping the actual upload if the push is
a dry run. That way, a failure to contact the LFS server leads to an
error in the dry run, as it should.

Bug: 546567
Change-Id: I155430f27c4979d91096ba72fd95c3775dd3f28b
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoMerge changes I5df54a92,Iecc61d1c
Matthias Sohn [Tue, 22 Mar 2022 16:15:33 +0000 (12:15 -0400)]
Merge changes I5df54a92,Iecc61d1c

* changes:
  LsRemoteCommand: apply url.*.insteadOf
  Factor out URL replacement from RemoteConfig

2 years agoLFS: clean up messages 31/191931/2
Thomas Wolf [Tue, 15 Mar 2022 21:29:05 +0000 (22:29 +0100)]
LFS: clean up messages

Remove an unused message, and remove unnecessary quotes.

Change-Id: I9da3eeb3db33324fa07bebd434bca3c0a4da27ab
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoDirCacheCheckout: use a LinkedHashMap instead of HashMap 32/191932/2
Thomas Wolf [Tue, 15 Mar 2022 21:48:48 +0000 (22:48 +0100)]
DirCacheCheckout: use a LinkedHashMap instead of HashMap

This guarantees that updates are checked out in git order, which
is important for LFS if a .lfsconfig file is used. That file comes
early in git order, and the LFS smudge filter will consider the
working tree version. To ensure that on branch switches the correct
version of that file is used, the checkout order must be stable and
should be the git order.

Change-Id: I20f6d11bf08558f9d5adfd2be71e36321460038c
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoRe-try reading a file when there are concurrent writes 24/191924/4
Thomas Wolf [Tue, 15 Mar 2022 18:12:46 +0000 (19:12 +0100)]
Re-try reading a file when there are concurrent writes

Git and JGit are very careful to replace git files atomically when
writing. The normal mechanism for this is to write to a temporary
file and then to rename it atomically to the final destination. This
works fine on POSIX-compliant systems, but on systems where renaming
may not be atomic, exceptions may be thrown if code tries to read
the file while the rename is still ongoing. This happens in particular
on Windows, where the typical symptom is that a FileNotFoundException
with message "The process cannot access the file because it is being
used by another process" is thrown, but file.isFile() == true at the
same time.

In FileBasedConfig, a re-try was already implemented for this case.
But the same problem can also occur in other places, for instance
in RefDirectory when reading loose or packed refs. Additionally,
JGit has similar re-tries when a stale NFS file handle is detected,
but that mechanism wasn't used consistently (only for git configs
and packed refs, but not for loose refs).

Factor out the general re-try mechanism for reading into a new method
FileUtils.readWithRetry() and use that in all three places. The
re-try parameters are hardcoded: at most 5 times for stale NFS handles,
and at most 5 times with increasing backoff delays (50, 100, 200, 400,
and 800ms) for the above concurrent write case.

Bug: 579116
Change-Id: If0c2ad367446d3c0f32b509274cf8e814aca12cf
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years ago[sideband] Ensure last bit of progress channel is written 27/191927/3
Thomas Wolf [Sat, 26 Feb 2022 11:46:50 +0000 (12:46 +0100)]
[sideband] Ensure last bit of progress channel is written

If the last sideband progress message didn't end in \r or \n, there
may still be a buffered message at the end of a fetch or push. Ensure
that message gets written, too, even if it may be only partial.

Bug: 575629
Change-Id: I38edccb5cffb89e00e468480b43c7d951fb63e8e
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoAdd tests for SideBandInputStream 26/191926/2
Thomas Wolf [Sat, 26 Feb 2022 11:46:20 +0000 (12:46 +0100)]
Add tests for SideBandInputStream

Bug: 575629
Change-Id: I4591a64a2c07c7841417ec7a5c7883134ffda1be
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoWinPipeConnector: Resolve warnings by using "equals" instead of "==" 10/191410/5
Fabio Ponciroli [Thu, 3 Mar 2022 16:27:25 +0000 (17:27 +0100)]
WinPipeConnector: Resolve warnings by using "equals" instead of "=="

Errorprone raises the following warning: "[ReferenceEquality] Comparison
using reference equality instead of value equality".

Change-Id: Ic73305b2af628f66e7659ea1b839b3a640e3cd8d

2 years agoLsRemoteCommand: apply url.*.insteadOf 29/191929/1
Thomas Wolf [Fri, 4 Mar 2022 20:00:26 +0000 (21:00 +0100)]
LsRemoteCommand: apply url.*.insteadOf

If LsRemoteCommand is used without repository, the remote URI was not
translated. If the git user config contains e.g.

  [url "ssh://git@github.com/"]
    insteadOf = https://github.com/

and LsRemoteCommand is called with an HTTPS GitHub repository URL, the
command should actually rewrite this to an SSH URI and use the SSH
transport.

Actually this same problem may exist everywhere Transport is used with
an URIish instead of with a remote name. However, doing this translation
in Transport.open(URIish) and in Transport.open(Repository, URIish,
String) if no remote name is given would change the behavior and might
break assumptions made in existing clients. For instance, EGit's
PushOperation assumes that the URI obtained from PushResult.getURI()
was the same as was passed in to Transport.open(Repository, URIish).

URIs obtained from a RemoteConfig have this translation applied
transparently, and in Transport we cannot know for sure whether or
not a URI has already been translated, if needed. So doing this in
Transport might also lead to translating URIs twice.

Therefore this commit does the translation in LsRemoteCommand, where
we can be sure that it won't affect other use cases. If other cases
besides LsRemoteCommand are found where such a URI translation is
missing, it'll have to be done at higher levels, possibly even in
client code directly.

Bug: 544769
Change-Id: I5df54a925d30b55d98e21f37f2851fe79649b064
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoFactor out URL replacement from RemoteConfig 28/191928/1
Thomas Wolf [Wed, 2 Mar 2022 19:47:49 +0000 (20:47 +0100)]
Factor out URL replacement from RemoteConfig

Add a new UrlConfig that encapsulates the basic URL replacement logic
for git configs url.<base>.insteadOf and pushInsteadof.

Change-Id: Iecc61d1c5e6089533552afa1d1e684ae72393b38
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoFix MANIFEST.MF in the LFS bundles 16/191816/1
Thomas Wolf [Sat, 12 Mar 2022 16:28:47 +0000 (17:28 +0100)]
Fix MANIFEST.MF in the LFS bundles

Somehow new dependencies added in commit a229072f got lost when merging
stable-6.1 into master.

Change-Id: I19c16c6be73d07e05f37241a44cf25133ff467a5
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoUpdate Tycho to 2.6.0 30/191530/3
Matthias Sohn [Mon, 7 Mar 2022 09:08:26 +0000 (10:08 +0100)]
Update Tycho to 2.6.0

Change-Id: Ic8b2b352721040ccc0164cf0c8637102518e5ce9

2 years agoMerge branch 'stable-6.1' 70/191670/2
Matthias Sohn [Tue, 8 Mar 2022 16:23:57 +0000 (17:23 +0100)]
Merge branch 'stable-6.1'

* stable-6.1:
  Prepare 6.1.1-SNAPSHOT builds
  JGit v6.1.0.202203080745-r
  [checkout] Use .gitattributes from the commit to be checked out
  Don't use final for method parameters
  [push] support the "matching" RefSpecs ":" and "+:"
  [push] Call the pre-push hook later in the push process
  IndexDiff: use tree filter also for SubmoduleWalk
  Run license check with option -Ddash.projectId=technology.jgit
  Exclude transitive dependencies of sshd-sftp
  Update DEPENDENCIES for 6.1.0 release
  Add dependency to dash-licenses
  Fix typos of some keys in LfsText
  Sort LfsText entries alphabetically
  Support for "lfs.url" from ".lfsconfig"

Change-Id: I1b9f0c0ed647837e00b9640d235dbfab2329c5a6

2 years agoPrepare 6.1.1-SNAPSHOT builds 14/191614/1
Matthias Sohn [Tue, 8 Mar 2022 16:04:10 +0000 (17:04 +0100)]
Prepare 6.1.1-SNAPSHOT builds

Change-Id: Ifc80355025d8459245843be1c24dc5a286913e77

2 years agoJGit v6.1.0.202203080745-r 04/191604/1 v6.1.0.202203080745-r
Matthias Sohn [Tue, 8 Mar 2022 12:45:56 +0000 (13:45 +0100)]
JGit v6.1.0.202203080745-r

Change-Id: I8766ed400020c9571f321bbbfe34b0688af0107d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2 years ago[checkout] Use .gitattributes from the commit to be checked out 66/190766/4
Thomas Wolf [Sun, 13 Feb 2022 22:30:36 +0000 (23:30 +0100)]
[checkout] Use .gitattributes from the commit to be checked out

JGit used only one set of attributes constructed from the global and
info attributes, plus the attributes from working tree, index, and
HEAD.

These attributes must be used to determine whether the working tree is
dirty.

But for actually checking out a file, one must use the attributes from
global, info, and *the commit to be checked out*. Otherwise one may not
pick up definitions that are only in the .gitattributes of the commit
to be checked out or that are changed in that commit with respect to
the attributes currently in HEAD, the index, or the working tree.

Maintain in TreeWalk different Attributes per tree, and add operations
to determine EOL handling and smudge filters per tree.

Use the new methods in DirCacheCheckout and ResolveMerger. Note that
merging in JGit actually used the attributes from the base, not those
from ours, which looks dubious at least. It now uses those from ours,
and for checking out the ones from theirs.

The canBeContentMerged() determination was also done from the base
attributes, and is newly done from the ours attributes. Possibly this
should take into account all three attributes, and only if all three
agree the item can be content merged, a content merge should be
attempted? (What if the binary/text setting changes between base, ours,
or theirs?)

Also note that JGit attempts to perform content merges on non-binary
LFS files; there it used the filter attribute from base, too, even for
the ours and theirs versions. Newly it takes the filter attribute from
the correct tree. I'm not convinced doing content merges on potentially
huge files like LFS files is really a good idea.

Add tests in FilterCommandsTest and LfsGitTest to verify the behavior.

Open question: using index and working tree as fallback for the
attributes of ours (assuming it is HEAD) is OK. But does it also make
sense for base and theirs in merging?

Bug: 578707
Change-Id: I0bf433e9e3eb28479b6272e17c0666e175e67d08
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoRefer to target platform as file 44/191544/1
Michael Keppler [Mon, 7 Mar 2022 14:52:58 +0000 (15:52 +0100)]
Refer to target platform as file

Since Tycho 2.3 the target platform can be referenced as file, without
using Maven coordinates.

Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Change-Id: I120223dd3dc740fdff13a69201624b4cdc02c6f6

2 years agoDon't use final for method parameters 20/191520/1
Matthias Sohn [Sun, 6 Mar 2022 17:52:59 +0000 (18:52 +0100)]
Don't use final for method parameters

See https://wiki.eclipse.org/EGit/Contributor_Guide#Use_of_the_.22final.22_modifier

Change-Id: Idc6ed85483e381689e5085c4a1bacd75d26f5489

2 years ago[push] support the "matching" RefSpecs ":" and "+:" 80/190980/5
Thomas Wolf [Sun, 20 Feb 2022 17:11:49 +0000 (18:11 +0100)]
[push] support the "matching" RefSpecs ":" and "+:"

The implementation of push.default=matching was not correct.
It used the RefSpec "refs/heads/*:refs/heads/*", which would push
_all_ local branches. But "matching" must push only those local
branches for which a remote branch with the same name already exists
at the remote.

This RefSpec can be expanded only once the advertisement from the
remote has been received.

Enhance RefSpec so that ":" and "+:" can be represented. Introduce a
special RemoteRefUpdate for such a RefSpec; it must carry through the
fetch RefSpecs to be able to fill in the remote tracking updates as
needed. Implement the expansion in PushProcess.

Bug: 353405
Change-Id: I54a4bfbb0a6a7d77b9128bf4a9c951d6586c3df4
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years ago[push] Call the pre-push hook later in the push process 89/190989/2
Thomas Wolf [Sun, 20 Feb 2022 17:10:24 +0000 (18:10 +0100)]
[push] Call the pre-push hook later in the push process

Call the pre-push hook only after having received the remote
advertisement and having determined rejections, like C git does.
Also similar to C git, don't pass rejected or up-to-date updates
to the pre-push hook.

Bug: 578852
Change-Id: I51d379ea7bd8234ec815f8f4a9fa325816f476cf
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoIndexDiff: use tree filter also for SubmoduleWalk 15/191515/1
Thomas Wolf [Fri, 17 Jul 2020 17:41:31 +0000 (19:41 +0200)]
IndexDiff: use tree filter also for SubmoduleWalk

The only uses of IndexDiff.setFilter() in JGit and EGit set a path
filter. Passing the filter on to the SubmoduleWalk gives the desired
result, which is consistent with command-line git.

Bug: 565251
Change-Id: I8eca1ed73eb1d237b8785f369352f72af9e0e168
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoRun license check with option -Ddash.projectId=technology.jgit 33/191433/1
Matthias Sohn [Fri, 4 Mar 2022 06:56:50 +0000 (07:56 +0100)]
Run license check with option -Ddash.projectId=technology.jgit

This ensures that works-with-dependencies are attributed properly.

Change-Id: Ie41733cdecc83ae0b532fb4bd9f692bc09e16107

2 years agoExclude transitive dependencies of sshd-sftp 29/191429/1
Matthias Sohn [Thu, 3 Mar 2022 23:30:36 +0000 (00:30 +0100)]
Exclude transitive dependencies of sshd-sftp

We don't need the dependencies of sshd-sftp to sshd-common and
sshd-core since they are contained in sshd-osgi.
Excluding them helps the dash IP log tool to not list them as required
dependencies of jgit.

Change-Id: I85bce4dca1b99ba880cf3e909fac9669c75e7854

2 years agoUpdate DEPENDENCIES for 6.1.0 release 24/191424/1
Matthias Sohn [Thu, 3 Mar 2022 21:11:06 +0000 (22:11 +0100)]
Update DEPENDENCIES for 6.1.0 release

Change-Id: I9ea925bd444952dc204e2538b9d16fe631202e0c

2 years agoAdd dependency to dash-licenses 23/191423/1
Matthias Sohn [Wed, 27 Jan 2021 23:25:06 +0000 (00:25 +0100)]
Add dependency to dash-licenses

This is required to run the license check using the license tool [1]
required by the Eclipse project handbook [2]:

mvn org.eclipse.dash:license-tool-plugin:license-check -Ddash.summary=DEPENDENCIES

Note: the tool still requires Java 11 hence it needs to be run in a
separate build step and is not yet integrated in the build which runs
on Java 8.

[1] https://github.com/eclipse/dash-licenses
[2] https://www.eclipse.org/projects/handbook/#ip-license-tool

Change-Id: Ib41d54de246c3c9499cc3be9f026294c39fdfd99

2 years agoPrepare 6.2.0-SNAPSHOT builds 99/191399/1
Matthias Sohn [Thu, 3 Mar 2022 09:49:58 +0000 (10:49 +0100)]
Prepare 6.2.0-SNAPSHOT builds

Change-Id: Ic2dde88bee3242169d6fa50956f8938f3fc4ba8e

2 years agoFix typos of some keys in LfsText 98/191398/1
Matthias Sohn [Thu, 3 Mar 2022 09:46:33 +0000 (10:46 +0100)]
Fix typos of some keys in LfsText

Change-Id: I86dee0b68e627e26cbd29976162bc7b953ebf276

2 years agoSort LfsText entries alphabetically 97/191397/1
Matthias Sohn [Thu, 3 Mar 2022 09:45:19 +0000 (10:45 +0100)]
Sort LfsText entries alphabetically

Change-Id: I3021cb246b51d861d51258808c75d5c6843ec82d

2 years agoSupport for "lfs.url" from ".lfsconfig" 31/189231/14
Matthias Fromme [Mon, 3 Jan 2022 12:06:34 +0000 (13:06 +0100)]
Support for "lfs.url" from ".lfsconfig"

- New class LfsConfig to enrich repository configuration by settings
from ".lfsconfig" file respecting configuration file precedence.
- Adapted LfsConnectionFactory to use LfsConfig instead of directly
using configuration from repository to calculate url of the lfs
repository

Bug: 578020
Change-Id: I156f4ec137c2e428136a2ca9b8a4011ecee2d915

2 years agoMerge branch 'stable-6.1' 88/191388/1
Matthias Sohn [Wed, 2 Mar 2022 22:02:21 +0000 (23:02 +0100)]
Merge branch 'stable-6.1'

* stable-6.1:
  Update Orbit to R20220302172233 for 2022-03
  Prepare 6.1.0-SNAPSHOT builds
  JGit v6.1.0.202203021511-rc1
  Prepare 6.1.0-SNAPSHOT builds
  JGit v6.1.0.202202221755-m3

Change-Id: Iff4b13ca8ae5e13a3f2f45c0d4653405f1ceb2f4

2 years agoUpdate Orbit to R20220302172233 for 2022-03 82/191382/1
Matthias Sohn [Wed, 2 Mar 2022 21:31:45 +0000 (22:31 +0100)]
Update Orbit to R20220302172233 for 2022-03

Change-Id: Ief504bf7f926d461e38186bf00711082d619fc08

2 years agoPrepare 6.1.0-SNAPSHOT builds 81/191381/1
Matthias Sohn [Wed, 2 Mar 2022 21:28:46 +0000 (22:28 +0100)]
Prepare 6.1.0-SNAPSHOT builds

Change-Id: I525fc1258a729c36d63fdb3c8170e9f04ad55cec

2 years agoJGit v6.1.0.202203021511-rc1 78/191378/1 v6.1.0.202203021511-rc1
Matthias Sohn [Wed, 2 Mar 2022 20:11:54 +0000 (21:11 +0100)]
JGit v6.1.0.202203021511-rc1

Change-Id: I4c75a58fd76102e773af4f1f8a1487d5e7ffc7cf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2 years agoMerge branch 'master' into stable-6.1 75/191375/1
Matthias Sohn [Wed, 2 Mar 2022 20:10:03 +0000 (21:10 +0100)]
Merge branch 'master' into stable-6.1

* master:
  Describe: add support for core.abbrev config option
  Add a typed config getter for integers confined to a range
  Remove odd prefix of PersonIdent test class
  PersonIdent: Add ctors that accept Instant in addition to Date
  Remove ignored potentiallyUnclosedCloseable check
  Make precedence more explicit
  [pgm] Add describe --abbrev option
  Cap describe abbrev option
  DescribeCommand: Add support for --abbrev=0

Change-Id: I1daa3501a38d57b628800fadb96b6b71eea8cbb3

2 years agoDescribe: add support for core.abbrev config option 09/191009/7
Matthias Sohn [Mon, 21 Feb 2022 01:29:27 +0000 (02:29 +0100)]
Describe: add support for core.abbrev config option

If core.abbrev is unset or "auto" estimate abbreviation length like C
git does:
- Estimate repository's object count by only considering packed objects,
  round up to next power of 2
- With the order of 2^len objects, we expect a collision at 2^(len/2).
  But we also care about hex chars, not bits, and there are 4 bits per
  hex. So all together we need to divide by 2; but we also want to round
  odd numbers up, hence adding one before dividing.
- For small repos use at least 7 hexdigits
- If object database fails to determine object count use 7 hexdigits as
  fallback

If it is set to "no" do not abbreviate object-ids.

Otherwise set it to the configured value capped to the range between 4
and length of an unabbreviated object-id.

Change-Id: I425f9724b69813dbb57872466bf2d2e1d6dc72c6

2 years agoAdd a typed config getter for integers confined to a range 36/191036/4
Matthias Sohn [Tue, 22 Feb 2022 00:20:07 +0000 (01:20 +0100)]
Add a typed config getter for integers confined to a range

Use Integer#MIN_VALUE to denote unset option.

Change-Id: I4d65f2434013111f25520c0ed2b9a9dc8123c6cf

2 years agoRemove odd prefix of PersonIdent test class 43/190543/2
Matthias Sohn [Mon, 7 Feb 2022 22:12:34 +0000 (23:12 +0100)]
Remove odd prefix of PersonIdent test class

Change-Id: I05ede49902527c435691fb2c0f0d4da7ba077b7a

2 years agoPersonIdent: Add ctors that accept Instant in addition to Date 92/189192/5
David Ostrovsky [Wed, 29 Dec 2021 20:18:52 +0000 (21:18 +0100)]
PersonIdent: Add ctors that accept Instant in addition to Date

Error Prone is flagging Date-API as obsolete and recommends to migrate
to Instant and LocalDate. Given that more JGit users starting to migrate
to new Time API, offer ctors that accept Instant type and also add new
getter that returns when attribute as Instant type.

Change-Id: I64a36bf40f191495c6889c1dff314ede06848880

2 years agoRemove ignored potentiallyUnclosedCloseable check 34/190534/3
Fabio Ponciroli [Mon, 7 Feb 2022 18:30:01 +0000 (19:30 +0100)]
Remove ignored potentiallyUnclosedCloseable check

potentiallyUnclosedCloseable currently is not checked and it creates
a warning when compiling with Maven.

Change-Id: I0715ead433270937f77f56a19aa203f8d6f5322f

2 years agoMake precedence more explicit 47/191347/3
Fabio Ponciroli [Wed, 2 Mar 2022 09:03:51 +0000 (10:03 +0100)]
Make precedence more explicit

Errorprone was failing the build with: "[OperatorPrecedence]. Use
grouping parenthesis to make the operator precedence explicit"

Add parentheses to silence it.

Change-Id: I81f1f249e38fd2543f5412b3501b0179d0759f55

2 years ago[pgm] Add describe --abbrev option 08/191008/2
Matthias Sohn [Sun, 20 Feb 2022 11:04:11 +0000 (12:04 +0100)]
[pgm] Add describe --abbrev option

Change-Id: I8adf2fad21db71b43266d3f274143eee6bc9dce2

2 years agoCap describe abbrev option 07/191007/2
Matthias Sohn [Sun, 20 Feb 2022 11:00:49 +0000 (12:00 +0100)]
Cap describe abbrev option

- minimum is 4 [1]
- maximum is length of a full ObjectId

[1] https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreabbrev

Change-Id: I145bde1a218f71b87b8d8260761dd0853770bb76

2 years agoDescribeCommand: Add support for --abbrev=0 06/191006/2
Matthias Sohn [Sun, 20 Feb 2022 11:03:22 +0000 (12:03 +0100)]
DescribeCommand: Add support for --abbrev=0

Setting --abbrev=0 suppresses long format and only shows the closest tag
[1].

[1] https://git-scm.com/docs/git-describe#Documentation/git-describe.txt---abbrevltngt

Change-Id: Ifcf4d7786dd0f0fb0315d8093fdb54384ed9d5f9

2 years agoPrepare 6.1.0-SNAPSHOT builds 17/191317/1
Matthias Sohn [Tue, 1 Mar 2022 16:21:11 +0000 (17:21 +0100)]
Prepare 6.1.0-SNAPSHOT builds

Change-Id: I30a89277373ad62c857151532942e135e34d1d0c

2 years agoJGit v6.1.0.202202221755-m3 95/191095/1 v6.1.0.202202221755-m3
Matthias Sohn [Tue, 22 Feb 2022 22:55:35 +0000 (23:55 +0100)]
JGit v6.1.0.202202221755-m3

Change-Id: Idcd46e05ca3eec376f8ac83209dba0978e004f9a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2 years agoRemove SuppressWarnings since currently ignored 57/190357/13
Fabio Ponciroli [Thu, 3 Feb 2022 08:49:13 +0000 (09:49 +0100)]
Remove SuppressWarnings since currently ignored

The following warning was raised by Eclipse:
"At least one of the problems in category
'unused' is not analysed due to a compiler option being ignored"

The org.eclipse.jdt.core.compiler.problem.unusedTypeParameter compiler
option is set to ignore, hence the warning suppression is redundant.

Change-Id: I5fd6efc9968be133c71e95c53803c44310d75e85

2 years agoAdd comment to explain why try-with-resource is not used 03/190703/7
Fabio Ponciroli [Fri, 11 Feb 2022 08:30:31 +0000 (09:30 +0100)]
Add comment to explain why try-with-resource is not used

Change-Id: I904f9890428334bdf2971511e0b2681f3da5a82a

2 years agoDescribeCommand: Support configuring the hash abbreviation 38/189338/7
Sebastian Schuberth [Wed, 5 Jan 2022 17:07:48 +0000 (18:07 +0100)]
DescribeCommand: Support configuring the hash abbreviation

Bug: 537883
Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
Change-Id: Ic52dcebc564bbb0d934cc3a6205704b7aeaee30e

2 years agoSimplify implementation of WorkingTreeIterator 65/190765/2
Thomas Wolf [Sun, 13 Feb 2022 22:24:14 +0000 (23:24 +0100)]
Simplify implementation of WorkingTreeIterator

All the filtering in WorkingTreeIterator is for check-in, i.e., clean
filtering. The implementation was in some parts too general, passing
around an OperationType. But since it's always CHECKIN_OP, that's not
actually necessary.

Change-Id: I73f8bc059e485a073e456962868f52b3a3db4fc1
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoUpdate Orbit to S20220215213605 53/190853/1
Matthias Sohn [Wed, 16 Feb 2022 12:09:15 +0000 (13:09 +0100)]
Update Orbit to S20220215213605

and
- org.apache.httpcomponents.httpcore to 4.4.15.v20220209-2345

Change-Id: I0c7a8cf5a282596fe3d3dac422716480b3d76c83

2 years agoTransport: load all refs only if push refspecs have wildcards 29/190729/2
Thomas Wolf [Fri, 11 Feb 2022 16:18:20 +0000 (17:18 +0100)]
Transport: load all refs only if push refspecs have wildcards

There is no need to load all refs if there are no wildcard push
refspecs. Load them lazily on the first wildcard refspec encountered
instead of loading them up-front.

Change-Id: I6d0e981f9ed4997dbdefeb7f83f37ff4f33e06a5
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoPushCommand: determine remote from git config if not given 28/190728/2
Thomas Wolf [Thu, 10 Feb 2022 18:04:21 +0000 (19:04 +0100)]
PushCommand: determine remote from git config if not given

Add ConfigConstants and expose branch.<name>.pushRemote in the
BranchConfig. Use the branch configuration and remote.pushDefault
if no remote is given explicitly. If nothing is configured, fall
back to "origin".

Bug: 578676
Change-Id: I6bb141ff02c8b04980ec34b26ef248b72614c3c9
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoPushCommand: consider push.default when no RefSpecs are given 29/136629/5
Rolf Theunissen [Sun, 10 Feb 2019 17:40:26 +0000 (18:40 +0100)]
PushCommand: consider push.default when no RefSpecs are given

When no RefSpecs are given, PushCommand until now simply fell back to
pushing the current branch to an upstream branch of the same name. This
corresponds to push.default=current. Any setting from the git config
for push.default was simply ignored.

Implement the other modes (nothing, matching, upstream, and simple),
too. Add a setter and getter for the PushDefault so that an application
can force a particular mode to be used. For backwards compatibility,
use "current" as the default setting; to figure out the value from the
git config, which defaults to "simple", call setPushDefault(null).

Bug: 351314
Change-Id: I86c5402318771e47d80b137e99947762e1150bb4
Signed-off-by: Rolf Theunissen <rolf.theunissen@gmail.com>
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoPrevent that an instance of PushCommand is reused 74/190774/1
Thomas Wolf [Mon, 14 Feb 2022 09:44:51 +0000 (10:44 +0100)]
Prevent that an instance of PushCommand is reused

We checked if the command instance is called but missed to set the flag
tracking if it actually was used.

Change-Id: I0f9fb85c47945a4d91eab01ec5e1abc1ab83332a

2 years agoRemove unused warning suppression 01/190701/2
Fabio Ponciroli [Fri, 11 Feb 2022 08:19:31 +0000 (09:19 +0100)]
Remove unused warning suppression

SuppressWarnings is not used. Remove  to avoid
warnings at compile  time.

Change-Id: I84e3e57017cf9fd68d3377f866d4dd907ccde454

2 years agoSupport for git config push.default 62/190662/1
Thomas Wolf [Wed, 9 Feb 2022 17:33:31 +0000 (18:33 +0100)]
Support for git config push.default

Enhance the (unused!?) PushConfig; include a PushDefault enumeration.
Add simple tests for this PushConfig.

Bug: 351314
Change-Id: Ibc5656a2a1fccf70d00c5e15de8ed3dd8add6337
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoUpdate Orbit to S20220208191225 91/190591/3
Matthias Sohn [Tue, 8 Feb 2022 23:18:20 +0000 (00:18 +0100)]
Update Orbit to S20220208191225

Change-Id: I091d82a26fb058eaa40c03e5cec1b004969d0894

2 years agoMerge branch 'stable-6.0' 94/190594/2
Matthias Sohn [Tue, 8 Feb 2022 23:47:49 +0000 (00:47 +0100)]
Merge branch 'stable-6.0'

* stable-6.0:
  Stop initCause throwing in readAdvertisedRefs

Change-Id: I2266814c613fd81e9dfc722532ac3daa30ca66b5

2 years agoMerge branch 'stable-5.13' into stable-6.0 93/190593/2
Matthias Sohn [Tue, 8 Feb 2022 23:32:10 +0000 (00:32 +0100)]
Merge branch 'stable-5.13' into stable-6.0

* stable-5.13:
  Stop initCause throwing in readAdvertisedRefs

Change-Id: I94251601aa7fae9cc65164eaddcf16471874b11e

2 years agoStop initCause throwing in readAdvertisedRefs 50/190250/16
Darius Jokilehto [Fri, 4 Feb 2022 16:13:27 +0000 (16:13 +0000)]
Stop initCause throwing in readAdvertisedRefs

BasePackConnection::readAdvertisedRefsImpl was creating an exception by
calling `noRepository`, and then blindly calling `initCause` on it. As
`noRepository` can be overridden, it's not guaranteed to be missing a
cause.

BasePackPushConnection overrides `noRepository` and initiates a fetch,
which may throw a `NoRemoteRepositoryException` with a cause.

In this case calling `initCause` threw an `IllegalStateException`.

In order to throw the correct exception, we now return the
BasePackPushConnection exception and suppress the one thrown by
BasePackConnection

Bug: 578511
Change-Id: Ic1018b214be1e83d895979ee6c7cbce3f6765f6f

2 years agoSupport LFS Server URL without .git suffix 27/190527/6
Nail Samatov [Mon, 7 Feb 2022 15:13:58 +0000 (18:13 +0300)]
Support LFS Server URL without .git suffix

According to Git LFS documentation, URLs with and without .git suffix
should be supported. By default, Git LFS will append .git/info/lfs to
the end of a Git remote URL. To build the LFS server URL it will use:

Git Remote: https://git-server.com/foo/bar
LFS Server: https://git-server.com/foo/bar.git/info/lfs

Git Remote: https://git-server.com/foo/bar.git
LFS Server: https://git-server.com/foo/bar.git/info/lfs

Fix the LfsConnectionFactory accordingly. Move a utility method to
add the ".git" suffix if not present yet from FileResolver to
StringUtils and use it.

Bug: 578621
Change-Id: I8d3645872d5f03bb8e82c9c73647adb3e81ce484
Signed-off-by: Nail Samatov <sanail@yandex.ru>
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years ago[rebase] InteractiveHandler2: handle Gerrit Change-Ids 44/190444/1
Thomas Wolf [Thu, 3 Feb 2022 19:24:53 +0000 (20:24 +0100)]
[rebase] InteractiveHandler2: handle Gerrit Change-Ids

Add a way for the handler to tell whether the commit should generate a
Gerrit Change-Id. Augment the ModifyResult interface, and set the flag
on the CommitCommand.

This enables users to have a Change-ID be generated when squashing or
rewording commits. A possibly already existing Change-Id will remain
unchanged.

Bug: 440211
Change-Id: I66a72e0646876d162a7011235cca969e20acf060
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years ago[errorprone] Fix DefaultCharset warning in BareSuperprojectWriterTest 51/190351/2
Luca Milanesio [Thu, 3 Feb 2022 01:20:19 +0000 (01:20 +0000)]
[errorprone] Fix DefaultCharset warning in BareSuperprojectWriterTest

Set the string encoding when converting a byte array into String,
avoiding the build-time warning on platform-dependent encoding.

See https://errorprone.info/bugpattern/DefaultCharset

Change-Id: I1f920043a8f303da43a8278793c38453e8773d69

2 years agoIntroduce a constant for the length of an abbreviated hash string 37/189337/5
Sebastian Schuberth [Wed, 5 Jan 2022 17:21:33 +0000 (18:21 +0100)]
Introduce a constant for the length of an abbreviated hash string

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
Change-Id: I196d58a813f7caa1965af4cf8e2f977ed4cdc350

2 years agoMake sure to close Repository in tests 34/190334/4
Fabio Ponciroli [Wed, 2 Feb 2022 19:05:55 +0000 (20:05 +0100)]
Make sure to close Repository in tests

Repository wasn't closed in FetchAndPullCommandsRecurseSubmodulesTest.
This caused a "Resource leak: 'g' is never closed" warning during
compilation.

Bug: 578546
Change-Id: I591ef1e286bcd9a7103c016fd47015e77fa95cbb

2 years agoFix resource leak in CancellableDigestOutputStreamTest 29/190329/7
Fabio Ponciroli [Wed, 2 Feb 2022 17:49:50 +0000 (18:49 +0100)]
Fix resource leak in CancellableDigestOutputStreamTest

CancellableDigestOutputStream resources are never closed in the tests.
This causes a "Resource leak: 'out' is never closed" warning
at compile time.

Suppress it by using a try with resources.

Bug: 578544
Change-Id: I0dc7de9162b8e3ac6fcaabe3002423f545baddb8

2 years agoFix "Empty block should be documented" warning 27/190327/2
Fabio Ponciroli [Wed, 2 Feb 2022 17:38:02 +0000 (18:38 +0100)]
Fix "Empty block should be documented" warning

Bug: 578543
Change-Id: Id7fb03c07c785ac0955e4969a9b781b707719749

2 years agoReplace deprecated org.eclipse.jgit.lib.RefDatabase.getRefs 45/190245/4
Fabio Ponciroli [Tue, 1 Feb 2022 15:48:14 +0000 (16:48 +0100)]
Replace deprecated org.eclipse.jgit.lib.RefDatabase.getRefs

The method has been deprecated since 5.0.
Use getRefsByPrefix instead.

Bug: 534731
Change-Id: I5f1cfc1fd5ae49dc7a4ed3e039f23ed785d674f6

2 years agoRebaseCommand: fix commit message in "fixup" case 28/189728/4
Thomas Wolf [Mon, 17 Jan 2022 23:37:33 +0000 (00:37 +0100)]
RebaseCommand: fix commit message in "fixup" case

JGit accumulated in MESSAGE_FIXUP commit messages of a fixup sequence,
just like it did in MESSAGE_SQUASH, and on the last step of a sequence
of fixups used that file, after stripping all comment lines, as the
commit message. That also stripped any lines from the original commit
message that happened to start with the comment character.

This is not how this is supposed to work. MESSAGE_FIXUP must contain
the original commit message of the base commit that is amended, and
the file contains the verbatim commit message for the final fixup.[1]

Change the implementation accordingly, and add new tests.

[1] https://github.com/git/git/blob/df3c41adeb/sequencer.c#L86 ff.

Bug: 513726
Change-Id: I885a2b7f10d6c74460a8693aa6cbf867ee0494a1
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoreftable: close old Db in FileRepository#convertToPackedRefs 25/190225/3
Han-Wen Nienhuys [Tue, 1 Feb 2022 10:51:32 +0000 (11:51 +0100)]
reftable: close old Db in FileRepository#convertToPackedRefs

This fixes test failures on Windows.

Change-Id: I701fbeb99ffd7951514ae6eae8b28cceb9aebd9f

2 years agoreftable: tweaks for Windows 00/190200/4
Han-Wen Nienhuys [Mon, 31 Jan 2022 11:23:55 +0000 (12:23 +0100)]
reftable: tweaks for Windows

Reload the stack _before_ trying to delete the files. This ensures we
don't trip over our own open file handles when deleting compacted
tables.

If there is another process reading the file, it may be impossible to
delete the compacted tables. In this case, ignore the failure.

For cleaning the garbage in this case, the protocol as described in
https://www.git-scm.com/docs/reftable#_windows should be implemented.
This is left for another commit.

Bug: 578454
Change-Id: I7aa43508450041eb9376d9f67a0262ff7cc53c73

2 years agoMerge changes I11366273,I256e1572
Ivan Frade [Tue, 1 Feb 2022 22:41:44 +0000 (17:41 -0500)]
Merge changes I11366273,I256e1572

* changes:
  RepoCommand: Offer to set extra files in the destination repository
  RepoCommand: Move bare/regular superproject writing to their own classes

2 years agoMerge "[test] Fix EolRepositoryTest for eol=native"
Matthias Sohn [Tue, 1 Feb 2022 10:23:14 +0000 (05:23 -0500)]
Merge "[test] Fix EolRepositoryTest for eol=native"

2 years ago[test] Fix EolRepositoryTest for eol=native 15/190215/1
Thomas Wolf [Mon, 31 Jan 2022 23:52:36 +0000 (00:52 +0100)]
[test] Fix EolRepositoryTest for eol=native

On Windows eol=native, which is also the default if nothing else
overrides it, means convert text files to CRLF on checkout.

Adapt tests for this. Also don't fiddle with the real system property
"line.separator", use the mocked SystemReader for this.

Bug: 550111
Change-Id: Ie19b80fc543fa4970d6d9f181041c5f4d6ef3ed4
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoMerge branch 'stable-6.0' 14/190214/1
Matthias Sohn [Mon, 31 Jan 2022 23:28:05 +0000 (00:28 +0100)]
Merge branch 'stable-6.0'

* stable-6.0:
  Fix warning: The value of the parameter otp is not used

Change-Id: I47996285c49ce85ab0bb835956a9ef58ed71de20

2 years agoFix FS_Win32 if a non-directory is listed 93/190193/2
Thomas Wolf [Mon, 31 Jan 2022 08:39:12 +0000 (09:39 +0100)]
Fix FS_Win32 if a non-directory is listed

FS.list() is supposed to return an empty array if the File given is not
a directory.

Bug: 550111
Change-Id: I245da5f1f2bdafd9dfb38fb8d7eff27d900cd5a8
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years ago[test] Fix ConfigTest for Windows 91/190191/3
Thomas Wolf [Mon, 31 Jan 2022 07:58:17 +0000 (08:58 +0100)]
[test] Fix ConfigTest for Windows

Escape paths when writing them to a config file to ensure they work
with backslashes and unusual characters.

Bug: 550111
Change-Id: Iedc5c0f2c0c02ac6cadf43cdae0f0d19578aed91
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years ago[test] Fix CommitTemplateConfigTest for Windows 90/190190/3
Thomas Wolf [Mon, 31 Jan 2022 07:43:57 +0000 (08:43 +0100)]
[test] Fix CommitTemplateConfigTest for Windows

Ensure that this test works on Windows.

Bug: 550111
Change-Id: Ib3ca803f4d9521a5f2a0e1344bfbc0d2beccc9cc
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years ago[test] RepoCommandTest: guard tests for executable files 89/190189/2
Thomas Wolf [Mon, 31 Jan 2022 07:25:44 +0000 (08:25 +0100)]
[test] RepoCommandTest: guard tests for executable files

On Windows, java.io.File.canExecute is always true. Guard assertions
testing the executable bit with FS.DETECTED.supportsExecute().

Bug: 550111
Change-Id: I2704d122f5b1086d01a0503a8c047a02ecbc1d4a
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoRepoCommand: Offer to set extra files in the destination repository 73/188073/2
Ivan Frade [Tue, 23 Nov 2021 22:42:01 +0000 (14:42 -0800)]
RepoCommand: Offer to set extra files in the destination repository

We want to save in the destination repository what manifest created its
structure. This helps to detect and debug failures in the manifest ->
superproject translations. The src commit should be easily readable from
the superproject tip.

Offer an API to write a file in the destination repository. RepoCommand
callers (e.g. gerrit supermanifest plugin) can use this to add a
file with the repo/ref/hash of the manifest.

Alternatives considered to write the source repo/ref/hash:

  * .gitattributes of the .gitmodules file. Some updates in the manifest
    don't touch the .gitmodules (e.g. a linkfile change), so it can fall
    out of sync.

  * commit message. Caller would need to follow the commit history to
    find the latest modification by repo command. This is not helpful
    e.g. for build bots that want to get the value in one call.

Change-Id: I113662734a7ccd39cbc60b46ad3f73038c807682

2 years agoRepoCommand: Move bare/regular superproject writing to their own classes 03/184503/11
Ivan Frade [Thu, 26 Aug 2021 20:19:01 +0000 (13:19 -0700)]
RepoCommand: Move bare/regular superproject writing to their own classes

RepoCommand parses the manifest to get a list of projects, clears up
conflicts and then writes to the superproject. The first steps are
common but the writing is completely different for bare or "regular"
(with working dir) repository.

Split writing to bare and regular repos into its own classes. This
simplifies RepoCommand class and makes clearer what happens on each side
(e.g. many options apply only to bare repos).

Change-Id: I256e15729bd53ee15fc56de88bce86a2edb2417a

2 years agoMerge conflict messages: prefix conflict lines with a hash 26/189726/2
Thomas Wolf [Sun, 16 Jan 2022 14:50:00 +0000 (15:50 +0100)]
Merge conflict messages: prefix conflict lines with a hash

C git also does so. Note that currently the comment character is
hard-coded as the hash '#' throughout JGit.

Bug: 548529
Change-Id: I4a5597694082a9e5b07412b365cfaf41fa034cfa
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoRebaseCommand: better commit message rewording 25/189725/2
Thomas Wolf [Sat, 15 Jan 2022 22:11:41 +0000 (23:11 +0100)]
RebaseCommand: better commit message rewording

Respect git config commit.cleanup for rewording. Note that by default
this is CleanupMode.STRIP, whereas before this change, JGit would take
the reworded message verbatim.

Squashing was the only place in JGit where it automatically and
unconditionally removed comment lines from commit messages. In other
places it didn't do so, and client code needed to do so.

Unconditionally removing comments is problematic if the commit message
_should_ contain some line starting with a hash, which can easily occur
with the way Github, Gitlab, and other git web servers link to issues
or PRs: they all allow the short-hand "#<number>".

Introduce a new InteractiveHandler2 extension interface, which can
return the edited message _and_ a clean-up mode. This way, client code
can decide on its own how to clean the message, and if JGit shouldn't
do any further cleaning, it can return CleanupMode.VERBATIM. Or
CleanupMode.WHITESPACE. (In the case of SQUASH, it is then of course
the client's responsibility to remove the squash comment lines.)

If the old InteractiveHandler interface is used, CleanupMode.STRIP is
applied unconditionally for squashing, as before.

Bug: 578173
Change-Id: Ia0040c247884e684587dd45d6cb85f8b72a4b876
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoCommitCommand: commit message cleanup 24/189724/2
Thomas Wolf [Mon, 17 Jan 2022 19:28:25 +0000 (20:28 +0100)]
CommitCommand: commit message cleanup

Use CommitConfig.CleanupMode to implement git commit --cleanup. Add
setters for the clean-up mode, the comment character, and for the
default default clean-up mode.

Behavior of existing client code is unchanged as the default clean-up
mode is set to "verbatim". To use git config defaults, one can call
setCleanupMode(CleanupMode.DEFAULT). The default comment character
is hard-coded as '#' for now, as in other parts of JGit. Implementing
full support for core.commentChar shall be done in a separate change.

Bug: 553065
Change-Id: I470785e464a762d3f409f163f1cbdbb98dd81aaf
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoProvide git config commit.cleanup 23/189723/2
Thomas Wolf [Sat, 15 Jan 2022 21:51:06 +0000 (22:51 +0100)]
Provide git config commit.cleanup

Add an enumeration for the possible values, and a method to resolve the
"default" value. Give CommitConfig a static method to process a text
according to a given clean-up mode and comment character.

(The core.commentChar is not yet handled by JGit; it's hard-coded as #.)

Bug: 553065
Change-Id: If6e384522275f73b713fbc29ffcaa1753c239dea
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years ago[test] Fix closing of test repositories 86/185486/7
Nail Samatov [Wed, 15 Sep 2021 18:00:59 +0000 (21:00 +0300)]
[test] Fix closing of test repositories

Fix tests failing on Windows because Repository instance is created but
not closed on tear down.

Fix repositories closed twice, except in tests that test this behavior
explicitly.

Name the temporary directories the tests run in after the test method;
that makes it easier to figure out in which tests repositories are
closed twice if it should occur again in the future.

Bug: 550111
Change-Id: I9398b58f0f36d2c29236d2a9a8599117d9083980
Signed-off-by: Nail Samatov <sanail@yandex.ru>
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years ago[test] DirCacheCheckoutTest: fix test expectation for eol=native 86/190186/1
Thomas Wolf [Sun, 30 Jan 2022 21:47:38 +0000 (22:47 +0100)]
[test] DirCacheCheckoutTest: fix test expectation for eol=native

With eol=native, we expect LF on Unixes, and CR-LF on Windows. One test
didn't account for this and always expected LF, and thus failed on
Windows.

Bug: 550111
Change-Id: I69354ac691c464d1b6003812ddb4510c5ab5e77a
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoObjectWalk: close ObjectReader on close() if needed 85/190185/2
Thomas Wolf [Sun, 30 Jan 2022 21:15:14 +0000 (22:15 +0100)]
ObjectWalk: close ObjectReader on close() if needed

If the walk is created via ObjectWalk(Repository), it creates a new
ObjectReader. This reader was closed only on dispose(). If such an
ObjectWalk was used in a try-with-resource statement the reader might
not get closed.

Bug: 578458
Change-Id: I1be31829dc466530f23006a53c29b657fd5fb410
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years ago[test] Fix a Windows-only test in CheckoutCommandTest 84/190184/1
Thomas Wolf [Sun, 30 Jan 2022 20:43:13 +0000 (21:43 +0100)]
[test] Fix a Windows-only test in CheckoutCommandTest

Test.txt should not be in the "removed" list if it can't be deleted
but only in the "not deleted" list. The test was wrong.

Bug: 550111
Change-Id: I3ecede4278014c15015c8c24089647fa3db3742f
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years ago[test] Fix ApplyCommandTest for Windows 83/190183/1
Thomas Wolf [Sun, 30 Jan 2022 20:27:33 +0000 (21:27 +0100)]
[test] Fix ApplyCommandTest for Windows

Some tests checked whether or not a file is executable via
java.io.File.canExecute(). But that always returns true on Windows.

Use FS.DETECTED.canExecute() instead, and guard all such assertions to
run only of file systems that do support the "execute" flag.

Bug: 550111
Change-Id: Iacb9e414b612359fcecb61312c3dfb830801cd36
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years ago[test] Fix OpenSshConfigFileTest for Windows 82/190182/1
Thomas Wolf [Sun, 30 Jan 2022 19:59:26 +0000 (20:59 +0100)]
[test] Fix OpenSshConfigFileTest for Windows

The tests assumed that a path like "/tmp" was an absolute path, and
also compared against strings with forward slashes. On Windows, "/tmp"
is not an absolute path and thus resolved against the current directory,
and the separator is a backslash.

Change the tests to use ~/ notation, and test paths resolved against
the (mocked) user home directory. That way, the tests are independent
of the file system used.

Bug: 550111
Change-Id: I1c31608ca83c8d8586256d1586a792e4a33cfaa4
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agoBinaryHunkInputStream: accept CR-LF 81/190181/2
Thomas Wolf [Sun, 30 Jan 2022 16:30:22 +0000 (17:30 +0100)]
BinaryHunkInputStream: accept CR-LF

Let's be lenient and accept hunk lines terminated by CR-LF, too, not
just lines terminated by LF.

Bug: 550111
Change-Id: I7f796df666300ab56cc6c07f22eda45fbf4c941e
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agosshd: Add README.md for SSH agents 79/189379/4
Thomas Wolf [Thu, 30 Dec 2021 16:49:44 +0000 (17:49 +0100)]
sshd: Add README.md for SSH agents

Explain SSH agent protocols, what transports are available and how to
choose them in ~/.ssh/config. For Windows, add some information on
which commonly used SSH agents can be used.

Change-Id: I0b08a95654fd76643512606edb1ed74d9980aa85
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agosshd: support the ConnectTimeout ssh config 78/189378/3
Thomas Wolf [Wed, 29 Dec 2021 19:11:04 +0000 (20:11 +0100)]
sshd: support the ConnectTimeout ssh config

Parse the value from the ssh config and if set use it when connecting.

Change-Id: I85b44c9468a5027602375706612c46ea7a99b2bd
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agosshd: Skip unknown keys from the SSH agent 77/189377/3
Thomas Wolf [Wed, 29 Dec 2021 19:33:33 +0000 (20:33 +0100)]
sshd: Skip unknown keys from the SSH agent

An SSH agent might contain keys that Apache MINA sshd cannot handle.
Pageant for instance can contain ed448 keys, which are not implemented
in OpenSSH or in Apache MINA sshd.

When an agent delivers such keys, simply skip (and log) them. That way,
we can work with the remaining keys. Otherwise a single unknown key in
the agent would break pubkey authentication.

Change-Id: I3945d932c7e64b628465004cfbaf10f4dc05f3e4
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 years agosshd: support the AddKeysToAgent ssh config 76/189376/3
Thomas Wolf [Tue, 28 Dec 2021 18:54:30 +0000 (19:54 +0100)]
sshd: support the AddKeysToAgent ssh config

Add parsing of the config. Implement the SSH agent protocol for adding
a key. In the pubkey authentication, add keys to the agent as soon as
they've been loaded successfully, before even attempting to use them
for authentication. OpenSSH does the same.

Bug: 577052
Change-Id: Id1c08d9676a74652256b22281c2f8fa0b6508fa6
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>