Commit Graph

5078 Commits

Author SHA1 Message Date
Matthias Sohn f8a632657e Merge "Prepare 5.4.0-SNAPSHOT builds" 2019-03-07 11:16:46 -05:00
Matthias Sohn 90107d53eb Prepare 5.4.0-SNAPSHOT builds
Change-Id: I90a4791f63d0eba23da744c720e869f1830b86e7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-03-07 00:34:14 +01:00
Minh Thai cc2a223fea Do not retain commit body in RevWalk for reachability checks
Commit body contains the message that is not needed for reachability checks, and
takes up memory unnecessarily.

Change-Id: I0c7f6da249bf9c4fda9dc9e62e809322c68effce
Signed-off-by: Minh Thai <mthai@google.com>
2019-03-06 15:29:59 -08:00
Matthias Sohn 0295ee1164 Prepare 5.3.0-SNAPSHOT builds
Change-Id: I9b934bcfad3d2091f4da163170348b0c8ef5e732
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-03-06 22:26:03 +01:00
Matthias Sohn aca889f8cc JGit v5.3.0.201903061415-rc1
Change-Id: I85866af97fe1c0c0a0da83a7605484082fa56b52
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-03-06 20:03:00 +01:00
Terry Parker e48410ae9a Track object inflation time in DfsReaderIoStats
This can help track down poor long tail performance that isn't accounted
for in the readIdxMicros or readBlockMicros metrics.

Change-Id: I701b9cfcc124f4ddb860d1766a11ea3557e604ce
Signed-off-by: Terry Parker <tparker@google.com>
2019-03-06 10:54:52 -08:00
David Pursehouse 01cf73c7ab Merge branch 'stable-4.11' into stable-5.0
* stable-4.11:
  Fix error log message in ObjectDirectory.handlePackError()
  Properly format pack checksums in PackFile.idx()
  Cancel gc if thread was interrupted
  PackFile: report correct message for checksum mismatch
  ObjectDirectory: Clean up logging
  Bazel: Stop using native.git_repository
  ObjectDirectory: extra logging on packfile exceptions

Change-Id: If75b149e693005dd3fe06b523e6e6784bedf44c1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-03-06 14:15:36 +09:00
David Pursehouse 3fc9d43339 Merge branch 'stable-4.10' into stable-4.11
* stable-4.10:
  Fix error log message in ObjectDirectory.handlePackError()
  Properly format pack checksums in PackFile.idx()
  Cancel gc if thread was interrupted
  PackFile: report correct message for checksum mismatch
  ObjectDirectory: Clean up logging
  Bazel: Stop using native.git_repository
  ObjectDirectory: extra logging on packfile exceptions

Change-Id: I9052e318b5d920770f7c7121d36e3c58df9d5f5a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-03-06 14:14:40 +09:00
David Pursehouse ae5ea80363 Merge branch 'stable-4.9' into stable-4.10
* stable-4.9:
  Fix error log message in ObjectDirectory.handlePackError()
  Properly format pack checksums in PackFile.idx()
  Cancel gc if thread was interrupted
  PackFile: report correct message for checksum mismatch
  ObjectDirectory: Clean up logging
  Bazel: Stop using native.git_repository
  ObjectDirectory: extra logging on packfile exceptions

Change-Id: I0847251eb010616a705e0b91df4bdebc225fa95d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-03-06 14:13:48 +09:00
Matthias Sohn 7b3ee6f62e Fix error log message in ObjectDirectory.handlePackError()
Change-Id: I154f392ad025c4b642eb1123d375a0afaa853885
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
(cherry picked from commit 997d785418)
2019-03-06 02:36:38 +01:00
Matthias Sohn e8f7bb3608 Properly format pack checksums in PackFile.idx()
Change-Id: Id805850dbe9a3d633168f3056e06ddeafd86f961
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
(cherry picked from commit a33e4dc58a)
2019-03-06 02:36:38 +01:00
Matthias Sohn e8bd9556c0 Cancel gc if thread was interrupted
see
https://groups.google.com/d/msg/repo-discuss/oDB2rl3doDc/tFEh5Xt0CAAJ

Change-Id: Ia6d4631c64e065d8b9b09e0b45e7a9ea8ac3f41d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
(cherry picked from commit 882fed0d96)
2019-03-06 02:36:38 +01:00
Luca Milanesio daefa69502 PackFile: report correct message for checksum mismatch
When the packfile checksum does not match the expected one
report the correct checksum error instead of reporting that
the number of objects is incorrect.

Change-Id: I040f36dacc4152ae05453e7acbf8dfccceb46e0d
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
(cherry picked from commit 436c99ce59)
2019-03-06 02:36:38 +01:00
David Pursehouse e6fd4732d0 ObjectDirectory: Clean up logging
Externalize the message and log the pack file with absolute path.

Change-Id: I019052dfae8fd96ab67da08b3287d699287004cb
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
(cherry picked from commit 9665d86ba1)
2019-03-06 02:36:37 +01:00
Luca Milanesio baf1bb20d0 ObjectDirectory: extra logging on packfile exceptions
Display extra logging, including the exception with the associated
stacktrace, whenever a packFile can't be read and thus removed
from the packlist.

Change-Id: I97a4e31dc427bfcc0baae438dcbe2dcd4704b824
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
(cherry picked from commit 962babc4b2)
2019-03-06 02:36:37 +01:00
David Pursehouse 52179ee247 Merge branch 'stable-5.2'
* stable-5.2:
  Fix error log message in ObjectDirectory.handlePackError()
  Properly format pack checksums in PackFile.idx()
  Cancel gc if thread was interrupted
  PackFile: report correct message for checksum mismatch
  ObjectDirectory: Clean up logging
  Bazel: Stop using native.git_repository

Change-Id: Ib972641105cef8089791fc65389c4f43e218620a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-03-05 10:24:34 +09:00
David Pursehouse c2dbdabfb9 Merge branch 'stable-5.1' into stable-5.2
* stable-5.1:
  Fix error log message in ObjectDirectory.handlePackError()
  Properly format pack checksums in PackFile.idx()
  Cancel gc if thread was interrupted
  PackFile: report correct message for checksum mismatch
  ObjectDirectory: Clean up logging
  Bazel: Stop using native.git_repository

Change-Id: I42b72a3bba3b4c9389d91a1a35a8004836567e7c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-03-05 10:23:38 +09:00
Matthias Sohn 997d785418 Fix error log message in ObjectDirectory.handlePackError()
Change-Id: I154f392ad025c4b642eb1123d375a0afaa853885
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-03-04 13:51:12 +01:00
Matthias Sohn a33e4dc58a Properly format pack checksums in PackFile.idx()
Change-Id: Id805850dbe9a3d633168f3056e06ddeafd86f961
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-03-04 13:28:40 +01:00
Matthias Sohn 882fed0d96 Cancel gc if thread was interrupted
see
https://groups.google.com/d/msg/repo-discuss/oDB2rl3doDc/tFEh5Xt0CAAJ

Change-Id: Ia6d4631c64e065d8b9b09e0b45e7a9ea8ac3f41d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-03-03 18:35:04 +01:00
Luca Milanesio 436c99ce59 PackFile: report correct message for checksum mismatch
When the packfile checksum does not match the expected one
report the correct checksum error instead of reporting that
the number of objects is incorrect.

Change-Id: I040f36dacc4152ae05453e7acbf8dfccceb46e0d
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-03-03 17:52:33 +01:00
David Pursehouse 9665d86ba1 ObjectDirectory: Clean up logging
Externalize the message and log the pack file with absolute path.

Change-Id: I019052dfae8fd96ab67da08b3287d699287004cb
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-03-03 13:15:19 +09:00
Dave Borowitz ea54b6a5a7 ResolveMerger: Destroy TemporaryBuffer on unchecked exceptions
Previously, we called destroy() to delete the temp file on failure only
when catching an IOException, not a RuntimeException. Use a slightly
different construction with a finally block to ensure it's always
deleted on error (assuming the JVM is still healthy enough).

Change-Id: Ie201f3cfc81099ee1cafed066632da76223cef1f
2019-03-01 12:35:38 -08:00
Ivan Frade e1b1e01bec FetchV2Request: make getWantedRefs public
There are valid cases where a hook, invoked by ProtocolV2Hook
and probably implemented in a different package, is interested
in knowing the wanted refs in the request.

Increase visibility to public in the wanted-ref method.

Change-Id: I5da085ac7af4c396c1cb85e630f40a57fc70b33e
Signed-off-by: Ivan Frade <ifrade@google.com>
2019-02-28 23:49:19 -08:00
Terry Parker 875dccf33c Expose the filter blob limit in UploadPack
Similar to UploadPack.getDepth() to know the shallow clone depth, expose
the user-specified filter blob limit for partial clones.

Change-Id: I04bde06862a1cf8a9862d950c15023c49d16a2a6
Signed-off-by: Terry Parker <tparker@google.com>
2019-02-28 16:00:24 -08:00
Thomas Wolf f491af08ea Merge changes from topic 'rebase_compatibility'
* changes:
  RebaseCommand: tighten check for --preserve-merges on --continue
  RebaseCommand: use orig-head to abort
  RebaseCommand: use orig-head in addition to head
2019-02-26 16:22:22 -05:00
Jonathan Nieder 2fe1f0d638 Merge "Strongly reference indices in DfsPackFile" 2019-02-26 15:08:39 -05:00
Gunnar Wagenknecht 98df7ec801 Merge "On Windows use %APPDATA%\gnupg as GPG directory if it exists" 2019-02-26 14:46:51 -05:00
Christian Halstrick 20b633d95d Merge "Remove duplicate externalized message" 2019-02-26 07:35:52 -05:00
Thomas Wolf ca011107b8 On Windows use %APPDATA%\gnupg as GPG directory if it exists
Hard-coding ~/.gnupg for the GPG directory doesn't work on Windows,
where GnuPG uses %APPDATA%\gnupg by default. Make the determination
of the directory platform-dependent.

Bug: 544797
Change-Id: Id4bfd39a981ef7c5b39fbde46fce9a7524418709
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-02-26 12:49:59 +01:00
Thomas Wolf 4169a95a65 Remove duplicate externalized message
Instead of a new "unexpectedNlinkValue" message use the already
existing "failedAtomicFileCreation". Remove a stray double quote
from the latter.

Change-Id: I1ba5e9ea48d3f7615354b2ace2575883070b3206
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-02-26 11:53:49 +01:00
Thomas Wolf 38e5a75ce4 RebaseCommand: tighten check for --preserve-merges on --continue
With native git, .git/rebase-merge/rewritten exists actually in two
different cases:

* as a file in git rebase --merge recording OIDs for copying notes
* as a directory in git rebase --preserve-merges

Add a comment, and check for isDirectory() instead of exists().

Bug: 511487
Change-Id: I6a3317b4234d4f41c41b3004cdc7ea0abf2c6223
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-02-26 16:18:27 +09:00
Thomas Wolf a64fa0bd7f RebaseCommand: fix ONTO_NAME, and --preserve-merges is interactive
ONTO_NAME must be "onto_name", not "onto-name".

For native git, --preserve-merges is an interactive mode. Create the
INTERACTIVE marker file, otherwise a native git rebase --continue
will fall back into rebase --merge mode before git 2.19.0 since it
started looking for the REWRITTEN directory to make the distinction
only then.[1]

This allows a JGit interactive rebase to be continued via native git
rebase --continue.

[1] https://github.com/git/git/commit/6d98d0c0

Bug: 511487
Change-Id: I13850e0fd96ac77d03fbb581c8790d76648dbbc6
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-02-26 16:18:27 +09:00
Thomas Wolf 4ad53c0cbf RebaseCommand: use orig-head to abort
Aborting a rebase used ORIG_HEAD to reset. Strictly speaking this is
not correct, since other commands run during the rebase (for instance,
when the rebase stopped on a conflict) might have changed ORIG_HEAD.

Prefer the OID recorded in the orig-head file, falling back to the
older "head" file if "orig-head" doesn't exist, and use ORIG_HEAD only
if neither exists.

Bug: 511487
Change-Id: Ifa99221bb33e4e4754377f9b8f46e76c8936e072
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-02-26 16:18:27 +09:00
Thomas Wolf 60cf85a4a3 Fix core.autocrlf for non-normalized index
With text=auto or core.autocrlf=true, git does not normalize upon
check-in if the file in the index contains already CR/LFs. The
documentation says: "When text is set to "auto", the path is
marked for automatic end-of-line conversion. If Git decides that
the content is text, its line endings are converted to LF on
checkin. When the file has been committed with CRLF, no conversion
is done."[1]

Implement the last bit as in canonical git: check the blob in the
index for CR/LFs. For very large files, we check only the first 8000
bytes, like RawText.isBinary() and AutoLFInputStream do.

In Auto(CR)LFInputStream, ensure that the buffer is filled as much as
possible for the isBinary() check.

Regarding these content checks, there are a number of inconsistencies:

* Canonical git considers files containing lone CRs as binary.
* RawText checks the first 8000 bytes.
* Auto(CR)LFInputStream checks the first 8096 (not 8192!) bytes.

None of these are changed with this commit. It appears that canonical
git will check the whole blob, not just the first 8k bytes. Also
note: the check for CR/LF text won't work with LFS (neither in JGit
nor in git) since the blob data is not run through the smudge filter.
C.f. [2].

Two tests in AddCommandTest actually tested that normalization was
done even if the file was already committed with CR/LF.These tests
had to be adapted. I find the git documentation unclear about the
case where core.autocrlf=input, but from [3] it looks as if this
non-normalization also applies in this case.

Add new tests in CommitCommandTest testing this for the case where
the index entry is for a merge conflict. In this case, canonical git
uses the "ours" version.[4] Do the same.

[1] https://git-scm.com/docs/gitattributes
[2] https://github.com/git/git/blob/3434569fc/convert.c#L225
[3] https://github.com/git/git/blob/3434569fc/convert.c#L529
[4] https://github.com/git/git/blob/f2b6aa98b/read-cache.c#L3281

Bug: 470643
Change-Id: Ie7310539fbe6c737d78b1dcc29e34735d4616b88
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-02-26 16:18:27 +09:00
Thomas Wolf b4c212309b RebaseCommand: use orig-head in addition to head
Since 2011-02-10 (i.e., git 1.7.6)[1] native git uses "orig-head" for
REBASE_HEAD. JGit was still using "head". Currently native git has a
legacy fall-back for reading this, but for how long? Let's write to
both. Note that JGit never reads this file.

[1] https://github.com/git/git/commit/84df4560

Bug: 511487
Change-Id: Id3742bf9bbc0001d850e801b26cc8880e646abfc
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-02-26 16:18:27 +09:00
David Pursehouse e54243278f SHA1: Use externalized message in log
The non-externalized warning message says there is a "possible SHA-1
collision" but then the Sha1CollisionException is always thrown.

Replace the message with the existing externalised string that does
not say "possible".

Change-Id: I9773ec76b416c356e234a658fb119f98d33eac83
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-02-25 11:05:44 +09:00
David Pursehouse a5a62a4cdb JGitText: Remove unnecessary suffix from externalized message identifier
Change-Id: I7a3ade56c219826b81d33d1d52566a86ad2e853a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-02-25 11:05:44 +09:00
David Pursehouse 6305869bf1 FS_POSIX: Externalize log message
Change-Id: Ida538e05c4595fdce99f1fa87469a3be60160adb
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-02-25 11:05:42 +09:00
Minh Thai 01f084f5d9 Strongly reference indices in DfsPackFile
DfsBlockCache.Ref might get cleared out if the JVM is running out of
memory. As a result, the index is not persisted for the request and
will be reloaded unnecessarily.

Change-Id: I3b57ad5e6673f77f2dc66177a649ac412a97fe20
Signed-off-by: Minh Thai <mthai@google.com>
2019-02-21 16:48:43 -08:00
David Pursehouse 2902255526 Merge branch 'stable-5.3'
* stable-5.3:
  ObjectDirectory: extra logging on packfile exceptions
  Prepare 5.3.0-SNAPSHOT builds
  JGit v5.3.0.201901162155-m1
  Fix tools/version.sh
  JGit v5.3.0.201901161700-m1

Change-Id: I3c511fbc08f21eec5bb49d443de33d43094da4a4
2019-02-18 11:22:31 +09:00
David Pursehouse 9d02e52406 Merge branch 'stable-5.2' into stable-5.3
* stable-5.2:
  ObjectDirectory: extra logging on packfile exceptions

Change-Id: I4bbeb1d28ab042e3c6c74f7284f5d882ed034305
2019-02-18 11:21:38 +09:00
David Pursehouse 90876890bc Merge branch 'stable-5.1' into stable-5.2
* stable-5.1:
  ObjectDirectory: extra logging on packfile exceptions

Change-Id: Id2fea30664d53b31ad026ee5ae06a5a24d731a52
2019-02-18 11:20:56 +09:00
Matthias Sohn 3ae22bdf66 Add missing @since tag for new API method getUpdateIndex
Change-Id: Idd4a580e241a9105a55bc6f0457ad02a35e55faf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-02-17 20:58:25 -05:00
Matthias Sohn ae79969715 Fix NPE in PlotCommitList
Bug: 544513
Change-Id: I2fca766bbdc441a2dca947fba5dde532de7a10fd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-02-18 01:25:12 +01:00
David Pursehouse 0368906353 CommitBuilder: Deprecate setEncoding(String)
Deprecate the method in favor of setEncoding(Charset).

