Commit Graph

4316 Commits

Author SHA1 Message Date
Shawn Pearce c221bd6c15 Fix unused throws CorruptObjectException from addTree
2262a794b4 removed throws CorruptObjectException, but was not
compiled under Eclipse and did not see errors generated by Eclipse.
Maven build silently ignored the unnecessary code.

Change-Id: I6e9014adcc604588e10e5963d13d0c6ef0e1c617
2016-01-21 17:07:50 +01:00
Matthias Sohn 4ec84fac86 Merge branch 'master' into stable-4.2
Change-Id: Ieec4f51aedadf5734ae0e3f4e8713248a3c4fc52
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-01-21 17:07:31 +01:00
David Pursehouse 7e8e4ec019 BundleWriterTest: Open RevWalk in try-with-resource
Change-Id: Ie25770a73b19d6522bad9fdc0966f48370f96265
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-21 19:13:23 +09:00
David Pursehouse 2a7b3ff00b DiffFormatterTest: Remove accidentally added trailing whitespace
Change-Id: Ia7a3b05b79c3a5530a4445e6e48ceae445425224
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-21 19:12:12 +09:00
David Pursehouse 776030f198 CherryPickCommandTest: Create Git instances in try-with-resource
Change-Id: I9d49258bdf12f3221013c37cfb8a21ea27f28860
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-21 18:07:54 +09:00
David Pursehouse 1257cfc262 DiffFormatterTest: Create auto-closeable instances in try-with-resource
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>
2016-01-21 17:01:25 +09:00
David Pursehouse 72c94465bc ConfigTest: Create Git instance in try-with-resource
Change-Id: Ie65c69e0f1aed95bcdf68ebd68d21b3e2590b41c
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-21 15:31:56 +09:00
David Pursehouse ce1a3d7ef8 CommitAndLogCommandTest: Use assumeFalse to skip test on Windows
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>
2016-01-21 15:30:49 +09:00
David Pursehouse b1d188fbb7 CommitAndLogCommandTest: Create Git instances in try-with-resource
Change-Id: Id06417f1d3914cd3addacdbe9b5801a06cc3955f
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-21 15:25:46 +09:00
David Pursehouse a8d99d9a4f AddCommandTest: Create Git instances in try-with-resource
Change-Id: Idf42f03099eeb9975fef9492ea8a75776afc2a3c
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-21 10:22:52 +09:00
David Pursehouse a833fec219 ArchiveCommandTest: Create Git instances in try-with-resource
Change-Id: Icbfd92395db85818736142fd3fb3432385e89ca9
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-21 10:22:18 +09:00
Shawn Pearce 7b6122908b Merge "TreeWalk: Remove CorruptObjectException from addTree(AbstractTreeIterator)" 2016-01-20 11:03:47 -05:00
Shawn Pearce 2262a794b4 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.

Change-Id: Id338035302903bab81569d1576eab063eee0885a
2016-01-20 07:41:08 -08:00
Christian Halstrick 7182cb2a26 Fix ResetCommand to return the resulting ref
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>
2016-01-20 11:27:31 +01:00
Christian Halstrick da43d8d798 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>
2016-01-20 11:14:19 +01:00
David Pursehouse ebbd007639 TagCommandTest: Instantiate Git and RevWalk objects in try-with-resource
Change-Id: I08959650e2970e964bc864dc6d120d7bddfd8232
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-20 18:39:45 +09:00
David Pursehouse 41ace0580c BlameCommandTest: Instantiate Git objects in try-with-resource
Change-Id: Icb9e6bb9ee99589fa2e0388c8b305a8a1f5954db
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-20 18:39:25 +09:00
David Pursehouse 0d77b4e5c8 SideBandOutputStreamTest: Use try-with-resource
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>
2016-01-20 11:38:35 +09:00
David Pursehouse 7c21aeb508 FileTreeIteratorJava7Test: Create Git instances in try-with-resource
Change-Id: I493e90e8a0d96db5acc49759c8e138b0a8c7b099
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-20 11:23:50 +09:00
Matthias Sohn a01d6c1e55 Merge "Remove declared IOException which is no longer thrown" 2016-01-19 20:05:35 -05:00
Matthias Sohn 3af05f6080 Remove declared IOException which is no longer thrown
Since 2ccea7f0 ChangeIdUtil.computeChangeId() doesn't throw IOException
anymore.

Change-Id: I0bf43f2346dadbbfe7e6cbcb38b5525456fbf686
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-01-20 01:55:51 +01:00
David Pursehouse aca07fac46 Merge branch 'stable-4.2'
* stable-4.2:
  CheckoutCommandTest: Create Git instances in try-with-resource
  BranchCommandTest: Create Git instances in try-with-resource
  CheckoutTest: Create Git instances in try-with-resource
  BranchTest: Create Git instances in try-with-resource
  URIishTest: Use @Test annotation's `expected` argument
  Suppress "The allocated object is never used" warning in tests
  Add $NON-NLS to suppress "Non-externalized string literal" warnings
  Don't use deprecated constructors of CmdLineException
  Prepare 4.2.0-SNAPSHOT builds
  Remove org.eclipse.jgit.updatesite project from tools/version.sh
  RevParse: Remove superfluous semicolon
  RefUpdateTest: Use try-with-resource for auto-closable types
  RefUpdateTest: Add null check to prevent potential NPE
  CommitCommand: Remove redundant null check
  JGit v4.2.0.201512141825-rc1

Change-Id: I2179859289b2f2e3d0b7c6d02ef7e7890c467f7b
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-20 09:45:48 +09:00
Dave Borowitz 2ccea7f05a 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.

