Git, ByteArrayOutputStream, and DiffFormatter are auto-closeable and
should be managed in try-with-resource.
Change-Id: I83395116acb4b4f7cd4300fd69564355bc07e4bb
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
Use JUnit's assumeFalse method to cause the test to skip when
run on Windows.
Change-Id: I3f59440cfe62c37c127e381052b60471fbe8ec5e
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
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.
Change-Id: Id338035302903bab81569d1576eab063eee0885a
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>
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>
Factor out the creation of the SideBandOutputStream objects into
a utility method that wraps it in a try-with-resource.
Remove the "unused" suppression that is now unnecessary, and add
declaration that the tests methods can throw Exception.
Change-Id: Iff02e4e3532bd6ab6e423f197e70d44c4f328d0b
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
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.
Change-Id: I191fec5cac718657407230de141440e86d0151fb
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.
Change-Id: I0c6ff3e39ebecdd7a028dbcae1856a818937b186
* changes:
Ignore API errors about Tree, TreeEntry, FileTreeEntry and friends being removed
Revert "Revert "Remove deprecated Tree, TreeEntry, FileTreeEntry and friends""
Also rename a local variable in one of the tests that was hiding
a class variable of the same name.
Change-Id: Ia9398157b87a78df6eef0b64a833c16ca2e57ce3
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
Also remove a local variable in one of the tests that was
hiding a member variable with the same name.
Change-Id: Ia4d94cdbf2d83d8be2645f0a93d8891d01606c59
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
Specify the expected exception in the annotation, instead of
catching it and calling `fail()` when it wasn't raised.
Change-Id: I8a640c0e42353533e4e73b85b50c224dc060f2d7
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
We don't need to update versions for this project which was removed
a long time ago.
Change-Id: Ie2d030134942add152847581797db3a213ec4c9e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
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.
Change-Id: I3b9399b7e26ce2b0dc5f7baa85d585a433b4eaed
Repository.getWorkTree is annotated as @NonNull, so the check
for it returning null is redundant.
Change-Id: I597b0f774ff857b8900519f14a1a17a904cf7c6f
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
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.
Change-Id: Ifda4450f5e488cbfefd728382b7d30797e229217