Update the only caller in the code base that was still using
the deprecated variant.

Change-Id: I6357f2d0c727007013c72e9d5b7c72a3f5f3f2b1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-02-18 00:14:35 +01:00
David Pursehouse e5c4057467 CommitBuilder: Add missing periods on methods' Javadoc
Change-Id: Ibcf64b23de8534f7831d6e40ee4b0ad2bade74ce
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-02-18 00:14:34 +01:00
Luca Milanesio 962babc4b2 ObjectDirectory: extra logging on packfile exceptions
Display extra logging, including the exception with the associated
stacktrace, whenever a packFile can't be read and thus removed
from the packlist.

Change-Id: I97a4e31dc427bfcc0baae438dcbe2dcd4704b824
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
2019-02-14 10:44:00 +09:00
Minh Thai 2b7fa04dad Fix bug in copyPackBypassCache's skip 'PACK' header logic
Bug caused the pack to be 12 bytes short when cold cache.  Also added
test for copyPackAsIs method.

Change-Id: Idf8fb0e50d1215245d4b032e2e00df4b218c115f
Signed-off-by: Minh Thai <mthai@google.com>
2019-02-13 12:48:05 -08:00
Thomas Wolf a29d11775c Atomic file creation: hard-linking may not be allowed
Android for instance forbids hard linking via a SELinux
policy. If we can't hard link, the NFS work-around for
atomic file creation cannot work at all. In this case,
fall back to not using the hard-linking mechanism.

Android throws an AccessDeniedException, so we catch that.
The javadoc on Files.createLink() indicates that another
possibility might be a SecurityException, so catch that,
too.

Bug: 543956
Change-Id: I551b7a45f7b2fbbd8cf94f0b7233dbd8a200520e
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-02-02 23:23:46 +01:00
Matthias Sohn 8cad84ccfb Fix GC.deleteEmptyRefsFolders
This method tried to iterate spurious files which may exist in the
.git/refs folder, e.g. on Mac a .DS_Store may have been created there by
inspecting the folder using the finder application. This led to a
NotDirectoryException when deleteEmptyRefsFolders tried to create an
iterator for such a file entry. Skip files contained in the refs folder
to ensure the method only tries to iterate contained folders but not
files.

Change-Id: I5f31e733072a35db1e93908a9c69a8891ae5c206
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-28 02:04:45 -05:00
Thomas Wolf e7b4d108e1 Enable cloning only specific tags
Single-branch-clone should be able to clone a single tag. Enhance
CloneCommand to accept also full refs of tags in setBranchesToClone().
Make sure we also include fetch ref specs for the fetch command for
tags. This mimics the behavior of native git's single-branch clone:
git clone --branch <tag> --single-branch <URI>

Bug: 542611
Change-Id: I285cf043751d9b0ba71258ee8214c0e5d1191428
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-01-27 22:56:06 +01:00
David Pursehouse afb6339314 Bazel: Format BUILD file with buildifier
$ buildifier -lint=fix BUILD

Change-Id: Ie2e069db3936ce6a85c4c29e6a0137cda5e21f09
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-01-24 11:43:37 +09:00
Thomas Wolf 447e107069 RenameBranchCommand: more consistent handling of short ref names
Several problems:

* The command didn't specify whether it expected short or full names.
* For the new name, it expected a short name, but then got confused
  if tags or both local and remote branches with the same name existed.
* For the old name, it accepted either a short or a full name, but
  again got confused if a short name was given and a tag with the
  same name existed.

With such an interface, one cannot use Repository.findRef() to
reliably find the branch to rename. Use exactRef() for the new
name as by the time the Ref is needed its full name is known.
For determining the old Ref from the name, do the resolution
explicitly: first try exactRef (assuming the old name is a full
name); if that doesn't find anything, try "refs/heads/<old>" and
"refs/remotes/<old>" explicitly. Throw an exception if the name
is ambiguous, or if exactRef returned something that is not a
branch (refs/tags/... or also refs/notes/...).

Document in the javadoc what kind of names are valid, and add tests.

A user can still shoot himself in the foot if he chooses exceptionally
stupid branch names. For instance, it is still possible to rename a
branch to "refs/heads/foo" (full name "refs/heads/refs/heads/foo"),
but it cannot be renamed further using the new short name if a branch
with the full name "refs/heads/foo" exists. Similar edge cases exist
for other dumb branch names, like a branch with the short name
"refs/tags/foo". Renaming using the full name is always possible.

Bug: 542446
Change-Id: I34ac91c80c0a00c79a384d16ce1e727c550d54e9
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-01-23 19:10:36 +01:00
Gunnar Wagenknecht c4420d2434 Allow to check for signing key
The new API is intended for UIs to check if signing will be possible or
would fail

Bug: 543579
Change-Id: I6ce1fd4210e46d49dcdf420c99d08c93e022136c
Signed-off-by: Gunnar Wagenknecht <gunnar@wagenknecht.org>
2019-01-22 03:38:36 -05:00
Thomas Wolf 55966dc592 Handle premature EOF in BundleFetchConnection
BundleFetchConnection.readLine() must abort on EOF, otherwise
it gets stuck in an endless loop.

Bug: 543390
Change-Id: I4cb3428560277888af114b928950d620bb6564f9
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2019-01-22 01:49:03 -05:00
David Pursehouse a0f69ff387 IO: Open TemporaryBuffer.Heap in try-with-resource
Change-Id: I78a947fd1263b47b3df17bcc6e9b32497e68dd4a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-01-21 14:19:29 +09:00
David Pursehouse d11a40a14c Scanner: Open RevWalk in try-with-resource
Change-Id: Ieeec292c1346edbda2b26f021e75cbc1435bb9f9
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-01-21 13:45:58 +09:00
David Pursehouse b7810bf5a8 RawParseUtils: Avoid import of java.nio.charset.StandardCharsets
The import is only needed because of a reference to it in the Javadoc,
and can be avoided by explicitly specifying the package instead, which
is how it's referenced in other cases (Constants, FileHeader).

Change-Id: I0c6254a9adf1f52fb8f2c04a858b11696ad264f5
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-01-20 20:27:12 +09:00
David Pursehouse 91b1fe4687 UploadPack: Suppress false-positive resource leak warning
Change-Id: Ida09cabb11740e6752a6f079d0528d38021fa2dd
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-01-20 17:41:59 +09:00
Matthias Sohn 23affa6c77 Prepare 5.3.0-SNAPSHOT builds
Change-Id: I9f0bf3ff2b26f4a8300c98206beb19c2b9d4946a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-17 04:23:42 +01:00
Matthias Sohn 05159ed656 JGit v5.3.0.201901162155-m1
Change-Id: I350925ff3b1fba2c83a448bc4e6d67368573693e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-17 04:17:18 +01:00
Matthias Sohn 8fc2aef89e JGit v5.3.0.201901161700-m1
Change-Id: I935cae5ae09ee5598ebdf6d9209048afec0d42dc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-17 02:39:39 +01:00
Medha Bhargav Prabhala 137e91a465 Implement signing commits using BouncyCastle
This also includes a change to generating the jgit CLI jar. Shading is
no longer possible because it breaks the signature of BouncyCastle.
Instead, the Spring Boot Loader Maven plug-in is now used to generate an
executable jar.

Bug: 382212
Change-Id: I35ee3d4b06d9d479475ab2e51b29bed49661bbdc
Also-by: Gunnar Wagenknecht <gunnar@wagenknecht.org>
Signed-off-by: Gunnar Wagenknecht <gunnar@wagenknecht.org>
Signed-off-by: Medha Bhargav Prabhala <mprabhala@salesforce.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-16 10:05:10 +01:00
Gunnar Wagenknecht 2343c688b1 Allow CommitCommand to sign commits
This change introduces the concept of a GpgSigner which will sign
commits. The GpgSigner will be of a specific implementation (eg.,
Bouncycastle or OpenPgP executable). The actual implementation is not
part of this change.

Bug: 382212
Change-Id: Iea5da1e885c039e06bc8d679d46b124cbe504c8e
Also-by: Medha Bhargav Prabhala <mprabhala@salesforce.com>
Signed-off-by: Medha Bhargav Prabhala <mprabhala@salesforce.com>
Signed-off-by: Gunnar Wagenknecht <gunnar@wagenknecht.org>
2019-01-16 10:05:09 +01:00
Jonathan Nieder 1131f35cd1 dfs: Remove synchronization in BlockBasedFile#LazyChannel
As explained in 'The "Double-Checked Locking is Broken"
Declaration'[*], Java's memory model does not support double-checked
locking:

 class LazyReadableChannel {
   private ReachableChannel rc = null;

   public ReadableChannel get() {
     if (rc == null) {
       synchronized (this) {
         if (rc == null) {
           rc = new ReadableChannel();
	 }
       }
     }
     return rc;
   }
 }

With JDK 5 and newer, there is a formal memory model that ensures this
works if "rc" is volatile, but it is still not thread-safe without
that.

Fortunately, this ReadableChannelSupplier is never passed between
threads, so it does not need to be thread-safe.  Simplify by removing
the synchronization.

[*] https://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html

Change-Id: I0698ee6618d734fc129dd4f63fc047c1c17c94a9
Signed-off-by: Jonathan Nieder <jrn@google.com>
2019-01-14 10:55:28 -08:00
Jonathan Nieder 5f355ed4ad UploadPack: Read wanted refs in one shot
This allows scanning through refs once instead of once per ref, which
should make the lookup less expensive for some RefDatabase
implementations.

Change-Id: I1434f834186cc9a6b4e52659e692b1000c926995
Signed-off-by: Jonathan Nieder <jrn@google.com>
2019-01-11 11:58:08 -08:00
Jonathan Nieder ec94268fd4 Merge branch 'stable-5.2'
* stable-5.2:
  Prepare 5.2.2-SNAPSHOT builds
  JGit v5.2.1.201812262042-r
  Prepare 5.1.6-SNAPSHOT builds
  JGit v5.1.5.201812261915-r
  UploadPack: Filter refs used for deepen-not resolution
  UploadPack: Avoid calling AdvertiseRefsHook twice
  Prepare 5.1.5-SNAPSHOT builds
  JGit v5.1.4.201812251853-r
  UploadPack: Filter refs used for want-ref resolution
  UploadPack: Defer want-ref resolution to after parsing
  Call AdvertiseRefsHook for protocol v2
  Prepare 4.11.7-SNAPSHOT builds
  JGit v4.11.6.201812241910-r
  Prepare 4.9.9-SNAPSHOT builds
  JGit v4.9.8.201812241815-r
  UploadPack: Test filtering by AdvertiseRefsHook in stateless transports
  Prepare 4.7.8-SNAPSHOT builds
  JGit v4.7.7.201812240805-r
  Fix feature versions imported by feature org.eclipse.jgit.pgm
  Prepare 4.5.6-SNAPSHOT builds
  JGit v4.5.5.201812240535-r
  Call AdvertiseRefsHook before validating wants

Change-Id: Ia56348e54d62630d7c50a4747df89516fc5afad9
Signed-off-by: Jonathan Nieder <jrn@google.com>
2019-01-10 20:23:33 -08:00
Minh Thai 513d80db10 Lazily open ReadableChannel in BlockBasedFile.getOrLoadBlock
To avoid opening the readable channel in case of DfsBlockCache
hits. Also cleaning up typos around DfsBlockCache.

Change-Id: I615e349cb4838387c1e6743cdc384d1b81b54369
Signed-off-by: Minh Thai <mthai@google.com>
2019-01-10 14:22:54 -08:00
Matthias Sohn 23c30c6310 Fix warnings for usage of deprecated RefDatabase#getRef
Change-Id: I22a244114ef973b3801cf3b639ff782f21c02f98
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-08 18:41:11 -05:00
Minh Thai 4207b8d6ae DfsBlockCache: Consolidate where ReadableChannel is opened
Opening a readable channel can be expensive and the number of channels
can be limited in DFS. Ensure that caller of
BlockBasedFile.readOneBlock() is responsible for opening and closing
the file, and that the ReadableChannel is reused in the request. As a side
effect, this makes the code easier to read, with better use of
try-with-resources.

The downside is that this means a readable channel is always opened, even
when the entire pack is already available for copying from cache. This
should be an acceptable cost: it's rare enough not to overload the server
and from a client latency perspective, the latency cost is in the noise
relative to the data transfer cost involved in a clone. If this turns out
to be a problem in practice, we can reintroduce that optimization in a
followup change.

Change-Id: I340428ee4bacd2dce019d5616ef12339a0c85f0b
Signed-off-by: Minh Thai <mthai@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
2019-01-08 14:31:56 -05:00
Minh Thai 8bc9acf264 DfsBlockCache to lock while loading object references
We see the same index being loaded by multiple threads. Each is
hundreds of MB and takes several seconds to load, causing server to
run out of memory.  This change introduces a lock to avoid these
duplicate works.  It uses a new set of locks similar in implementation
to the loadLocks for getOrLoad of blocks.  The locks are kept separate
to prevent long-running index loading from blocking out fast block
loading. The cache instance can be configured with a consumer to
monitor the wait time of the new locks.

Change-Id: I44962fe84093456962d5981545e3f7851ecb6e43
Signed-off-by: Minh Thai <mthai@google.com>
2019-01-08 09:59:40 -08:00
Christian Halstrick e406d500de Fix "jgit checkout -f" to overwrite dirty worktree files
CheckoutCommand had a setForce() method. But this didn't correspond
to native git's 'git checkout -f' option. Deprecate the old setForce()
method and move its implementation to a new method setForceRefUpdate()
and use it to implement the -B option in the CLI class Checkout.

Add a setForced() method and use it to fix the associated '-f' option of
the CLI Checkout class to behave like native git's 'git checkout -f'
which overwrites dirty worktree files during checkout.

This is still not fully matching native git's behavior: updating
additionally dirty index entries is not done yet.

Bug: 530771
Change-Id: I776b78eb623b6ea0aca42f681788f2e4b1667f15
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-08 10:01:09 +01:00
Mario Molina 6c8240a751 Return 'this' from setters in commands
To avoid breaking ABI, take the opportunity to give these setters
(hopefully sometimes better) names and deprecate their old names.

Change-Id: Ib45011678c3d941f8ecc1a1e0fdf4c09cdc337e3
Signed-off-by: Mario Molina <mmolimar@gmail.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
2019-01-07 20:00:11 -05:00
Jonathan Nieder d83e85736e Don't swallow IOException
Swallowing intermittent errors and trying to recover from them
makes JGit's behavior hard to predict and difficult to debug.

Propagate the errors instead.  This doesn't violate JGit's usual
backward compatibility promise for clients because in these
contexts an IOException indicates either repository corruption or
a true I/O error.  Let's consider these cases one at a time.

In the case of repository corruption, falling back e.g. to an empty
set of refs or a missing ref will not serve a caller well.  The
fallback does not indicate the nature of the corruption, so they are
not in a good place to recover from the error.  This is analogous to
Git, which attempts to provide sufficient support to recover from
corruption (by ensuring commands like "git branch -D" cope with
corruption) but little else.

In the case of an I/O error, the best we can do is to propagate the
error so that the user sees a dialog and has an opportunity to try
again.  As in the corruption case, the fallback behavior does not
provide enough information for a caller to rely on the current error
handling, and callers such as EGit already need to be able to handle
runtime exceptions.

To be conservative, keep the existing behavior for the deprecated
Repository#peel method.  In this example, the fallback behavior is to
return an unpeeled ref, which is distinguishable from the ref not
existing and should thus at least be possible to debug.

Change-Id: I0eb58eb8c77519df7f50d21d1742016b978e67a3
Signed-off-by: Jonathan Nieder <jrn@google.com>
2019-01-07 14:00:28 -05:00
Jonathan Nieder 3f9a5ce13f Deprecate Repository#hasObject
Its implementation contains

		} catch (IOException e) {
			// Legacy API, assume error means "no"
			return false;
		}

Better to use ObjectDatabase#has, which throws IOException to report
errors.

Change-Id: I7de02f7ceb8f57b2a8ebdb16d2aa4376775ff933
Signed-off-by: Jonathan Nieder <jrn@google.com>
2019-01-04 17:21:20 -08:00
Michael Keppler d8bb1d09d2 Deprecate RawParseUtils.UTF8-CHARSET
That constant is just a redirection to a java standard constant
meanwhile. It is not referenced anymore in jgit code (and egit is just
removing it). Clients can use the redirection target directly.