Change-Id: I191fec5cac718657407230de141440e86d0151fb
2016-01-19 17:59:19 -05:00
Shawn Pearce a693d7b33c Merge "Transport: Implement AutoCloseable" 2016-01-19 17:36:39 -05:00
Shawn Pearce 6b662af76e 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.

Change-Id: I0c6ff3e39ebecdd7a028dbcae1856a818937b186
2016-01-19 14:27:11 -08:00
Shawn Pearce 68a6d0c0ab 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""
2016-01-19 17:08:54 -05:00
Shawn Pearce 9d3b56a905 Merge "ReceiveCommand.abort(): Utility to mark batch of commands as failed" 2016-01-19 15:54:07 -05:00
Shawn Pearce 462017e02b Ignore API errors about Tree, TreeEntry, FileTreeEntry and friends being
removed

Bug: 486105
Change-Id: I04adcdb68bee7d5f608bb7ab959fe36a890f9ecd
2016-01-19 18:49:11 +01:00
Andrey Loskutov 7f31a9c9ad Revert "Revert "Remove deprecated Tree, TreeEntry, FileTreeEntry and
friends""

This reverts commit 2cc80187d3.

Bug: 486105
Change-Id: Id4f9987c33d66cbed9de6e4d4d6784afdd01a3cf
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
2016-01-19 18:48:48 +01:00
David Pursehouse 4b93de43ba CheckoutCommandTest: Create Git instances in try-with-resource
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>
2016-01-19 17:27:47 +01:00
David Pursehouse 78b3f174f2 BranchCommandTest: Create Git instances in try-with-resource
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>
2016-01-19 17:27:46 +01:00
David Pursehouse 7f84e40f31 CheckoutTest: Create Git instances in try-with-resource
Change-Id: I49a03f7bee0b61c062ce160674f9aa0cd1bcc8ba
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-19 17:27:46 +01:00
David Pursehouse 9d721de69b BranchTest: Create Git instances in try-with-resource
Change-Id: I8becee479fab91a18e6daffd6f4fd57338c9d120
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-19 17:27:46 +01:00
David Pursehouse 3b63a242ef URIishTest: Use @Test annotation's `expected` argument
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>
2016-01-19 17:27:46 +01:00
David Pursehouse 75e096c80a Suppress "The allocated object is never used" warning in tests
Change-Id: Ibb405e0b36ce5a2cb30268a7de31ab2bd079ad80
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-19 17:27:45 +01:00
David Pursehouse 9ddc0ed83d Add $NON-NLS to suppress "Non-externalized string literal" warnings
Change-Id: I3e6f83ad2bc7d493e2c1ab5a8c60affa2b49c386
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-19 17:27:45 +01:00
David Pursehouse d1e821ec3f Don't use deprecated constructors of CmdLineException
Change-Id: If01fa896537209821d6a7a262ee978572195a397
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-19 17:27:44 +01:00
Matthias Sohn 62718a9cbc Merge "Prepare 4.2.0-SNAPSHOT builds" into stable-4.2 2016-01-19 10:04:06 -05:00
Matthias Sohn cc0afe601b Merge "Remove org.eclipse.jgit.updatesite project from tools/version.sh" into stable-4.2 2016-01-19 09:15:59 -05:00
Andrey Loskutov 2006e90abc Annotated to be removed Tree API with @noreference and @noextend
See https://wiki.eclipse.org/Eclipse/API_Central/API_Removal_Process.

Bug: 486105
Change-Id: I460e43da0d487279608729a2081c614e7065f56f
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
2016-01-19 14:27:41 +01:00
Matthias Sohn 20f272a71c Prepare 4.2.0-SNAPSHOT builds
Change-Id: Ibe38a95bf36db0c0ed948280b28c416943ec0329
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2016-01-19 13:10:20 +01:00
Matthias Sohn 8d3584f4d3 Remove org.eclipse.jgit.updatesite project from tools/version.sh
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>
2016-01-19 13:08:23 +01:00
Shawn Pearce eadfcd3ec1 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.

Change-Id: I3b9399b7e26ce2b0dc5f7baa85d585a433b4eaed
2016-01-18 11:39:09 -08:00
Shawn Pearce f52581c6a5 Merge "Revert "Remove deprecated Tree, TreeEntry, FileTreeEntry and friends"" 2016-01-15 10:45:43 -05:00
Shawn Pearce 2cc80187d3 Revert "Remove deprecated Tree, TreeEntry, FileTreeEntry and friends"
This reverts commit 0f8743d4d7.

JGit is unable to iterate its API.

Change-Id: Ie3d6a28e622a5c0cf54768a2299f1c44c0114c19
2016-01-15 10:45:36 -05:00
David Pursehouse 559e493648 RevParse: Remove superfluous semicolon
Change-Id: I5975bc58d7933dafb3e7a8d891e9f6878b98a9a1
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-14 15:17:46 +09:00
David Pursehouse 0352276da7 RefUpdateTest: Use try-with-resource for auto-closable types
Change-Id: I25c8db0e410aa2a4a53dc7d8863e4a6efefcf7cb
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-14 15:09:53 +09:00
David Pursehouse 56634de0cc RefUpdateTest: Add null check to prevent potential NPE
Change-Id: I64b1850c3bb80b09409044461ca3fdde1c46d4bb
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
2016-01-14 15:06:10 +09:00
David Pursehouse 1ed5382b37 CommitCommand: Remove redundant null check
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>
2016-01-14 15:04:34 +09:00
Shawn Pearce 95bdc589b8 Merge "PackWriter: Declare preparePack object sets as @NonNull" 2016-01-12 19:45:40 -05:00