Commit Graph

2444 Commits

Author SHA1 Message Date
Dariusz Luksza 84fb2b59d1 Add support for rebase interactive 'reword' command
'reword' command is used to change commit message of any
commit in git history.

Bug: 394575
Change-Id: Ic974e76dfd923fd6f0cb8f07d1a6fbecd9abbf31
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-19 09:40:53 -06:00
Matthias Sohn 9051af3c4d Add GarbageCollectCommand to porcelain API
Bug: 394544
Change-Id: I73faa55d860db64efc3412fee27386df47552a75
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-18 19:19:12 -06:00
Ketan Padegaonkar 360be05fd4 Have git-ls tree to accept path args like git-ls-tree
Usage is:

jgit ls-tree [-r|--recursive] <tree-ish> [-- paths...]

Change-Id: I2e1c9c3cc8cddfa12ca4bfb9afc4df0492a9fce1
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-18 18:36:13 -06:00
Tomasz Zarna 20c3b6b8a0 Add config constant for "mergeoptions"
Bug: 336933
Change-Id: Idcc0fbc8a8143dd665e80e4d6f4a4adaeae287db
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-18 18:32:37 -06:00
Jonathan Nieder 6a94f027b6 Add "jgit archive" tool that writes a tree as a ZIP file
C Git's "git archive" command represents a tree object using a
standard archival format like tar, zip, or tgz, ready for consumption
by other, git-unaware users or tools.

Add a bare-bones analagous "jgit archive" command to show what is
possible, supporting only ZIP format for now.  It uses java.util.zip
which is not aware of the InfoZIP extensions for representing symlinks
and file permissions, so symlinks, executable files, and submodule
entries are represented as plain text files.

Making this functionality available from the library, improving
handling of special entries, and support for other output formats are
left for later patches.  Ultimately the intent is to offer a
TreeArchiveStream class for use by web frontends like Gitiles to offer
"download as zip/tgz/txz" links and use by, for example, code search
tools to get easy access to the content of git tree objects.

Test with "jgit archive my-favorite-tree >out.zip".

Change-Id: Ib590f173ceff3df4b58493cecccd6b9a1b355e3d
2012-11-16 16:21:25 -08:00
Jonathan Nieder 789ca39ade Allow commandline tests to use raw output
Introduce a new CLIGitCommand.rawExecute() helper that behaves
just like execute() except that instead of processing its output
it returns it raw.

So now you can do

	final byte[] expect = { 0, 1, 2, 3 };
	final byte[] actual = CLIGitCommand.rawExecute(
			"git show HEAD:goo.raw", db);
	assertArrayEquals(expect, actual);

to test the output from "git show HEAD:goo.raw" without being
distracted by encoding issues.

Noticed while writing tests for a new "jgit archive" command that
writes its output in ZIP format.

Change-Id: I2fe6020a537975d0ccf414b7125d85d6cd86898c
2012-11-16 15:45:52 -08:00
Mikael Karlsson fa5231191d Add support for pull with --rebase and --no-rebase
Bug: 394501
Change-Id: I697e2fc82a46c03762111eb1de93e673a2643b4f
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-16 12:51:35 -08:00
Dani Megert 58dd286848 Declare all thrown exceptions in Repository
Bug 393155
Change-Id: If702f2e54b17e82890f016126ee7bde4bff4af1d
Signed-off-by: Dani Megert <Daniel_Megert@ch.ibm.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-16 12:42:19 -08:00
Matthias Sohn 6abb1b37a1 Import non-java.* JRE packages
Otherwise loading javax.net.ssl.TrustManager fails if
osgi.compatibility.bootdelegation=false which became the Equinox default
since bug 344850 was fixed.

Bug: 392056
Change-Id: I464871723649095942dbf77da93890ac8ec39075
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-16 12:33:22 -08:00
Markus Duft f64237d5ff Adapt Status and CleanCommand to support cleaning directories
This adds the possibility to:

 * retrieve untracked directories from the status
 * instruct the CleanCommand to clean those directories.
 * retrieve ignored paths from the status
 * instruct the CleanCommand to leave those ignored paths alone