Change-Id: I058d013f61da8d7b771c499d8743aafb8faa5ea8
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-01-04 03:05:39 +01:00
Christian Halstrick 530812d936 Fix detection of "initial checkout"
A checkout done directly after cloning (the "initial
checkout") has a different semantic as a default
checkout. That is defined in the documentation of
"git read-tree" [1]. JGit was detecting that it is
doing an initial checkout differently from native
git: jgit used to check that the index is empty
but native git required that the index file does
not exist [2]. Teach JGit to behave like native
git.

[1] https://github.com/git/git/blob/master/Documentation/git-read-tree.txt#L187
[2] https://marc.info/?t=154150811200001&r=1&w=2

Change-Id: I1dd0f1ede7cd7ea60d28607916d0165269a9f628
2019-01-02 21:18:29 -05:00
Michael Keppler 0d9e486714 Replace deprecated FirstLine by FirstCommand
and allow package org.eclipse.jgit.http.server to use package
org.eclipse.jgit.internal.transport.parser.

Change-Id: Ief330c3e75a735853d0a5a265a9ff56fb5128b99
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-31 16:31:37 +01:00
Jonathan Nieder dbf6f9f692 Move BaseReceivePack#advertisedRefs getter and setter to ReceivePack
Another step toward merging BaseReceivePack into ReceivePack.

Change-Id: If861e28ce512f556e574352fa7d4a0df0984693f
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-29 11:59:27 +01:00
Jonathan Nieder 939723807e Move BaseReceivePack#walk getter to ReceivePack
Another step toward merging BaseReceivePack into ReceivePack.

Change-Id: I43cf2e36e2d5b0cd85bf23c81469909c14757b63
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-29 11:59:27 +01:00
Jonathan Nieder aaf41a51b7 Move BaseReceivePack#db getter to ReceivePack
Another step toward eliminating BaseReceivePack as a separate API.

Change-Id: If7b7d5c65a043607a2424211adb479fa33a9077b
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-29 11:59:27 +01:00
Jonathan Nieder 937beaa1ae Move BaseReceivePack#pushCert getter and setter to ReceivePack
This is a first step toward eliminating the BaseReceivePack API.

Inspired by a larger change by Dan Wang <dwwang@google.com>.

Change-Id: I5c876a67d8db24bf808823d9ea44d991b1ce5277
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-29 11:59:26 +01:00
Matthias Sohn e78776fa5b Remove unused API problem filters
Change-Id: I8ed98ac60362ba071506b0bdacd2941ab72b6bf4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-29 11:55:02 +01:00
Matthias Sohn bd6aa22333 Silence API error for RefDatabase.getRef declared final
RefDatabase.getRef was declared final in
c1954f6c36
which only affects implementers.

Change-Id: I4c14232a119670d263d88db2b8d725dcdd36ab2a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-29 01:07:24 +01:00
Matthias Sohn 7b989eed72 Suppress API errors and add missing @since tags caused by 6ea888a
Change-Id: Id042d46ba078af35b9c22a079da4ae14fc5fa231
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-29 00:17:33 +01:00
Jonathan Nieder 2f9ebeacc8 Merge changes Id3bb9443,I1be1948b
* changes:
  RefDatabase: Introduce findRef synonym for getRef
  RefDirectory: Look up several exact refs in one shot
2018-12-28 15:57:51 -05:00
Jonathan Nieder b4e415f8a9 Move first line parsing for v0 push out of BaseReceivePack
This simplifies the BaseReceivePack class and decreases its API
surface, which should make merging with ReceivePack easier.

Inspired by 6aca8899a5 (Move first line
parsing for v0/v1 pack negotiation out of UploadPack, 2018-09-17).

Change-Id: I1fc175d15aa7cb5968c26fc83a95480403af617c
2018-12-27 14:07:41 -08:00
Jonathan Nieder c1954f6c36 RefDatabase: Introduce findRef synonym for getRef
Using findRef instead of getRef makes it clearer that the caller wants
to search for the ref in the search path, instead of looking for a ref
that exactly matches the input.

This change introduces the new findRef method and deprecates getRef.
It updates Repository#findRef to use the new method, ensuring some
test coverage.  Other callers will be updated in followup changes.

A nice side effect of introducing the new findRef method is that it is
final and based on firstExactRef, so implementers can focus on
implementing the latter efficiently and do not have to carefully write
custom path search code respecting SEARCH_PATH.

Change-Id: Id3bb944344a9743705fd1f20193ab679298fa51c
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-12-26 20:49:35 -08:00
Jonathan Nieder d2bab65470 RefDirectory: Look up several exact refs in one shot
Override exactRef(String...) and firstExactRef(String...) with
implementations specific to FileRepository.

The specialized implementations are similar to the generic ones from
RefDatabase, but because these use readRef directly instead of
exactRef, they only need to call fireRefsChanged once.

This will allow replacing RefDirectory#getRef with a generic
implementation that uses firstExactRef without hurting performance.

Change-Id: I1be1948bd6121c1a1e8152e201aab97e7fb308bb
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-12-26 20:48:40 -08:00
Jonathan Nieder b2ec6405e4 RefDirectory: Do not use search path to find additional refs
Psuedorefs like FETCH_HEAD and MERGE_HEAD are supposed to be directly
under the .git directory, not in other locations in the SEARCH_PATH
like refs/ and refs/heads/.  Use exactRef to access them.

Change-Id: Iab8ac47008822fa78fc0691e239e518c34d7a98e
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-12-26 19:29:27 -08:00
Matthias Sohn 56562221d6 Prepare 5.2.2-SNAPSHOT builds
Change-Id: I9487f6a59ed684ad13bcfbff7d6c730ae4f37030
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-27 03:32:48 +01:00
Matthias Sohn 24e89950e7 JGit v5.2.1.201812262042-r
Change-Id: Idfefc54e898f364407a931b787a26db2489b031c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-27 02:44:17 +01:00
Matthias Sohn fafad4196d Prepare 5.1.6-SNAPSHOT builds
Change-Id: If3313d602aa57cfa031ba2c9ec03bd51b464dc19
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-27 01:35:30 +01:00
Matthias Sohn 510011b05c JGit v5.1.5.201812261915-r
Change-Id: I249a440d1ca1c997343da942ae55fcb27a645b92
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-27 01:16:15 +01:00
Jonathan Nieder 9895338de1 RefDatabase: Remove fallback exactRef implementation
This is simpler to implement than getRef.  Make it abstract so
implementers remember to override it.

Change-Id: I5f319be1fb1206d7a0142ea939dc4e1039f850ab
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-12-26 14:33:13 -08:00
Jonathan Nieder f46e223187 RefDirectory: Fire RefsChangedEvent on error, too
getRef and exactRef can produce recoverable exceptions --- for
example, a corrupt loose ref that cannot be parsed.  If readRef was
called and updated looseRefs in the process, RefsChangedEvent should
still be fired.

Noticed while improving the implementation of getRef.  This commit
only affects exactRef and getRef.  Other methods might be similarly
skipping firing RefsChangedEvent in their error handling code, and
this change does not fix them.

Change-Id: I0f460f6c8d9a585ad8453a4a47c1c77e24a1fb83
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-12-26 14:30:42 -08:00
Jonathan Nieder 32da5ac3c3 RefDirectory: Refactor getRef and exactRef to share code
Both getRef and exactRef look for a ref or pseudoref in the $GIT_DIR
directory, with careful error handling to handle non-refs like
.git/config.

Avoid the duplication by factoring out a helper that takes care of
this.  This should make the code easier to understand and manipulate.

Change-Id: I2ea67816d2385e84e2d3394b897e23df5826ba50
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-12-26 14:25:11 -08:00
Jonathan Nieder eb4c63fbbf UploadPack: Filter refs used for deepen-not resolution
Clients can use --shallow-exclude to obtain information about what
commits are reachable from refs they are not supposed to be able to
see.  Plug the hole by allowing the AdvertiseRefsHook and RefFilter to
take effect here, too.

Change-Id: If2b8e95344fa49e10a6a202144318b60d002490e
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-12-26 13:26:39 -08:00
Jonathan Nieder f909de5c44 Merge branch 'stable-5.1' into stable-5.2
* stable-5.1:
  UploadPack: Avoid calling AdvertiseRefsHook twice
  Prepare 5.1.5-SNAPSHOT builds
  JGit v5.1.4.201812251853-r
  UploadPack: Filter refs used for want-ref resolution
  UploadPack: Defer want-ref resolution to after parsing
  Call AdvertiseRefsHook for protocol v2
  Prepare 4.11.7-SNAPSHOT builds
  JGit v4.11.6.201812241910-r
  Prepare 4.9.9-SNAPSHOT builds
  JGit v4.9.8.201812241815-r
  UploadPack: Test filtering by AdvertiseRefsHook in stateless transports
  Prepare 4.7.8-SNAPSHOT builds
  JGit v4.7.7.201812240805-r
  Fix feature versions imported by feature org.eclipse.jgit.pgm
  Prepare 4.5.6-SNAPSHOT builds
  JGit v4.5.5.201812240535-r
  Call AdvertiseRefsHook before validating wants

Change-Id: I5879df9b723a0dbf6a1eff89a34bbb269f3b773d
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-12-26 13:26:23 -08:00
Jonathan Nieder 53ab1188d5 Merge branch 'stable-5.0' into stable-5.1
* stable-5.0:
  UploadPack: Avoid calling AdvertiseRefsHook twice

Change-Id: Ie9ce67921e38fff8338a148c4d9f2776be01d0b0
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-12-26 13:24:26 -08:00
Jonathan Nieder c961e2d773 UploadPack: Avoid calling AdvertiseRefsHook twice
The AdvertiseRefsHook can be called twice if the following conditions
hold:

 1. This AdvertiseRefsHook doesn't set this.refs.
 2. getAdvertisedOrDefaultRefs is called after getFilteredRefs.

For example, this can happen when fetchV2 is called after lsRefsV2
when using a stateful bidirectional transport.

The second call does not accomplish anything useful.  Guard it with
'if (!advertiseRefsHookCalled)' to avoid wasted work.

Reported-by: Jonathan Tan <jonathantanmy@google.com>
Change-Id: Ib746582e4ef645b767a5b3fb969596df99ac2ab5
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-12-26 13:19:01 -08:00
Jonathan Nieder f5bdb9745f Merge changes from topic 'update-index-ref-decorator'
* changes:
  RefCursor: Remove unnecessary getUpdateIndex method
  RefDatabase/Ref: Add versioning to reference database
2018-12-26 13:12:14 -05:00
Ivan Frade 3381bf7e6a RefCursor: Remove unnecessary getUpdateIndex method
Now the reference carries its updateIndex, so the cursor doesn't need
to expose it.

Change-Id: Icbfca46f92a13f3d8215ad10b2a166a6f40b0b0f
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-12-26 09:42:59 -08:00
Ivan Frade 6ea888a036 RefDatabase/Ref: Add versioning to reference database
In DFS implementations the reference table can fall out of sync, but
it is not possible to check this situation in the current API.

Add a property to the Refs indicating the order of its updates.  This
version is set only by RefDatabase implementations that support
versioning (e.g reftable based).

Caller is responsible to check if the reference db creates versioned
refs before accessing getUpdateIndex(). E.g:

   Ref ref = refdb.exactRef(...);
   if (refdb.hasVersioning()) {
       ref.getUpdateIndex();
   }

Change-Id: I0d5ec8e8df47c730301b2e12851a6bf3dac9d120
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-12-26 09:42:59 -08:00
Matthias Sohn d14209e81b Prepare 5.1.5-SNAPSHOT builds
Change-Id: I3eeb24b01a4f955e7e933238defb42635ebfec7d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-26 00:57:01 +01:00
Matthias Sohn c93aec2b73 JGit v5.1.4.201812251853-r
Change-Id: I30ba167bcd8144074553d7446a45fa6be19584fe
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-26 00:53:51 +01:00
Jonathan Nieder fcafdcc404 UploadPack: Filter refs used for want-ref resolution
In the longer term, we can add support for this to the
RequestValidator interface.  In the short term, this is a minimal
band-aid to ensure any refs the client requests are visible to the
client.

Change-Id: I0683c7a00e707cf97eef6c6bb782671d0a550ffe
Reported-by: Ivan Frade <ifrade@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-26 00:40:00 +01:00
Jonathan Nieder 1638a2fce8 UploadPack: Defer want-ref resolution to after parsing
ProtocolV2Parser explains:

  // TODO(ifrade): This validation should be done after the
  // protocol parsing. It is not a protocol problem asking for an
  // unexisting ref and we wouldn't need the ref database here.

Do so.  This way all ref database accesses are in one place, in the
UploadPack class.

No user-visible change intended --- this is just to make the code
easier to manipulate.

Change-Id: I68e87dff7b9a63ccc169bd0836e8e8baaf5d1048
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-26 00:39:44 +01:00
Matthias Sohn 25deb30460 Merge branch 'stable-5.0' into stable-5.1
* stable-5.0:
  Call AdvertiseRefsHook for protocol v2
  Prepare 4.11.7-SNAPSHOT builds
  JGit v4.11.6.201812241910-r
  Prepare 4.9.9-SNAPSHOT builds
  JGit v4.9.8.201812241815-r
  UploadPack: Test filtering by AdvertiseRefsHook in stateless transports
  Prepare 4.7.8-SNAPSHOT builds
  JGit v4.7.7.201812240805-r
  Fix feature versions imported by feature org.eclipse.jgit.pgm
  Prepare 4.5.6-SNAPSHOT builds
  JGit v4.5.5.201812240535-r
  Call AdvertiseRefsHook before validating wants

Change-Id: Icdc212bf5be2485d0f8028acf6c62fb8531d0e3c
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-25 23:58:53 +01:00
Masaya Suzuki 8eecb4f8b7 Call AdvertiseRefsHook for protocol v2
AdvertiseRefsHook is used to limit the visibility of the refs in Gerrit.
If this hook is not called, then all refs are treated as visible.

In protocol v2, the hook is not called, causing the server to advertise
all refs.  This bug was introduced in v5.0.0.201805221745-rc1~1^2~9
(Execute AdvertiseRefsHook only for protocol v0 and v1, 2018-05-14).

Even before then, the hook was not called in requests after the
capability advertisement, so in transports like HTTP that do not retain
state between round-trips, the server would advertise all refs in
response to an ls-refs (ls-remote) request.

Fix both cases by using getAdvertisedOrDefaultRefs to retrieve the
advertised refs in lsRefs, ensuring the hook is called in all cases that
use its result.

[jn: backported to stable-5.0; split out from a larger patch that also
 fixes protocol v0; avoided filtering this.refs by ref prefix]

Change-Id: I64bce0e72d15b90baccc235c067e57b6af21b55f
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-25 23:36:11 +01:00
Matthias Sohn 9caa94239a Merge branch 'stable-4.11' into stable-5.0
* stable-4.11:
  Prepare 4.11.7-SNAPSHOT builds
  JGit v4.11.6.201812241910-r
  Prepare 4.9.9-SNAPSHOT builds
  JGit v4.9.8.201812241815-r
  UploadPack: Test filtering by AdvertiseRefsHook in stateless transports
  Prepare 4.7.8-SNAPSHOT builds
  JGit v4.7.7.201812240805-r
  Fix feature versions imported by feature org.eclipse.jgit.pgm
  Prepare 4.5.6-SNAPSHOT builds
  JGit v4.5.5.201812240535-r
  Call AdvertiseRefsHook before validating wants

Change-Id: Ie81284ca6d580b0712c49eec610393d0c0c50203
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-25 23:27:13 +01:00
Matthias Sohn 23e4765a65 Prepare 4.11.7-SNAPSHOT builds
Change-Id: I97dc0f4aeb51c2084f40531ceac84e90bf70608d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-25 01:08:03 +01:00
Matthias Sohn cc76de549a JGit v4.11.6.201812241910-r
Change-Id: I21bfe7a76450184bce43cbe8ebcaa7891e4b12ed
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-25 00:56:54 +01:00
Matthias Sohn affbb99271 Merge branch 'stable-4.10' into stable-4.11
* stable-4.10:
  Prepare 4.9.9-SNAPSHOT builds
  JGit v4.9.8.201812241815-r
  UploadPack: Test filtering by AdvertiseRefsHook in stateless transports
  Prepare 4.7.8-SNAPSHOT builds
  JGit v4.7.7.201812240805-r
  Fix feature versions imported by feature org.eclipse.jgit.pgm
  Prepare 4.5.6-SNAPSHOT builds
  JGit v4.5.5.201812240535-r
  Call AdvertiseRefsHook before validating wants

Change-Id: I937e9a4547fc10e4de7c887163022d1ab0322d64
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-25 00:54:15 +01:00
Matthias Sohn 60a606a261 Merge branch 'stable-4.9' into stable-4.10
* stable-4.9:
  Prepare 4.9.9-SNAPSHOT builds
  JGit v4.9.8.201812241815-r
  UploadPack: Test filtering by AdvertiseRefsHook in stateless transports
  Prepare 4.7.8-SNAPSHOT builds
  JGit v4.7.7.201812240805-r
  Fix feature versions imported by feature org.eclipse.jgit.pgm
  Prepare 4.5.6-SNAPSHOT builds
  JGit v4.5.5.201812240535-r
  Call AdvertiseRefsHook before validating wants

Change-Id: I2e499f34b1c481af794fa9325b0dfebaccdf3cb0
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-25 00:41:41 +01:00
Matthias Sohn 8f1fd09bea Prepare 4.9.9-SNAPSHOT builds
Change-Id: I0f7238ce8f79063a410c85701020ffce2b1234cf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-25 00:10:49 +01:00
Matthias Sohn 67af2d46dd JGit v4.9.8.201812241815-r
Change-Id: Ic75e4611cce396b186680bc962f0c73b2ee5fff1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-25 00:01:29 +01:00
Matthias Sohn 3dd3fe9ea4 Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  Prepare 4.7.8-SNAPSHOT builds
  JGit v4.7.7.201812240805-r
  Fix feature versions imported by feature org.eclipse.jgit.pgm
  Prepare 4.5.6-SNAPSHOT builds
  JGit v4.5.5.201812240535-r
  Call AdvertiseRefsHook before validating wants

Change-Id: Ib44e314a68bca2349b45f4937257aa1298c8d74b
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-24 23:36:29 +01:00
Matthias Sohn a65ce1bfd1 Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  Prepare 4.7.8-SNAPSHOT builds
  JGit v4.7.7.201812240805-r
  Fix feature versions imported by feature org.eclipse.jgit.pgm
  Prepare 4.5.6-SNAPSHOT builds
  JGit v4.5.5.201812240535-r
  Call AdvertiseRefsHook before validating wants

Change-Id: I68a21067705b580b40840f8039001ff1e5273c15
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-24 23:27:25 +01:00
Matthias Sohn 391371cad2 Prepare 4.7.8-SNAPSHOT builds
Change-Id: Ic4ab4aae6d87392d1a5a8bbda06384b7a5b64182
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-24 23:16:19 +01:00
Matthias Sohn 4d32049bb3 JGit v4.7.7.201812240805-r
Change-Id: I57b6001b1fbd6042299ccd4dd7d70765a46ea10b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-24 13:50:12 +01:00
Matthias Sohn 193a164925 Merge branch 'stable-4.6' into stable-4.7
* stable-4.6:
  Fix feature versions imported by feature org.eclipse.jgit.pgm
  Prepare 4.5.6-SNAPSHOT builds
  JGit v4.5.5.201812240535-r
  Call AdvertiseRefsHook before validating wants

Change-Id: If637694f80dbd1e774d60c672fe78a6500650bb8
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-24 13:25:31 +01:00
Matthias Sohn 4ad74d2f9b Merge branch 'stable-4.5' into stable-4.6
* stable-4.5:
  Prepare 4.5.6-SNAPSHOT builds
  JGit v4.5.5.201812240535-r
  Call AdvertiseRefsHook before validating wants

Change-Id: I0fd67ddd9c4966c20d82cdfe78b2f9d4898b4665
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-24 12:09:39 +01:00
Matthias Sohn ce76f773f8 Prepare 4.5.6-SNAPSHOT builds
Change-Id: I57c55187ada6d824b94a17f5a79a5bcff61f9ee9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-24 12:00:26 +01:00
Matthias Sohn 40366c1cf5 JGit v4.5.5.201812240535-r
Change-Id: I6e89e937c08757887967d91afb39cfbe8372d6b5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-24 11:21:27 +01:00
Masaya Suzuki 61f0bd54d0 Call AdvertiseRefsHook before validating wants
AdvertiseRefsHook is used to limit the visibility of the refs in Gerrit.
If this hook is not called, then all refs are treated as visible,
causing the server to serve commits reachable from branches the client
should not be able to access, if asked to via a request naming a guessed
object id.

This bug was introduced in v2.0.0.201206130900-r~123 (Modify refs in
UploadPack/ReceivePack using a hook interface, 2012-02-08).  Stateful
bidirectional transports are not affected.

Fix it by moving the AdvertiseRefsHook call to
getAdvertisedOrDefaultRefs, ensuring the hook is called in all cases.

[jn: backported to stable-4.5 by splitting out tests and the protocol v2
 specific parts]

Change-Id: I159f396216354f2eda3968d17802e166d8c8ec2d
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-24 10:58:43 +01:00
David Pursehouse ccc21c7d4a JGitInternalException: Fix typo in Javadoc
Change-Id: I46fabab3cb2d9164234ce04de346826687a3fa35
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-12-22 08:06:40 +09:00
Mincong HUANG d09388e156 Avoid double words
Change-Id: I0fdf595cba93f5a5cdd0496cee07ac91db304532
Signed-off-by: Mincong Huang <mincong.h@gmail.com>
2018-12-21 08:07:08 +01:00
Matthias Sohn 8f11539265 Silence API error for 3 digit version number in @since tag
Change-Id: I4943d9338ddf294e2ef67f0d459a3030f528d0c9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-21 01:30:30 +01:00
David Pursehouse e6b4ae2e14 Remove unnecessary @since tags from non-API classes
Change-Id: I6bed174c062a0785641dc8ad69151bf7e843cdcf
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-12-20 20:02:31 +09:00
David Pursehouse 3e51a078d9 Merge branch 'stable-5.2'
* stable-5.2:
  BasePackConnection: Check for expected length of ref advertisement
  TransferConfig: Make constructors public
  Update last JGit version

Change-Id: I4406d4f68136a2ce363701324b9a842ad468bc59
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-12-20 15:55:02 +09:00
David Pursehouse 3cb80a433d Merge branch 'stable-5.1' into stable-5.2
* stable-5.1:
  BasePackConnection: Check for expected length of ref advertisement
  TransferConfig: Make constructors public

Change-Id: I2480a0455250ee381fae93cac2db30f8305fa6aa
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-12-20 14:02:19 +09:00
David Pursehouse f4fc6404ba BasePackConnection: Check for expected length of ref advertisement
When a server sends a ref advertisement using protocol v2 it contains
lines other than ref names and sha1s.  Attempting to get the sha1 out
of such a line using the substring method can result in a SIOOB error
when it doesn't actually contain the sha1 and ref name.

Add a check that the line is of the expected length, and subsequently
that the extracted object id is valid, and if not throw an exception.

Change-Id: Id92fe66ff8b6deb2cf987d81929f8d0602c399f4
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-12-20 11:41:02 +09:00
David Pursehouse 2269669fb1 TransferConfig: Make constructors public
UploadPack has a setTransferConfig method which allows to set the
transfer config, however since the constructors of TransferConfig
have the default package visibility it is not possible for any
application using UploadPack, for example Gerrit, to actually set
a transfer config.

Make the constructors public. This is consistent with the public
constructors for example on PackConfig.

Change-Id: I07080255838421871403b2b2bcc294aa8f621c57
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-12-20 08:37:45 +09:00
David Pursehouse 38d42d5ccd UploadPack: Rewrite setAdvertiseRefsHook to use ternary operator
This makes the implementation consistent with the other similar
methods in this class.

Change-Id: I007876aad883615d696c8eabc886818ae00b10ee
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-12-19 15:31:38 +09:00
David Pursehouse fc07fa26b9 UploadPack: Prevent setting null protocolV2Hook
The setProtocolV2Hook sets the protocolV2Hook to whatever value is
passed, which could be null, but the invocations of protocolV2Hook's
methods are not guarded by null-checks.

Annotate the parameter as @Nullable and set ProtocolV2Hook.DEFAULT
when null is passed. This makes the implementation consistent with
other similar methods that set a hook or filter with possible null
value.

Change-Id: I70919a3248d4c2658783941a37c47e437cff0baa
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-12-19 15:31:31 +09:00
David Pursehouse 3d203114bd UploadPack: Add @Nullable annotations
The class has several methods where passing a null parameter is
valid. Annotate those parameters as @Nullable.

Change-Id: Ie08893ee3ab34c1ffb2db875b4ab049ad065c697
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-12-19 15:31:25 +09:00
Matthias Sohn 57b8cf4261 Prepare 5.2.1-SNAPSHOT builds
Change-Id: I68d9f5b1c8ca8e8eada9143093dc4fa82519edd8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-07 01:46:38 +01:00
Matthias Sohn c84c08107d JGit v5.2.0.201812061821-r
Change-Id: I8528c913ad1a820ee9a2fa6be1c9125b518caefe
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-07 00:20:43 +01:00
Matthias Sohn 38da21d6b0 Prepare 5.3.0-SNAPSHOT builds
Change-Id: I8951c2cf650cc3e41d2baa0b330b94468cfed5c2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-12-03 02:32:49 +01:00
Thomas Wolf 450b196627 Include id_ed25519 in the known default identity files
Change-Id: I9fb30c8fbb65536782ee73644c8990eb6661c660
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-12-02 16:35:12 +01:00
Thomas Wolf a08ffb0444 Merge "Set git environment variables for hooks" into stable-5.2 2018-12-02 05:34:18 -05:00
Matthias Sohn 055c312bd1 Prepare 5.2.0-SNAPSHOT builds
Change-Id: I18646aaeee51047b234b758dcc1c2f89fd01b2f8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-11-30 22:57:04 +01:00
Thomas Wolf 9c755c9e7c Set git environment variables for hooks
Set GIT_DIR and GIT_WORK_TREE when calling hooks.

Bug: 541622
Change-Id: I6153d8a6a934ec37a3a5e7319c2d0e516f539ab7
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-11-30 00:37:03 +01:00
Matthias Sohn 12d840dfcb JGit v5.2.0.201811281532-m3
Change-Id: I79988b473d67e565d8f6bcac40ee9a14b26c9e60
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-11-28 21:35:26 +01:00
Christian Halstrick 158294f912 Merge "Fix IndexDiffs for git links" 2018-11-28 06:11:05 -05:00
David Pursehouse c5306b84ae Merge branch 'stable-5.1'
* stable-5.1:
  Fix DescribeCommand with multiple match options
  Fix git-describe tie-breakers

Change-Id: I64d9b0099fc0d8449ec08f0b5653572b5c2f840f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-11-27 20:01:45 +09:00
David Pursehouse 9372cf496f Merge branch 'stable-5.0' into stable-5.1
* stable-5.0:
  Fix DescribeCommand with multiple match options
  Fix git-describe tie-breakers

Change-Id: I63e7a56bb617b5ce8774e1dc7f5efdde25e7cd97
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-11-27 20:01:11 +09:00
David Pursehouse 28f0ef8509 Merge branch 'stable-4.11' into stable-5.0
* stable-4.11:
  Fix DescribeCommand with multiple match options
  Fix git-describe tie-breakers

Change-Id: Ibb98f143ee0ce7635beb30ec404b4134a73788f6
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-11-27 19:51:01 +09:00
Matthias Sohn 7c798905ed Remove unused externalized text "submodulesNotSupported"
This text is unused since d72b9328.

Change-Id: I82e5652e205d7b238ff8adc21994029b828b09f4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-11-27 03:48:09 -05:00
Thomas Wolf 4678f4b735 Fix IndexDiffs for git links
After cloning a repo with a submodule, non-recursively, JGit would
encounter in its TreeWalk in IndexDiff:

* first, a missing gitlink (in index & HEAD, not in working tree)
* second, the untracked folder (not in index and head, in working tree)

As a result, it would report the submodule as missing. Canonical git
reports a clean workspace.

The root cause of this is that the path of a gitlink "x" did
not compare equal to the path of a tree "x" in JGit.

Correct Paths.compare() to account for that. If two paths are otherwise
equal, then let gitlinks match both trees and files. Matching trees
solves the bug. Matching files is necessary to handle the case where
the gitlink directory was replaced by a file; see the new test case
IndexDiffSubmoduleTest.testSubmoduleReplacedByFile(). Comparisons of
unequal paths are left untouched, so the sort order is unchanged.

After the fix, another bug(?) in WorkingTreeIterator became apparent:
with core.dirNoGitLinks = true, it was no longer possible to overwrite
a gitlink in the index. This is now fixed in WorkingTreeIterator.

Add new test cases for the bug itself and for some related cases
(submodule directory deleted or replaced by a file) in
IndexDiffSubmoduleTest. Add a test for missing files in IndexDiffTest,
and adapt the PathsTest to test matching gitlinks.

Bug: 467631
Change-Id: I0549d10d46b1858e5eec3cc15095aa9f1d5f5280
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-11-26 20:53:42 +01:00
Matthias Sohn df6263644b Fix DescribeCommand with multiple match options
when multiple match options are given in git describe the result must
not depend on the order of the match options. JGit wrongly picked the
first match using the match options in the order they were defined. Fix
this by concatenating the streams of matching tags for all match options
and then choosing the first match on the concatenated stream sorted in
tie break order.

See https://git-scm.com/docs/git-describe#git-describe---matchltpatterngt

Change-Id: Id01433d35fa16fb4c30526605bee041ac1d954b2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-11-26 18:49:30 +01:00
Matthias Sohn 3f745e40a1 Add a method to get all values of HTTP header defined as list
According to RFC 2616 [1] header field names are case insensitive.
Header fields defined as a comma separated list can have multiple header
fields with the same field name. Add a method to HttpConnection which
retrieves all values with a given header field name with the field name
compared case insensitive.

[1] https://tools.ietf.org/html/rfc2616#section-4.2"

Change-Id: I7f601b21cda99e84f43f866c7c7cb4cb0e3cf5c3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-11-26 03:07:58 -05:00
Thomas Wolf f974c9c790 Undo treating blobs with NULs as a single line
This partially reverts commit a551b646: revert the changes in
RawParseUtils.lineMap(). Forcing all blobs containing a NUL byte
as a single line causes blame to produce useless results as soon
as it hits any version containing a NUL byte.

Doing binary detection at this level also has the problem that the
user cannot control it. Not by setting the text attribute nor in any
other way.

This came up in bug 541036, where a Java source inadvertently
contained NUL bytes in strings. Even fixing this by using escapes
"\000" will not fix JGit's blame for this file because the past
versions will still contain the NUL byte.

Native git can blame that file from bug 541036 fine.

Added new tests verifying that blaming a text file containing a NUL
byte produces sensible results.

Bug: 541036
Change-Id: I8991bec88e9827cc096868c6026ea1890b6d0d32
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-11-26 00:30:21 +01:00
Jonathan Nieder 647cc8f604 Remove unnecessary modifiers from interfaces
This continues what commit d9ac7ddf10
(Remove unnecessary modifiers from interfaces, 2018-11-15) started.

Change-Id: I89720985a5a986722a0dcb9b5e9bbc25996bd5b3
2018-11-20 16:18:44 -08:00
Gunnar Wagenknecht e751c878b0 New GpgConfig for typed access to GPG settings
Change-Id: Ifece38132e0390931d33b5678bbbd4a43f9099da
Signed-off-by: Gunnar Wagenknecht <gunnar@wagenknecht.org>
2018-11-20 19:35:50 +01:00
Masaya Suzuki 49befd84d7 Revert C Git 1.7.5 bug workaround
This reverts the workaround introduced by
1c6c73c5a9, which is a patch for dealing
with a buggy C Git client v1.7.5 in 2012. We'll stop supporting very old
C Git clients.

Change-Id: I94999a39101c96f210b5eca3c2f620c15eb1ac1b
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
2018-11-19 13:37:28 -08:00
Ivan Frade d9ac7ddf10 Remove unnecessary modifiers from interfaces
From Oracle's "Defining an interface":

"All abstract, default, and static methods in an interface are
implicitly public, so you can omit the public modifier."

(Without any modifier, the interface methods are also abstract, so we
omit also the "abstract")

"In addition, an interface can contain constant declarations. All
constant values defined in an interface are implicitly public, static,
and final. Once again, you can omit these modifiers."

This makes the code more consistent. Now all interfaces under
org.eclipse.jgit follow the guidelines.

Change-Id: I4fe6deb111899ec1b4318ab5a6050f3851fa1fd3
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-11-15 22:36:43 -08:00
David Pursehouse c56afbf18c Merge "Call unlockPack in finally" 2018-11-14 22:11:26 -05:00
Thomas Wolf 488d95571f Apache MINA sshd client
Add a new ssh client implementation based on Apach MINA sshd 2.0.0.

This implementation uses JGit's own config file parser and host entry
resolver. Code inspection of the Apache MINA implementation revealed
a few bugs or idiosyncrasies that immediately would re-introduce bugs
already fixed in the past in JGit.

Apache MINA sshd is not without quirks either, and I had to configure
and override more than I had expected. But at least it was all doable
in clean ways.

Apache MINA boasts support for Bouncy Castle, so in theory this should
open the way to using more ssh key algorithms, such as ed25519.

The implementation is in a separate bundle and is still not used in
the core org.eclipse.jgit bundle. The tests re-use the ssh tests from
the core test bundle.

Bug: 520927
Change-Id: Ib35e73c35799140fe050d1ff4fb18d0d3596580e
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-11-13 10:49:26 -08:00
Thomas Wolf 0173b25415 Add more ssh tests: pushing, known_host file handling, etc.
Add support for git-receive-pack to the ssh git server and add two
new tests for pushing.

This actually uncovered an undocumented requirement in TransportSftp:
the FTP rename operation assumes POSIX semantics, i.e., that the
target is removed. This works as written only for servers that
support and advertise the "posix-rename@openssh.com" FTP extension.

Our little Apache MINA server does not advertise this extension.

Fix the FtpChannel implementation for Jsch to handle this case in a
meaningful way so that it can pass the new "push over sftp" test.

Add more tests to test the behavior of server host key checking.

Also refactor the tests generally to separate better the test
framework from the actual tests.

Bug: 520927
Change-Id: Ia4bb85e17ddacde7b36ee8c2d5d454bbfa66dfc3
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-11-13 10:49:26 -08:00
Thomas Wolf 705691ee51 TransportSftp: eliminate dependency on Jsch
Introduce an FtpChannel abstraction, which can be obtained from a
RemoteSession. In JSchSession, wrap a JSch ChannelSftp as such an
FtpChannel. The JSch-specific SftpException is also mapped to a
generic FtpException. Rewrite TransportSftp to use only the new
abstraction layer.

This makes it possible to provide alternate ssh/sftp implementations.

Bug: 520927
Change-Id: I379026f7d4122f34931df909a28e73c02cd8a1da
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-11-13 10:46:00 -08:00
Masaya Suzuki ad379793c7 Call unlockPack in finally
The lock is obtained in receivePackAndCheckConnectivity. It seems to me
the structure that requres the caller to unlock the lock is wrong, but
at least by calling in finally ensures it is called even if an exception
is thrown.

Change-Id: I123841b017baf5acffe0064d1004ef11a0a5e6c2
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
2018-11-11 17:28:20 -08:00
Michael Keppler ddde209655 Remove line break from sslFailureInfo text
Do not add an artificial line break to the message, since it may become
much wider due to the embedded exception messages anyway.

The layout shall be controlled by the egit supplied message dialog using
layout constraints.

Bug: 540537
Change-Id: I4257b52e5e59689dfcbab47bd7c075b3fd031837
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
2018-11-11 11:35:44 +01:00
Håvard Wall f9de917547 Fix git-describe tie-breakers
Correct behaviour as git 1.7.1.1 is to resolve tie-breakers to choose
the most recent tag.

https://github.com/git/git/blob/master/Documentation/RelNotes/1.7.1.1.txt:
* "git describe" did not tie-break tags that point at the same commit
   correctly; newer ones are preferred by paying attention to the
   tagger date now.

Bug: 538610
Change-Id: Ib0b2a301997bb7f75935baf7005473f4de952a64
Signed-off-by: Håvard Wall <haavardw@gmail.com>
2018-11-09 08:54:44 +01:00
David Pursehouse 54dd1d112a Merge changes I97c062d0,Ib4e1f37c
* changes:
  Simplify RevWalk#iterator by factoring out common code
  Simplify exception handling in RevWalk#iterator
2018-11-08 22:51:48 -05:00
Jonathan Nieder a0cd400c37 Simplify RevWalk#iterator by factoring out common code
Factor out a helper that calls next() and tunnels IOException in a
RuntimeException, similar to TunnelException.tunnel(RevWalk::next) in
Guava terms[1].

This should make the code a little more readable.  No functional
change intended.

[1] https://github.com/google/guava/issues/2828#issuecomment-304187823

Change-Id: I97c062d03a17663d5c40895fd3d2c6a7306d4f39
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-11-08 18:19:01 -08:00
Jonathan Nieder aeba003200 Simplify exception handling in RevWalk#iterator
MissingObjectException and IncorrectObjectTypeException are subclasses
of IOException.

Change-Id: Ib4e1f37ce1b0b08e69ba3375bbdb6ee82ee4f036
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-11-08 17:55:19 -08:00
Jonathan Tan df21eec1ad DepthGenerator: fix multi-child boundary handling
Suppose that a repository has the following commit graph:

 B   C
  \ /
   A

and it was cloned with --shallow-exclude=A. DepthGenerator does not mark
C as shallow, causing an invalid repository to be produced on the
client, because A is not sent. (A similar issue occurs when
--shallow-since is used to exclude A but neither B nor C.)

This happens whenever an excluded commit has more than one child that is
to be sent to the client. Fix DepthGenerator to handle this case
correctly.

While we're editing DepthWalk.Commit, fix the documentation of
DepthWalk.Commit#isBoundary.

Change-Id: I7068abf0fe0c864d1b0e56e1616dad1aa8719411
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
2018-11-08 15:33:23 -08:00
Thomas Wolf cc000f93a8 Factor out a JSch-independent ssh config parser
Move the bulk of the basic parsing and host entry handling into a
new class OpenSshConfigFile that has no dependencies on any concrete
ssh implementation. Make the existing OpenSshConfig use the new
parser.

Introduce a new class SshConstants collecting all the various ssh-
related string literals. Also use TreeMaps with a case-insensitive
key comparator instead of converting keys to uppercase. Add a test
to verify that keys are matched case-insensitively.

Most of the parsing code was simply moved, except that the new
parser supports looking up entries given host name, port, and user
name, and can thus handle more %-substitutions correctly. This
feature is not yet used and cannot be used with JSch since JSch
only has a ConfigRepository.getConfig(String) interface.

The split is still worth the trouble as it opens the way to using
another ssh client altogether. Apache MINA sshd, for instance,
resolves host entries giving host name, port, and user name.

(Apache MINA has a built-in ssh config handling, but that has
problems, too: its pattern matching is case-insensitive, and its
merging of host entries if several match is not the same as in
OpenSsh. But with this refactoring, it will be possible to plug in
OpenSshConfigFile into an Apache MINA sshd  client without dragging
along JSch.)

One test case that doesn't make sense anymore has been removed. It
tested that repeatedly querying for a host entry returned the same
object. That is no longer true since the caching has been moved to
a deeper level.

Bug: 520927
Change-Id: I6381d52b29099595e6eaf8b05c786aeeaefbf9cc
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-11-06 13:17:22 +01:00
Thomas Wolf f8d2738ff4 Fix package exports in org.eclipse.jgit MANIFEST.MF
Do not export o.e.j.internal.transport.parser as public package;
restrict visibility to org.eclipse.jgit.test only.

Add two packages that were not listed at all (o.e.j.internal.revwalk
and o.e.j.internal.submodule) marked as x-internal:=true.

Change-Id: I9188356075515ad354b724102fbd6304b682de6a
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-11-05 12:56:36 +01:00
Thomas Wolf 2429ea2c41 TransportSftp: remove final modifiers from parameters
Change-Id: I1b12a9765575a1368e0c6bd11d87084b2064a17e
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-11-05 12:08:55 +01:00
Matthias Sohn 00472a6d7c Silence API errors introduced by f648a3bd
The removed method and the new interface method only affect implementors
which is ok in a minor release following OSGi semantic versioning.

Change-Id: Ia5e55bd803965c7590c9278eecc6bdd36241383f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-11-01 20:28:00 +01:00
Ivan Frade e64ce267f8 RepoCommand: Preserve executable bit in <copyfile>
The copyfile entry in the manifest file copies the contents of the file
but doesn't keep the executable flag. This is inconsistent with repo
tool behaviour, plus is natural to expect that the copy of a executable
file is executable.

Transfer the executable bit when copying the file, aligning the
RepoCommand with repo tool and user expectations.

Change-Id: I01b24f482d5939e01d496f032388b3a5c02a912a
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-31 16:40:12 -07:00
Ivan Frade f648a3bd81 RepoCommand.RemoteReader: Add method to read contents and mode of file
The RepoCommand.RemoteReader interface doesn't offer access to the mode
of a file. Caller can only default to mark the copied objects as regular
files, losing e.g. the executable bit (if set).

Add a new method readFileWithMode that returns the contents and mode of
the remote file. It supersedes the readFile method, that is marked as
deprecated.

Now callers can set correctly the file mode of the copied file.

Change-Id: I8fce01e4bc5707434c0cbc4aebbae1b6b64756f0
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-31 16:40:06 -07:00
Matthias Sohn 6f359c1709 Silence API errors for new methods added to DepthWalk
237abe6a added method getDeepenNots() with a default implementation and
method getDeepenNotFlag() to the interface DepthWalk. This affects
implementers which is ok in minor release following OSGi semantic
versioning.

Change-Id: I1c872da261fc6825e1e310127761b8b8a6d397d4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-29 00:43:48 +01:00
Matthias Sohn 06bce43338 Remove unused text "symlinkCannotBeWrittenAsTheLinkTarget"
The only reference to this externalized text was deleted in c88d34b0.

Change-Id: Iecc7cc89192d69431dddb6550a02f66f0b09accc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-28 14:43:38 +01:00
Michael Keppler d9e67c8d8f Fix typos
s/occured/occurred/
s/stablished/established/

Change-Id: Ib052bef60bd18043001a30ed43754ee1a5182016
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-28 14:41:22 +01:00
Marc Strapetz aaf71bfbcc gitignore/gitattributes: fix matching of \r
Patterns should treat \r in file names as normal characters

Change-Id: Ica3e0fa4a58acf5326db46bb28571fe5f20f6cd2
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
2018-10-27 04:24:05 -04:00
Dave Borowitz 0e5cc09afe Merge "InternalPushConnection: don't swallow RuntimeException" 2018-10-25 10:35:43 -04:00
Jonathan Tan 237abe6ab5 UploadPack: Implement deepen-not for protocol v2
This allows clients to use the --shallow-exclude parameter (producing a
"deepen-not <ref>" line when communicating with the server) in their fetch
commands when fetching against a JGit server using protocol v2.

Note that the implementation in this commit is somewhat inefficient, as
described in the TODO comment in DepthGenerator.

Change-Id: I9fad3ed9276b624d8f668356ffd99a067dc67ef7
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
2018-10-23 17:13:09 -07:00
Jonathan Tan f5fa1eaf39 Throw error when deepen-since excludes all commits
In C Git, when a client fetches with "git fetch --shallow-since=<date>
origin <ref>", and all commits reachable from <ref> are older than
<date>, the server dies with a message "no commits selected for shallow
requests". That is, (1) the --shallow-since filter applies to the commit
pointed to by the ref itself, and (2) there is a check that at least one
commit is not filtered out. (The pack-protocol.txt documentation does
not describe this, but the C implementation does this.)

The implementation in commit 1bb430dc21 ("UploadPack: support
deepen-since in protocol v2", 2018-09-27) does neither (1) nor (2), so
do both of these.

Change-Id: I9946327a71627626ecce34ca2d017d2add8867fc
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
2018-10-23 11:10:07 -07:00
Jonathan Nieder a579a56e3a Merge changes from topic 'moving-to-request-2'
* changes:
  UploadPack v0: Extract "agent" client capability at parse time
  UploadPack: Return correct peer user agent on v2 requests
2018-10-22 13:49:38 -04:00
Ivan Frade 94a3d8bae9 UploadPack v0: Extract "agent" client capability at parse time
The request receives a list of capabilities and takes out the "agent" to
offer it on its own setter (getAgent).

Do this at parse time: when reading the line if the capability is
"agent" set it directly in the builder.

This makes the treatment of "agent" consistent in v0/v1 and v2.

Change-Id: Ie4f9f2cad8639adeeaef4921df49a30a8ce5b42f
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-22 10:23:15 -07:00
Markus Keller 8420c729a0 Make PrePushHook properly terminate ref lines
All of the input lines passed to pre-push hook scripts must be properly
terminated by '\n', so that normal shell scripts like the git-supplied
pre-push.sample work properly, even when pushing just a single branch.

With the old code, hook scripts that use the following pattern didn't
process the last line, because 'read' has a non-zero exit status when
EOF is encountered:
  while read local_ref local_sha remote_ref remote_sha; do ... done

Change-Id: Id899662ed3fedef6c314fc4b2ddf91a6dcb98cbb
Signed-off-by: Markus Keller <markus.kell.r@gmail.com>
2018-10-21 17:07:58 -04:00
David Pursehouse e4fdc571c9 RemoteRefUpdate#toString: Fix indentation
Change-Id: Ide2a7e914ab0ff50cf34ff5bc6df3219efe4ba96
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-21 20:05:56 +09:00
Michael Keppler f2db2a1f65 [releng] Fix boxing warning
Use Integer.valueOf() to avoid the warning by implicit conversion due to
usage as argument object in String.format().

Change-Id: Ib314f629d54ae1ce9729c3837d66ce8982a1898a
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
2018-10-20 15:20:51 +02:00
Ned Twigg d056a54384 CheckoutCommand: force flag now allows overwrite
Before this commit, a force checkout would fail if there
were any conflicting files. After this commit, a force
checkout will overwrite the conflicting files, as expected.

Making this work required fixing a bug in DirCacheCheckout.
Before this commit, when DirCacheCheckout had
failOnConflict=false, it would delete all conflicting files
from the working copy and just leave them missing. After
this commit, DirCacheCheckout overwrites conflicting files
with the merge tree.

This change in DirCacheCheckout causes "reset --hard" and
"revert --abort" to behave as expected (previously they
would simply delete conflicting files, now they will be
overwritten from the merge tree).

Change-Id: If7e328ee792ef6511ab7d9c26d8d77c39210ec9f
Signed-off-by: Ned Twigg <ned.twigg@diffplug.com>
2018-10-20 06:53:23 -04:00
Matthias Sohn b65e247568 Prepare 5.1.4-SNAPSHOT builds
Change-Id: Iee86860f3b4eb9f4af818c60342fd29465c0474c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-20 10:39:16 +02:00
Matthias Sohn cf24983b23 JGit v5.1.3.201810200350-r
Change-Id: Ib2c5a79d4fdf77680b7b65652fc3659527df27ad
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-20 09:50:16 +02:00
Matthias Sohn 9b6d30f2c1 Prepare 4.11.6-SNAPSHOT builds
Change-Id: Ic823775aad59530f516602e7e848474d65763314
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-20 02:08:35 +02:00
Ivan Frade 8d4f8d55d3 UploadPack: Return correct peer user agent on v2 requests
UploadPack.getPeerUserAgent() doesn't produce the expected results for
protocol v2 requests. In v2, the agent reported in the request (in an
"agent=" line) is not in the clientCapabilities but in a field on its
own. This makes getPeerUserAgent default to the transport user agent.

Making "agent" a shared property between protocol v0/v1 and v2 fixes the
problem, simplifies the function and harmonizes the implementation
between protocol versions.

In a follow up commit the "agent" will be identified on parsing time,
instead of taking it from the client capabilities.

Change-Id: Idf9825ec4e0b81a1458c8e3701f3e28aafd8a32a
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-19 16:55:56 -07:00
Matthias Sohn 92aca6195d JGit v4.11.5.201810191925-r
Change-Id: I9d11536062de74775ca545c26f341610d0ddaeb2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-20 01:27:52 +02:00
Matthias Sohn 7ae004509c Prepare 4.9.8-SNAPSHOT builds
Change-Id: Iab7b0f2a21a76f801a83fbeb54f09d1525878f4d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-20 00:10:02 +02:00
Matthias Sohn 97534056fc JGit v4.9.7.201810191756-r
Change-Id: Ib980731eb9ec7f4c92deac9b4cf2f7a994d670c2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-19 23:58:47 +02:00
Matthias Sohn 97b62cf9dd Update API problem filter
Change-Id: Iba8650900d3936edccbe30de9d3eafd4f9e0dba6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-19 23:54:38 +02:00
Ivan Frade 40f5b28545 Accept protocol v2 server options on fetch and ls-refs requests
In protocol v2, a command request can be followed by server options
(lines like "agent=<>" and "server-option=<>"), but current code
doesn't accept those lines.

Advertise the "server-option" capability, parse the lines and add
them to the request objects.

Other code in JGit can see this options and act accordingly via the
protocol v2 hooks.

This should not require any change in the client side.

Change-Id: If3946390f9cc02d29644b6ca52534b6f757bda9f
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-19 14:04:02 -07:00
Matthias Sohn d6c587faef Prepare 4.7.7-SNAPSHOT builds
Change-Id: I131e40cbbf32bc75d2ed24ca31ba3613a3bbca25
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-19 22:27:47 +02:00
Matthias Sohn b811e4fc51 JGit v4.7.6.201810191618-r
Change-Id: Iaee27d5e2de016240f1a0940653fef82c6044a1d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-19 22:18:38 +02:00
Matthias Sohn 2674bec32b Update API problem filter
Change-Id: I66c0c490bb66adafac5d670d2d9571f1674a281e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-19 22:15:39 +02:00
Ivan Frade 0691c4b94b UploadPack: Use request instead of field for client capabilities
Change-Id: Idc21e2b3fd145d2a4b15c1cea5ec1956541e3b40
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-19 11:01:28 -07:00
David Pursehouse 95579e6af3 Merge branch 'stable-5.1'
* stable-5.1:
  ssh: Prefer algorithms of the known host keys

Change-Id: I4868359c9df75cb2c51331789cb9f34473801569
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-19 08:06:45 +09:00
Ivan Frade 7fde9ab8d2 UploadPack.FirstLine: Revert renaming of getOptions into getCapabilities
This is public facing, stable API.

Fortunately, this class is deprecated and will be removed in the next
major version bump.

Change-Id: I91193964732e9d1943e9dc613256196e9c9d1274
Signed-off-by: Ivan Frade <ifrade@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-18 15:54:46 -07:00
Saša Živkov b6e2800560 ssh: Prefer algorithms of the known host keys
JSch prefers ssh-rsa key type. When the remote server supports ssh-rsa
key type then this key type will be used even if the known_hosts file
contains a host key for that host, but with different key type.
This caused an unexpected UnknownHostKey error.

To fix the issue first scan the known_hosts, the HostKeyRepository in
JSch API, for any already existing host keys for the target host and
modify the default session settings to prefer their algorithms. However,
do this only if there is no HostKeyAlgorithms setting active.

Change-Id: I236df2a860ddd9289a0a820ddf09c2dea3673d36
2018-10-18 11:59:16 +02:00
David Pursehouse 7ebd434e91 Disable Eclipse warning about unrecognized @SuppressWarnings value
The code base has several @SuppressWarnings annotations to suppress
warnings raised by Error Prone, but those are not recognized by
Eclipse and there is currently no way to tell it about them [1].

Suppress them for now.

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=392045

Change-Id: I3de7cfa8ad4370ca5be71e1303879c73ab6829c1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-17 10:40:36 +09:00
Ivan Frade 13b3881b3e UploadPack: Use request instead of field for clientShallowCommits
Yet another member to field transition.

Change-Id: Ic801f4ac3a270b287591ef3cf722c399126ccdd4
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-16 16:13:04 -07:00
Ivan Frade 9694d89ea1 UploadPack: Use request instead of field for depth
One more step in removing state from UploadPack, using the request
object instead.

Unfortunately, hooks get from UploadPack information about the current
request. Changing the hooks to receive the request is a public API
change, so at the moment lets keep a reference to the current request.

This kills half the benefit of using a request object vs fields, but
at least we still get better modularity.

Change-Id: I86803d876a621b727c66ee73f2880c93190629e9
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-16 16:13:04 -07:00
Ivan Frade 81a752bef7 UploadPack: Use request instead of field for shallowSince
Change-Id: I1b9fdb6c58c574f66dbd152c1049ddcd52cc1683
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-16 16:13:04 -07:00
Ivan Frade 3c974d0251 UploadPack: Use request in computeShallowUnshallow
All data required in this function is available in the request object.
Use that object instead of class members. This reduces class state and
is more readable.

Make the function use a request object and remove the now unnecessary
field "deepenNotRefs".

Change-Id: If861e44c2860a78cf19f456d1b3feb7ddc314cce
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-16 16:13:04 -07:00
Ivan Frade b41d7624b8 Move deepenSince and deepenNotRefs up to FetchRequest
These properties are protocol v2 specific, but they have clear default
no-op values and having them in the common superclass simplifies client
code.

Move properties deepenSince and deepenNotRefs up to FetchRequest. In
FetchV0Request, they are initialized with their no-op values (0 for
deepenSince and empty list for deepenNotRefs)

Change-Id: I9d46a6dfbe29ebd794b5a6482033cdc70d411a23
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-16 16:12:59 -07:00
Ivan Frade 2bedc6e08b UploadPack: Use request instead of field for filterBlobLimt
filterBlobLimit is not part of the UploadPack state, and as field
of the class is difficult to see where it is set or accessed.

Use the request object instead of a field. This reduces
UploadPack state and makes clearer how the value is used.

Change-Id: I96a04a5a8b31bf2243de701e1fd7ebb4080b49e2
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-16 11:17:42 -07:00
Ivan Frade ec838fee0c Mark fetch requests fields as final and @NonNull when possible
Mark reference fields as final, annotate constructor parameters and
getters as @NonNull when appropiate and assert the incoming references
are non-null.

Change-Id: I0ef9a513a99313bf461fe9629ce6cc8b409bdedb
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-16 11:11:26 -07:00
Ivan Frade 1a0b48fecd Create FetchRequest superclass with common elements
Some code apply to both, v1 and v2 requests, so it should receive
just a request instance.

Move all common fields to an abstract superclass that can be passed
to "version neutral" functions.

Change-Id: I47c22fb12065bc93767f78175e2b36cc43ccb5c5
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-15 16:37:22 -07:00
Ivan Frade 8460ab8e87 Rename Fetch V2 request wantsIds and options
In FetchV0Request, the fields "wantsIds" and "options" are called
"wantIds" and "clientCapabilities". Those names describe them better.

Rename FetchV2Request fields to follow fetch v0. This will make easier
to extract a superclass later.

Take also the chance to polish the javadoc.

Change-Id: Ia17dbbab8084f39cc529fef9ca5c65e189073767
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-15 16:27:58 -07:00
Ivan Frade 7d7b8dec56 Move protocol v0/v1 parsing to its own class and request objects
Protocol v0/v1 parsing code doesn't have any real dependency on UploadPack.

Move it to its class and use a request object to read the data in
UploadPack.

This makes the code easier to test, keeps similar structure than protocol v2,
reduces the line count of UploadPack and paves the way to remove the
members as implicit parameters in it.

Change-Id: I8188da8bd77e90230a7e37c02d800ea18463694f
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-15 16:27:55 -07:00
Han-Wen Nienhuys 8a5b044a99 InternalPushConnection: don't swallow RuntimeException
Uncaught exceptions are handled by java.lang.Thread's handler, which
prints it to stderr.

This is useful because InternalPushConnection is used in tests, and
during development, the server side may have programming errors that
manifest as RuntimeExceptions.

Before this change, all types of failures would lead to a uniform
failure message "test://test/conn0: push not permitted" on the client.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I0983cbeb86d36fa7a9313373f5fce54971f804ec
2018-10-15 16:45:19 +02:00
David Pursehouse 33744a2dfe Merge branch 'stable-4.6' into stable-4.7
* stable-4.6:
  Replace Findbugs with Spotbugs in org.eclipse.jgit/pom.xml
  Replace FindBugs with SpotBugs

Change-Id: I24417e4ebbba31f7ff6896d585ef807327411392
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-13 09:18:03 +09:00
David Pursehouse 27f7a590d1 Merge branch 'stable-4.5' into stable-4.6
* stable-4.5:
  Replace Findbugs with Spotbugs in org.eclipse.jgit/pom.xml
  Replace FindBugs with SpotBugs

Change-Id: I1c077e8f3530ac717b1603d3307fd15d4335b8fe
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-13 09:16:55 +09:00
David Pursehouse 2db49bc679 Replace Findbugs with Spotbugs in org.eclipse.jgit/pom.xml
Change-Id: If9cb0de7a0e7bd95eac7daeee140a18385192a48
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-13 09:14:57 +09:00
Ivan Frade e82cb5a6d3 FirstWant: tighten first-want line validation
First-want line parsing accepts lines with an optional whitespace, when
the spec is strict requiring a white space.

Validate the line enforcing that there is a white space between oid and
capabilities list.

Change-Id: I45ada67030e0720f9b402c298be18c7518c799b1
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-12 15:41:00 -07:00
Ivan Frade 6aca8899a5 Move first line parsing for v0/v1 pack negotiation out of UploadPack
In protocol v0/v1 pack negotiation, the first want line contains the
options the client wants in effect. This parsing is done in UploadPack
but it doesn't have any interaction with that class.

Move the code to its own class and package, mark the current one
as deprecated (it is public API) and add unit tests.

Take the chance to move the parsing code from the constructor to a
factory method, making the class a simple container of results.

Change-Id: I1757f535dda78a4111a1c12c3a3b455a4b6f0c51
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-12 13:59:06 -07:00
David Pursehouse b3adaf7741 PackOutputStream: Suppress Error Prone's ShortCircuitBoolean warning
The usage of non-short-circuit logic is intentional, per the inline
comment added in change Ib4b35e357 as a follow-up to Ie3761ffb4 which
was a previously rejected attempt to "fix" a similar warning that had
been raised by FindBugs.

Change-Id: I3f6729f954d45d30ce697356d2ab3cc877d3ad54
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-10 11:30:25 +02:00
Matthias Sohn 36536e3396 Add missing @since tags for ObjectChecker.ErrorType
Change-Id: I4d0cd25d6cfaf8b81e58f35e58890ac580eaf9c6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-10 11:28:24 +02:00
Matthias Sohn de8de3bbd4 Revert "Remove unused API problem filters"
This reverts commit 37c7fbd661.

These filters weren't unused. Without them Eclipse raises 4 API errors.

Change-Id: I5ce443d40b5f517be4a315479e81246d40af1983
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-10 11:28:16 +02:00
David Pursehouse 37c7fbd661 Remove unused API problem filters
Change-Id: I4fb1d2cf1cea92dd314edc776ddbaa6640c99cf1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-09 20:59:23 -04:00
Jonathan Nieder b0991ca805 Format @NonNull on return value as method annotation
For example, instead of using

	public @NonNull String getMyFavoriteString() { ... }

use

	@NonNull
	public String getMyFavoriteString() { ... }

This makes the style more consistent (the existing JGit code base
tends to lean toward the second style) and makes the source code
better reflect how the annotation is parsed, as a METHOD annotation.

Longer term, we should switch to a TYPE_USE annotation and switch to
the first style.

Noticed using a style checker that follows
https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations

Change-Id: I9b9fa08035d805ca660520f812a84d2f47eff507
Reported-by: Ivan Frade <ifrade@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-09 15:56:55 -07:00
Jonathan Nieder 608b6b03b1 Format @Nullable on return value as method annotation
For example, instead of using

	public @Nullable String getMyFavoriteString() { ... }

use

	@Nullable
	public String getMyFavoriteString() { ... }

This makes the style more consistent (the existing JGit code base
tends to lean toward the second style) and makes the source code
better reflect how the annotation is parsed, as a METHOD annotation.

Longer term, we should switch to a TYPE_USE annotation and switch to
the first style.

Noticed using a style checker that follows
https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations

Change-Id: I07f4e67cc149fb8007f696a4663e10d4bfc57e3a
Reported-by: Ivan Frade <ifrade@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-09 15:52:54 -07:00
Jonathan Nieder c58362c174 Avoid using @Nullable to annotate arrays
As described in the javadoc for org.eclipse.jgit.annotations.Nullable:

  Warning: Please do not use this annotation on arrays. Different
  annotation processors treat `@Nullable Object[]` differently: some
  treat it as an array of nullable objects, for consistency with
  versions of `Nullable` defined with `@Target TYPE_USE`, while others
  treat it as a nullable array of objects. JGit therefore avoids using
  this annotation on arrays altogether.

  See the checker-framework manual[1] for details.

  [1] http://types.cs.washington.edu/checker-framework/current/checker-framework-manual.html#faq-array-syntax-meaning

Change-Id: I14ffcf80adbb8145d797998de2f2fa6ab84c3ae3
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-09 15:52:54 -07:00
Ivan Frade 81b7f0e835 FsckError: Use @Nullable as field annotation (before any modifier)
More consistent with general coding style.

Change-Id: Idd0695c63d0b4a17640460e8c388ce12e952879a
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-09 14:43:08 -07:00
Ivan Frade 39b27f7c7b DfsFsck: Check that .gitmodules in the repository have valid contents
Previous commits block the addition to the repo of dangerous .gitmodules
files, but some could have been committed before those safeguards where
in place.

Add a check in DfsFsck to validate the .gitmodules files in the repo.
Use the same validation than the ReceivePack, translating the
results to FsckErrors.

Note that *all* .gitmodules files in the storage will be checked, not
only the latest version.

Change-Id: I040cf1f31a779419aad0292ba5e6e76eb7f32b66
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-09 13:48:47 -07:00
Ivan Frade 7aebb6779c FsckError.CorruptObject: Use @Nullable constructor for errorType
errorType is already null in the caller and callee when unknown, so we
can replace a conditional call to a setter in the only caller with an
unconditionally provided @Nullable constructor parameter.

As a bonus, this lets us mark the field as final.

Change-Id: Ie2f929180e74ffa1aba8ec6caccfa81fbd8bfc04
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-09 11:53:06 -07:00
Ivan Frade 9372791fcf SubmoduleValidator: Always throw SubmoduleValidationException
The fsck test needs more detail about the error than an IOException
with an explanatory message.

Add an error identifier to the SubmoduleValidatorException and make
it the only throwable exception when parsing a file.

Change-Id: Ic3f0955b497e1681b25e681e1282e876cdf3d2c5
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-10-09 11:52:57 -07:00
Jonathan Nieder 18dce03a41 Merge branch 'stable-5.1'
* stable-5.1:
  SubmoduleValidator: Remove unused import of ConfigConstants
  SubmoduleValidator: Permit missing path or url

Change-Id: Ie0e35231c81a0c53c2051c4c123a5210b5a1c6d3
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 23:42:09 +00:00
Jonathan Nieder 6dd50d2e1b Merge branch 'stable-5.0' into stable-5.1
* stable-5.0:
  SubmoduleValidator: Remove unused import of ConfigConstants
  SubmoduleValidator: Permit missing path or url

Change-Id: Iaa3160a1307777cc4233d82e50a57c63d75d141c
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 23:41:38 +00:00
Jonathan Nieder e63ca8d094 Merge branch 'stable-4.11' into stable-5.0
* stable-4.11:
  SubmoduleValidator: Remove unused import of ConfigConstants
  SubmoduleValidator: Permit missing path or url

Change-Id: Iaf3b994e763bd02054b820cd87fe68ff83675001
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 23:41:15 +00:00
Jonathan Nieder eb41de5b25 Merge branch 'stable-4.10' into stable-4.11
* stable-4.10:
  SubmoduleValidator: Remove unused import of ConfigConstants
  SubmoduleValidator: Permit missing path or url

Change-Id: Id74c837d6cb728439ccbd6ade71936b493c09e08
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 23:40:47 +00:00
Jonathan Nieder 8b239e5b75 Merge branch 'stable-4.9' into stable-4.10
* stable-4.9:
  SubmoduleValidator: Remove unused import of ConfigConstants
  SubmoduleValidator: Permit missing path or url

Change-Id: Ib3c311f1e8d2db95510292a72f2f49825ffce9d9
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 23:40:05 +00:00
Jonathan Nieder 9d91bf189e Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  SubmoduleValidator: Remove unused import of ConfigConstants

Change-Id: Id01fd9945e23a9343f96c42db89d5a1b302dad33
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 23:39:18 +00:00
Jonathan Nieder f282aaa137 Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  SubmoduleValidator: Remove unused import of ConfigConstants

Change-Id: I6a7d19602d6d9099928ee52de727743b9717f262
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 23:38:59 +00:00
David Pursehouse 26e7a74601 SubmoduleValidator: Remove unused import of ConfigConstants
Change-Id: I6afe5690bf9d1f1f4d414aa618daefc8b48d217e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-09 08:29:26 +09:00
Jonathan Nieder 8ef8b71db9 Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  SubmoduleValidator: Permit missing path or url

Change-Id: I989ac2c0c124c82385fc7cac7e0544ec225f7589
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 21:49:24 +00:00
Jonathan Nieder 830e0d6b8c Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  SubmoduleValidator: Permit missing path or url

Change-Id: I94fdaf45abbf7665f9eddc14b1a7f7144aafeadf
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 21:49:09 +00:00
Jonathan Nieder d3eaf1007b SubmoduleValidator: Permit missing path or url
A .gitmodules file can include a submodule without a path to configure
the URL for a submodule that is only present on other branches.

A .gitmodules file can include a submodule with no URL and no path to
reserve the name for a submodule that existed in earlier history but
is not available from any URL any more.

"git fsck" permits both of these cases.  Permit them in JGit as well
(instead of throwing NullPointerException).

Change-Id: I3b442639ad79ea7a59227f96406a12e62d3573ae
Reported-by: David Pursehouse <david.pursehouse@gmail.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-08 21:40:56 +00:00
Michael Keppler 03ccdb0782 RefAdvertiser: Add Javadoc for usage of send(Collection)
This was not updated with the original introduction of the new method.

Bug: 534731
Change-Id: Ic4589c3a209109a829fbb706a9bf38845134e904
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
2018-10-08 08:45:11 +02:00
Jonathan Nieder 51d656586b SubmoduleAddCommand: Remove double-check of submodule name
Since v4.7.5.201810051826-r~3 (SubmoduleAddCommand: Reject submodule
URIs that look like cli options, 2018-09-24), SubmoduleAddCommand
checks submodule names for ".." path components in
assertValidSubmoduleName.  This additional check for the same is
redundant.

Change-Id: I993326a370978880b690dc133a81fa3025935bcb
Signed-off-by: Jonathan Nieder <jrn@gmail.com>
2018-10-07 22:14:02 -04:00
Matthias Sohn 1bec897ada Update API warning filter to 5.1.3
We added API in 4.7.5 to fix CVE-2018-17456

Change-Id: I14698fb088de91b8ba8856e461f64138025a89fa
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-07 09:46:05 +02:00
Jonathan Nieder 7647b03e94 Merge branch 'stable-5.1'
* stable-5.1:
  ObjectChecker#getGitsubmodules: Fix malformed javadoc

Change-Id: I20f19666c2faccc68bfd5ea15582b534784a027a
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-07 03:46:37 +00:00
Jonathan Nieder c1ef0d2cfd Merge branch 'stable-5.0' into stable-5.1
* stable-5.0:
  ObjectChecker#getGitsubmodules: Fix malformed javadoc

Change-Id: Ib32077c6640621670649fa4fbfcc8d0c9d8346f1
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-07 03:45:28 +00:00
Jonathan Nieder 3e73672c06 Merge branch 'stable-4.11' into stable-5.0
* stable-4.11:
  ObjectChecker#getGitsubmodules: Fix malformed javadoc

Change-Id: If82e40c5a39b84c6a63e8cc10d168696c4eb3e91
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-07 03:43:16 +00:00
Jonathan Nieder 735f79c663 Merge branch 'stable-4.10' into stable-4.11
* stable-4.10:
  ObjectChecker#getGitsubmodules: Fix malformed javadoc

Change-Id: Id2c8d1d4ffdf7bf18ef64479cfa1e959d9b2c37e
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-07 03:40:23 +00:00
Jonathan Nieder 112a19711d Merge branch 'stable-4.9' into stable-4.10
* stable-4.9:
  ObjectChecker#getGitsubmodules: Fix malformed javadoc

Change-Id: I847bdb9ef2b9e733c79489577b8b6e852ce6abf3
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-07 03:39:32 +00:00
Jonathan Nieder acd35d5384 Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  ObjectChecker#getGitsubmodules: Fix malformed javadoc

Change-Id: Ic73df5571e1ae86e5e026d0bf9d8e9e330cbfa97
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-10-07 03:38:26 +00:00
David Pursehouse f6eb785551 Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  ObjectChecker#getGitsubmodules: Fix malformed javadoc

Change-Id: I51ddd8fa1c2fbcabfb010bc4662d2c925563b55a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-07 11:04:24 +09:00
David Pursehouse df8bd762a1 ObjectChecker#getGitsubmodules: Fix malformed javadoc
The text "<tree, blob>" with angle brackets should not be used in javadoc
since it is interpreted as an HTML tag and then rejected since it's not a
valid HTML tag. Wrap the text in a @literal tag.

Also add a missing space.

Change-Id: Ide045e8c04a39a916f5b2e964e58c151e4555830
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-07 09:20:31 +09:00
Matthias Sohn 1133faff8c Merge branch 'stable-5.1'
* stable-5.1:
  Prepare 5.1.3-SNAPSHOT builds
  JGit v5.1.2.201810061102-r
  Prepare 4.11.5-SNAPSHOT builds
  JGit v4.11.4.201810060650-r
  Fix configuration of maven-javadoc-plugin
  Prepare 4.9.7-SNAPSHOT builds
  JGit v4.9.6.201810051924-r
  Prepare 4.7.6-SNAPSHOT builds
  JGit v4.7.5.201810051826-r
  BaseReceivePack: Validate incoming .gitmodules files
  ObjectChecker: Report .gitmodules files found in the pack
  SubmoduleAddCommand: Reject submodule URIs that look like cli options
  Revert "Configure WindowCache settings to use in JGit CLI"

Change-Id: I833d30d6de75b097377872c000b2ef5a1b96cf89
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 19:28:51 +02:00
Matthias Sohn 2078b23cee Prepare 5.1.3-SNAPSHOT builds
Change-Id: I75c1a01885115fc709ab37f181234264c3f7423a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 18:54:50 +02:00
Matthias Sohn b63870200b JGit v5.1.2.201810061102-r
Change-Id: Id34e4ae12a796460862edc37c5eb072314199bf4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 17:10:45 +02:00
Matthias Sohn dff99a272a Merge branch 'stable-5.0' into stable-5.1
* stable-5.0:
  Prepare 4.11.5-SNAPSHOT builds
  JGit v4.11.4.201810060650-r
  Fix configuration of maven-javadoc-plugin
  Prepare 4.9.7-SNAPSHOT builds
  JGit v4.9.6.201810051924-r
  Prepare 4.7.6-SNAPSHOT builds
  JGit v4.7.5.201810051826-r
  BaseReceivePack: Validate incoming .gitmodules files
  ObjectChecker: Report .gitmodules files found in the pack
  SubmoduleAddCommand: Reject submodule URIs that look like cli options

* Fix todos in SubmoduleAddTest

Change-Id: I53272081094b8948a40a1ce409af08b6ef330c1e
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 16:56:12 +02:00
Matthias Sohn 23ebbe5662 Merge branch 'stable-4.11' into stable-5.0
* stable-4.11:
  Prepare 4.11.5-SNAPSHOT builds
  JGit v4.11.4.201810060650-r
  Fix configuration of maven-javadoc-plugin
  Prepare 4.9.7-SNAPSHOT builds
  JGit v4.9.6.201810051924-r
  Prepare 4.7.6-SNAPSHOT builds
  JGit v4.7.5.201810051826-r
  BaseReceivePack: Validate incoming .gitmodules files
  ObjectChecker: Report .gitmodules files found in the pack
  SubmoduleAddCommand: Reject submodule URIs that look like cli options

* Fix configuration of maven-javadoc-plugin for site generation

Change-Id: Ic6ff8d324867ee41f15a5b890c7eee5092e8453e
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 16:40:46 +02:00
Matthias Sohn 620370ab6a Prepare 4.11.5-SNAPSHOT builds
Change-Id: Ifbe76e14264e8b547930e2320e8e81d728bd6e38
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 14:17:48 +02:00
Matthias Sohn c2a866b109 JGit v4.11.4.201810060650-r
Change-Id: I5700ebd341b6b997a7757b17e7d731c4ce608ec2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 14:05:29 +02:00
Matthias Sohn f016e32471 Merge branch 'stable-4.10' into stable-4.11
* stable-4.10:
  Prepare 4.9.7-SNAPSHOT builds
  JGit v4.9.6.201810051924-r
  Prepare 4.7.6-SNAPSHOT builds
  JGit v4.7.5.201810051826-r
  BaseReceivePack: Validate incoming .gitmodules files
  ObjectChecker: Report .gitmodules files found in the pack
  SubmoduleAddCommand: Reject submodule URIs that look like cli options

Change-Id: Ibd759f5d425f714e79b3137ff8e5b0f989933de0
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 02:26:05 +02:00
Matthias Sohn c0a973657f Merge branch 'stable-4.9' into stable-4.10
* stable-4.9:
  Prepare 4.9.7-SNAPSHOT builds
  JGit v4.9.6.201810051924-r
  Prepare 4.7.6-SNAPSHOT builds
  JGit v4.7.5.201810051826-r
  BaseReceivePack: Validate incoming .gitmodules files
  ObjectChecker: Report .gitmodules files found in the pack
  SubmoduleAddCommand: Reject submodule URIs that look like cli options

Change-Id: Ie59e34eb591a827d1ce8e483eec6d390a3c81702
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 01:52:38 +02:00
Matthias Sohn bf7a611dac Prepare 4.9.7-SNAPSHOT builds
Change-Id: I20e7bd6bdebcdb55a8c771314759bd8f98f04ef6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 01:32:40 +02:00
Matthias Sohn 73e6a93ba2 JGit v4.9.6.201810051924-r
Change-Id: Ib39aaae26da17aa37d654b24c1defd45126f4ea2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 01:24:42 +02:00
Matthias Sohn 7d94b446fe Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  Prepare 4.7.6-SNAPSHOT builds
  JGit v4.7.5.201810051826-r
  BaseReceivePack: Validate incoming .gitmodules files
  ObjectChecker: Report .gitmodules files found in the pack
  SubmoduleAddCommand: Reject submodule URIs that look like cli options

Change-Id: Ia7a826399d8d5b8a0eb7169b40e98a6f5c207a4c
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 01:16:08 +02:00
Matthias Sohn a8bd7dcc58 Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  Prepare 4.7.6-SNAPSHOT builds
  JGit v4.7.5.201810051826-r
  BaseReceivePack: Validate incoming .gitmodules files
  ObjectChecker: Report .gitmodules files found in the pack
  SubmoduleAddCommand: Reject submodule URIs that look like cli options

Change-Id: Id6fabec4d0b682a7e20a46e88cbc05432efca062
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 01:03:20 +02:00
Matthias Sohn 4a68f1a3c7 Prepare 4.7.6-SNAPSHOT builds
Change-Id: I99b59116999742d8d6cdba26287ea7c6eba11a30
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 00:36:30 +02:00
Matthias Sohn 9c90816cd9 JGit v4.7.5.201810051826-r
Change-Id: I60c7a2eff3dab5083f71df0d9465a4e94b5e2513
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-06 00:27:38 +02:00
Ivan Frade e4c28665b6 BaseReceivePack: Validate incoming .gitmodules files
The main concern are submodule urls starting with '-' that could pass as
options to an unguarded tool.

Pass through the parser the ids of blobs identified as .gitmodules
files in the ObjectChecker. Load the blobs and parse/validate them
in SubmoduleValidator.

Change-Id: Ia0cc32ce020d288f995bf7bc68041fda36be1963
Signed-off-by: Ivan Frade <ifrade@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-05 23:49:00 +02:00
Ivan Frade 3ed3eafbd1 ObjectChecker: Report .gitmodules files found in the pack
In order to validate .gitmodules files, we first need to find them
in the incoming pack.

Do it in the ObjectChecker stage. Check in the tree objects if they
point to a .gitmodules file and report the tree id and the .gitmodules
blob id.

This can be used later to check if the file is in the root of the
project and if the contents are good.

While we're here, make isMacHFSGit more accurate by detecting variants
of filenames that vary in case.

[jn: tweaked NTFS and HFS+ checking; added more tests]

Change-Id: I70802e7d2c1374116149de4f89836b9498f39582
Signed-off-by: Ivan Frade <ifrade@google.com>
Signed-off-by: Jonathan Nieder <jrn@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-05 21:45:54 +02:00
Ivan Frade db9f7b028d SubmoduleAddCommand: Reject submodule URIs that look like cli options
In C git versions before 2.19.1, the submodule is fetched by running
"git clone <uri> <path>". A URI starting with "-" would be interpreted
as an option, causing security problems. See CVE-2018-17456.

Refuse to add submodules with URIs, names or paths starting with "-",
that could be confused with command line arguments.

[jn: backported to JGit 4.7.y, bringing portions of Masaya Suzuki's
 dotdot check code in v5.1.0.201808281540-m3~57 (Add API to specify
 the submodule name, 2018-07-12) along for the ride]

Change-Id: I2607c3acc480b75ab2b13386fe2cac435839f017
Signed-off-by: Ivan Frade <ifrade@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-05 21:38:22 +02:00
Thomas Wolf 569cf1856c Fix handling of core.eol=native and of crlf attribute
EolStreamTypeUtil didn't handle these correctly on Windows.

Add three new tests to verify that the crlf attribute is handled as
described at [1], and that core.eol=native produces the expected
line endings on check-out.

[1] https://git-scm.com/docs/gitattributes

Bug: 497290
Change-Id: Idd9b435e3256c1e3251cc7b966f2f0460e787f07
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-04 19:17:41 -04:00
Matthias Sohn abe43a5841 Silence API warning for method added to interface DepthWalk
Breaking implementers is ok in a minor version update following OSGi
semantic versioning. According to [1] adding a default method is ok if
risk of inheriting a method with the same name from multiple interfaces
is low.

[1] https://wiki.eclipse.org/Evolving_Java-based_APIs_2#Evolving_API_Interfaces

Change-Id: Iad354cb73cfff9a96b9a9852a3c4d9ba0c5df430
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-10-04 23:02:02 +02:00
David Pursehouse 731d638f69 LfsFactory#LfsInputStream: Override int read(byte[], int, int)
According to Error Prone, the class should also override:

  int read(byte[], int, int)

otherwise multi-byte reads from this input stream are likely to be slow.

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

Change-Id: I33ab8cd30013447f2a0363b3a7b1424b79cb1818
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-10-01 11:16:05 +09:00
Jonathan Nieder 1f4ab45166 MergeFormatterPass: Remove constructor taking charset name as string
Since this constructor is package-private, so instead of deprecating
it, we can remove it right away.

Change-Id: I84ba72e8c94fb09412bbf7ce73b7eec72f61e964
Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-09-30 17:08:32 -07:00
David Pursehouse a5c0a8dfa5 ConfigConstants: Add constants for i18n.logOutputEncoding
Change-Id: I6073c7fc8ec30840e2ee2e90ac4cfdb136f48b9a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-30 17:14:50 +09:00
David Pursehouse 74789e7786 SidebandInputStream: Specify charset when calling String.getBytes()
Change-Id: I96c3f6b2ef3db9619bb3ae46dfbf8bcff3c1cbca
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-30 14:34:14 +09:00
David Pursehouse b65a310abc MergeFormatter{Pass}: Use Charset instead of String
Deprecate constructors and methods taking a character set name as
a String, in favor of new variants taking a Charset.

Change-Id: I616c601daf232fa17610dba1087fd902030d46ea
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-30 14:34:14 +09:00
David Pursehouse fbf6ce65ba Deprecate Constants.CHARACTER_ENCODING in favor of StandardCharsets.UTF_8
Change-Id: I621ba174235a6fb56236e54d24bce704bb5afb28
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-30 14:34:14 +09:00
Jonathan Tan 1bb430dc21 UploadPack: support deepen-since in protocol v2
Support the deepen-since parameter when requested by a client using
protocol v2. This is done by:
 - adding a DepthWalk.RevWalk#setDeepenSince method
 - updating DepthGenerator to recognize when deepen-since is set
 - recording in DepthWalk.Commit whether a commit is a boundary commit

Existing users of DepthWalk such as UploadPack previously recognized
boundary commits by comparing their depths against the threshold, not
tracking whether any parents were truly excluded. This behavior is
preserved - UploadPack considers a commit as boundary if its depth is
equal to the threshold *or* a parent was excluded (whether by depth or
by deepen-since).

Change-Id: I852bba6b1279f9cc8aee38282e9339d62b8dcddc
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
2018-09-27 14:43:05 -07:00
Jonathan Tan 953cf2c9da DepthGenerator: remove redundant depth check
In DepthGenerator, commits are always added to the "pending" queue
either at depth 0 (in the constructor) or after a depth check (in
next()), so it is redundant to check for depth after removing them from
the queue. Remove the check.

This redundancy seems to have been present since the introduction of
server-side shallow clone support in commit 9952223e06 ("Implement
server support for shallow clones", 2011-08-21).

Change-Id: Iad334935293367400c2901a25c0f4bf36c437cf2
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
2018-09-27 14:35:29 -07:00
David Pursehouse 62012d0bdd Explicitly specify charset when constructing BufferedReader
Replace explicit construction of BufferedReader with calls to the
utility method Files.newBufferedReader, which allows to specify
the charset.

Change-Id: I61b9451dbc8d9cf83fc8a5981292b8fdc713ce37
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-26 13:33:24 +09:00
David Pursehouse dbabe5f37a Explicitly specify charset in constructor of InputStreamReader
Change-Id: Id43e27c590f41f7435c2ca1d127f27e45745da7f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-26 08:31:13 +09:00
David Pursehouse ee40efcea4 Make inner classes static where possible
As reported by Error Prone:

An inner class should be static unless it references members of its
enclosing class. An inner class that is made non-static unnecessarily
uses more memory and does not make the intent of the class clear.

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

Change-Id: Ib99d120532630dba63cf400cc1c61c318286fc41
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-26 08:31:13 +09:00
Matthias Sohn 6a2be5c12c Fix @since tag on RefDatabase#getRefsByPrefix
Change-Id: Ic1615e680a131ef178c62c4ea92d2b389a0afd2b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-25 21:58:05 +02:00
Minh Thai c0f89747b6 Using getRefsByPrefix with multiple prefixes
Change-Id: I9901e733797bd661f2485cc42914ad01699617d3
Signed-off-by: Minh Thai <mthai@google.com>
2018-09-24 15:18:58 -07:00
Minh Thai a51e686e47 Query references by multiple prefixes
Support multiple prefixes when querying references to allow
implementor to minimize number of RPC calls.

Change-Id: I5f822fd7eaf9756b44750080d3056de138b64f4a
Signed-off-by: Minh Thai <mthai@google.com>
2018-09-24 15:17:48 -07:00
Michael Keppler 751abf4a50 Fix Mylyn commit message template
The commit message template contains a superfluous blank at the end of
the first line, which is deleted by this change. This is only relevant
for jgit contributors using Eclipse, not for jgit users.

Change-Id: I462deb49c26fb64b3dc2d1d75f1e40ef302b0fc9
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
2018-09-23 04:11:58 -04:00
Marc Strapetz cbc65bd659 Config.set-methods should not touch lines from included files
Bug: 538270
Change-Id: I4128213e83e267eb2667f451b8fb3301dd251656
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
2018-09-20 17:05:40 +02:00
Marc Strapetz f5614d471d Don't inline included configs on FileBasedConfig.save()
Bug: 529825
Change-Id: Id23d4602aa2082d7f2dfe15ae92d7b175b1b8944
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
2018-09-20 17:05:39 +02:00
Marc Strapetz 31abb329b4 ConfigLine.includedFrom stores source, if it was read from included file
This is a base change which prepares for subsequent bugfixes.

Change-Id: Iaadc93df37e45753d700be73669e68c03590adb5
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
2018-09-20 17:05:39 +02:00
Matthias Sohn 48e21dc10b Prepare 5.1.2-SNAPSHOT builds
Change-Id: I095d246e27de747a234bc058725454c222be51ce
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 17:03:49 +02:00
Matthias Sohn b06d2e6a31 JGit v5.1.1.201809181055-r
Change-Id: I2366444fca125139eadb6d513be721167a266d70
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 16:55:20 +02:00
Matthias Sohn 35255a2a29 Prepare 4.11.4-SNAPSHOT builds
Change-Id: Id2f83eb3b2070637997cfece59f4f15698267908
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 16:46:18 +02:00
Matthias Sohn 47ad1f6c8a JGit v4.11.3.201809181037-r
Change-Id: I6b57b02e41f02916127b1866d573a634d6f6d796
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 16:36:53 +02:00
Matthias Sohn 430ff2187c Prepare 4.9.6-SNAPSHOT builds
Change-Id: I9fb8f6cc45409e0884b898187323ac91953754c3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 15:55:12 +02:00
Matthias Sohn 0bd9cb62cc JGit v4.9.5.201809180939-r
Change-Id: I36199607f3ec6e8bb841e9d9eade12251312447c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 15:44:16 +02:00
Matthias Sohn 0de8e1e65c Prepare 4.7.5-SNAPSHOT builds
Change-Id: Ifce4311fe9429d751cec5b326b540d6233762153
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 15:16:36 +02:00
Matthias Sohn 6d4864ff15 JGit v4.7.4.201809180905-r
Change-Id: Iceee69df5fd593bece4532d5781e3771f5761ef8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 15:05:11 +02:00
Matthias Sohn e39cf68af4 Update API problem filter
Change-Id: Ie15c7d0b320f75915c362f5bd3bd6b39d84a900a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 15:03:40 +02:00
David Pursehouse ab9364fe6c Merge branch 'stable-5.1'
* stable-5.1:
  Fix ObjectUploadListener#close
  Fix error handling in FileLfsServlet
  ObjectDownloadListener#onWritePossible: Make code spec compatible
  ObjectDownloadListener: Return from onWritePossible when data is written
  Fix IOException when LockToken#close fails

Change-Id: If6e4b4786401c6598b9f3b1c2b7d7081b08acd35
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-18 09:19:47 +09:00
David Pursehouse 1cfb4241de Merge branch 'stable-5.0' into stable-5.1
* stable-5.0:
  Fix ObjectUploadListener#close
  Fix error handling in FileLfsServlet
  ObjectDownloadListener#onWritePossible: Make code spec compatible
  ObjectDownloadListener: Return from onWritePossible when data is written
  Fix IOException when LockToken#close fails

Change-Id: Ib7a63b5144a89c213aff3b32c30a2a6526355e64
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-18 09:19:18 +09:00
David Pursehouse ca922217e2 Merge branch 'stable-4.11' into stable-5.0
* stable-4.11:
  Fix ObjectUploadListener#close
  Fix error handling in FileLfsServlet
  ObjectDownloadListener#onWritePossible: Make code spec compatible
  ObjectDownloadListener: Return from onWritePossible when data is written
  Fix IOException when LockToken#close fails

Change-Id: Iffe202a412b3bca1c8d8d7dc5dfd646c49838de9
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-18 09:18:40 +09:00
David Pursehouse 1e170b16a4 Merge branch 'stable-4.10' into stable-4.11
* stable-4.10:
  Fix ObjectUploadListener#close
  Fix error handling in FileLfsServlet
  ObjectDownloadListener#onWritePossible: Make code spec compatible
  ObjectDownloadListener: Return from onWritePossible when data is written
  Fix IOException when LockToken#close fails

Change-Id: I28ebf6138ccd9425fc05319de78c7716f0bdd199
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-18 09:17:02 +09:00
David Pursehouse ecf3227d32 Merge branch 'stable-4.9' into stable-4.10
* stable-4.9:
  Fix ObjectUploadListener#close
  Fix error handling in FileLfsServlet
  ObjectDownloadListener#onWritePossible: Make code spec compatible
  ObjectDownloadListener: Return from onWritePossible when data is written
  Fix IOException when LockToken#close fails

Change-Id: Ib7d01cb0ece8b259156855045a53b8baf3fa2968
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-18 09:16:29 +09:00
David Pursehouse 1780a12e20 Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  Fix ObjectUploadListener#close
  Fix error handling in FileLfsServlet
  ObjectDownloadListener#onWritePossible: Make code spec compatible
  ObjectDownloadListener: Return from onWritePossible when data is written
  Fix IOException when LockToken#close fails

Change-Id: Id8eb635094336567d9f3c28ec985cd5127d31632
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-18 09:16:01 +09:00
David Pursehouse 531da4e5e9 Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  Fix ObjectUploadListener#close
  Fix error handling in FileLfsServlet
  ObjectDownloadListener#onWritePossible: Make code spec compatible
  ObjectDownloadListener: Return from onWritePossible when data is written
  Fix IOException when LockToken#close fails

Change-Id: Iad9836811be034cf992ea25dad4409addba75115
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-18 09:15:24 +09:00
Matthias Sohn e6e9073fc7 Fix IOException when LockToken#close fails
This happened if the LockTokens hard link was already deleted earlier.

Bug: 531759
Change-Id: Idc84bd695fac1a763b3cbb797c9c4c636a16e329
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-15 09:11:17 +02:00
Thomas Wolf 50deacdd57 Set TagOpt.AUTO_FOLLOW when not cloning all branches
Otherwise fetching all tags may pull in commits not on the
specified branches. Canonical git also does this.[1]

[1] https://github.com/git/git/blob/b160b6e69/builtin/clone.c#L1124

Bug: 538768
Change-Id: If0ac75fb9fae0c95d1a48b22954c54d4c3c09a47
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-09-15 00:57:13 +02:00
Thomas Wolf 54a502f6c6 Fix fetch refspecs when not cloning all branches
When not all branches are cloned, the fetch refspec for the
remote should not be "+refs/heads/*:refs/remotes/origin/*":
that would fetch all branches on the very next fetch, thus
making a clone with only a subset of the branches rather
pointless.

Instead, produce refspecs for the cloned branches only.

Canonical git also does this for its --single-branch case;
it doesn't have an option to clone only a subset of the branches
(only one or all).

Bug: 466858
Change-Id: Ie871880f757663437efac1e8b3313094f9e629b3
Also-by: Julian Enoch <julian.enoch@ericsson.com>
Signed-off-by: Julian Enoch <julian.enoch@ericsson.com>
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-15 00:57:13 +02:00
Ivan Frade cb4de02e5e Move ls-refs parsing code to the ProtocolV2Parser
Fetch code has been moved to a ProtocolV2Parser, but ls-refs code is
still in UploadPack.

Moving it to the parser makes it easier to test, keeps the parsing
together and makes the two commands follow similar structure.

Change-Id: I573ce543e804ddeb9f83303b4af250b7cddc8cad
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-09-14 08:52:23 -07:00
David Pursehouse d6d4cc3ab8 Merge "Remove unused API problem filters" 2018-09-13 23:55:20 -04:00
David Pursehouse b17bab31c2 Remove unused API problem filters
Change-Id: Iac95de60df6f2928d491e952a531e8dfa90045f6
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-14 11:18:54 +09:00
Ivan Frade 2d26ddfb64 Untangle UploadPack.processShallow
UploadPack.processShallow is doing too many things and offering a
confusing API. It is filtering or splitting commit ids depending
if a parameter is null and writing them out (or not) depending on another
flag.

Iterate the list and announce to Consumers what object ids need
to be marked as (un)shallow. They decide what to do with them.

As java consumers don't allow to propagate exceptions, define
our own functional interface for it.

Change-Id: I619cf2eed9b1e0338151120b8ef87a463fbe8827
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-09-13 18:41:01 -07:00
Ivan Frade 093fa8ef52 UploadPack.fetchV2: Make shallow commits list non-nullable
shallowCommits variable is nullable only to signal later
if code has gone through the processShallow code.

Use a flag to indicate that condition and make shallowCommits
non-nullable. This makes code clearer and paves the way to untangle
processShallow in a follow-up commit.

Change-Id: I898e6aaf6f860bb6afafbac05653ba116c9b2da6
Signed-off-by: Ivan Frade <ifrade@google.com>
2018-09-13 17:54:04 -07:00
David Pursehouse 6ad4bd7618 Merge branch 'stable-5.1'
* stable-5.1:
  Fix logging null if called process fails

Change-Id: Iba771dd8d680b154cb628c7571a2bbc2ecf50a3b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-13 10:01:01 +09:00
Cliffred van Velzen 0c8200b27b Fix logging null if called process fails
If some process executed by FS#readPipe ends in an error,
the error stream is never set as errorMessage because
FS#GobblerThread#waitForProcessCompletion always returned true.
This caused LOG#warn to be called with null.

Return false whenever FS#GobblerThread#waitForProcessCompletion fails.

Bug: 538723
Change-Id: Ic9492bd688431d52c8665f7a2efec2989e95a4ce
Signed-off-by: Cliffred van Velzen <cliffred@cliffred.nl>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-12 23:42:35 +02:00
Matthias Sohn cdeecbd21f Merge branch 'stable-5.1'
* stable-5.1:
  Fix NoSuchFileException during directory cleanup in RefDirectory
  Update japicmp to 0.13.0
  Prepare 5.1.1-SNAPSHOT builds
  JGit v5.1.0.201809111528-r
  Externalize warning message in RefDirectory.delete()
  Suppress warning for trying to delete non-empty directory
  Fix replacement quoting for replaceAll in filter command
  Prepare 4.11.3-SNAPSHOT builds
  JGit v4.11.2.201809100523-r

Change-Id: Ia27fec6dabf87db26e2fd29c17570932649e234a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-12 14:54:49 +02:00
David Pursehouse fc480b3efc Merge branch 'stable-4.11' into stable-5.0
* stable-4.11:
  Fix NoSuchFileException during directory cleanup in RefDirectory
  Externalize warning message in RefDirectory.delete()
  Suppress warning for trying to delete non-empty directory

Change-Id: Ic7eaa0b6a4e750bc7853eb549a9e126269ae22cf
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-12 19:03:32 +09:00
David Pursehouse 83c0369e29 Merge branch 'stable-4.10' into stable-4.11
* stable-4.10:
  Fix NoSuchFileException during directory cleanup in RefDirectory
  Externalize warning message in RefDirectory.delete()
  Suppress warning for trying to delete non-empty directory

Change-Id: I191d56e3c0f11cf53076b06c7e7a05492c7a03f1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-12 17:02:23 +09:00
David Pursehouse 59ee33aee4 Merge branch 'stable-4.9' into stable-4.10
* stable-4.9:
  Fix NoSuchFileException during directory cleanup in RefDirectory
  Externalize warning message in RefDirectory.delete()
  Suppress warning for trying to delete non-empty directory

Change-Id: Ied2d7a70c5544ff012687a1aeb6e07394d9bd6fd
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-12 16:38:56 +09:00
David Pursehouse b81092cc99 Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  Fix NoSuchFileException during directory cleanup in RefDirectory
  Externalize warning message in RefDirectory.delete()
  Suppress warning for trying to delete non-empty directory

Change-Id: I5e6cc35f3673545e7ff857e6ed0bcd2c44e50316
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-12 15:55:07 +09:00
David Pursehouse db756e9147 Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  Fix NoSuchFileException during directory cleanup in RefDirectory
  Externalize warning message in RefDirectory.delete()
  Suppress warning for trying to delete non-empty directory

Change-Id: I9ec6352b5ff57aa1a3380079dc9165890cc76d49
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-12 14:05:54 +09:00
Matthias Sohn 667ac8b318 Fix NoSuchFileException during directory cleanup in RefDirectory
Bug: 538285
Change-Id: Iab5c381a412cb2c2176af55189668c267ed29fbc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
(cherry picked from commit 8ab89ef066)
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-12 09:12:11 +09:00
Matthias Sohn a44d95c814 Prepare 5.1.1-SNAPSHOT builds
Change-Id: Ie220dd95fae18f894e2a04a5ae6d29a1e5a6d76b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-11 23:28:07 +02:00
Matthias Sohn 47956bcc68 JGit v5.1.0.201809111528-r
Change-Id: I583bf7d60bccc876156be1f605bfda32b89cd08b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-11 21:30:23 +02:00
Matthias Sohn c78d6445ec Externalize warning message in RefDirectory.delete()
Change-Id: Icec16c01853a3f5ea016d454b3d48624498efcce
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
(cherry picked from commit 5e68fe245f)
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-11 08:29:02 +09:00
Thomas Wolf 94fad4412a Suppress warning for trying to delete non-empty directory
This is actually a fairly common occurrence; deleting the parent
directories can work only if the file deleted was the last one
in the directory.

Bug: 537872
Change-Id: I86d1d45e1e2631332025ff24af8dfd46c9725711
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
(cherry picked from commit d9e767b431)
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-11 08:26:52 +09:00
Markus Duft 303adeb8bf Fix replacement quoting for replaceAll in filter command
According to String.replaceAll JavaDoc:

"Note that backslashes (\) and dollar signs ($) in the replacement
string may cause the results to be different than if it were being
treated as a literal replacement string; see Matcher.replaceAll. Use
java.util.regex.Matcher.quoteReplacement to suppress the special meaning
of these characters, if desired."

Bug: 536318
Change-Id: Ib70cfec41bf73e14d23d94d14aee05a25b1e87f6
Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
2018-09-10 22:21:15 +02:00
Matthias Sohn c857e7f09b Merge branch 'stable-5.0' into stable-5.1
* stable-5.0:
  Prepare 4.11.3-SNAPSHOT builds
  JGit v4.11.2.201809100523-r

Change-Id: I6bd3cb830b7b44dc6e5fd66ff0732957be6b5710
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-10 21:30:49 +02:00
Matthias Sohn 8527e74ea0 Merge branch 'stable-4.11' into stable-5.0
* stable-4.11:
  Prepare 4.11.3-SNAPSHOT builds
  JGit v4.11.2.201809100523-r

Change-Id: I8a6f2667f9e43d53e995554224c2a538d1959996
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-10 21:29:46 +02:00
Matthias Sohn 34618a4f86 Prepare 4.11.3-SNAPSHOT builds
Change-Id: I4f5dda6da3f6ecd9b99c1d9a220844c5402f1988
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-10 13:13:19 +02:00
Matthias Sohn ae21714768 JGit v4.11.2.201809100523-r
Change-Id: I85dab173a94b3036ccf669c20b9dffb4af0922b4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-10 11:24:32 +02:00
Matthias Sohn f19625a1b8 SpotBugs: don't rely on default encoding
Change-Id: Ic42f30c564270230fc629a917be85194d27d0338
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-10 00:51:59 +02:00
Matthias Sohn f0517b5f38 Merge branch 'stable-5.1'
* stable-5.1:
  Update Orbit 2018-09 to R20180905201904
  Prepare 5.0.4-SNAPSHOT builds
  JGit v5.0.3.201809091024-r
  Use the same default diff.renameLimit = 400 like native git
  Prepare 4.9.5-SNAPSHOT builds
  JGit v4.9.4.201809090327-r
  Fix @since tag for LOCK_SUFFIX
  Prepare 4.7.4-SNAPSHOT builds
  JGit v4.7.3.201809090215-r

Change-Id: Ic6f2c858dc653f654de36189943c77972c974269
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-10 00:51:16 +02:00
Matthias Sohn b44bba618b Merge branch 'stable-5.0' into stable-5.1
* stable-5.0:
  Prepare 5.0.4-SNAPSHOT builds
  JGit v5.0.3.201809091024-r
  Prepare 4.9.5-SNAPSHOT builds
  JGit v4.9.4.201809090327-r
  Fix @since tag for LOCK_SUFFIX
  Prepare 4.7.4-SNAPSHOT builds
  JGit v4.7.3.201809090215-r

Change-Id: I9117b961035ee527cb8e1dd5df59976fff83829d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 21:05:41 +02:00
Matthias Sohn 0b11e31a4c Prepare 5.0.4-SNAPSHOT builds
Change-Id: Ib9042662c3f2a1544d597d476c5952c61767687b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 17:28:59 +02:00
Matthias Sohn faf1ae230e JGit v5.0.3.201809091024-r
Change-Id: I9e8e74a10dbb235b08c6a5e1b169c5cae440f129
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 16:24:44 +02:00
Matthias Sohn a9e5ee3f06 Merge branch 'stable-4.11' into stable-5.0
* stable-4.11:
  Prepare 4.9.5-SNAPSHOT builds
  JGit v4.9.4.201809090327-r
  Fix @since tag for LOCK_SUFFIX
  Prepare 4.7.4-SNAPSHOT builds
  JGit v4.7.3.201809090215-r

Change-Id: Ia72fc409f0262565cf31b8bc62737c78fc4c3485
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 15:53:35 +02:00
Matthias Sohn 0d4e04c575 Merge branch 'stable-4.10' into stable-4.11
* stable-4.10:
  Prepare 4.9.5-SNAPSHOT builds
  JGit v4.9.4.201809090327-r
  Fix @since tag for LOCK_SUFFIX
  Prepare 4.7.4-SNAPSHOT builds
  JGit v4.7.3.201809090215-r

Change-Id: I8e962758973753fe7baffd959050593a059ee44e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 15:44:44 +02:00
Matthias Sohn 8f46488385 Merge branch 'stable-4.9' into stable-4.10
* stable-4.9:
  Prepare 4.9.5-SNAPSHOT builds
  JGit v4.9.4.201809090327-r
  Fix @since tag for LOCK_SUFFIX
  Prepare 4.7.4-SNAPSHOT builds
  JGit v4.7.3.201809090215-r

Change-Id: I78099d2a5ba895273ca3ac587c7aa5f3f43fe869
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 15:43:04 +02:00
Matthias Sohn a253c39729 Use the same default diff.renameLimit = 400 like native git
Bug: 434085
Change-Id: I43a0401049cd85b2c7a2162ccc071af7fffdfed3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 13:03:36 +02:00
Matthias Sohn de0a687948 Prepare 4.9.5-SNAPSHOT builds
Change-Id: Ie8d2b60be1803399027e1a3e9734625278a63861
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 09:36:35 +02:00
Matthias Sohn 6657f93adb JGit v4.9.4.201809090327-r
Change-Id: I13488a915fe0ba871c5f37c6e9efc6f436083171
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 09:29:05 +02:00
Matthias Sohn f8de0596d7 Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  Fix @since tag for LOCK_SUFFIX
  Prepare 4.7.4-SNAPSHOT builds
  JGit v4.7.3.201809090215-r

Change-Id: Id3c85149316cbe671e55f41438bd3a3a892b4ed0
2018-09-09 09:25:54 +02:00
Matthias Sohn b0a0c1004f Fix @since tag for LOCK_SUFFIX
Change-Id: Ia65cf3f12ec6d35a21b4d9332be912f06d8bf834
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 08:46:11 +02:00
Matthias Sohn 6fe4505b2a Prepare 4.7.4-SNAPSHOT builds
Change-Id: Ie4d17e1604270946606e75145012c5b7fa1283eb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 08:24:16 +02:00
Matthias Sohn 9796e86165 JGit v4.7.3.201809090215-r
Change-Id: I1ded7a2b61235509c5a6ba95e7329e288bbfddb1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 08:15:48 +02:00