Commit Graph

2316 Commits

Author SHA1 Message Date
Jonathan Nieder 78009782cd archive: Add tar support
Unlike ZIP files, tar files do not treat symlinks as ordinary files
with a different mode, so tar support involves a little more code than
would be ideal.

Change-Id: Ica2568f4a0e443bf4b955ef0c029bc8eec62d369
2012-12-04 15:37:42 -08:00
Jonathan Nieder 345ab401ce archive: Add --format option that switches between formats
Prepare for .tar support.

Change-Id: Ieb07702da1a54b41ae764fbb425f70826907b593
Improved-by: Shawn O. Pearce <spearce@spearce.org>
2012-12-04 15:36:32 -08:00
Jonathan Nieder 7123cbf470 archive: Record executable and symlink bits
Setting the mode for a zip entry is now as simple as
"entry.setUnixMode(mode)", so do that.

The test checks using the system's "zipinfo" command (from InfoZIP)
that the mode has been recorded correctly on systems that happen to
have a "zipinfo" command, using org.junit.Assume to distinguish them.

Change-Id: I4236c102fd76f18d01b2dc926eeb9b9fa11a61b7
2012-12-04 15:34:07 -08:00
Shawn Pearce 72ee3280e0 Merge "[RFC] archive: Switch to commons-compress as ZIP archiver" 2012-12-04 18:28:20 -05:00
Shawn Pearce e9a1df6c56 Merge "Commit message may not necessarily be in UTF-8" 2012-12-04 10:00:30 -05:00
Colby Ranger b9e485661d Fix DeltaWindow.clear() to release loaded buffer bytes.
It is possible for the buffer to be set but not the index. It
ocurrs when an exception occurs during creating an index, but
after the buffer is loaded. Furthermore, the cleared DeltaWindowEntry
should have been ent and not res.

Change-Id: I2e0d79540316635bf7aa43efd225e4eb38230844
2012-12-03 12:46:53 -08:00
Jonathan Nieder 1547eaf7c5 [RFC] archive: Switch to commons-compress as ZIP archiver
The Apache Commons Compress library provides a similar interface to
java.util.zip with some features not found in java.util.zip, including
support for inclusion of metadata (file mode and symlink targets) and
support for multiple file formats (zip, .tar.xz, etc).

Use it, in preparation for making use of these features.  No
functional change intended yet.

A previous version of this patch used plexus-archiver.  That is a
heavier-weight dependency and offers a less convenient interface.

Thanks to James Moger and Chris Aniszczyk for advice.

Change-Id: Id01146950bb9c18dae0169311e3cde2c3bfa675e
2012-12-03 10:49:06 -08:00
Robin Stocker 4213a91c97 Enable reuse of FileTreeIterator and FileEntry for non subclasses
For EGit change I2c41d86b8b74c2a334433de1bbfed5b36af872bf,
ContainerTreeIterator also needs to create entries for File objects in
case of filtered resources. Instead of reimplementing FileEntry there,
make the constructor public so that it can be reused.

Also allow to pass a WorkingTreeIterator instead of a FileTreeIterator
in FileTreeIterator's constructor, which is enough and allows to pass
other subclasses.

Bug: 358901
Change-Id: Ie0f9c9434ef7d73a8d73d4fe46db4147ded1d267
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-12-03 11:26:39 -06:00
Chris Aniszczyk 55e8f2a433 Merge "Support --cached in RmCommand" 2012-12-03 11:56:12 -05:00
Robin Stocker beb16cec26 Support --cached in RmCommand
Also extend documentation and add examples.

Bug: 395599
Change-Id: Id1ddbc9da787472f82e58834092bc073224b262b
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-12-03 10:40:54 -06:00
Jonathan Nieder c9a857a60a Add basic "jgit add" tests
Change-Id: I056c2556c7db98bf57e2527dec11af7c3daf472a
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-29 16:38:07 -08:00
Jonathan Nieder b46b27e389 add: Fix bad metaVar reference in <filepattern> help
Without this patch, "jgit add --help" throws two exceptions
(NoSuchFieldException: metavar_filepattern; MissingResourceException:
Can't find resource for bundle java.util.PropertyResourceBundle, key
metavar_filepattern) instead of printing a usage message, due to a
small typo and a missing declaration.

Change-Id: I4b848b3a8c7b1a49d8b9582809375daa4aca6b50
2012-11-28 17:48:25 -08:00
Robin Rosenberg 257f3fe4a1 Commit message may not necessarily be in UTF-8
Trying different encoding makes presentation nicer
to user.

Change-Id: I2d2c2a95d0b5cd709855d7a67cbc247478434d2f
2012-11-27 08:34:40 +01:00
Chris Aniszczyk 3537f3cc2d Merge "Do not warn about non-translated strings in the ant library" 2012-11-25 15:46:42 -05:00
Chris Aniszczyk c3aecadd1d Merge "Do not warn about non-translated strings in the iplog generator" 2012-11-25 15:46:31 -05:00
Chris Aniszczyk 9fffa19ca2 Merge "Do not warn about non-translated strings in the http library" 2012-11-25 15:46:16 -05:00
Robin Rosenberg 8b06c46e30 Add a case statement for fast-forward merge
This case was ommitted. Treat the same as a non-fastworwad
merge.

Change-Id: Ia81e2430dfe04c3ce9b6e2f8fb4b6c646293a174
2012-11-25 21:11:28 +01:00
Robin Rosenberg efdfd1babf Do not warn about non-translated strings in the ant library
Ant tasks are generally not translated, hence don't warn about
untranslated strings

Change-Id: I60920ccdaf3c0139979bb4ef19eb42036bb7e07f
2012-11-25 17:20:27 +01:00
Robin Rosenberg 0791a9c3e7 Do not warn about non-translated strings in the iplog generator
This module is used by very few people so translation is not a priority
and hence we need no warnings about untranslated strings.

Change-Id: I11be2e9903583d1a3dade7bf3d5eb77a30152b7c
2012-11-25 17:20:23 +01:00
Robin Rosenberg e365265ad7 Do not warn about non-translated strings in the http library
The strings here are for machine-to-machine communications.

Change-Id: Ia0d19fce3d9843d18d329d9bc5b10d62c4125db8
2012-11-25 17:20:17 +01:00
Marc Strapetz 67edd3eda7 RevWalk support for shallow clones
StartGenerator now processes .git/shallow to have the
RevWalk stop for shallow commits.

See RevWalkShallowTest for tests.

Bug: 394543
CQ: 6908
Change-Id: Ia5af1dab3fe9c7888f44eeecab1e1bcf2e8e48fe
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-21 10:46:02 -06:00
Dariusz Luksza 8eb4d92637 Add support for rebase interactive 'edit' command
The 'edit' command allows you to change arbitrary commit
content and the message of any commit in the repository.

Bug: 394577
Change-Id: I43a44782cdb10b29f13784fa75ab37fe5d4da01b
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-11-19 10:02:25 -06:00
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