Bug: 338717
Change-Id: Ibed0459005a5e306c010b9932f5b5fd107fb5448
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-16 12:17:28 -08:00
Tomasz Zarna fb33e80218 Add reflog command to JGit CLI
Bug: 394497
Change-Id: Ib8bc1d9fd789d22fe5f10e03068a11cfdd3e46eb
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-16 12:02:28 -08:00
Robin Stocker cdaded26b0 CheckoutCommand: Support checking out ours and theirs
The checkoutPaths body is split into two implementations, depending on
whether we are checking out the index or a branch. This improves
readability, as in the index case we now also need to have access to
DirCacheIterator.

Bug: 390147
Change-Id: I99fd599b25b2ace9bdd84535a56565286a3cb7f1
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-16 10:31:32 -08:00
Robin Rosenberg 20c829838a Make an exception for the formatting rules (turn off) for some files
Our rule to enforce javodocs for public members gives us a problem
because there are some patterns where javadoc make little sense so we
make the comments as small as possible, which our formatting rules do
not like, so disable it for those source files.

Change-Id: I6e3edb1e650ed45428b89cf41e6151b6536bca8a
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-16 10:28:42 -08:00
Robin Rosenberg 57333a8e93 Harmonize the JDT settings within JGit
Note the the settings are slightly less restrictive for test bundles.
-Also cleanup a couple of malformed javadocs
-Update compiler warnings/errors to include default values from Juno
-We now flag diagnosed null dereference as error. We didn't do that
 earlier because of some false positives.

Change-Id: I58386d63164e65d3d8d1998da3390d99bdc7381a
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-16 10:25:45 -08:00
Robin Stocker a2e691351f DirCacheEditor: Apply PathEdit for each stage
This behavior was defined in the Javadoc of PathEdit, but not actually
implemented.

It's necessary when one wants to use a PathEdit to check out a specific
stage in apply.

Bug: 390147
Change-Id: Iaed5cf60c554fc17e6c4d188caf4f0231da920d0
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-16 10:12:40 -08:00
Matthias Sohn 05a7113002 Add missing @since tags to mark API added in 2.2
Change-Id: I458167739210214fa54c4b3d62fac5abc82f96f7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-16 10:08:07 -08:00
Tomasz Zarna 318f3d4643 Add support for --no-ff while merging
Bug: 394432
Change-Id: I373128c0ba949f9b24248874f77f3d68b50ccfd1
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-16 11:04:13 +01:00
Tomasz Zarna cb0f0ad4cf Add a test for org.eclipse.jgit.pgm.Tag
The test checks if an error is thrown when trying to create the same tag
for the second time.

Change-Id: I4ed2f6c997587f0ea23bd26a32fb64a2d48a980e
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-15 16:28:02 -08:00
Tomasz Zarna 790126c145 Do not fail when checking out HEAD
Change-Id: I99f5467477ed53101121a5a5d8a0910c55758401
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-15 16:05:09 -08:00
Tomasz Zarna 074f9194dc Prefix an abnormal CLI command termination with 'fatal:'
Change-Id: I3d257666c6fbed7b238c575808f73ec518e811b9
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-15 15:45:35 -08:00
Chris Aniszczyk e73c6873c7 Merge "CommitCommand: Ensure unmerged paths are added correctly with setOnly" 2012-11-15 18:43:54 -05:00
Matthias Sohn 6a3b0668b7 Merge "Fix formatting in org.eclipse.jgit.pgm.CLIText" 2012-11-14 17:34:34 -05:00
Jonathan Nieder dfb8bd694c diff, log -p: do not use outs before it is initialized
Since commit caa362f20d (Check for write errors in standard out and
exit with error, 2012-09-14), running "jgit diff" results in a
NullPointerException:

| $ jgit diff
| java.lang.NullPointerException
|	at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
|	at java.io.BufferedOutputStream.write(BufferedOutputStream.java:126)
|	at org.eclipse.jgit.diff.DiffFormatter.format(DiffFormatter.java:688)
|	at org.eclipse.jgit.diff.DiffFormatter.format(DiffFormatter.java:630)
|	at org.eclipse.jgit.diff.DiffFormatter.format(DiffFormatter.java:616)
|	at org.eclipse.jgit.diff.DiffFormatter.format(DiffFormatter.java:600)
|	at org.eclipse.jgit.pgm.Diff.run(Diff.java:211)
|	at org.eclipse.jgit.pgm.TextBuiltin.execute(TextBuiltin.java:166)
|	at org.eclipse.jgit.pgm.Main.execute(Main.java:200)
|	at org.eclipse.jgit.pgm.Main.run(Main.java:120)
|	at org.eclipse.jgit.pgm.Main.main(Main.java:94)

That patch replaced most uses of System.out with a wrapper, with
changes like the following:

	 class Diff extends TextBuiltin {
		private final DiffFormatter diffFmt = new DiffFormatter( //
	-			new BufferedOutputStream(System.out));
	+			new BufferedOutputStream(outs));

outs is not set for TextBuiltin objects until init() has been run.
Moving the initialization to after the super.init() call gets
"jgit diff" and "jgit log -p" working well again.

Change-Id: I80fcf259c4fb733990bd16e52bcf94e66d820826
2012-11-14 12:14:20 -08:00
Robin Stocker 0f88d7b72f CommitCommand: Ensure unmerged paths are added correctly with setOnly
With bug 391855, PathEdit will be changed to apply an edit for each
stage. With that, CommitCommand would no longer work correctly when
committing an unmerged path.

This changes it to use a DirCacheBuilder which allows us to correctly
replace the entries for the three stages with one, which is not possible
with PathEdit.

Bug: 391859
Change-Id: I6dc180aec7e2cbf8d1e91f50482c95bc420f79de
2012-11-12 22:51:18 +01:00
Tomasz Zarna 77d98b7ed5 Fix formatting in org.eclipse.jgit.pgm.CLIText
Change-Id: Ia87f28fa440cb354bf591713c8aadbe3969edbf1
2012-11-11 23:45:28 +01:00
Robin Stocker 106e8b8762 Fix redundant null check warning in Repository
rev is always null because of `if (rev != null) return ...` above.

Change-Id: I8168aefd344e0c4b0c68caea1a3daee66c07173b
2012-11-08 14:18:21 +01:00
Colby Ranger f3a8d7413c Merge "Add the an event and listener for a dfs PackIndex being loaded." 2012-11-02 13:27:36 -04:00
Colby Ranger 034ff96674 Add the an event and listener for a dfs PackIndex being loaded.
The DfsPackFile will fire any static repository listeners on the event
just before the PackIndex is loaded.

Change-Id: Ie51098106bd5a1a32feae7d2dd068abf02b030ee
2012-11-02 09:33:01 -07:00
Tomasz Zarna 908d219dbd Add ReflogCommandTest#testAmendReflog
Add a test for reflog with an amend commit and add assertions for
branch comments

Change-Id: Ie44076ff1abf1f8954b85d8c74ac6cb41ab789cb
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-01 16:56:30 -07:00
Robin Stocker de2455af67 ResetCommand: Use DirCacheBuilder in resetIndex
With bug 391855, DirCacheEditor's PathEdit will be applied for each
stage. For an unmerged path, this would result in 3 equal entries for
the same path.

By using a DirCacheBuilder, the code is simpler and does not have the
above problem with unmerged paths.

Bug: 391860
Change-Id: I785deeaeb8474f8c7a7fbc9ef00d3131fac87e41
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-01 10:47:10 -07:00
Robin Stocker 3f1d56d6b7 ResetCommand: Correctly reset unmerged paths in resetIndexForPaths
The previous implementation used a PathEdit, which does not reset the
stage of the entry.

Bug: 391860
Change-Id: If26d3a35abfee85424ad69de724f06a28b6e9efb
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-01 10:33:50 -07:00
Shawn Pearce 8acaae802c Merge "Add isIndexLoaded() to DfsPackFile." 2012-11-01 13:07:23 -04:00
Shawn Pearce 69b2a9f539 Merge "[blame] Don't pass null to PersonIdent constructor" 2012-11-01 12:48:23 -04:00
Colby Ranger f6f8bcd9df Add isIndexLoaded() to DfsPackFile.
The method reports whether the index file for the pack has been loaded
and cached in memory.

