Matthias Sohn [Wed, 6 Mar 2019 23:25:22 +0000 (00:25 +0100)]
Merge branch 'stable-5.3'
* stable-5.3:
Prepare 5.3.0-SNAPSHOT builds
JGit v5.3.0.201903061415-rc1
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
Matthias Sohn [Wed, 6 Mar 2019 10:57:39 +0000 (11:57 +0100)]
Merge branch 'master' into stable-5.3
* master:
Update Orbit to R20190226160451
Upgrade maven-javadoc-plugin to 3.1.0
diff: add option metaVar for --src-prefix and --dst-prefix
ResolveMerger: Destroy TemporaryBuffer on unchecked exceptions
Expose the filter blob limit in UploadPack
Upgrade error_prone_core to 2.3.3
On Windows use %APPDATA%\gnupg as GPG directory if it exists
Remove duplicate externalized message
RebaseCommand: tighten check for --preserve-merges on --continue
RebaseCommand: fix ONTO_NAME, and --preserve-merges is interactive
RebaseCommand: use orig-head to abort
Fix core.autocrlf for non-normalized index
RebaseCommand: use orig-head in addition to head
SHA1: Use externalized message in log
JGitText: Remove unnecessary suffix from externalized message identifier
FS_POSIX: Externalize log message
Strongly reference indices in DfsPackFile
Update Orbit to S20190219190953
Update README
Update README
Add missing @since tag for new API method getUpdateIndex
Fix NPE in PlotCommitList
CommitBuilder: Deprecate setEncoding(String)
CommitBuilder: Add missing periods on methods' Javadoc
Upgrade wagon-ssh to 3.3.2
Fix bug in copyPackBypassCache's skip 'PACK' header logic
Upgrade spotbugs to 3.1.11
Atomic file creation: hard-linking may not be allowed
Update Orbit to S20190129210011
Fix GC.deleteEmptyRefsFolders
Enable cloning only specific tags
Delete jgit-4.5 target platform
Add 4.11-staging target platform and update Orbit to I20190123233226
Upgrade jacoco-maven-plugin to 0.8.3
Bazel: Format BUILD file with buildifier
RenameBranchCommand: more consistent handling of short ref names
SshdSessionFactory: generalize providing default keys
Allow to check for signing key
Handle premature EOF in BundleFetchConnection
pgm: Fix missing braces in Version.run()
pgm: Handle IOException in Version command
pgm: Fix missing braces in UploadPack.run()
pgm: Handle IOException in UploadPack command
pgm: Handle exceptions in Tag command
pgm: Fix missing braces in Status.run()
pgm: Handle exceptions in Status command
pgm: Fix missing braces in ShowRef.run()
pgm: Handle IOException in ShowRef command
pgm: Fix missing braces in Show.run()
pgm: Handle exceptions in Show command
pgm: Fix missing braces in Rm command
pgm: Handle GitAPIException in Rm command
pgm: Handle exceptions in RevParse command
pgm: Externalize error message
pgm: Fix missing braces in Reset.run()
pgm: Handle GitAPIException in Reset command
pgm: Handle GitAPIException in Repo command
pgm: Handle exceptions in Remote command
pgm: Handle exceptions in Reflog command
pgm: Handle IOException in ReceivePack command
SmartClientSmartServerTest: Open Repository in try-with-resource
SmartClientSmartServerTest: Open ObjectInserter.Formatter in try-with-resource
SmartClientSmartServerTest#addBrokenContext: Remove unused TestRepository
IO: Open TemporaryBuffer.Heap in try-with-resource
GitSmartHttpTools: Open SideBandOutputStream in try-with-resource
TemporaryBufferTest: Open TemporaryBuffer in try-with-resource
Scanner: Open RevWalk in try-with-resource
SubmoduleWalkTest: Open Repository in try-with-resource
SideBandOutputStreamTest: Open SideBandOutputStream in try-with-resource
UnionInputStreamTest: Open UnionInputStream in try-with-resource
Merge: Avoid non-localised literal string warning for "recursive"
pgm: Fix missing braces in Push.run()
pgm: Handle exceptions in Push command
pgm: Fix missing braces in MergeBase.run()
pgm: Handle IOException in MergeBase command
pgm: Fix missing braces in Merge command
pgm: Handle exceptions in Merge command
pgm: Fix missing braces in LsTree.run()
pgm: Handle exceptions in LsTree command
pgm: Fix missing braces in LsRemote.run()
pgm: Handle exceptions in LsRemote command
pgm: Handle exceptions in LsFiles command
pgm: Fix missing braces in Log.run()
pgm: Handle exceptions in Log command
pgm: Handle exceptions in Init command
pgm: Handle IOException in IndexPack command
pgm: Fix missing braces in Fetch.run()
pgm: Handle IOException in Fetch command
pgm: Handle GitAPIException in Gc command
pgm: Fix missing braces in DiffTree.run()
pgm: Handle exceptions in DiffTree command
pgm: Fix missing braces in Diff.run()
pgm: Handle exceptions in Diff command
RawParseUtils: Avoid import of java.nio.charset.StandardCharsets
Consistently import constants from StandardCharsets as static
LocalDiskRepositoryTestCase#createRepository: Default auto-close to false
UploadPack: Suppress false-positive resource leak warning
PushConnectionTest: Open TestRepository in try-with-resource
MergerTest: Open TestRepository in try-with-resource
MergeCommandTest: Open TestRepository in try-with-resource
PackWriterTest: Open TestRepository in try-with-resource
ReceivePackAdvertiseRefsHookTest: Open TestRepository in try-with-resource
SubmoduleStatusTest: Open TestRepository in try-with-resource
UploadPackTest: Open TestRepository in try-with-resource
PackParserTest: Open TestRepository in try-with-resource
SmartClientSmartServerTest: Open TestRepository in try-with-resource
Stop using deprecated methods of RemoteSetUrlCommand/RemoteRemoveCommand
SmartClientSmartServerTest: Stop using deprecated Repository#hasObject
DumbClientSmartServerTest: Open TestRepository in try-with-resource
DumbClientDumbServerTest: Open TestRepository in try-with-resource
DirCacheCheckoutTest: Open TestRepository in try-with-resource
HttpTestCase#fsck: Open TestRepository in try-with-resource
CheckoutCommandTest: Add comment to document intentionally empty catch block
pgm: Fix missing braces in Describe.run()
pgm: Handle exceptions in Describe command
pgm: Handle exceptions in Config command
pgm: Fix too wide lines in Commit.run()
pgm: Fix missing braces in Commit.run()
pgm: Handle exceptions in Commit command
pgm: Handle exceptions in Clean command
pgm: Handle GitAPIException in Fetch command
Fix missing braces in Branch.run()
pgm: Handle exceptions in Branch command
Fix missing braces in Blame.run()
pgm: Handle NoWorkTreeException and IOException in Blame command
Use try-with-resource for reader in Blame.run()
pgm: Handle GitAPIException in Add command
Matthias Sohn [Wed, 6 Mar 2019 08:44:37 +0000 (09:44 +0100)]
Merge branch 'stable-5.2' into stable-5.3
* 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
ObjectDirectory: extra logging on packfile exceptions
* 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
ObjectDirectory: extra logging on packfile exceptions
Change-Id: Id9f957ca8386f6035f4ab34d242cb6fb8c38e012 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* stable-5.0:
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: I056f41f619a1bb22ca6be75ec21c32c1f6d4fd2f Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* 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>
* 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>
* 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>
Luca Milanesio [Sat, 23 Feb 2019 21:57:09 +0000 (21:57 +0000)]
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 436c99ce5946f31f06b8704b1fd33136f39dc814)
* 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>
* 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>
Luca Milanesio [Sat, 23 Feb 2019 21:57:09 +0000 (21:57 +0000)]
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>
Dave Borowitz [Fri, 1 Mar 2019 20:35:38 +0000 (12:35 -0800)]
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).
Thomas Wolf [Tue, 26 Feb 2019 21:22:21 +0000 (16:22 -0500)]
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
Thomas Wolf [Tue, 26 Feb 2019 11:49:59 +0000 (12:49 +0100)]
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>
Thomas Wolf [Wed, 19 Dec 2018 10:03:29 +0000 (11:03 +0100)]
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.
Thomas Wolf [Wed, 19 Dec 2018 10:26:21 +0000 (11:26 +0100)]
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>
Thomas Wolf [Sun, 12 Aug 2018 17:30:36 +0000 (19:30 +0200)]
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.
Thomas Wolf [Wed, 19 Dec 2018 10:07:43 +0000 (11:07 +0100)]
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.
Minh Thai [Fri, 22 Feb 2019 00:36:59 +0000 (16:36 -0800)]
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.
Thomas Wolf [Tue, 29 Jan 2019 21:20:07 +0000 (22:20 +0100)]
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>
Matthias Sohn [Sun, 27 Jan 2019 01:22:34 +0000 (02:22 +0100)]
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>
Thomas Wolf [Mon, 10 Dec 2018 23:47:13 +0000 (00:47 +0100)]
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>
Matthias Sohn [Fri, 25 Jan 2019 23:34:08 +0000 (00:34 +0100)]
Add 4.11-staging target platform and update Orbit to I20190123233226
Update
- org.apache.httpcomponents.httpcore to 4.4.10.v20190123-2214
- org.apache.httpcomponents.httpclient.source to 4.5.6.v20190123-2215
- org.bouncycastle.bcpg to 1.60.0.v20181210-2057
- org.bouncycastle.pkix to 1.60.0.v20181210-2057
- org.bouncycastle.prov to 1.60.0.v20181210-2057
Change-Id: I132b6686aa29b2a76cc529f7cae34115604c754d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Thomas Wolf [Thu, 6 Dec 2018 14:49:25 +0000 (15:49 +0100)]
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>
Provide a mechanism for a subclass to provide its own set
of default identities from anywhere as an Iterable<KeyPair>.
The default implementation is functionally unchanged and uses
the known default identity files in the ~/.ssh directory. A subclass
can override the getDefaultKeys() function and return whatever keys
are appropriate.
Bug: 543152
Change-Id: I500d63146bc67e20e051f617790eb87c7cb500b6 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
David Pursehouse [Mon, 21 Jan 2019 06:35:38 +0000 (15:35 +0900)]
SmartClientSmartServerTest: Open Repository in try-with-resource
Since 52923e9 ("LocalDiskRepositoryTestCase#createRepository: Default
auto-close to false", Jan 20, 2019) the createBareRepository method
creates repositories that do not get automatically closed in #tearDown.
Convert invocations of createBareRepository to use try-with-resource.
Change-Id: I320030c5d4438713971bee33316bff408bac47fc Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>