Matthias Sohn [Thu, 21 Jan 2016 13:04:39 +0000 (14:04 +0100)]
Merge branch 'stable-4.2'
* stable-4.2:
BundleWriterTest: Open RevWalk in try-with-resource
DiffFormatterTest: Remove accidentally added trailing whitespace
CherryPickCommandTest: Create Git instances in try-with-resource
DiffFormatterTest: Create auto-closeable instances in try-with-resource
ConfigTest: Create Git instance in try-with-resource
CommitAndLogCommandTest: Use assumeFalse to skip test on Windows
CommitAndLogCommandTest: Create Git instances in try-with-resource
AddCommandTest: Create Git instances in try-with-resource
ArchiveCommandTest: Create Git instances in try-with-resource
TagCommandTest: Instantiate Git and RevWalk objects in try-with-resource
BlameCommandTest: Instantiate Git objects in try-with-resource
SideBandOutputStreamTest: Use try-with-resource
FileTreeIteratorJava7Test: Create Git instances in try-with-resource
Change-Id: Ib572e98e6117b70442aee9cd7e7b8c3cf65562a7 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Laurent Delaigue [Wed, 13 Jan 2016 15:56:00 +0000 (16:56 +0100)]
Add progress monitor to Merger
Monitoring progress of merges can be useful for users for large
repositories or complex merge processes that take some time.
This enables setting a monitor. Existing merge implementations in jgit
do not yet report progress if a monitor is set. This will be added in a
later change.
Change-Id: I17b978b3fc91750dd88649638b90a46820a0877c Signed-off-by: Laurent Delaigue <laurent.delaigue@obeo.fr> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Chris Gavin [Wed, 6 Jan 2016 15:53:22 +0000 (15:53 +0000)]
Fix TransportException when reading bundle
When reading a bundle file, commit messages who's oneline format is
longer than 982 characters caused JGit to treat subsequent text in
the commit as a SHA, then throw a TransportException because it's
not a valid SHA.
Now the readLine method will read all the way to the end of the
line, not just the first 1024 characters of it.
Change-Id: If15b491aa9a1e4fd9b8bbed2dd9e6be47a64ccb7 Signed-off-by: Chris Gavin <chris@chrisgavin.me>
Shawn Pearce [Thu, 21 Jan 2016 06:08:23 +0000 (22:08 -0800)]
Fix unused throws CorruptObjectException from addTree
2262a794b48ea removed throws CorruptObjectException, but was not
compiled under Eclipse and did not see errors generated by Eclipse.
Maven build silently ignored the unnecessary code.
Shawn Pearce [Thu, 21 Jan 2016 05:32:17 +0000 (00:32 -0500)]
Merge changes from topic 'reftree'
* changes:
debug-rebuild-ref-tree: Copy HEAD into RefTree
debug-rebuild-ref-tree: Add --enable flag to turn the database on
RefTreeDatabase: Allow ORIG_HEAD, etc. on non-bare repositories
RefTreeDatabase: Expose bootstrap refs in getAdditionalRefs
Shawn Pearce [Thu, 21 Jan 2016 04:15:09 +0000 (23:15 -0500)]
Merge changes from topic 'ketch'
* changes:
daemon: Add --ketch=LEADER flag
Ketch: Intercept push and route it through Ketch
Ketch: Simple map of running leader instances
Ketch: Basic replication system
Shawn Pearce [Wed, 20 Jan 2016 15:41:08 +0000 (07:41 -0800)]
TreeWalk: Remove CorruptObjectException from addTree(AbstractTreeIterator)
This form of addTree() does not parse any objects and cannot throw the
declared checked exception. Callers are being forced to try-catch
CorruptObjectException that cannot occur when the iterator instance
has already been constructed.
ResetCommand was not returning the updated ref as a result of the call()
method. Since the ResetCommand is always updating the same ref (HEAD)
this should always be the HEAD ref.
Bug: 440750
Change-Id: I7974975c3ab05e68c208384e69cf0692ded6e8db Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Add option to allow empty commits to CommitCommand
CommitCommand should allow to specify whether empty commits (commits
having the same tree as the sole predecessor commit) are allowed or not.
Similar to native git's "--allow-empty" flag.
The defaults differ between JGit and native git even after this change.
When not specifying paths then by default JGit allows to create empty
commits while native git does not. It would be API breaking to change
this now.
Bug: 460301
Change-Id: I88feb0c3ffb2c686b1d0594e669729b065cda4cb Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Shawn Pearce [Wed, 13 Jan 2016 05:55:43 +0000 (21:55 -0800)]
daemon: Add --ketch=LEADER flag
Experimental flag to turn on the KetchLeader within this daemon JVM.
This is a manually elected leader process, set from the command line.
Remote followers for each repository are configured per-repository
using remote sections with ketch-type = FULL. For example:
Manually elected leader's $GIT_DIR/config:
[ketch]
name = A
[remote "A"]
ketch-type = FULL
[remote "B"]
url = git://127.0.0.1:9421/sample.git
ketch-type = FULL
[remote "C"]
url = git://127.0.0.1:9422/sample.git
ketch-type = FULL
Shawn Pearce [Mon, 18 Jan 2016 18:33:31 +0000 (10:33 -0800)]
Ketch: Basic replication system
Git Ketch is a multi-master Git repository management system. Writes
are successful only if a majority of participant servers agree. Acked
writes are durable against server failures as a majority of the
participants store all required objects.
Git Ketch is modeled on the Raft Consensus Algorithm[1]. A ketch
sailing vessel is faster and more nimble than a raft. It can also
carry more source codes.
Git Ketch front-loads replication costs, which vaguely resembles a
ketch sailing vessel's distinguishing feature of the main mast on the
front of the ship.
Dave Borowitz [Tue, 19 Jan 2016 16:13:40 +0000 (11:13 -0500)]
ChangeIdUtil: Don't throw IOException
This could have only happened during the getBytes call. Instead, use
Constants.encode, which is a non-throwing implementation.
This change is binary compatible with existing code compiled against
older versions of JGit, although it might break compilation of
previously compiling code due to dead catch blocks.
Shawn Pearce [Tue, 19 Jan 2016 21:08:38 +0000 (13:08 -0800)]
Transport: Implement AutoCloseable
After creating a Transport instance callers should always call
its close() method. Use AutoCloseable to document this idiom
and allow use of try-with-resources.
Shawn Pearce [Tue, 19 Jan 2016 22:08:53 +0000 (17:08 -0500)]
Merge changes from topic 'deadtree'
* changes:
Ignore API errors about Tree, TreeEntry, FileTreeEntry and friends being removed
Revert "Revert "Remove deprecated Tree, TreeEntry, FileTreeEntry and friends""
Shawn Pearce [Mon, 18 Jan 2016 18:42:00 +0000 (10:42 -0800)]
ReceiveCommand.abort(): Utility to mark batch of commands as failed
If one or more commands is failing the entire group usually has to
also fail with "transaction aborted". Pull this loop into a helper
so the idiom can be easily reused in several places throughout JGit.
Shawn Pearce [Fri, 15 Jan 2016 22:13:25 +0000 (14:13 -0800)]
debug-rebuild-ref-tree: Copy HEAD into RefTree
HEAD is not part of getRefs(ALL) and must be copied explicitly.
This allows `jgit debug-rebuild-ref-tree --enable` to convert an
existing repository to use RefTree with a local working tree:
Shawn Pearce [Fri, 15 Jan 2016 00:11:15 +0000 (16:11 -0800)]
RefTreeDatabase: Expose bootstrap refs in getAdditionalRefs
By showing the bootstrap layer in getAdditionalRefs() garbage
collector code can be more RefDatabase agnostic and not care about
the special case of RefTree and RefTreeNames for the purposes of
building up the roots to GC. Instead they can combine getRefs(ALL)
and getAdditionalRefs() and have a clean set of roots.
Shawn Pearce [Wed, 13 Jan 2016 00:11:36 +0000 (16:11 -0800)]
PackWriter: Declare preparePack object sets as @NonNull
Require callers to pass in valid sets for both want and have
collections. Offer PackWriter.NONE as a handy constant for an
empty collection for the have part of preparePack instead of null.
Shawn Pearce [Tue, 12 Jan 2016 18:50:36 +0000 (10:50 -0800)]
GC: Pack RefTrees in their own pack
The RefTree graph needs to be quickly accessed to read references.
It is also distinct graph disconnected from the rest of the
repository. Store the commit and tree objects in their own pack.
Shawn Pearce [Sun, 10 Jan 2016 01:27:25 +0000 (17:27 -0800)]
RefTree: Change peel suffix to " ^" (space carrot)
Using ^{} as the peel suffix has caused problems when projects used
tags like v2.1 and then v2.1.1, v2.2.2, etc. The peeled value for
v2.1 was stored very far away in the tree relative to v2.1 itself as
^ sorts in the ASCII/UTF-8 encoding after all other common tag
characters like digits and dots.
Use " ^" instead as space is not valid in a reference name, sorts
before all other valid reference characters (thus forcing next entry
locality) and this looks like a peeled marker for the prior tag.
Shawn Pearce [Sat, 9 Jan 2016 20:51:14 +0000 (12:51 -0800)]
FileRepository: Support extensions.refsBackendType = RefTree
This experimental code can be enabled in $GIT_DIR/config:
[core]
repositoryformatversion = 1
[extensions]
refsBackendType = RefTree
When these are set the repository will read references from the
RefTree rooted by the $GIT_DIR/refs/txn/committed reference.
Update debug-rebuild-ref-tree to rebuild refs/txn/committed only from
the bootstrap layer. This avoids misuse by rebuilding using packed-refs
and $GIT_DIR/refs tree.
Shawn Pearce [Sat, 28 Nov 2015 07:21:43 +0000 (23:21 -0800)]
RefTreeDatabase: Ref database using refs/txn/committed
Instead of storing references in the local filesystem rely on the
RefTree rooted at refs/txn/committed. This avoids needing to store
references in the packed-refs file by keeping all data rooted under
a single refs/txn/committed ref.
Performance to scan all references from a well packed RefTree is very
close to reading the packed-refs file from local disk.
Storing a packed RefTree is smaller due to pack file compression,
about 49.39 bytes/ref (on average) compared to packed-refs using
~65.49 bytes/ref.
Shawn Pearce [Mon, 11 Jan 2016 20:30:35 +0000 (12:30 -0800)]
RevCommit: Better support invalid encoding headers
With this support we no longer need the 'utf-8' alias. UTF-8 will be
automatically tried when the encoding header is not recognized and used
if the character sequence cleanly decodes as UTF-8.
Modernize some of the references to use StandardCharsets.
Shawn Pearce [Sat, 28 Nov 2015 03:34:36 +0000 (19:34 -0800)]
debug-rebuild-ref-tree: Simple program to build a RefTree
This tool scans all references in the repository and writes out a new
reference pointing to a single commit whose root tree is a RefTree
containing the current refs of this repository.
It alway skips storing the reference it will write to, avoiding the
obvious cycle.
Shawn Pearce [Wed, 18 Nov 2015 00:22:18 +0000 (16:22 -0800)]
RefTree: Store references in a Git tree
A group of updates can be applied by updating the tree in one step,
writing out a new root tree, and storing its SHA-1. If references
are stored in RefTrees, comparing two repositories is a matter of
checking if two SHA-1s are identical. Without RefTrees comparing two
repositories requires listing all references and comparing the sets.
Track the "refs/" directory as a root tree by storing references
that point directly at an object as a GITLINK entry in the tree.
For example "refs/heads/master" is written as "heads/master".
Annotated tags also store their peeled value with ^{} suffix, using
"tags/v1.0" and "tags/v1.0^{}" GITLINK entries.
Symbolic references are written as SYMLINK entries with the blob of
the symlink carrying the name of the symbolic reference target.
HEAD is outside of "refs/" namespace so it is stored as a special
"..HEAD" entry. This name is chosen because ".." is not valid in
a reference name and it almost looks like "../HEAD" which names
HEAD if the reader was inside of the "refs/" directory.
A new Command type is required to handle symbolic references and
peeled references.
Andrey Loskutov [Sun, 3 Jan 2016 11:29:55 +0000 (12:29 +0100)]
Make sure CLIGitCommand and Main produce (almost) same results
Currently execution of tests in pgm uses CLIGitCommand which
re-implements few things from Main. Unfortunately this can results in a
different test behavior compared to the real CLI runtime.
The change let CLIGitCommand extend Main and only slightly modifies the
runtime (stream redirection and undesired exit() termination).
Andrey Loskutov [Sun, 3 Jan 2016 14:27:01 +0000 (15:27 +0100)]
Added CLIText.fatalError(String) API for tests
In different places (Main, TextBuiltin, CLIGitCommand) we report fatal
errors and at same time want to check for fatal errors in the tests.
Using common API simplifies the error testing and helps to navigate to
the actual error check implementation.
The recent ObjectChecker changes to pass in AnyObjectId as part
of the checkCommit method signature meant the override here was no
longer throwing an exception as expected.
David Ostrovsky [Sun, 3 Jan 2016 23:44:07 +0000 (00:44 +0100)]
buck: Make :jgit_src target work in cross-cell environment
This artifact is used from unzip utility in Gerrit Code Review
build toolchain and thus the file must exist on the file system.
Moreover, trying to use java_binary() didn't work either, as the
zip layout was wrong: all files contained 'org.eclipse.jgit/src/'
prefix.
Change-Id: I00e3269a7a1a6c6d1fe7e60d1bf1c69b8e57d79d Signed-off-by: David Ostrovsky <david@ostrovsky.org>
Matthias Sohn [Sat, 2 Jan 2016 01:09:16 +0000 (02:09 +0100)]
Ensure all http tests are run and fix broken tests
HttpClientTests were broken. This wasn't discovered since
maven-surefire-plugin's by default only executes test classes
matching **/*Test.java. Fix this by also including **/*.Tests.java
and fix the failing tests.
Change-Id: I487a30fb333de993a9f8d8fff491d3b0e7fb02cc Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Matthias Sohn [Fri, 1 Jan 2016 22:54:15 +0000 (23:54 +0100)]
buck: run http tests
Running tests using buck reveals that HttpClientTests are broken
and weren't executed by Maven since these test classes don't match the
maven-surefire-plugin's default for test classes **/*Test.java.
Will be fixed in a follow-up change.
Change-Id: I82a01b5fd3f0a930bec2423a29a256601dadc248 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Shawn Pearce [Fri, 1 Jan 2016 19:04:11 +0000 (11:04 -0800)]
buck: set vm_args for tests
Maven pom files force the local encoding to UTF-8 to ensure there are
no differences between machines. They also set the JVM max heap to
256m. Match both in Buck so that results are consistent.
Shawn Pearce [Fri, 1 Jan 2016 04:07:03 +0000 (20:07 -0800)]
buck: pin to stable version
Like with Gerrit, pin JGit to a single version of Buck that is known
to work with current Buck files and JUnit tests. Notably a more recent
version of Buck used by Gerrit (01a0c54d827) fails WalkEncryptionTest.
Shawn Pearce [Fri, 1 Jan 2016 17:58:34 +0000 (12:58 -0500)]
Merge changes from topic 'add-df'
* changes:
DirCache: Do not create duplicate tree entries
DirCacheEditor: Replace file-with-tree and tree-with-file
AddCommand: Use NameConflictTreeWalk to identify file-dir changes