Change-Id: Ifa8d63f737458e102cb3d28579c9711d46693d17
2012-11-01 09:07:52 -07:00
Robin Stocker b7f5ed5612 Add Javadoc description for packages
These appear as descriptions in the index, see here (currently empty):

http://download.eclipse.org/jgit/docs/latest/apidocs/

Change-Id: If7996deef30ae688bade8b3ad6b19547ca3d8b50
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-10-31 21:26:22 -07:00
Chris Aniszczyk cda5e861b9 Merge "Refactor ResolveMergerTest to allow testing multiple strategies" 2012-10-30 20:00:14 -04:00
Robin Stocker ecf97083e5 [blame] Don't pass null to PersonIdent constructor
The API was changed to not allow null values anymore with
I0ac994ae8e47789d38f7c6e6db55d482f0f1bac3, leading to an IAE.

Bug: 393054
Change-Id: If33560ae976b46a02ff75b2e4ec05c13a8ad2d41
2012-10-29 20:48:38 +01:00
Robin Stocker 54aceb1769 Pull up method for creating DirCacheEntry into RepositoryTestCase
Change-Id: I6e6522289553137df1a46ceeb52f461e9d25a290
2012-10-28 14:25:11 +01:00
Robin Rosenberg 81fa566295 Suppress resource warnings with Java 7
For streams that should not be closed, i.e. don't own an underlying
stream, and in-memory streams that do not need to be closed we just
suppress the warning. This mostly apply to test cases. GC is enough.

For streams with external resources (i.e. files) we add the necessary
call to close().

Change-Id: I4d883ba2e7d07f199fe57ccb3459ece00441a570
2012-10-25 15:17:23 -07:00
Shawn Pearce bc8794eb21 Merge "Extend Javadoc of CheckoutCommand and add examples" 2012-10-25 18:13:56 -04:00
Shawn Pearce 71ac75fea3 Merge "Add a check in fstick that the reference file exists" 2012-10-25 18:01:04 -04:00
Shawn Pearce 4e6e267b8a Merge "Fix for Iff768422c, use offset 0 when going back to work tree iterator" 2012-10-25 17:55:22 -04:00
Robin Rosenberg 243e14d051 Add a check in fstick that the reference file exists
This helps avoiding some stupid thinkos.

Change-Id: I5b386cd9c6bf0e11f270bb2b8cfaac66ce9b341b
2012-10-25 14:48:48 -07:00
Shawn Pearce cd61e85fa1 Merge "Don't allow null name or e-mail in PersonIdent" 2012-10-25 17:19:15 -04:00
Shawn Pearce 88eb017c6c Merge "Fix Javadoc formatting of org.eclipse.jgit.diff package" 2012-10-25 17:16:27 -04:00
Shawn O. Pearce 500becfc63 Merge "Simplify push error message when ref already exists" 2012-10-25 17:15:02 -04:00
Christian Halstrick 37ab3ffdaf Refactor ResolveMergerTest to allow testing multiple strategies
By making use of JUnit Theories and Datapoints ResolveMergerTests is now
capable to run the tests against multiple Merge strategies.

Change-Id: Ifa0075e0a2aca7576ef268291b73fa2f4d79b591
2012-10-25 17:48:39 +02:00
Christian Halstrick b7d2c9a446 Merge "AbstractTreeIterator: Add toString with entry path" 2012-10-22 07:11:01 -04:00
Robin Stocker ad52ec5207 StashCreateCommand: Abort in case of unmerged paths
Bug: 391861
Change-Id: I5f8ffe072c08c8ca2ca6be6b6afa67c8e16a63b6
2012-10-22 11:14:40 +02:00
Robin Stocker f54b74225c AbstractTreeIterator: Add toString with entry path
Helps when debugging tree walking code.

Change-Id: I7ba3846a028a1538787a7d4fbf50f7c487cae6c7
2012-10-20 20:12:25 +02:00