Initial JGit contribution to eclipse.org
Per CQ 3448 this is the initial contribution of the JGit project to eclipse.org. It is derived from the historical JGit repository at commit 3a2dd9921c8a08740a9e02c421469e5b1a9e47cb. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
commit
1a6964c827
|
@ -0,0 +1 @@
|
|||
*.java diff=java
|
|
@ -0,0 +1,6 @@
|
|||
/jgit
|
||||
/jgit.jar
|
||||
/jgit_src.zip
|
||||
/jgit_docs.zip
|
||||
/org.eclipse.jgit/lib/jsch-*.jar
|
||||
/org.eclipse.jgit.pgm/lib/args4j-*.jar
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
== Java GIT ==
|
||||
|
||||
This package is licensed under the BSD.
|
||||
|
||||
org.eclipse.jgit/
|
||||
|
||||
A pure Java library capable of being run standalone, with no
|
||||
additional support libraries. Some JUnit tests are provided
|
||||
to exercise the library. The library provides functions to
|
||||
read and write a GIT formatted repository.
|
||||
|
||||
All portions of jgit are covered by the BSD. Absolutely no GPL,
|
||||
LGPL or EPL contributions are accepted within this package.
|
||||
|
||||
org.eclipse.jgit.test/
|
||||
Unit tests for org.eclipse.jgit and the same licensing rules.
|
||||
|
||||
== WARNINGS / CAVEATS ==
|
||||
|
||||
- Symbolic links are not supported because java does not support it.
|
||||
Such links could be damaged.
|
||||
|
||||
- Only the timestamp of the index is used by jgit check if the index
|
||||
is dirty.
|
||||
|
||||
- Don't try the library with a JDK other than 1.6 (Java 6) unless you
|
||||
are prepared to investigate problems yourself. JDK 1.5.0_11 and later
|
||||
Java 5 versions *may* work. Earlier versions do not. JDK 1.4 is *not*
|
||||
supported. Apple's Java 1.5.0_07 is reported to work acceptably. We
|
||||
have no information about other vendors. Please report your findings
|
||||
if you try.
|
||||
|
||||
- CRLF conversion is never performed. On Windows you should thereforc
|
||||
make sure your projects and workspaces are configured to save files
|
||||
with Unix (LF) line endings.
|
||||
|
||||
== Package Features ==
|
||||
|
||||
org.eclipse.jgit/
|
||||
|
||||
* Read loose and packed commits, trees, blobs, including
|
||||
deltafied objects.
|
||||
|
||||
* Read objects from shared repositories
|
||||
|
||||
* Write loose commits, trees, blobs.
|
||||
|
||||
* Write blobs from local files or Java InputStreams.
|
||||
|
||||
* Read blobs as Java InputStreams.
|
||||
|
||||
* Copy trees to local directory, or local directory to a tree.
|
||||
|
||||
* Lazily loads objects as necessary.
|
||||
|
||||
* Read and write .git/config files.
|
||||
|
||||
* Create a new repository.
|
||||
|
||||
* Read and write refs, including walking through symrefs.
|
||||
|
||||
* Read, update and write the Git index.
|
||||
|
||||
* Checkout in dirty working directory if trivial.
|
||||
|
||||
* Walk the history from a given set of commits looking for commits
|
||||
introducing changes in files under a specified path.
|
||||
|
||||
* Object transport
|
||||
Fetch via ssh, git, http, Amazon S3 and bundles.
|
||||
Push via ssh, git and Amazon S3. JGit does not yet deltify
|
||||
the pushed packs so they may be a lot larger than C Git packs.
|
||||
|
||||
org.eclipse.jgit.pgm/
|
||||
|
||||
* Assorted set of command line utilities. Mostly for ad-hoc testing of jgit
|
||||
log, glog, fetch etc.
|
||||
|
||||
== Missing Features ==
|
||||
|
||||
There are a lot of missing features. You need the real Git for this.
|
||||
For some operations it may just be the preferred solution also. There
|
||||
are not just a command line, there is e.g. git-gui that makes committing
|
||||
partial files simple.
|
||||
|
||||
- Merging.
|
||||
|
||||
- Repacking.
|
||||
|
||||
- Generate a GIT format patch.
|
||||
|
||||
- Apply a GIT format patch.
|
||||
|
||||
- Documentation. :-)
|
||||
|
||||
- gitattributes support
|
||||
In particular CRLF conversion is not implemented. Files are treated
|
||||
as byte sequences.
|
||||
|
||||
- submodule support
|
||||
Submodules are not supported or even recognized.
|
||||
|
||||
== Support ==
|
||||
|
||||
Post question, comments or patches to the git@vger.kernel.org mailing list.
|
||||
|
||||
|
||||
== Contributing ==
|
||||
|
||||
See SUBMITTING_PATCHES in this directory. However, feedback and bug reports
|
||||
are also contributions.
|
||||
|
||||
|
||||
== About GIT ==
|
||||
|
||||
More information about GIT, its repository format, and the canonical
|
||||
C based implementation can be obtained from the GIT websites:
|
||||
|
||||
http://git.or.cz/
|
||||
http://www.kernel.org/pub/software/scm/git/
|
||||
http://www.kernel.org/pub/software/scm/git/docs/
|
||||
|
|
@ -0,0 +1,366 @@
|
|||
Short Version:
|
||||
|
||||
- Make small logical changes.
|
||||
- Provide a meaningful commit message.
|
||||
|
||||
- Include your Signed-Off-By line to note you agree with the
|
||||
Developer's Certificate of Origin (see below).
|
||||
- Make sure all code is under the proper license:
|
||||
|
||||
3-clause BSD
|
||||
|
||||
- Use a subject prefix of "[PATCH JGIT ...]" when sending any
|
||||
patches directly by email.
|
||||
|
||||
- Send by email to the maintainers, cc'ing the git mailing list
|
||||
which is currently used for both Git and JGit:
|
||||
|
||||
maintainers : "Shawn O. Pearce" <spearce@spearce.org>
|
||||
Robin Rosenberg <robin.rosenberg@dewire.com>
|
||||
|
||||
git list : git@vger.kernel.org
|
||||
|
||||
git list info : http://vger.kernel.org/vger-lists.html#git
|
||||
|
||||
Long Version:
|
||||
|
||||
I wanted a file describing how to submit patches for JGit,
|
||||
so I started with the one found in the core Git distribution
|
||||
(Documentation/SubmittingPatches), which itself was based on the
|
||||
patch submission guidelines for the Linux kernel.
|
||||
|
||||
However there are some differences, so please review and familiarize
|
||||
yourself with the following relevant bits:
|
||||
|
||||
|
||||
(1) Make separate commits for logically separate changes.
|
||||
|
||||
Unless your patch is really trivial, you should not be sending
|
||||
out a patch that was generated between your working tree and your
|
||||
commit head. Instead, always make a commit with complete commit
|
||||
message and generate a series of patches from your repository.
|
||||
It is a good discipline.
|
||||
|
||||
Describe the technical detail of the change(s).
|
||||
|
||||
If your description starts to get too long, that's a sign that you
|
||||
probably need to split up your commit to finer grained pieces.
|
||||
|
||||
I am very picky about formatting. Make sure your final version
|
||||
of every file was formatted using the Eclipse code formatter
|
||||
using the project specific settings (Properties->Java Code
|
||||
Style->Formatter->"Java Conventions [built-in]").
|
||||
|
||||
|
||||
(2) Generate your patch using git tools out of your commits.
|
||||
|
||||
git based diff tools (git, and StGIT included) generate unidiff,
|
||||
which is the only acceptable format.
|
||||
|
||||
You do not have to be afraid to use -M option to "git diff" or "git
|
||||
format-patch", if your patch involves file renames. The receiving
|
||||
end can handle them just fine.
|
||||
|
||||
Please make sure your patch does not include any extra files which
|
||||
do not belong in a patch submission. Make sure to review your
|
||||
patch after generating it, to ensure accuracy. Before sending out,
|
||||
please make sure it cleanly applies to the "master" branch head.
|
||||
|
||||
|
||||
(3) Sending your patches.
|
||||
|
||||
People on the git mailing list need to be able to read and comment
|
||||
on the changes you are submitting. It is important for a developer
|
||||
to be able to "quote" your changes, using standard e-mail tools, so
|
||||
that they may comment on specific portions of your code. For this
|
||||
reason, all patches should be submitted "inline". WARNING: Be wary
|
||||
of your MUAs word-wrap corrupting your patch. Do not cut-n-paste
|
||||
your patch; you can lose tabs that way if you are not careful.
|
||||
|
||||
It is a common convention to prefix your subject line with [PATCH].
|
||||
This lets people easily distinguish patches from other e-mail
|
||||
discussions.
|
||||
|
||||
"git format-patch" command follows the best current practice to
|
||||
format the body of an e-mail message. At the beginning of the patch
|
||||
should come your commit message, ending with the Signed-off-by:
|
||||
lines, and a line that consists of three dashes, followed by the
|
||||
diffstat information and the patch itself. If you are forwarding a
|
||||
patch from somebody else, optionally, at the beginning of the e-mail
|
||||
message just before the commit message starts, you can put a "From:
|
||||
" line to name that person.
|
||||
|
||||
You often want to add additional explanation about the patch,
|
||||
other than the commit message itself. Place such "cover letter"
|
||||
material between the three dash lines and the diffstat.
|
||||
|
||||
Do not attach the patch as a MIME attachment, compressed or not.
|
||||
Do not let your e-mail client send quoted-printable. Do not let your
|
||||
e-mail client send format=flowed which would destroy whitespaces
|
||||
in your patches. Many popular e-mail applications will not always
|
||||
transmit a MIME attachment as plain text, making it impossible to
|
||||
comment on your code. A MIME attachment also takes a bit more
|
||||
time to process. This does not decrease the likelihood of your
|
||||
MIME-attached change being accepted, but it makes it more likely
|
||||
that it will be postponed.
|
||||
|
||||
Exception: If your mailer is mangling patches then someone may ask
|
||||
you to re-send them using MIME, that is OK.
|
||||
|
||||
Do not PGP sign your patch, at least for now. Most likely, your
|
||||
maintainer or other people on the list would not have your PGP
|
||||
key and would not bother obtaining it anyway. Your patch is not
|
||||
judged by who you are; a good patch from an unknown origin has a
|
||||
far better chance of being accepted than a patch from a known,
|
||||
respected origin that is done poorly or does incorrect things.
|
||||
|
||||
If you really really really really want to do a PGP signed
|
||||
patch, format it as "multipart/signed", not a text/plain message
|
||||
that starts with '-----BEGIN PGP SIGNED MESSAGE-----'. That is
|
||||
not a text/plain, it's something else.
|
||||
|
||||
Note that your maintainer does not necessarily read everything
|
||||
on the git mailing list. If your patch is for discussion first,
|
||||
send it "To:" the mailing list, and optionally "cc:" him. If it
|
||||
is trivially correct or after the list reached a consensus, send it
|
||||
"To:" the maintainer and optionally "cc:" the list.
|
||||
|
||||
|
||||
(4) Check the license
|
||||
|
||||
JGit is licensed under the 3-clause (new-style) BSD.
|
||||
|
||||
Because of this licensing model *every* file within the project
|
||||
*must* list which license covers it in the header of the file.
|
||||
Any new contributions to an existing file *must* be submitted under
|
||||
the current license of that file. Any new files *must* clearly
|
||||
indicate which license they are provided under in the file header.
|
||||
|
||||
Please verify that you are legally allowed and willing to submit your
|
||||
changes under the license covering each file *prior* to submitting
|
||||
your patch. It is virtually impossible to remove a patch once it
|
||||
has been applied and pushed out.
|
||||
|
||||
|
||||
(5) Sign your work
|
||||
|
||||
To improve tracking of who did what, we've borrowed the "sign-off"
|
||||
procedure from the Linux kernel project on patches that are being
|
||||
emailed around. Although JGit is a lot smaller project it is
|
||||
a good discipline to follow it.
|
||||
|
||||
The sign-off is a simple line at the end of the explanation for the
|
||||
patch, which certifies that you wrote it or otherwise have the right
|
||||
to pass it on as a open-source patch. The rules are pretty simple:
|
||||
if you can certify the below:
|
||||
|
||||
Developer's Certificate of Origin 1.1
|
||||
|
||||
By making a contribution to this project, I certify that:
|
||||
|
||||
(a) The contribution was created in whole or in part by me
|
||||
and I have the right to submit it under the open source
|
||||
license indicated in the file; or
|
||||
|
||||
(b) The contribution is based upon previous work that, to the
|
||||
best of my knowledge, is covered under an appropriate
|
||||
open source license and I have the right under that
|
||||
license to submit that work with modifications, whether
|
||||
created in whole or in part by me, under the same open
|
||||
source license (unless I am permitted to submit under
|
||||
a different license), as indicated in the file; or
|
||||
|
||||
(c) The contribution was provided directly to me by some
|
||||
other person who certified (a), (b) or (c) and I have
|
||||
not modified it.
|
||||
|
||||
(d) I understand and agree that this project and the
|
||||
contribution are public and that a record of the
|
||||
contribution (including all personal information I
|
||||
submit with it, including my sign-off) is maintained
|
||||
indefinitely and may be redistributed consistent with
|
||||
this project or the open source license(s) involved.
|
||||
|
||||
then you just add a line saying
|
||||
|
||||
Signed-off-by: Random J Developer <random@developer.example.org>
|
||||
|
||||
This line can be automatically added by git if you run the git-commit
|
||||
command with the -s option.
|
||||
|
||||
Some people also put extra tags at the end. They'll just be ignored
|
||||
for now, but you can do this to mark internal company procedures
|
||||
or just point out some special detail about the sign-off.
|
||||
|
||||
|
||||
------------------------------------------------
|
||||
MUA specific hints
|
||||
|
||||
Some of patches I receive or pick up from the list share common
|
||||
patterns of breakage. Please make sure your MUA is set up
|
||||
properly not to corrupt whitespaces. Here are two common ones
|
||||
I have seen:
|
||||
|
||||
* Empty context lines that do not have _any_ whitespace.
|
||||
|
||||
* Non empty context lines that have one extra whitespace at the
|
||||
beginning.
|
||||
|
||||
One test you could do yourself if your MUA is set up correctly is:
|
||||
|
||||
* Send the patch to yourself, exactly the way you would, except
|
||||
To: and Cc: lines, which would not contain the list and
|
||||
maintainer address.
|
||||
|
||||
* Save that patch to a file in UNIX mailbox format. Call it say
|
||||
a.patch.
|
||||
|
||||
* Try to apply to the tip of the "master" branch from the
|
||||
egit.git public repository:
|
||||
|
||||
$ git fetch git://repo.or.cz/egit.git master:test-apply
|
||||
$ git checkout test-apply
|
||||
$ git reset --hard
|
||||
$ git am a.patch
|
||||
|
||||
If it does not apply correctly, there can be various reasons.
|
||||
|
||||
* Your patch itself does not apply cleanly. That is _bad_ but
|
||||
does not have much to do with your MUA. Please rebase the
|
||||
patch appropriately.
|
||||
|
||||
* Your MUA corrupted your patch; applymbox would complain that
|
||||
the patch does not apply. Look at .dotest/ subdirectory and
|
||||
see what 'patch' file contains and check for the common
|
||||
corruption patterns mentioned above.
|
||||
|
||||
* While you are at it, check what are in 'info' and
|
||||
'final-commit' files as well. If what is in 'final-commit' is
|
||||
not exactly what you would want to see in the commit log
|
||||
message, it is very likely that your maintainer would end up
|
||||
hand editing the log message when he applies your patch.
|
||||
Things like "Hi, this is my first patch.\n", if you really
|
||||
want to put in the patch e-mail, should come after the
|
||||
three-dash line that signals the end of the commit message.
|
||||
|
||||
|
||||
Pine
|
||||
----
|
||||
|
||||
(Johannes Schindelin)
|
||||
|
||||
I don't know how many people still use pine, but for those poor
|
||||
souls it may be good to mention that the quell-flowed-text is
|
||||
needed for recent versions.
|
||||
|
||||
... the "no-strip-whitespace-before-send" option, too. AFAIK it
|
||||
was introduced in 4.60.
|
||||
|
||||
(Linus Torvalds)
|
||||
|
||||
And 4.58 needs at least this.
|
||||
|
||||
---
|
||||
diff-tree 8326dd8350be64ac7fc805f6563a1d61ad10d32c (from e886a61f76edf5410573e92e38ce22974f9c40f1)
|
||||
Author: Linus Torvalds <torvalds@g5.osdl.org>
|
||||
Date: Mon Aug 15 17:23:51 2005 -0700
|
||||
|
||||
Fix pine whitespace-corruption bug
|
||||
|
||||
There's no excuse for unconditionally removing whitespace from
|
||||
the pico buffers on close.
|
||||
|
||||
diff --git a/pico/pico.c b/pico/pico.c
|
||||
--- a/pico/pico.c
|
||||
+++ b/pico/pico.c
|
||||
@@ -219,7 +219,9 @@ PICO *pm;
|
||||
switch(pico_all_done){ /* prepare for/handle final events */
|
||||
case COMP_EXIT : /* already confirmed */
|
||||
packheader();
|
||||
+#if 0
|
||||
stripwhitespace();
|
||||
+#endif
|
||||
c |= COMP_EXIT;
|
||||
break;
|
||||
|
||||
|
||||
(Daniel Barkalow)
|
||||
|
||||
> A patch to SubmittingPatches, MUA specific help section for
|
||||
> users of Pine 4.63 would be very much appreciated.
|
||||
|
||||
Ah, it looks like a recent version changed the default behavior to do the
|
||||
right thing, and inverted the sense of the configuration option. (Either
|
||||
that or Gentoo did it.) So you need to set the
|
||||
"no-strip-whitespace-before-send" option, unless the option you have is
|
||||
"strip-whitespace-before-send", in which case you should avoid checking
|
||||
it.
|
||||
|
||||
|
||||
Thunderbird
|
||||
-----------
|
||||
|
||||
(A Large Angry SCM)
|
||||
|
||||
Here are some hints on how to successfully submit patches inline using
|
||||
Thunderbird.
|
||||
|
||||
This recipe appears to work with the current [*1*] Thunderbird from Suse.
|
||||
|
||||
The following Thunderbird extensions are needed:
|
||||
AboutConfig 0.5
|
||||
http://aboutconfig.mozdev.org/
|
||||
External Editor 0.7.2
|
||||
http://globs.org/articles.php?lng=en&pg=8
|
||||
|
||||
1) Prepare the patch as a text file using your method of choice.
|
||||
|
||||
2) Before opening a compose window, use Edit->Account Settings to
|
||||
uncheck the "Compose messages in HTML format" setting in the
|
||||
"Composition & Addressing" panel of the account to be used to send the
|
||||
patch. [*2*]
|
||||
|
||||
3) In the main Thunderbird window, _before_ you open the compose window
|
||||
for the patch, use Tools->about:config to set the following to the
|
||||
indicated values:
|
||||
mailnews.send_plaintext_flowed => false
|
||||
mailnews.wraplength => 0
|
||||
|
||||
4) Open a compose window and click the external editor icon.
|
||||
|
||||
5) In the external editor window, read in the patch file and exit the
|
||||
editor normally.
|
||||
|
||||
6) Back in the compose window: Add whatever other text you wish to the
|
||||
message, complete the addressing and subject fields, and press send.
|
||||
|
||||
7) Optionally, undo the about:config/account settings changes made in
|
||||
steps 2 & 3.
|
||||
|
||||
|
||||
[Footnotes]
|
||||
*1* Version 1.0 (20041207) from the MozillaThunderbird-1.0-5 rpm of Suse
|
||||
9.3 professional updates.
|
||||
|
||||
*2* It may be possible to do this with about:config and the following
|
||||
settings but I haven't tried, yet.
|
||||
mail.html_compose => false
|
||||
mail.identity.default.compose_html => false
|
||||
mail.identity.id?.compose_html => false
|
||||
|
||||
|
||||
|
||||
Gnus
|
||||
----
|
||||
|
||||
'|' in the *Summary* buffer can be used to pipe the current
|
||||
message to an external program, and this is a handy way to drive
|
||||
"git am". However, if the message is MIME encoded, what is
|
||||
piped into the program is the representation you see in your
|
||||
*Article* buffer after unwrapping MIME. This is often not what
|
||||
you would want for two reasons. It tends to screw up non ASCII
|
||||
characters (most notably in people's names), and also
|
||||
whitespaces (fatal in patches). Running 'C-u g' to display the
|
||||
message in raw form before using '|' to run the pipe can work
|
||||
this problem around.
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
= JGit Wishlist =
|
||||
|
||||
Below are some of the areas that needs work. Also take a look at JGit
|
||||
related issues in the EGit project:
|
||||
|
||||
- http://code.google.com/p/egit/issues/list?q=label:Component-JGit
|
||||
|
||||
== Switch Branch ==
|
||||
|
||||
Switch to an existing branch, updating the working directory to match.
|
||||
|
||||
Note that updating the working directory may require a 3 way merge
|
||||
if the working directory is dirty (git checkout -m).
|
||||
|
||||
My usual git working style is to not switch branches with a dirty
|
||||
working directory; I always commit to the current branch before
|
||||
switching to a new one. I mention that because I assume it'll be
|
||||
easier to implement that workflow first; once you have commit
|
||||
capability, you can do that style of branch switching (either
|
||||
preventing the switch or doing an implicit commit when the working
|
||||
directory is dirty) without having to worry about merging. ''--
|
||||
Steven Grimm''
|
||||
|
||||
== Merge ==
|
||||
|
||||
Merging changes from one local branch to another.
|
||||
|
||||
Again, like fetch I'd like to keep egit/jgit 100% pure Java and
|
||||
implement merge-recursive in Java. We may need to invoke RCS
|
||||
merge if Eclipse doesn't have its own 3 way file merge algorithm
|
||||
available, or do what core Git just did and implement a 3 way in
|
||||
memory merge algorithm. git-merge-recursive is only 1336 lines of C
|
||||
so it should not be too difficult to port the algorithm to pure Java.
|
||||
|
||||
== SVN Integration ==
|
||||
|
||||
It would be swell -- but put it at the bottom of your priority list
|
||||
-- to have git-svn interoperability; sadly most of my git usage at
|
||||
the moment is in cloned svn repositories and it would be great if
|
||||
egit could do the right thing when the current git repo is cloned
|
||||
from svn. What "the right thing" is, exactly, is debatable, but I
|
||||
suppose some kind of integration with the Subclipse plugin is one
|
||||
possibility (and if nothing else, that plugin probably has code
|
||||
that can be reused.) I'd like to be able to update from and commit
|
||||
to the parent svn repository. ''-- Steven Grimm''
|
||||
|
||||
I'm considering this to be out of scope for the time being, but if
|
||||
someone takes it on and submits reasonable patches we'll include
|
||||
them. ''-- Shawn Pearce''
|
|
@ -0,0 +1 @@
|
|||
target
|
|
@ -0,0 +1,226 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2008, Imran M Yousuf <imyousuf@smartitengineering.com>
|
||||
and other copyright owners as documented in the project's IP log.
|
||||
|
||||
This program and the accompanying materials are made available
|
||||
under the terms of the Eclipse Distribution License v1.0 which
|
||||
accompanies this distribution, is reproduced below, and is
|
||||
available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or
|
||||
without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
- Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.eclipse</groupId>
|
||||
<artifactId>jgit</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>0.5.0-SNAPSHOT</version>
|
||||
<name>jgit</name>
|
||||
<url>http://repo.or.cz/w/jgit.git</url>
|
||||
<mailingLists>
|
||||
<mailingList>
|
||||
<name>GIT Mailing List</name>
|
||||
<post>git@vger.kernel.org</post>
|
||||
<archive>http://marc.info/?l=git</archive>
|
||||
</mailingList>
|
||||
</mailingLists>
|
||||
<description>Pure Java implementation of Git</description>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Shawn O. Pearce</name>
|
||||
<email>spearce@spearce.org</email>
|
||||
<roles>
|
||||
<role>Maintainer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Robin Rosenberg</name>
|
||||
<email>robin.rosenberg@dewire.com</email>
|
||||
<roles>
|
||||
<role>Maintainer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Dave Watson</name>
|
||||
<email>dwatson@mimvista.com</email>
|
||||
<roles>
|
||||
<role>Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Roger C. Soares</name>
|
||||
<email>rogersoares@intelinet.com.br</email>
|
||||
<roles>
|
||||
<role>Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Marek Zawirski</name>
|
||||
<email>marek.zawirski@gmail.com</email>
|
||||
<roles>
|
||||
<role>Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Charles O'Farrell</name>
|
||||
<email>charleso@charleso.org</email>
|
||||
<roles>
|
||||
<role>Contributor</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Imran M Yousuf</name>
|
||||
<email>imyousuf@smartitengineering.com</email>
|
||||
<organization>Smart IT Engineering</organization>
|
||||
<roles>
|
||||
<role>Contributor</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Eclipse Distribution License (New BSD License)</name>
|
||||
<comments>
|
||||
All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or
|
||||
without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
names of its contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
</comments>
|
||||
</license>
|
||||
</licenses>
|
||||
<build>
|
||||
<sourceDirectory>../../org.eclipse.jgit/src/</sourceDirectory>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>../../org.eclipse.jgit.test/tst-rsrc/</directory>
|
||||
</testResource>
|
||||
</testResources>
|
||||
<testSourceDirectory>../../org.eclipse.jgit.test/tst/</testSourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.0.2</version>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.4.2</version>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
<include>**/*TestCase.java</include>
|
||||
<include>**/T000*.java</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jcraft</groupId>
|
||||
<artifactId>jsch</artifactId>
|
||||
<version>0.1.41</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>jgit-maven-snapshot-repository</id>
|
||||
<name>JGit Maven Snapshot Repository</name>
|
||||
<url>dav:https://egit.googlecode.com/svn/maven/snapshot-repository/</url>
|
||||
<uniqueVersion>true</uniqueVersion>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</project>
|
|
@ -0,0 +1,94 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2008-2009, Google Inc.
|
||||
# Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
# and other copyright owners as documented in the project's IP log.
|
||||
#
|
||||
# This program and the accompanying materials are made available
|
||||
# under the terms of the Eclipse Distribution License v1.0 which
|
||||
# accompanies this distribution, is reproduced below, and is
|
||||
# available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or
|
||||
# without modification, are permitted provided that the following
|
||||
# conditions are met:
|
||||
#
|
||||
# - Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# - Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
# names of its contributors may be used to endorse or promote
|
||||
# products derived from this software without specific prior
|
||||
# written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
if [ "@@use_self@@" = "1" ]
|
||||
then
|
||||
this_script=`which "$0" 2>/dev/null`
|
||||
[ $? -gt 0 -a -f "$0" ] && this_script="$0"
|
||||
cp=$this_script
|
||||
else
|
||||
jgit_home=`dirname $0`
|
||||
cp="$jgit_home/org.eclipse.jgit/bin"
|
||||
cp="$cp:$jgit_home/org.eclipse.jgit/lib/jsch-0.1.37.jar"
|
||||
cp="$cp:$jgit_home/org.eclipse.jgit.pgm/bin"
|
||||
cp="$cp:$jgit_home/org.eclipse.jgit.pgm/lib/args4j-2.0.9.jar"
|
||||
unset jgit_home
|
||||
java_args=
|
||||
fi
|
||||
|
||||
if [ -n "$JGIT_CLASSPATH" ]
|
||||
then
|
||||
cp="$cp:$JGIT_CLASSPATH"
|
||||
fi
|
||||
|
||||
# Cleanup paths for Cygwin.
|
||||
#
|
||||
case "`uname`" in
|
||||
CYGWIN*)
|
||||
cp=`cygpath --windows --mixed --path "$cp"`
|
||||
;;
|
||||
Darwin)
|
||||
if test -e /System/Library/Frameworks/JavaVM.framework
|
||||
then
|
||||
java_args='
|
||||
-Dcom.apple.mrj.application.apple.menu.about.name=JGit
|
||||
-Dcom.apple.mrj.application.growbox.intrudes=false
|
||||
-Dapple.laf.useScreenMenuBar=true
|
||||
-Xdock:name=JGit
|
||||
'
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH="$cp"
|
||||
export CLASSPATH
|
||||
|
||||
java=java
|
||||
if test -n "$JAVA_HOME"
|
||||
then
|
||||
java="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
|
||||
exec "$java" $java_args org.eclipse.jgit.pgm.Main "$@"
|
||||
exit 1
|
|
@ -0,0 +1,179 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2009, Christian Halstrick <christian.halstrick@sap.com>
|
||||
# Copyright (C) 2008-2009, Google Inc.
|
||||
# Copyright (C) 2009, Johannes Schindelin <Johannes.Schindelin@gmx.de>
|
||||
# Copyright (C) 2008, Mike Ralphson <mike@abacus.co.uk>
|
||||
# Copyright (C) 2009, Nicholas Campbell <nicholas.j.campbell@gmail.com>
|
||||
# Copyright (C) 2009, Robin Rosenberg <robin.rosenberg@gmail.com>
|
||||
# Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
# and other copyright owners as documented in the project's IP log.
|
||||
#
|
||||
# This program and the accompanying materials are made available
|
||||
# under the terms of the Eclipse Distribution License v1.0 which
|
||||
# accompanies this distribution, is reproduced below, and is
|
||||
# available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or
|
||||
# without modification, are permitted provided that the following
|
||||
# conditions are met:
|
||||
#
|
||||
# - Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# - Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
# names of its contributors may be used to endorse or promote
|
||||
# products derived from this software without specific prior
|
||||
# written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
O_CLI=jgit
|
||||
O_JAR=jgit.jar
|
||||
O_SRC=jgit_src.zip
|
||||
O_DOC=jgit_docs.zip
|
||||
|
||||
PLUGINS="
|
||||
org.eclipse.jgit
|
||||
org.eclipse.jgit.pgm
|
||||
"
|
||||
JARS="
|
||||
org.eclipse.jgit/lib/jsch-0.1.37.jar
|
||||
org.eclipse.jgit.pgm/lib/args4j-2.0.9.jar
|
||||
"
|
||||
|
||||
PSEP=":"
|
||||
T=".temp$$.$O_CLI"
|
||||
T_MF="$T.MF"
|
||||
R=`pwd`
|
||||
if [ "$OSTYPE" = "cygwin" ]
|
||||
then
|
||||
R=`cygpath -m $R`
|
||||
PSEP=";"
|
||||
fi
|
||||
if [ "$MSYSTEM" = "MINGW" -o "$MSYSTEM" = "MINGW32" ]
|
||||
then
|
||||
PSEP=";"
|
||||
R=`pwd -W`
|
||||
fi
|
||||
|
||||
if [ -n "$JAVA_HOME" ]
|
||||
then
|
||||
PATH=${JAVA_HOME}/bin${PSEP}${PATH}
|
||||
fi
|
||||
|
||||
cleanup_bin() {
|
||||
rm -f $T $O_CLI+ $O_JAR+ $O_SRC+ $T_MF
|
||||
for p in $PLUGINS
|
||||
do
|
||||
rm -rf $p/bin2
|
||||
done
|
||||
rm -rf docs
|
||||
}
|
||||
|
||||
die() {
|
||||
cleanup_bin
|
||||
rm -f $O_CLI $O_JAR $O_SRC
|
||||
echo >&2 "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
cleanup_bin
|
||||
rm -f $O_CLI $O_JAR $O_SRC $O_DOC
|
||||
|
||||
VN=`git describe --abbrev=4 HEAD 2>/dev/null`
|
||||
git update-index -q --refresh
|
||||
if [ -n "`git diff-index --name-only HEAD --`" ]
|
||||
then
|
||||
VN="$VN-dirty"
|
||||
fi
|
||||
VN=${VN:-untagged}`echo "$VN" | sed -e s/-/./g`
|
||||
|
||||
CLASSPATH=
|
||||
for j in $JARS
|
||||
do
|
||||
if [ -z "$CLASSPATH" ]
|
||||
then
|
||||
CLASSPATH="$R/$j"
|
||||
else
|
||||
CLASSPATH="${CLASSPATH}${PSEP}$R/$j"
|
||||
fi
|
||||
done
|
||||
export CLASSPATH
|
||||
|
||||
for p in $PLUGINS
|
||||
do
|
||||
echo "Entering $p ..."
|
||||
(cd $p/src &&
|
||||
mkdir ../bin2 &&
|
||||
find . -name \*.java -type f |
|
||||
xargs javac \
|
||||
-source 1.5 \
|
||||
-target 1.5 \
|
||||
-encoding UTF-8 \
|
||||
-g \
|
||||
-d ../bin2) || die "Building $p failed."
|
||||
CLASSPATH="${CLASSPATH}${PSEP}$R/$p/bin2"
|
||||
done
|
||||
echo
|
||||
|
||||
echo "Version $VN" &&
|
||||
echo Manifest-Version: 1.0 >$T_MF &&
|
||||
echo Implementation-Title: jgit >>$T_MF &&
|
||||
echo Implementation-Version: $VN >>$T_MF &&
|
||||
|
||||
java org.eclipse.jgit.pgm.build.JarLinkUtil \
|
||||
-include org.eclipse.jgit/bin2 \
|
||||
-file META-INF/MANIFEST.MF=$T_MF \
|
||||
>$O_JAR+ &&
|
||||
mv $O_JAR+ $O_JAR &&
|
||||
echo "Created $O_JAR." &&
|
||||
|
||||
java org.eclipse.jgit.pgm.build.JarLinkUtil \
|
||||
-include org.eclipse.jgit/src \
|
||||
-file META-INF/MANIFEST.MF=$T_MF \
|
||||
>$O_SRC+ &&
|
||||
mv $O_SRC+ $O_SRC &&
|
||||
echo "Created $O_SRC." &&
|
||||
|
||||
M_TB=META-INF/services/org.eclipse.jgit.pgm.TextBuiltin &&
|
||||
sed s/@@use_self@@/1/ jgit.sh >$O_CLI+ &&
|
||||
java org.eclipse.jgit.pgm.build.JarLinkUtil \
|
||||
`for p in $JARS ; do printf %s " -include $p" ;done` \
|
||||
`for p in $PLUGINS; do printf %s " -include $p/bin2";done` \
|
||||
-file $M_TB=org.eclipse.jgit.pgm/src/$M_TB \
|
||||
-file META-INF/MANIFEST.MF=$T_MF \
|
||||
>>$O_CLI+ &&
|
||||
chmod 555 $O_CLI+ &&
|
||||
mv $O_CLI+ $O_CLI &&
|
||||
echo "Created $O_CLI." || die "Build failed."
|
||||
|
||||
echo "Building Javadocs ..."
|
||||
for p in $PLUGINS; do
|
||||
javadoc -quiet -sourcepath "$p/src/" -d "docs/$p/" \
|
||||
`find "$p/src" -name "*.java"`
|
||||
done
|
||||
|
||||
(cd docs && jar cf "../$O_DOC" .)
|
||||
echo "Created $O_DOC."
|
||||
|
||||
cleanup_bin
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/args4j-2.0.9.jar" sourcepath="lib/args4j-2.0.9.zip"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/org.eclipse.jgit"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1 @@
|
|||
/bin
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.eclipse.jgit.pgm</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,3 @@
|
|||
#Mon Aug 11 16:46:23 PDT 2008
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -0,0 +1,3 @@
|
|||
#Mon Mar 24 18:55:50 EDT 2008
|
||||
eclipse.preferences.version=1
|
||||
line.separator=\n
|
|
@ -0,0 +1,321 @@
|
|||
#Sun Mar 15 19:46:39 CET 2009
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
|
||||
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
|
||||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
|
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
|
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=error
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.nullReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
|
||||
org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
|
||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedImport=error
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLabel=error
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLocal=error
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_field=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_header=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_html=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_source_code=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.comment.line_length=80
|
||||
org.eclipse.jdt.core.formatter.compact_else_if=true
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation=2
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
|
||||
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_empty_lines=false
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
|
||||
org.eclipse.jdt.core.formatter.indentation.size=4
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.lineSplit=80
|
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
|
||||
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
|
||||
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
|
||||
org.eclipse.jdt.core.formatter.tabulation.char=tab
|
||||
org.eclipse.jdt.core.formatter.tabulation.size=4
|
||||
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
|
@ -0,0 +1,9 @@
|
|||
#Wed May 09 00:20:24 CEST 2007
|
||||
eclipse.preferences.version=1
|
||||
formatter_profile=_JGit
|
||||
formatter_settings_version=10
|
||||
org.eclipse.jdt.ui.ignorelowercasenames=true
|
||||
org.eclipse.jdt.ui.importorder=java;javax;org;com;
|
||||
org.eclipse.jdt.ui.ondemandthreshold=99
|
||||
org.eclipse.jdt.ui.staticondemandthreshold=99
|
||||
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates/>
|
|
@ -0,0 +1,30 @@
|
|||
org.eclipse.jgit.pgm.Branch
|
||||
org.eclipse.jgit.pgm.Clone
|
||||
org.eclipse.jgit.pgm.Daemon
|
||||
org.eclipse.jgit.pgm.DiffTree
|
||||
org.eclipse.jgit.pgm.Fetch
|
||||
org.eclipse.jgit.pgm.Glog
|
||||
org.eclipse.jgit.pgm.IndexPack
|
||||
org.eclipse.jgit.pgm.Init
|
||||
org.eclipse.jgit.pgm.Log
|
||||
org.eclipse.jgit.pgm.LsRemote
|
||||
org.eclipse.jgit.pgm.LsTree
|
||||
org.eclipse.jgit.pgm.MergeBase
|
||||
org.eclipse.jgit.pgm.Push
|
||||
org.eclipse.jgit.pgm.ReceivePack
|
||||
org.eclipse.jgit.pgm.RevList
|
||||
org.eclipse.jgit.pgm.RevParse
|
||||
org.eclipse.jgit.pgm.Rm
|
||||
org.eclipse.jgit.pgm.ShowRev
|
||||
org.eclipse.jgit.pgm.ShowRef
|
||||
org.eclipse.jgit.pgm.Tag
|
||||
org.eclipse.jgit.pgm.UploadPack
|
||||
org.eclipse.jgit.pgm.Version
|
||||
|
||||
org.eclipse.jgit.pgm.debug.MakeCacheTree
|
||||
org.eclipse.jgit.pgm.debug.ReadDirCache
|
||||
org.eclipse.jgit.pgm.debug.RebuildCommitGraph
|
||||
org.eclipse.jgit.pgm.debug.ShowCacheTree
|
||||
org.eclipse.jgit.pgm.debug.ShowCommands
|
||||
org.eclipse.jgit.pgm.debug.ShowDirCache
|
||||
org.eclipse.jgit.pgm.debug.WriteDirCache
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Charles O'Farrell <charleso@charleso.org>
|
||||
* Copyright (C) 2008-2009, Google Inc.
|
||||
* Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.RefUpdate;
|
||||
import org.eclipse.jgit.transport.FetchResult;
|
||||
import org.eclipse.jgit.transport.TrackingRefUpdate;
|
||||
import org.eclipse.jgit.transport.Transport;
|
||||
|
||||
abstract class AbstractFetchCommand extends TextBuiltin {
|
||||
@Option(name = "--verbose", aliases = { "-v" }, usage = "be more verbose")
|
||||
private boolean verbose;
|
||||
|
||||
protected void showFetchResult(final Transport tn, final FetchResult r) {
|
||||
boolean shownURI = false;
|
||||
for (final TrackingRefUpdate u : r.getTrackingRefUpdates()) {
|
||||
if (!verbose && u.getResult() == RefUpdate.Result.NO_CHANGE)
|
||||
continue;
|
||||
|
||||
final char type = shortTypeOf(u.getResult());
|
||||
final String longType = longTypeOf(u);
|
||||
final String src = abbreviateRef(u.getRemoteName(), false);
|
||||
final String dst = abbreviateRef(u.getLocalName(), true);
|
||||
|
||||
if (!shownURI) {
|
||||
out.print("From ");
|
||||
out.print(tn.getURI());
|
||||
out.println();
|
||||
shownURI = true;
|
||||
}
|
||||
|
||||
out.format(" %c %-17s %-10s -> %s", type, longType, src, dst);
|
||||
out.println();
|
||||
}
|
||||
}
|
||||
|
||||
private String longTypeOf(final TrackingRefUpdate u) {
|
||||
final RefUpdate.Result r = u.getResult();
|
||||
if (r == RefUpdate.Result.LOCK_FAILURE)
|
||||
return "[lock fail]";
|
||||
if (r == RefUpdate.Result.IO_FAILURE)
|
||||
return "[i/o error]";
|
||||
if (r == RefUpdate.Result.REJECTED)
|
||||
return "[rejected]";
|
||||
if (ObjectId.zeroId().equals(u.getNewObjectId()))
|
||||
return "[deleted]";
|
||||
|
||||
if (r == RefUpdate.Result.NEW) {
|
||||
if (u.getRemoteName().startsWith(Constants.R_HEADS))
|
||||
return "[new branch]";
|
||||
else if (u.getLocalName().startsWith(Constants.R_TAGS))
|
||||
return "[new tag]";
|
||||
return "[new]";
|
||||
}
|
||||
|
||||
if (r == RefUpdate.Result.FORCED) {
|
||||
final String aOld = u.getOldObjectId().abbreviate(db).name();
|
||||
final String aNew = u.getNewObjectId().abbreviate(db).name();
|
||||
return aOld + "..." + aNew;
|
||||
}
|
||||
|
||||
if (r == RefUpdate.Result.FAST_FORWARD) {
|
||||
final String aOld = u.getOldObjectId().abbreviate(db).name();
|
||||
final String aNew = u.getNewObjectId().abbreviate(db).name();
|
||||
return aOld + ".." + aNew;
|
||||
}
|
||||
|
||||
if (r == RefUpdate.Result.NO_CHANGE)
|
||||
return "[up to date]";
|
||||
return "[" + r.name() + "]";
|
||||
}
|
||||
|
||||
private static char shortTypeOf(final RefUpdate.Result r) {
|
||||
if (r == RefUpdate.Result.LOCK_FAILURE)
|
||||
return '!';
|
||||
if (r == RefUpdate.Result.IO_FAILURE)
|
||||
return '!';
|
||||
if (r == RefUpdate.Result.NEW)
|
||||
return '*';
|
||||
if (r == RefUpdate.Result.FORCED)
|
||||
return '+';
|
||||
if (r == RefUpdate.Result.FAST_FORWARD)
|
||||
return ' ';
|
||||
if (r == RefUpdate.Result.REJECTED)
|
||||
return '!';
|
||||
if (r == RefUpdate.Result.NO_CHANGE)
|
||||
return '=';
|
||||
return ' ';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,216 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2008, Charles O'Farrell <charleso@charleso.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.ExampleMode;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.RefComparator;
|
||||
import org.eclipse.jgit.lib.RefUpdate;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.lib.RefUpdate.Result;
|
||||
import org.eclipse.jgit.pgm.opt.CmdLineParser;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
|
||||
@Command(common = true, usage = "List, create, or delete branches")
|
||||
class Branch extends TextBuiltin {
|
||||
|
||||
@Option(name = "--remote", aliases = { "-r" }, usage = "act on remote-tracking branches")
|
||||
private boolean remote = false;
|
||||
|
||||
@Option(name = "--all", aliases = { "-a" }, usage = "list both remote-tracking and local branches")
|
||||
private boolean all = false;
|
||||
|
||||
@Option(name = "--delete", aliases = { "-d" }, usage = "delete fully merged branch")
|
||||
private boolean delete = false;
|
||||
|
||||
@Option(name = "--delete-force", aliases = { "-D" }, usage = "delete branch (even if not merged)")
|
||||
private boolean deleteForce = false;
|
||||
|
||||
@Option(name = "--create-force", aliases = { "-f" }, usage = "force create branch even exists")
|
||||
private boolean createForce = false;
|
||||
|
||||
@Option(name = "--verbose", aliases = { "-v" }, usage = "be verbose")
|
||||
private boolean verbose = false;
|
||||
|
||||
@Argument
|
||||
private List<String> branches = new ArrayList<String>();
|
||||
|
||||
private final Map<String, Ref> printRefs = new LinkedHashMap<String, Ref>();
|
||||
|
||||
/** Only set for verbose branch listing at-the-moment */
|
||||
private RevWalk rw;
|
||||
|
||||
private int maxNameLength;
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
if (delete || deleteForce)
|
||||
delete(deleteForce);
|
||||
else {
|
||||
if (branches.size() > 2)
|
||||
throw die("Too many refs given\n" + new CmdLineParser(this).printExample(ExampleMode.ALL));
|
||||
|
||||
if (branches.size() > 0) {
|
||||
String newHead = branches.get(0);
|
||||
String startBranch;
|
||||
if (branches.size() == 2)
|
||||
startBranch = branches.get(1);
|
||||
else
|
||||
startBranch = Constants.HEAD;
|
||||
Ref startRef = db.getRef(startBranch);
|
||||
ObjectId startAt = db.resolve(startBranch + "^0");
|
||||
if (startRef != null)
|
||||
startBranch = startRef.getName();
|
||||
else
|
||||
startBranch = startAt.name();
|
||||
startBranch = db.shortenRefName(startBranch);
|
||||
String newRefName = newHead;
|
||||
if (!newRefName.startsWith(Constants.R_HEADS))
|
||||
newRefName = Constants.R_HEADS + newRefName;
|
||||
if (!Repository.isValidRefName(newRefName))
|
||||
throw die(String.format("%s is not a valid ref name", newRefName));
|
||||
if (!createForce && db.resolve(newRefName) != null)
|
||||
throw die(String.format("branch %s already exists", newHead));
|
||||
RefUpdate updateRef = db.updateRef(newRefName);
|
||||
updateRef.setNewObjectId(startAt);
|
||||
updateRef.setForceUpdate(createForce);
|
||||
updateRef.setRefLogMessage("branch: Created from " + startBranch, false);
|
||||
Result update = updateRef.update();
|
||||
if (update == Result.REJECTED)
|
||||
throw die(String.format("Could not create branch %s: %s", newHead, update.toString()));
|
||||
} else {
|
||||
if (verbose)
|
||||
rw = new RevWalk(db);
|
||||
list();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void list() throws Exception {
|
||||
Map<String, Ref> refs = db.getAllRefs();
|
||||
Ref head = refs.get(Constants.HEAD);
|
||||
// This can happen if HEAD is stillborn
|
||||
if (head != null) {
|
||||
String current = head.getName();
|
||||
if (current.equals(Constants.HEAD))
|
||||
addRef("(no branch)", head);
|
||||
addRefs(refs, Constants.R_HEADS, !remote);
|
||||
addRefs(refs, Constants.R_REMOTES, remote);
|
||||
for (final Entry<String, Ref> e : printRefs.entrySet()) {
|
||||
final Ref ref = e.getValue();
|
||||
printHead(e.getKey(), current.equals(ref.getName()), ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addRefs(final Map<String, Ref> allRefs, final String prefix,
|
||||
final boolean add) {
|
||||
if (all || add) {
|
||||
for (final Ref ref : RefComparator.sort(allRefs.values())) {
|
||||
final String name = ref.getName();
|
||||
if (name.startsWith(prefix))
|
||||
addRef(name.substring(name.indexOf('/', 5) + 1), ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addRef(final String name, final Ref ref) {
|
||||
printRefs.put(name, ref);
|
||||
maxNameLength = Math.max(maxNameLength, name.length());
|
||||
}
|
||||
|
||||
private void printHead(final String ref, final boolean isCurrent,
|
||||
final Ref refObj) throws Exception {
|
||||
out.print(isCurrent ? '*' : ' ');
|
||||
out.print(' ');
|
||||
out.print(ref);
|
||||
if (verbose) {
|
||||
final int spaces = maxNameLength - ref.length() + 1;
|
||||
out.print(String.format("%" + spaces + "s", ""));
|
||||
final ObjectId objectId = refObj.getObjectId();
|
||||
out.print(objectId.abbreviate(db).name());
|
||||
out.print(' ');
|
||||
out.print(rw.parseCommit(objectId).getShortMessage());
|
||||
}
|
||||
out.println();
|
||||
}
|
||||
|
||||
private void delete(boolean force) throws IOException {
|
||||
String current = db.getBranch();
|
||||
ObjectId head = db.resolve(Constants.HEAD);
|
||||
for (String branch : branches) {
|
||||
if (current.equals(branch)) {
|
||||
String err = "Cannot delete the branch '%s' which you are currently on.";
|
||||
throw die(String.format(err, branch));
|
||||
}
|
||||
RefUpdate update = db.updateRef((remote ? Constants.R_REMOTES
|
||||
: Constants.R_HEADS)
|
||||
+ branch);
|
||||
update.setNewObjectId(head);
|
||||
update.setForceUpdate(force || remote);
|
||||
Result result = update.delete();
|
||||
if (result == Result.REJECTED) {
|
||||
String err = "The branch '%s' is not an ancestor of your current HEAD.\n"
|
||||
+ "If you are sure you want to delete it, run 'jgit branch -D %1$s'.";
|
||||
throw die(String.format(err, branch));
|
||||
} else if (result == Result.NEW)
|
||||
throw die(String.format("branch '%s' not found.", branch));
|
||||
if (remote)
|
||||
out.println(String.format("Deleted remote branch %s", branch));
|
||||
else if (verbose)
|
||||
out.println(String.format("Deleted branch %s", branch));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
* Copyright (C) 2008-2009, Google Inc.
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.errors.NotSupportedException;
|
||||
import org.eclipse.jgit.errors.TransportException;
|
||||
import org.eclipse.jgit.lib.Commit;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.GitIndex;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.RefComparator;
|
||||
import org.eclipse.jgit.lib.RefUpdate;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.lib.TextProgressMonitor;
|
||||
import org.eclipse.jgit.lib.Tree;
|
||||
import org.eclipse.jgit.lib.WorkDirCheckout;
|
||||
import org.eclipse.jgit.transport.FetchResult;
|
||||
import org.eclipse.jgit.transport.RefSpec;
|
||||
import org.eclipse.jgit.transport.RemoteConfig;
|
||||
import org.eclipse.jgit.transport.Transport;
|
||||
import org.eclipse.jgit.transport.URIish;
|
||||
|
||||
@Command(common = true, usage = "Clone a repository into a new directory")
|
||||
class Clone extends AbstractFetchCommand {
|
||||
@Option(name = "--origin", aliases = { "-o" }, metaVar = "name", usage = "use <name> instead of 'origin' to track upstream")
|
||||
private String remoteName = "origin";
|
||||
|
||||
@Argument(index = 0, required = true, metaVar = "uri-ish")
|
||||
private String sourceUri;
|
||||
|
||||
@Argument(index = 1, metaVar = "directory")
|
||||
private String localName;
|
||||
|
||||
@Override
|
||||
protected final boolean requiresRepository() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
if (localName != null && gitdir != null)
|
||||
throw die("conflicting usage of --git-dir and arguments");
|
||||
|
||||
final URIish uri = new URIish(sourceUri);
|
||||
if (localName == null) {
|
||||
String p = uri.getPath();
|
||||
while (p.endsWith("/"))
|
||||
p = p.substring(0, p.length() - 1);
|
||||
final int s = p.lastIndexOf('/');
|
||||
if (s < 0)
|
||||
throw die("cannot guess local name from " + sourceUri);
|
||||
localName = p.substring(s + 1);
|
||||
if (localName.endsWith(".git"))
|
||||
localName = localName.substring(0, localName.length() - 4);
|
||||
}
|
||||
if (gitdir == null)
|
||||
gitdir = new File(localName, ".git");
|
||||
|
||||
db = new Repository(gitdir);
|
||||
db.create();
|
||||
db.getConfig().setBoolean("core", null, "bare", false);
|
||||
db.getConfig().save();
|
||||
|
||||
out.println("Initialized empty Git repository in "
|
||||
+ gitdir.getAbsolutePath());
|
||||
out.flush();
|
||||
|
||||
saveRemote(uri);
|
||||
final FetchResult r = runFetch();
|
||||
final Ref branch = guessHEAD(r);
|
||||
doCheckout(branch);
|
||||
}
|
||||
|
||||
private void saveRemote(final URIish uri) throws URISyntaxException,
|
||||
IOException {
|
||||
final RemoteConfig rc = new RemoteConfig(db.getConfig(), remoteName);
|
||||
rc.addURI(uri);
|
||||
rc.addFetchRefSpec(new RefSpec().setForceUpdate(true)
|
||||
.setSourceDestination(Constants.R_HEADS + "*",
|
||||
Constants.R_REMOTES + remoteName + "/*"));
|
||||
rc.update(db.getConfig());
|
||||
db.getConfig().save();
|
||||
}
|
||||
|
||||
private FetchResult runFetch() throws NotSupportedException,
|
||||
URISyntaxException, TransportException {
|
||||
final Transport tn = Transport.open(db, remoteName);
|
||||
final FetchResult r;
|
||||
try {
|
||||
r = tn.fetch(new TextProgressMonitor(), null);
|
||||
} finally {
|
||||
tn.close();
|
||||
}
|
||||
showFetchResult(tn, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
private Ref guessHEAD(final FetchResult result) {
|
||||
final Ref idHEAD = result.getAdvertisedRef(Constants.HEAD);
|
||||
final List<Ref> availableRefs = new ArrayList<Ref>();
|
||||
Ref head = null;
|
||||
for (final Ref r : result.getAdvertisedRefs()) {
|
||||
final String n = r.getName();
|
||||
if (!n.startsWith(Constants.R_HEADS))
|
||||
continue;
|
||||
availableRefs.add(r);
|
||||
if (idHEAD == null || head != null)
|
||||
continue;
|
||||
if (r.getObjectId().equals(idHEAD.getObjectId()))
|
||||
head = r;
|
||||
}
|
||||
Collections.sort(availableRefs, RefComparator.INSTANCE);
|
||||
if (idHEAD != null && head == null)
|
||||
head = idHEAD;
|
||||
return head;
|
||||
}
|
||||
|
||||
private void doCheckout(final Ref branch) throws IOException {
|
||||
if (branch == null)
|
||||
throw die("cannot checkout; no HEAD advertised by remote");
|
||||
if (!Constants.HEAD.equals(branch.getName()))
|
||||
db.writeSymref(Constants.HEAD, branch.getName());
|
||||
|
||||
final Commit commit = db.mapCommit(branch.getObjectId());
|
||||
final RefUpdate u = db.updateRef(Constants.HEAD);
|
||||
u.setNewObjectId(commit.getCommitId());
|
||||
u.forceUpdate();
|
||||
|
||||
final GitIndex index = new GitIndex(db);
|
||||
final Tree tree = commit.getTree();
|
||||
final WorkDirCheckout co;
|
||||
|
||||
co = new WorkDirCheckout(db, db.getWorkDir(), index, tree);
|
||||
co.checkout();
|
||||
index.write();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Annotation to document a {@link TextBuiltin}.
|
||||
* <p>
|
||||
* This is an optional annotation for TextBuiltin subclasses and it carries
|
||||
* documentation forward into the runtime system describing what the command is
|
||||
* and why users may want to invoke it.
|
||||
*/
|
||||
@Retention(RUNTIME)
|
||||
@Target( { TYPE })
|
||||
public @interface Command {
|
||||
/**
|
||||
* @return name the command is invoked as from the command line. If the
|
||||
* (default) empty string is supplied the name will be generated
|
||||
* from the class name.
|
||||
*/
|
||||
public String name() default "";
|
||||
|
||||
/**
|
||||
* @return one line description of the command's feature set.
|
||||
*/
|
||||
public String usage() default "";
|
||||
|
||||
/**
|
||||
* @return true if this command is considered to be commonly used.
|
||||
*/
|
||||
public boolean common() default false;
|
||||
}
|
|
@ -0,0 +1,194 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* List of all commands known by jgit's command line tools.
|
||||
* <p>
|
||||
* Commands are implementations of {@link TextBuiltin}, with an optional
|
||||
* {@link Command} class annotation to insert additional documentation or
|
||||
* override the default command name (which is guessed from the class name).
|
||||
* <p>
|
||||
* Commands may be registered by adding them to a services file in the same JAR
|
||||
* (or classes directory) as the command implementation. The service file name
|
||||
* is <code>META-INF/services/org.eclipse.jgit.pgm.TextBuiltin</code> and it
|
||||
* contains one concrete implementation class name per line.
|
||||
* <p>
|
||||
* Command registration is identical to Java 6's services, however the catalog
|
||||
* uses a lightweight wrapper to delay creating a command instance as much as
|
||||
* possible. This avoids initializing the AWT or SWT GUI toolkits even if the
|
||||
* command's constructor might require them.
|
||||
*/
|
||||
public class CommandCatalog {
|
||||
private static final CommandCatalog INSTANCE = new CommandCatalog();
|
||||
|
||||
/**
|
||||
* Locate a single command by its user friendly name.
|
||||
*
|
||||
* @param name
|
||||
* name of the command. Typically in dash-lower-case-form, which
|
||||
* was derived from the DashLowerCaseForm class name.
|
||||
* @return the command instance; null if no command exists by that name.
|
||||
*/
|
||||
public static CommandRef get(final String name) {
|
||||
return INSTANCE.commands.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return all known commands, sorted by command name.
|
||||
*/
|
||||
public static CommandRef[] all() {
|
||||
return toSortedArray(INSTANCE.commands.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return all common commands, sorted by command name.
|
||||
*/
|
||||
public static CommandRef[] common() {
|
||||
final ArrayList<CommandRef> common = new ArrayList<CommandRef>();
|
||||
for (final CommandRef c : INSTANCE.commands.values())
|
||||
if (c.isCommon())
|
||||
common.add(c);
|
||||
return toSortedArray(common);
|
||||
}
|
||||
|
||||
private static CommandRef[] toSortedArray(final Collection<CommandRef> c) {
|
||||
final CommandRef[] r = c.toArray(new CommandRef[c.size()]);
|
||||
Arrays.sort(r, new Comparator<CommandRef>() {
|
||||
public int compare(final CommandRef o1, final CommandRef o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
});
|
||||
return r;
|
||||
}
|
||||
|
||||
private final ClassLoader ldr;
|
||||
|
||||
private final Map<String, CommandRef> commands;
|
||||
|
||||
private CommandCatalog() {
|
||||
ldr = Thread.currentThread().getContextClassLoader();
|
||||
commands = new HashMap<String, CommandRef>();
|
||||
|
||||
final Enumeration<URL> catalogs = catalogs();
|
||||
while (catalogs.hasMoreElements())
|
||||
scan(catalogs.nextElement());
|
||||
}
|
||||
|
||||
private Enumeration<URL> catalogs() {
|
||||
try {
|
||||
final String pfx = "META-INF/services/";
|
||||
return ldr.getResources(pfx + TextBuiltin.class.getName());
|
||||
} catch (IOException err) {
|
||||
return new Vector<URL>().elements();
|
||||
}
|
||||
}
|
||||
|
||||
private void scan(final URL cUrl) {
|
||||
final BufferedReader cIn;
|
||||
try {
|
||||
final InputStream in = cUrl.openStream();
|
||||
cIn = new BufferedReader(new InputStreamReader(in, "UTF-8"));
|
||||
} catch (IOException err) {
|
||||
// If we cannot read from the service list, go to the next.
|
||||
//
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
String line;
|
||||
while ((line = cIn.readLine()) != null) {
|
||||
if (line.length() > 0 && !line.startsWith("#"))
|
||||
load(line);
|
||||
}
|
||||
} catch (IOException err) {
|
||||
// If we failed during a read, ignore the error.
|
||||
//
|
||||
} finally {
|
||||
try {
|
||||
cIn.close();
|
||||
} catch (IOException e) {
|
||||
// Ignore the close error; we are only reading.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void load(final String cn) {
|
||||
final Class<? extends TextBuiltin> clazz;
|
||||
try {
|
||||
clazz = Class.forName(cn, false, ldr).asSubclass(TextBuiltin.class);
|
||||
} catch (ClassNotFoundException notBuiltin) {
|
||||
// Doesn't exist, even though the service entry is present.
|
||||
//
|
||||
return;
|
||||
} catch (ClassCastException notBuiltin) {
|
||||
// Isn't really a builtin, even though its listed as such.
|
||||
//
|
||||
return;
|
||||
}
|
||||
|
||||
final CommandRef cr;
|
||||
final Command a = clazz.getAnnotation(Command.class);
|
||||
if (a != null)
|
||||
cr = new CommandRef(clazz, a);
|
||||
else
|
||||
cr = new CommandRef(clazz);
|
||||
|
||||
commands.put(cr.getName(), cr);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
/**
|
||||
* Description of a command (a {@link TextBuiltin} subclass.
|
||||
* <p>
|
||||
* These descriptions are lightweight compared to creating a command instance
|
||||
* and are therefore suitable for catalogs of "known" commands without linking
|
||||
* the command's implementation and creating a dummy instance of the command.
|
||||
*/
|
||||
public class CommandRef {
|
||||
private final Class<? extends TextBuiltin> impl;
|
||||
|
||||
private final String name;
|
||||
|
||||
private String usage;
|
||||
|
||||
boolean common;
|
||||
|
||||
CommandRef(final Class<? extends TextBuiltin> clazz) {
|
||||
this(clazz, guessName(clazz));
|
||||
}
|
||||
|
||||
CommandRef(final Class<? extends TextBuiltin> clazz, final Command cmd) {
|
||||
this(clazz, cmd.name().length() > 0 ? cmd.name() : guessName(clazz));
|
||||
usage = cmd.usage();
|
||||
common = cmd.common();
|
||||
}
|
||||
|
||||
private CommandRef(final Class<? extends TextBuiltin> clazz, final String cn) {
|
||||
impl = clazz;
|
||||
name = cn;
|
||||
usage = "";
|
||||
}
|
||||
|
||||
private static String guessName(final Class<? extends TextBuiltin> clazz) {
|
||||
final StringBuilder s = new StringBuilder();
|
||||
if (clazz.getName().startsWith("org.eclipse.jgit.pgm.debug."))
|
||||
s.append("debug-");
|
||||
|
||||
boolean lastWasDash = true;
|
||||
for (final char c : clazz.getSimpleName().toCharArray()) {
|
||||
if (Character.isUpperCase(c)) {
|
||||
if (!lastWasDash)
|
||||
s.append('-');
|
||||
lastWasDash = !lastWasDash;
|
||||
s.append(Character.toLowerCase(c));
|
||||
} else {
|
||||
s.append(c);
|
||||
}
|
||||
}
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name the command is invoked as from the command line.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return one line description of the command's feature set.
|
||||
*/
|
||||
public String getUsage() {
|
||||
return usage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if this command is considered to be commonly used.
|
||||
*/
|
||||
public boolean isCommon() {
|
||||
return common;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of the Java class which implements this command.
|
||||
*/
|
||||
public String getImplementationClassName() {
|
||||
return impl.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return loader for {@link #getImplementationClassName()}.
|
||||
*/
|
||||
public ClassLoader getImplementationClassLoader() {
|
||||
return impl.getClassLoader();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a new instance of the command implementation.
|
||||
*/
|
||||
public TextBuiltin create() {
|
||||
final Constructor<? extends TextBuiltin> c;
|
||||
try {
|
||||
c = impl.getDeclaredConstructor();
|
||||
} catch (SecurityException e) {
|
||||
throw new RuntimeException("Cannot create command " + getName(), e);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException("Cannot create command " + getName(), e);
|
||||
}
|
||||
c.setAccessible(true);
|
||||
|
||||
final TextBuiltin r;
|
||||
try {
|
||||
r = c.newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
throw new RuntimeException("Cannot create command " + getName(), e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException("Cannot create command " + getName(), e);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new RuntimeException("Cannot create command " + getName(), e);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new RuntimeException("Cannot create command " + getName(), e);
|
||||
}
|
||||
r.setCommandName(getName());
|
||||
return r;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* Copyright (C) 2008-2009, Google Inc.
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.transport.DaemonService;
|
||||
|
||||
@Command(common = true, usage = "Export repositories over git://")
|
||||
class Daemon extends TextBuiltin {
|
||||
@Option(name = "--port", metaVar = "PORT", usage = "port number to listen on")
|
||||
int port = org.eclipse.jgit.transport.Daemon.DEFAULT_PORT;
|
||||
|
||||
@Option(name = "--listen", metaVar = "HOSTNAME", usage = "hostname (or ip) to listen on")
|
||||
String host;
|
||||
|
||||
@Option(name = "--timeout", metaVar = "SECONDS", usage = "abort connection if no activity")
|
||||
int timeout = -1;
|
||||
|
||||
@Option(name = "--enable", metaVar = "SERVICE", usage = "enable the service in all repositories", multiValued = true)
|
||||
final List<String> enable = new ArrayList<String>();
|
||||
|
||||
@Option(name = "--disable", metaVar = "SERVICE", usage = "disable the service in all repositories", multiValued = true)
|
||||
final List<String> disable = new ArrayList<String>();
|
||||
|
||||
@Option(name = "--allow-override", metaVar = "SERVICE", usage = "configure the service in daemon.servicename", multiValued = true)
|
||||
final List<String> canOverride = new ArrayList<String>();
|
||||
|
||||
@Option(name = "--forbid-override", metaVar = "SERVICE", usage = "configure the service in daemon.servicename", multiValued = true)
|
||||
final List<String> forbidOverride = new ArrayList<String>();
|
||||
|
||||
@Option(name = "--export-all", usage = "export without git-daemon-export-ok")
|
||||
boolean exportAll;
|
||||
|
||||
@Argument(required = true, metaVar = "DIRECTORY", usage = "directories to export")
|
||||
final List<File> directory = new ArrayList<File>();
|
||||
|
||||
@Override
|
||||
protected boolean requiresRepository() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
final org.eclipse.jgit.transport.Daemon d;
|
||||
|
||||
d = new org.eclipse.jgit.transport.Daemon(
|
||||
host != null ? new InetSocketAddress(host, port)
|
||||
: new InetSocketAddress(port));
|
||||
d.setExportAll(exportAll);
|
||||
if (0 <= timeout)
|
||||
d.setTimeout(timeout);
|
||||
|
||||
for (final String n : enable)
|
||||
service(d, n).setEnabled(true);
|
||||
for (final String n : disable)
|
||||
service(d, n).setEnabled(false);
|
||||
|
||||
for (final String n : canOverride)
|
||||
service(d, n).setOverridable(true);
|
||||
for (final String n : forbidOverride)
|
||||
service(d, n).setOverridable(false);
|
||||
|
||||
for (final File f : directory) {
|
||||
out.println("Exporting " + f.getAbsolutePath());
|
||||
d.exportDirectory(f);
|
||||
}
|
||||
d.start();
|
||||
out.println("Listening on " + d.getAddress());
|
||||
}
|
||||
|
||||
private DaemonService service(final org.eclipse.jgit.transport.Daemon d,
|
||||
final String n) {
|
||||
final DaemonService svc = d.getService(n);
|
||||
if (svc == null)
|
||||
throw die("Service '" + n + "' not supported");
|
||||
return svc;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
/**
|
||||
* Indicates a {@link TextBuiltin} implementation has failed during execution.
|
||||
* <p>
|
||||
* Typically the stack trace for a Die exception is not shown to the user as it
|
||||
* may indicate a simple error condition that the end-user can fix on their own,
|
||||
* without needing a screen of Java stack frames.
|
||||
*/
|
||||
public class Die extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Construct a new message explaining what has gone wrong.
|
||||
*
|
||||
* @param why
|
||||
* the message to show to the end-user.
|
||||
*/
|
||||
public Die(final String why) {
|
||||
super(why);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Jonas Fonseca <fonseca@diku.dk>
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.lib.FileMode;
|
||||
import org.eclipse.jgit.pgm.opt.PathTreeFilterHandler;
|
||||
import org.eclipse.jgit.treewalk.AbstractTreeIterator;
|
||||
import org.eclipse.jgit.treewalk.TreeWalk;
|
||||
import org.eclipse.jgit.treewalk.filter.AndTreeFilter;
|
||||
import org.eclipse.jgit.treewalk.filter.TreeFilter;
|
||||
|
||||
class DiffTree extends TextBuiltin {
|
||||
@Option(name = "--recursive", usage = "recurse into subtrees", aliases = { "-r" })
|
||||
private boolean recursive;
|
||||
|
||||
@Argument(index = 0, metaVar = "tree-ish", required = true)
|
||||
void tree_0(final AbstractTreeIterator c) {
|
||||
trees.add(c);
|
||||
}
|
||||
|
||||
@Argument(index = 1, metaVar = "tree-ish", required = true)
|
||||
private final List<AbstractTreeIterator> trees = new ArrayList<AbstractTreeIterator>();
|
||||
|
||||
@Option(name = "--", metaVar = "path", multiValued = true, handler = PathTreeFilterHandler.class)
|
||||
private TreeFilter pathFilter = TreeFilter.ALL;
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
final TreeWalk walk = new TreeWalk(db);
|
||||
walk.reset();
|
||||
walk.setRecursive(recursive);
|
||||
for (final AbstractTreeIterator i : trees)
|
||||
walk.addTree(i);
|
||||
walk.setFilter(AndTreeFilter.create(TreeFilter.ANY_DIFF, pathFilter));
|
||||
|
||||
final int nTree = walk.getTreeCount();
|
||||
while (walk.next()) {
|
||||
for (int i = 1; i < nTree; i++)
|
||||
out.print(':');
|
||||
for (int i = 0; i < nTree; i++) {
|
||||
final FileMode m = walk.getFileMode(i);
|
||||
final String s = m.toString();
|
||||
for (int pad = 6 - s.length(); pad > 0; pad--)
|
||||
out.print('0');
|
||||
out.print(s);
|
||||
out.print(' ');
|
||||
}
|
||||
|
||||
for (int i = 0; i < nTree; i++) {
|
||||
out.print(walk.getObjectId(i).name());
|
||||
out.print(' ');
|
||||
}
|
||||
|
||||
char chg = 'M';
|
||||
if (nTree == 2) {
|
||||
final int m0 = walk.getRawMode(0);
|
||||
final int m1 = walk.getRawMode(1);
|
||||
if (m0 == 0 && m1 != 0)
|
||||
chg = 'A';
|
||||
else if (m0 != 0 && m1 == 0)
|
||||
chg = 'D';
|
||||
else if (m0 != m1 && walk.idEqual(0, 1))
|
||||
chg = 'T';
|
||||
}
|
||||
out.print(chg);
|
||||
|
||||
out.print('\t');
|
||||
out.print(walk.getPathString());
|
||||
out.println();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* Copyright (C) 2008-2009, Google Inc.
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.lib.TextProgressMonitor;
|
||||
import org.eclipse.jgit.transport.FetchResult;
|
||||
import org.eclipse.jgit.transport.RefSpec;
|
||||
import org.eclipse.jgit.transport.Transport;
|
||||
|
||||
@Command(common = true, usage = "Update remote refs from another repository")
|
||||
class Fetch extends AbstractFetchCommand {
|
||||
@Option(name = "--timeout", metaVar = "SECONDS", usage = "abort connection if no activity")
|
||||
int timeout = -1;
|
||||
|
||||
@Option(name = "--fsck", usage = "perform fsck style checks on receive")
|
||||
private Boolean fsck;
|
||||
|
||||
@Option(name = "--no-fsck")
|
||||
void nofsck(final boolean ignored) {
|
||||
fsck = Boolean.FALSE;
|
||||
}
|
||||
|
||||
@Option(name = "--prune", usage = "prune stale tracking refs")
|
||||
private Boolean prune;
|
||||
|
||||
@Option(name = "--dry-run")
|
||||
private boolean dryRun;
|
||||
|
||||
@Option(name = "--thin", usage = "fetch thin pack")
|
||||
private Boolean thin;
|
||||
|
||||
@Option(name = "--no-thin")
|
||||
void nothin(final boolean ignored) {
|
||||
thin = Boolean.FALSE;
|
||||
}
|
||||
|
||||
@Argument(index = 0, metaVar = "uri-ish")
|
||||
private String remote = "origin";
|
||||
|
||||
@Argument(index = 1, metaVar = "refspec")
|
||||
private List<RefSpec> toget;
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
final Transport tn = Transport.open(db, remote);
|
||||
if (fsck != null)
|
||||
tn.setCheckFetchedObjects(fsck.booleanValue());
|
||||
if (prune != null)
|
||||
tn.setRemoveDeletedRefs(prune.booleanValue());
|
||||
tn.setDryRun(dryRun);
|
||||
if (thin != null)
|
||||
tn.setFetchThin(thin.booleanValue());
|
||||
if (0 <= timeout)
|
||||
tn.setTimeout(timeout);
|
||||
final FetchResult r;
|
||||
try {
|
||||
r = tn.fetch(new TextProgressMonitor(), toget);
|
||||
if (r.getTrackingRefUpdates().isEmpty())
|
||||
return;
|
||||
} finally {
|
||||
tn.close();
|
||||
}
|
||||
showFetchResult(tn, r);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
import org.eclipse.jgit.awtui.CommitGraphPane;
|
||||
import org.eclipse.jgit.revplot.PlotWalk;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevSort;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
|
||||
class Glog extends RevWalkTextBuiltin {
|
||||
final JFrame frame;
|
||||
|
||||
final CommitGraphPane graphPane;
|
||||
|
||||
Glog() {
|
||||
frame = new JFrame();
|
||||
frame.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(final WindowEvent e) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
graphPane = new CommitGraphPane();
|
||||
|
||||
final JScrollPane graphScroll = new JScrollPane(graphPane);
|
||||
|
||||
final JPanel buttons = new JPanel(new FlowLayout());
|
||||
final JButton repaint = new JButton();
|
||||
repaint.setText("Repaint");
|
||||
repaint.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
graphPane.repaint();
|
||||
}
|
||||
});
|
||||
buttons.add(repaint);
|
||||
|
||||
final JPanel world = new JPanel(new BorderLayout());
|
||||
world.add(buttons, BorderLayout.SOUTH);
|
||||
world.add(graphScroll, BorderLayout.CENTER);
|
||||
|
||||
frame.getContentPane().add(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int walkLoop() throws Exception {
|
||||
graphPane.getCommitList().source(walk);
|
||||
graphPane.getCommitList().fillTo(Integer.MAX_VALUE);
|
||||
|
||||
frame.setTitle("[" + repoName() + "]");
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
return graphPane.getCommitList().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void show(final RevCommit c) throws Exception {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RevWalk createWalk() {
|
||||
if (objects)
|
||||
throw die("Cannot use --objects with glog");
|
||||
final PlotWalk w = new PlotWalk(db);
|
||||
w.sort(RevSort.BOUNDARY, true);
|
||||
return w;
|
||||
}
|
||||
|
||||
private String repoName() {
|
||||
final File f = db.getDirectory();
|
||||
String n = f.getName();
|
||||
if (".git".equals(n))
|
||||
n = f.getParentFile().getName();
|
||||
return n;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (C) 2009, Google Inc.
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.lib.TextProgressMonitor;
|
||||
|
||||
class IndexPack extends TextBuiltin {
|
||||
@Option(name = "--fix-thin", usage = "fix a thin pack to be complete")
|
||||
private boolean fixThin;
|
||||
|
||||
@Option(name = "--index-version", usage = "index file format to create")
|
||||
private int indexVersion = -1;
|
||||
|
||||
@Argument(index = 0, required = true, metaVar = "base")
|
||||
private File base;
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
if (indexVersion == -1)
|
||||
indexVersion = db.getConfig().getCore().getPackIndexVersion();
|
||||
final BufferedInputStream in;
|
||||
final org.eclipse.jgit.transport.IndexPack ip;
|
||||
in = new BufferedInputStream(System.in);
|
||||
ip = new org.eclipse.jgit.transport.IndexPack(db, in, base);
|
||||
ip.setFixThin(fixThin);
|
||||
ip.setIndexVersion(indexVersion);
|
||||
ip.index(new TextProgressMonitor());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright (C) 2009, Constantine Plotnikov <constantine.plotnikov@gmail.com>
|
||||
* Copyright (C) 2008, Google Inc.
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
|
||||
@Command(common = true, usage = "Create an empty git repository")
|
||||
class Init extends TextBuiltin {
|
||||
@Option(name = "--bare", usage = "Create a bare repository")
|
||||
private boolean bare;
|
||||
|
||||
@Override
|
||||
protected final boolean requiresRepository() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
if (gitdir == null)
|
||||
gitdir = new File(bare ? "." : ".git");
|
||||
db = new Repository(gitdir);
|
||||
db.create(bare);
|
||||
out.println("Initialized empty Git repository in "
|
||||
+ gitdir.getAbsolutePath());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* Copyright (C) 2006-2008, Robin Rosenberg <robin.rosenberg@dewire.com>
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.lib.AnyObjectId;
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
|
||||
@Command(common = true, usage = "View commit history")
|
||||
class Log extends RevWalkTextBuiltin {
|
||||
private final TimeZone myTZ = TimeZone.getDefault();
|
||||
|
||||
private final DateFormat fmt;
|
||||
|
||||
private Map<AnyObjectId, Set<Ref>> allRefsByPeeledObjectId;
|
||||
|
||||
@Option(name="--decorate", usage="Show ref names matching commits")
|
||||
private boolean decorate;
|
||||
|
||||
Log() {
|
||||
fmt = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy ZZZZZ", Locale.US);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RevWalk createWalk() {
|
||||
RevWalk ret = super.createWalk();
|
||||
if (decorate)
|
||||
allRefsByPeeledObjectId = getRepository().getAllRefsByPeeledObjectId();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void show(final RevCommit c) throws Exception {
|
||||
out.print("commit ");
|
||||
c.getId().copyTo(outbuffer, out);
|
||||
if (decorate) {
|
||||
Collection<Ref> list = allRefsByPeeledObjectId.get(c.copy());
|
||||
if (list != null) {
|
||||
out.print(" (");
|
||||
for (Iterator<Ref> i = list.iterator(); i.hasNext(); ) {
|
||||
out.print(i.next().getOrigName());
|
||||
if (i.hasNext())
|
||||
out.print(" ");
|
||||
}
|
||||
out.print(")");
|
||||
}
|
||||
}
|
||||
out.println();
|
||||
|
||||
final PersonIdent author = c.getAuthorIdent();
|
||||
out.print("Author: ");
|
||||
out.print(author.getName());
|
||||
out.print(" <");
|
||||
out.print(author.getEmailAddress());
|
||||
out.print(">");
|
||||
out.println();
|
||||
|
||||
final TimeZone authorTZ = author.getTimeZone();
|
||||
fmt.setTimeZone(authorTZ != null ? authorTZ : myTZ);
|
||||
out.print("Date: ");
|
||||
out.print(fmt.format(author.getWhen()));
|
||||
out.println();
|
||||
|
||||
out.println();
|
||||
final String[] lines = c.getFullMessage().split("\n");
|
||||
for (final String s : lines) {
|
||||
out.print(" ");
|
||||
out.print(s);
|
||||
out.println();
|
||||
}
|
||||
|
||||
out.println();
|
||||
out.flush();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* Copyright (C) 2009, Google Inc.
|
||||
* Copyright (C) 2008, Jonas Fonseca <fonseca@diku.dk>
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.lib.AnyObjectId;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.transport.FetchConnection;
|
||||
import org.eclipse.jgit.transport.Transport;
|
||||
|
||||
class LsRemote extends TextBuiltin {
|
||||
@Option(name = "--timeout", metaVar = "SECONDS", usage = "abort connection if no activity")
|
||||
int timeout = -1;
|
||||
|
||||
@Argument(index = 0, metaVar = "uri-ish", required = true)
|
||||
private String remote;
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
final Transport tn = Transport.open(db, remote);
|
||||
if (0 <= timeout)
|
||||
tn.setTimeout(timeout);
|
||||
final FetchConnection c = tn.openFetch();
|
||||
try {
|
||||
for (final Ref r : c.getRefs()) {
|
||||
show(r.getObjectId(), r.getName());
|
||||
if (r.getPeeledObjectId() != null)
|
||||
show(r.getPeeledObjectId(), r.getName() + "^{}");
|
||||
}
|
||||
} finally {
|
||||
c.close();
|
||||
tn.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void show(final AnyObjectId id, final String name) {
|
||||
out.print(id.name());
|
||||
out.print('\t');
|
||||
out.print(name);
|
||||
out.println();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Jonas Fonseca <fonseca@diku.dk>
|
||||
* Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.FileMode;
|
||||
import org.eclipse.jgit.treewalk.AbstractTreeIterator;
|
||||
import org.eclipse.jgit.treewalk.TreeWalk;
|
||||
|
||||
class LsTree extends TextBuiltin {
|
||||
@Option(name = "--recursive", usage = "recurse into subtrees", aliases = { "-r" })
|
||||
private boolean recursive;
|
||||
|
||||
@Argument(index = 0, required = true, metaVar = "tree-ish")
|
||||
private AbstractTreeIterator tree;
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
final TreeWalk walk = new TreeWalk(db);
|
||||
walk.reset(); // drop the first empty tree, which we do not need here
|
||||
walk.setRecursive(recursive);
|
||||
walk.addTree(tree);
|
||||
|
||||
while (walk.next()) {
|
||||
final FileMode mode = walk.getFileMode(0);
|
||||
if (mode == FileMode.TREE)
|
||||
out.print('0');
|
||||
out.print(mode);
|
||||
out.print(' ');
|
||||
out.print(Constants.typeString(mode.getObjectType()));
|
||||
|
||||
out.print(' ');
|
||||
out.print(walk.getObjectId(0).name());
|
||||
|
||||
out.print('\t');
|
||||
out.print(walk.getPathString());
|
||||
out.println();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,184 @@
|
|||
/*
|
||||
* Copyright (C) 2008-2009, Google Inc.
|
||||
* Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
|
||||
* Copyright (C) 2006, Robin Rosenberg <robin.rosenberg@dewire.com>
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.ExampleMode;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.awtui.AwtAuthenticator;
|
||||
import org.eclipse.jgit.errors.TransportException;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.pgm.opt.CmdLineParser;
|
||||
import org.eclipse.jgit.pgm.opt.SubcommandHandler;
|
||||
import org.eclipse.jgit.util.HttpSupport;
|
||||
|
||||
/** Command line entry point. */
|
||||
public class Main {
|
||||
@Option(name = "--help", usage = "display this help text", aliases = { "-h" })
|
||||
private boolean help;
|
||||
|
||||
@Option(name = "--show-stack-trace", usage = "display the Java stack trace on exceptions")
|
||||
private boolean showStackTrace;
|
||||
|
||||
@Option(name = "--git-dir", metaVar = "GIT_DIR", usage = "set the git repository to operate on")
|
||||
private File gitdir;
|
||||
|
||||
@Argument(index = 0, metaVar = "command", required = true, handler = SubcommandHandler.class)
|
||||
private TextBuiltin subcommand;
|
||||
|
||||
@Argument(index = 1, metaVar = "ARG")
|
||||
private List<String> arguments = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Execute the command line.
|
||||
*
|
||||
* @param argv
|
||||
* arguments.
|
||||
*/
|
||||
public static void main(final String[] argv) {
|
||||
final Main me = new Main();
|
||||
try {
|
||||
AwtAuthenticator.install();
|
||||
HttpSupport.configureHttpProxy();
|
||||
me.execute(argv);
|
||||
} catch (Die err) {
|
||||
System.err.println("fatal: " + err.getMessage());
|
||||
if (me.showStackTrace)
|
||||
err.printStackTrace();
|
||||
System.exit(128);
|
||||
} catch (Exception err) {
|
||||
if (!me.showStackTrace && err.getCause() != null
|
||||
&& err instanceof TransportException)
|
||||
System.err.println("fatal: " + err.getCause().getMessage());
|
||||
|
||||
if (err.getClass().getName().startsWith("org.eclipse.jgit.errors.")) {
|
||||
System.err.println("fatal: " + err.getMessage());
|
||||
if (me.showStackTrace)
|
||||
err.printStackTrace();
|
||||
System.exit(128);
|
||||
}
|
||||
err.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private void execute(final String[] argv) throws Exception {
|
||||
final CmdLineParser clp = new CmdLineParser(this);
|
||||
try {
|
||||
clp.parseArgument(argv);
|
||||
} catch (CmdLineException err) {
|
||||
if (argv.length > 0 && !help) {
|
||||
System.err.println("fatal: " + err.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (argv.length == 0 || help) {
|
||||
final String ex = clp.printExample(ExampleMode.ALL);
|
||||
System.err.println("jgit" + ex + " command [ARG ...]");
|
||||
if (help) {
|
||||
System.err.println();
|
||||
clp.printUsage(System.err);
|
||||
System.err.println();
|
||||
} else if (subcommand == null) {
|
||||
System.err.println();
|
||||
System.err.println("The most commonly used commands are:");
|
||||
final CommandRef[] common = CommandCatalog.common();
|
||||
int width = 0;
|
||||
for (final CommandRef c : common)
|
||||
width = Math.max(width, c.getName().length());
|
||||
width += 2;
|
||||
|
||||
for (final CommandRef c : common) {
|
||||
System.err.print(' ');
|
||||
System.err.print(c.getName());
|
||||
for (int i = c.getName().length(); i < width; i++)
|
||||
System.err.print(' ');
|
||||
System.err.print(c.getUsage());
|
||||
System.err.println();
|
||||
}
|
||||
System.err.println();
|
||||
}
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
final TextBuiltin cmd = subcommand;
|
||||
if (cmd.requiresRepository()) {
|
||||
if (gitdir == null)
|
||||
gitdir = findGitDir();
|
||||
if (gitdir == null || !gitdir.isDirectory()) {
|
||||
System.err.println("error: can't find git directory");
|
||||
System.exit(1);
|
||||
}
|
||||
cmd.init(new Repository(gitdir), gitdir);
|
||||
} else {
|
||||
cmd.init(null, gitdir);
|
||||
}
|
||||
try {
|
||||
cmd.execute(arguments.toArray(new String[arguments.size()]));
|
||||
} finally {
|
||||
if (cmd.out != null)
|
||||
cmd.out.flush();
|
||||
}
|
||||
}
|
||||
|
||||
private static File findGitDir() {
|
||||
File current = new File(".").getAbsoluteFile();
|
||||
while (current != null) {
|
||||
final File gitDir = new File(current, ".git");
|
||||
if (gitDir.isDirectory())
|
||||
return gitDir;
|
||||
current = current.getParentFile();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Jonas Fonseca <fonseca@diku.dk>
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.filter.RevFilter;
|
||||
|
||||
class MergeBase extends TextBuiltin {
|
||||
@Option(name = "--all", usage = "display all possible merge bases")
|
||||
private boolean all;
|
||||
|
||||
@Argument(index = 0, metaVar = "commit-ish", required = true)
|
||||
void commit_0(final RevCommit c) {
|
||||
commits.add(c);
|
||||
}
|
||||
|
||||
@Argument(index = 1, metaVar = "commit-ish", required = true)
|
||||
private final List<RevCommit> commits = new ArrayList<RevCommit>();
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
for (final RevCommit c : commits)
|
||||
argWalk.markStart(c);
|
||||
argWalk.setRevFilter(RevFilter.MERGE_BASE);
|
||||
int max = all ? Integer.MAX_VALUE : 1;
|
||||
while (max-- > 0) {
|
||||
final RevCommit b = argWalk.next();
|
||||
if (b == null)
|
||||
break;
|
||||
out.println(b.getId().name());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,256 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.TextProgressMonitor;
|
||||
import org.eclipse.jgit.transport.PushResult;
|
||||
import org.eclipse.jgit.transport.RefSpec;
|
||||
import org.eclipse.jgit.transport.RemoteRefUpdate;
|
||||
import org.eclipse.jgit.transport.Transport;
|
||||
import org.eclipse.jgit.transport.URIish;
|
||||
import org.eclipse.jgit.transport.RemoteRefUpdate.Status;
|
||||
|
||||
@Command(common = true, usage = "Update remote repository from local refs")
|
||||
class Push extends TextBuiltin {
|
||||
@Option(name = "--timeout", metaVar = "SECONDS", usage = "abort connection if no activity")
|
||||
int timeout = -1;
|
||||
|
||||
@Argument(index = 0, metaVar = "uri-ish")
|
||||
private String remote = "origin";
|
||||
|
||||
@Argument(index = 1, metaVar = "refspec")
|
||||
private final List<RefSpec> refSpecs = new ArrayList<RefSpec>();
|
||||
|
||||
@Option(name = "--all")
|
||||
void addAll(final boolean ignored) {
|
||||
refSpecs.add(Transport.REFSPEC_PUSH_ALL);
|
||||
}
|
||||
|
||||
@Option(name = "--tags")
|
||||
void addTags(final boolean ignored) {
|
||||
refSpecs.add(Transport.REFSPEC_TAGS);
|
||||
}
|
||||
|
||||
@Option(name = "--verbose", aliases = { "-v" })
|
||||
private boolean verbose = false;
|
||||
|
||||
@Option(name = "--thin")
|
||||
private boolean thin = Transport.DEFAULT_PUSH_THIN;
|
||||
|
||||
@Option(name = "--no-thin")
|
||||
void nothin(final boolean ignored) {
|
||||
thin = false;
|
||||
}
|
||||
|
||||
@Option(name = "--force", aliases = { "-f" })
|
||||
private boolean force;
|
||||
|
||||
@Option(name = "--receive-pack", metaVar = "path")
|
||||
private String receivePack;
|
||||
|
||||
@Option(name = "--dry-run")
|
||||
private boolean dryRun;
|
||||
|
||||
private boolean shownURI;
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
if (force) {
|
||||
final List<RefSpec> orig = new ArrayList<RefSpec>(refSpecs);
|
||||
refSpecs.clear();
|
||||
for (final RefSpec spec : orig)
|
||||
refSpecs.add(spec.setForceUpdate(true));
|
||||
}
|
||||
|
||||
final List<Transport> transports;
|
||||
transports = Transport.openAll(db, remote, Transport.Operation.PUSH);
|
||||
for (final Transport transport : transports) {
|
||||
if (0 <= timeout)
|
||||
transport.setTimeout(timeout);
|
||||
transport.setPushThin(thin);
|
||||
if (receivePack != null)
|
||||
transport.setOptionReceivePack(receivePack);
|
||||
transport.setDryRun(dryRun);
|
||||
|
||||
final Collection<RemoteRefUpdate> toPush = transport
|
||||
.findRemoteRefUpdatesFor(refSpecs);
|
||||
|
||||
final URIish uri = transport.getURI();
|
||||
final PushResult result;
|
||||
try {
|
||||
result = transport.push(new TextProgressMonitor(), toPush);
|
||||
} finally {
|
||||
transport.close();
|
||||
}
|
||||
printPushResult(uri, result);
|
||||
}
|
||||
}
|
||||
|
||||
private void printPushResult(final URIish uri,
|
||||
final PushResult result) {
|
||||
shownURI = false;
|
||||
boolean everythingUpToDate = true;
|
||||
|
||||
// at first, print up-to-date ones...
|
||||
for (final RemoteRefUpdate rru : result.getRemoteUpdates()) {
|
||||
if (rru.getStatus() == Status.UP_TO_DATE) {
|
||||
if (verbose)
|
||||
printRefUpdateResult(uri, result, rru);
|
||||
} else
|
||||
everythingUpToDate = false;
|
||||
}
|
||||
|
||||
for (final RemoteRefUpdate rru : result.getRemoteUpdates()) {
|
||||
// ...then successful updates...
|
||||
if (rru.getStatus() == Status.OK)
|
||||
printRefUpdateResult(uri, result, rru);
|
||||
}
|
||||
|
||||
for (final RemoteRefUpdate rru : result.getRemoteUpdates()) {
|
||||
// ...finally, others (problematic)
|
||||
if (rru.getStatus() != Status.OK
|
||||
&& rru.getStatus() != Status.UP_TO_DATE)
|
||||
printRefUpdateResult(uri, result, rru);
|
||||
}
|
||||
|
||||
if (everythingUpToDate)
|
||||
out.println("Everything up-to-date");
|
||||
}
|
||||
|
||||
private void printRefUpdateResult(final URIish uri,
|
||||
final PushResult result, final RemoteRefUpdate rru) {
|
||||
if (!shownURI) {
|
||||
shownURI = true;
|
||||
out.format("To %s\n", uri);
|
||||
}
|
||||
|
||||
final String remoteName = rru.getRemoteName();
|
||||
final String srcRef = rru.isDelete() ? null : rru.getSrcRef();
|
||||
|
||||
switch (rru.getStatus()) {
|
||||
case OK:
|
||||
if (rru.isDelete())
|
||||
printUpdateLine('-', "[deleted]", null, remoteName, null);
|
||||
else {
|
||||
final Ref oldRef = result.getAdvertisedRef(remoteName);
|
||||
if (oldRef == null) {
|
||||
final String summary;
|
||||
if (remoteName.startsWith(Constants.R_TAGS))
|
||||
summary = "[new tag]";
|
||||
else
|
||||
summary = "[new branch]";
|
||||
printUpdateLine('*', summary, srcRef, remoteName, null);
|
||||
} else {
|
||||
boolean fastForward = rru.isFastForward();
|
||||
final char flag = fastForward ? ' ' : '+';
|
||||
final String summary = oldRef.getObjectId().abbreviate(db)
|
||||
.name()
|
||||
+ (fastForward ? ".." : "...")
|
||||
+ rru.getNewObjectId().abbreviate(db).name();
|
||||
final String message = fastForward ? null : "forced update";
|
||||
printUpdateLine(flag, summary, srcRef, remoteName, message);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NON_EXISTING:
|
||||
printUpdateLine('X', "[no match]", null, remoteName, null);
|
||||
break;
|
||||
|
||||
case REJECTED_NODELETE:
|
||||
printUpdateLine('!', "[rejected]", null, remoteName,
|
||||
"remote side does not support deleting refs");
|
||||
break;
|
||||
|
||||
case REJECTED_NONFASTFORWARD:
|
||||
printUpdateLine('!', "[rejected]", srcRef, remoteName,
|
||||
"non-fast forward");
|
||||
break;
|
||||
|
||||
case REJECTED_REMOTE_CHANGED:
|
||||
final String message = "remote ref object changed - is not expected one "
|
||||
+ rru.getExpectedOldObjectId().abbreviate(db).name();
|
||||
printUpdateLine('!', "[rejected]", srcRef, remoteName, message);
|
||||
break;
|
||||
|
||||
case REJECTED_OTHER_REASON:
|
||||
printUpdateLine('!', "[remote rejected]", srcRef, remoteName, rru
|
||||
.getMessage());
|
||||
break;
|
||||
|
||||
case UP_TO_DATE:
|
||||
if (verbose)
|
||||
printUpdateLine('=', "[up to date]", srcRef, remoteName, null);
|
||||
break;
|
||||
|
||||
case NOT_ATTEMPTED:
|
||||
case AWAITING_REPORT:
|
||||
printUpdateLine('?', "[unexpected push-process behavior]", srcRef,
|
||||
remoteName, rru.getMessage());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void printUpdateLine(final char flag, final String summary,
|
||||
final String srcRef, final String destRef, final String message) {
|
||||
out.format(" %c %-17s", flag, summary);
|
||||
|
||||
if (srcRef != null)
|
||||
out.format(" %s ->", abbreviateRef(srcRef, true));
|
||||
out.format(" %s", abbreviateRef(destRef, true));
|
||||
|
||||
if (message != null)
|
||||
out.format(" (%s)", message);
|
||||
|
||||
out.println();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright (C) 2008-2009, Google Inc.
|
||||
* Copyright (C) 2009, Robin Rosenberg <robin.rosenberg@dewire.com>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
|
||||
@Command(common = false, usage = "Server side backend for 'jgit push'")
|
||||
class ReceivePack extends TextBuiltin {
|
||||
@Argument(index = 0, required = true, metaVar = "DIRECTORY", usage = "Repository to receive into")
|
||||
File dstGitdir;
|
||||
|
||||
@Override
|
||||
protected final boolean requiresRepository() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
final org.eclipse.jgit.transport.ReceivePack rp;
|
||||
|
||||
if (new File(dstGitdir, ".git").isDirectory())
|
||||
dstGitdir = new File(dstGitdir, ".git");
|
||||
db = new Repository(dstGitdir);
|
||||
if (!db.getObjectsDirectory().isDirectory())
|
||||
throw die("'" + dstGitdir.getPath() + "' not a git repository");
|
||||
rp = new org.eclipse.jgit.transport.ReceivePack(db);
|
||||
rp.receive(System.in, System.out, System.err);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import org.eclipse.jgit.revwalk.ObjectWalk;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevFlag;
|
||||
import org.eclipse.jgit.revwalk.RevObject;
|
||||
import org.eclipse.jgit.revwalk.RevTree;
|
||||
|
||||
class RevList extends RevWalkTextBuiltin {
|
||||
@Override
|
||||
protected void show(final RevCommit c) throws Exception {
|
||||
if (c.has(RevFlag.UNINTERESTING))
|
||||
out.print('-');
|
||||
c.getId().copyTo(outbuffer, out);
|
||||
if (parents)
|
||||
for (int i = 0; i < c.getParentCount(); i++) {
|
||||
out.print(' ');
|
||||
c.getParent(i).getId().copyTo(outbuffer, out);
|
||||
}
|
||||
out.println();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void show(final ObjectWalk ow, final RevObject obj)
|
||||
throws Exception {
|
||||
if (obj.has(RevFlag.UNINTERESTING))
|
||||
out.print('-');
|
||||
obj.getId().copyTo(outbuffer, out);
|
||||
final String path = ow.getPathString();
|
||||
if (path != null) {
|
||||
out.print(' ');
|
||||
out.print(path);
|
||||
} else if (obj instanceof RevTree)
|
||||
out.print(' ');
|
||||
out.println();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright (C) 2009, Daniel Cheng (aka SDiZ) <git@sdiz.net>
|
||||
* Copyright (C) 2009, Daniel Cheng (aka SDiZ) <j16sdiz+freenet@gmail.com>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
|
||||
class RevParse extends TextBuiltin {
|
||||
@Option(name = "--all")
|
||||
boolean all = false;
|
||||
|
||||
@Argument(index = 0, metaVar = "commit-ish")
|
||||
private final List<ObjectId> commits = new ArrayList<ObjectId>();
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
if (all) {
|
||||
Map<String, Ref> allRefs = db.getAllRefs();
|
||||
for (final Ref r : allRefs.values())
|
||||
out.println(r.getObjectId().name());
|
||||
} else {
|
||||
for (final ObjectId o : commits)
|
||||
out.println(o.name());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,208 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.pgm.opt.PathTreeFilterHandler;
|
||||
import org.eclipse.jgit.revwalk.ObjectWalk;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevFlag;
|
||||
import org.eclipse.jgit.revwalk.RevObject;
|
||||
import org.eclipse.jgit.revwalk.RevSort;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.eclipse.jgit.revwalk.filter.AndRevFilter;
|
||||
import org.eclipse.jgit.revwalk.filter.AuthorRevFilter;
|
||||
import org.eclipse.jgit.revwalk.filter.CommitterRevFilter;
|
||||
import org.eclipse.jgit.revwalk.filter.MessageRevFilter;
|
||||
import org.eclipse.jgit.revwalk.filter.RevFilter;
|
||||
import org.eclipse.jgit.treewalk.filter.AndTreeFilter;
|
||||
import org.eclipse.jgit.treewalk.filter.TreeFilter;
|
||||
|
||||
abstract class RevWalkTextBuiltin extends TextBuiltin {
|
||||
RevWalk walk;
|
||||
|
||||
@Option(name = "--objects")
|
||||
boolean objects = false;
|
||||
|
||||
@Option(name = "--parents")
|
||||
boolean parents = false;
|
||||
|
||||
@Option(name = "--total-count")
|
||||
boolean count = false;
|
||||
|
||||
char[] outbuffer = new char[Constants.OBJECT_ID_LENGTH * 2];
|
||||
|
||||
private final EnumSet<RevSort> sorting = EnumSet.noneOf(RevSort.class);
|
||||
|
||||
private void enableRevSort(final RevSort type, final boolean on) {
|
||||
if (on)
|
||||
sorting.add(type);
|
||||
else
|
||||
sorting.remove(type);
|
||||
}
|
||||
|
||||
@Option(name = "--date-order")
|
||||
void enableDateOrder(final boolean on) {
|
||||
enableRevSort(RevSort.COMMIT_TIME_DESC, on);
|
||||
}
|
||||
|
||||
@Option(name = "--topo-order")
|
||||
void enableTopoOrder(final boolean on) {
|
||||
enableRevSort(RevSort.TOPO, on);
|
||||
}
|
||||
|
||||
@Option(name = "--reverse")
|
||||
void enableReverse(final boolean on) {
|
||||
enableRevSort(RevSort.REVERSE, on);
|
||||
}
|
||||
|
||||
@Option(name = "--boundary")
|
||||
void enableBoundary(final boolean on) {
|
||||
enableRevSort(RevSort.BOUNDARY, on);
|
||||
}
|
||||
|
||||
@Argument(index = 0, metaVar = "commit-ish")
|
||||
private final List<RevCommit> commits = new ArrayList<RevCommit>();
|
||||
|
||||
@Option(name = "--", metaVar = "path", multiValued = true, handler = PathTreeFilterHandler.class)
|
||||
private TreeFilter pathFilter = TreeFilter.ALL;
|
||||
|
||||
private final List<RevFilter> revLimiter = new ArrayList<RevFilter>();
|
||||
|
||||
@Option(name = "--author")
|
||||
void addAuthorRevFilter(final String who) {
|
||||
revLimiter.add(AuthorRevFilter.create(who));
|
||||
}
|
||||
|
||||
@Option(name = "--committer")
|
||||
void addCommitterRevFilter(final String who) {
|
||||
revLimiter.add(CommitterRevFilter.create(who));
|
||||
}
|
||||
|
||||
@Option(name = "--grep")
|
||||
void addCMessageRevFilter(final String msg) {
|
||||
revLimiter.add(MessageRevFilter.create(msg));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
walk = createWalk();
|
||||
for (final RevSort s : sorting)
|
||||
walk.sort(s, true);
|
||||
|
||||
if (pathFilter != TreeFilter.ALL)
|
||||
walk.setTreeFilter(AndTreeFilter.create(pathFilter,
|
||||
TreeFilter.ANY_DIFF));
|
||||
|
||||
if (revLimiter.size() == 1)
|
||||
walk.setRevFilter(revLimiter.get(0));
|
||||
else if (revLimiter.size() > 1)
|
||||
walk.setRevFilter(AndRevFilter.create(revLimiter));
|
||||
|
||||
if (commits.isEmpty()) {
|
||||
final ObjectId head = db.resolve(Constants.HEAD);
|
||||
if (head == null)
|
||||
throw die("Cannot resolve " + Constants.HEAD);
|
||||
commits.add(walk.parseCommit(head));
|
||||
}
|
||||
for (final RevCommit c : commits) {
|
||||
final RevCommit real = argWalk == walk ? c : walk.parseCommit(c);
|
||||
if (c.has(RevFlag.UNINTERESTING))
|
||||
walk.markUninteresting(real);
|
||||
else
|
||||
walk.markStart(real);
|
||||
}
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
final int n = walkLoop();
|
||||
if (count) {
|
||||
final long end = System.currentTimeMillis();
|
||||
System.err.print(n);
|
||||
System.err.print(' ');
|
||||
System.err.print(end - start);
|
||||
System.err.print(" ms");
|
||||
System.err.println();
|
||||
}
|
||||
}
|
||||
|
||||
protected RevWalk createWalk() {
|
||||
if (objects)
|
||||
return new ObjectWalk(db);
|
||||
if (argWalk == null)
|
||||
argWalk = new RevWalk(db);
|
||||
return argWalk;
|
||||
}
|
||||
|
||||
protected int walkLoop() throws Exception {
|
||||
int n = 0;
|
||||
for (final RevCommit c : walk) {
|
||||
n++;
|
||||
show(c);
|
||||
}
|
||||
if (walk instanceof ObjectWalk) {
|
||||
final ObjectWalk ow = (ObjectWalk) walk;
|
||||
for (;;) {
|
||||
final RevObject obj = ow.nextObject();
|
||||
if (obj == null)
|
||||
break;
|
||||
show(ow, obj);
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
protected abstract void show(final RevCommit c) throws Exception;
|
||||
|
||||
protected void show(final ObjectWalk objectWalk,
|
||||
final RevObject currentObject) throws Exception {
|
||||
// Do nothing by default. Most applications cannot show an object.
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Google Inc.
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.kohsuke.args4j.spi.StopOptionHandler;
|
||||
import org.eclipse.jgit.dircache.DirCache;
|
||||
import org.eclipse.jgit.dircache.DirCacheBuildIterator;
|
||||
import org.eclipse.jgit.dircache.DirCacheBuilder;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.FileMode;
|
||||
import org.eclipse.jgit.pgm.opt.PathTreeFilterHandler;
|
||||
import org.eclipse.jgit.treewalk.TreeWalk;
|
||||
import org.eclipse.jgit.treewalk.filter.TreeFilter;
|
||||
|
||||
@Command(usage = "Stop tracking a file", common = true)
|
||||
class Rm extends TextBuiltin {
|
||||
@Argument(metaVar = "path", usage = "path", multiValued = true, required = true, handler = PathTreeFilterHandler.class)
|
||||
@Option(name = "--", handler = StopOptionHandler.class)
|
||||
private TreeFilter paths;
|
||||
|
||||
private File root;
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
root = db.getWorkDir();
|
||||
|
||||
final DirCache dirc = DirCache.lock(db);
|
||||
final DirCacheBuilder edit = dirc.builder();
|
||||
|
||||
final TreeWalk walk = new TreeWalk(db);
|
||||
walk.reset(); // drop the first empty tree, which we do not need here
|
||||
walk.setRecursive(true);
|
||||
walk.setFilter(paths);
|
||||
walk.addTree(new DirCacheBuildIterator(edit));
|
||||
|
||||
while (walk.next()) {
|
||||
final File path = new File(root, walk.getPathString());
|
||||
final FileMode mode = walk.getFileMode(0);
|
||||
if (mode.getObjectType() == Constants.OBJ_BLOB) {
|
||||
// Deleting a blob is simply a matter of removing
|
||||
// the file or symlink named by the tree entry.
|
||||
delete(path);
|
||||
}
|
||||
}
|
||||
|
||||
edit.commit();
|
||||
}
|
||||
|
||||
private void delete(File p) {
|
||||
while (p != null && !p.equals(root) && p.delete())
|
||||
p = p.getParentFile();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Jonas Fonseca <fonseca@diku.dk>
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.eclipse.jgit.lib.AnyObjectId;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
|
||||
class ShowRef extends TextBuiltin {
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
for (final Ref r : new TreeMap<String, Ref>(db.getAllRefs()).values()) {
|
||||
show(r.getObjectId(), r.getName());
|
||||
if (r.getPeeledObjectId() != null)
|
||||
show(r.getPeeledObjectId(), r.getName() + "^{}");
|
||||
}
|
||||
}
|
||||
|
||||
private void show(final AnyObjectId id, final String name) {
|
||||
out.print(id.name());
|
||||
out.print('\t');
|
||||
out.print(name);
|
||||
out.println();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Charles O'Farrell <charleso@charleso.org>
|
||||
* Copyright (C) 2009, Google Inc.
|
||||
* Copyright (C) 2008, Robin Rosenberg <robin.rosenberg.lists@dewire.com>
|
||||
* Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.ObjectLoader;
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
|
||||
@Command(common = true, usage = "Create a tag")
|
||||
class Tag extends TextBuiltin {
|
||||
@Option(name = "-f", usage = "force replacing an existing tag")
|
||||
private boolean force;
|
||||
|
||||
@Option(name = "-m", metaVar = "message", usage = "tag message")
|
||||
private String message = "";
|
||||
|
||||
@Argument(index = 0, required = true, metaVar = "name")
|
||||
private String tagName;
|
||||
|
||||
@Argument(index = 1, metaVar = "object")
|
||||
private ObjectId object;
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
if (object == null) {
|
||||
object = db.resolve(Constants.HEAD);
|
||||
if (object == null)
|
||||
throw die("Cannot resolve " + Constants.HEAD);
|
||||
}
|
||||
|
||||
if (!tagName.startsWith(Constants.R_TAGS))
|
||||
tagName = Constants.R_TAGS + tagName;
|
||||
if (!force && db.resolve(tagName) != null) {
|
||||
throw die("fatal: tag '"
|
||||
+ tagName.substring(Constants.R_TAGS.length())
|
||||
+ "' exists");
|
||||
}
|
||||
|
||||
final ObjectLoader ldr = db.openObject(object);
|
||||
if (ldr == null)
|
||||
throw new MissingObjectException(object, "any");
|
||||
|
||||
org.eclipse.jgit.lib.Tag tag = new org.eclipse.jgit.lib.Tag(db);
|
||||
tag.setObjId(object);
|
||||
tag.setType(Constants.typeString(ldr.getType()));
|
||||
tag.setTagger(new PersonIdent(db));
|
||||
tag.setMessage(message.replaceAll("\r", ""));
|
||||
tag.setTag(tagName.substring(Constants.R_TAGS.length()));
|
||||
tag.tag();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,241 @@
|
|||
/*
|
||||
* Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import static org.eclipse.jgit.lib.Constants.R_HEADS;
|
||||
import static org.eclipse.jgit.lib.Constants.R_REMOTES;
|
||||
import static org.eclipse.jgit.lib.Constants.R_TAGS;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.pgm.opt.CmdLineParser;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
|
||||
/**
|
||||
* Abstract command which can be invoked from the command line.
|
||||
* <p>
|
||||
* Commands are configured with a single "current" repository and then the
|
||||
* {@link #execute(String[])} method is invoked with the arguments that appear
|
||||
* on the command line after the command name.
|
||||
* <p>
|
||||
* Command constructors should perform as little work as possible as they may be
|
||||
* invoked very early during process loading, and the command may not execute
|
||||
* even though it was constructed.
|
||||
*/
|
||||
public abstract class TextBuiltin {
|
||||
private String commandName;
|
||||
|
||||
@Option(name = "--help", usage = "display this help text", aliases = { "-h" })
|
||||
private boolean help;
|
||||
|
||||
/** Stream to output to, typically this is standard output. */
|
||||
protected PrintWriter out;
|
||||
|
||||
/** Git repository the command was invoked within. */
|
||||
protected Repository db;
|
||||
|
||||
/** Directory supplied via --git-dir command line option. */
|
||||
protected File gitdir;
|
||||
|
||||
/** RevWalk used during command line parsing, if it was required. */
|
||||
protected RevWalk argWalk;
|
||||
|
||||
final void setCommandName(final String name) {
|
||||
commandName = name;
|
||||
}
|
||||
|
||||
/** @return true if {@link #db}/{@link #getRepository()} is required. */
|
||||
protected boolean requiresRepository() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void init(final Repository repo, final File gd) {
|
||||
try {
|
||||
final String outputEncoding = repo != null ? repo.getConfig()
|
||||
.getString("i18n", null, "logOutputEncoding") : null;
|
||||
if (outputEncoding != null)
|
||||
out = new PrintWriter(new BufferedWriter(
|
||||
new OutputStreamWriter(System.out, outputEncoding)));
|
||||
else
|
||||
out = new PrintWriter(new BufferedWriter(
|
||||
new OutputStreamWriter(System.out)));
|
||||
} catch (IOException e) {
|
||||
throw die("cannot create output stream");
|
||||
}
|
||||
|
||||
if (repo != null) {
|
||||
db = repo;
|
||||
gitdir = repo.getDirectory();
|
||||
} else {
|
||||
db = null;
|
||||
gitdir = gd;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse arguments and run this command.
|
||||
*
|
||||
* @param args
|
||||
* command line arguments passed after the command name.
|
||||
* @throws Exception
|
||||
* an error occurred while processing the command. The main
|
||||
* framework will catch the exception and print a message on
|
||||
* standard error.
|
||||
*/
|
||||
public final void execute(String[] args) throws Exception {
|
||||
parseArguments(args);
|
||||
run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the command line arguments prior to running.
|
||||
* <p>
|
||||
* This method should only be invoked by {@link #execute(String[])}, prior
|
||||
* to calling {@link #run()}. The default implementation parses all
|
||||
* arguments into this object's instance fields.
|
||||
*
|
||||
* @param args
|
||||
* the arguments supplied on the command line, if any.
|
||||
*/
|
||||
protected void parseArguments(final String[] args) {
|
||||
final CmdLineParser clp = new CmdLineParser(this);
|
||||
try {
|
||||
clp.parseArgument(args);
|
||||
} catch (CmdLineException err) {
|
||||
if (!help) {
|
||||
System.err.println("fatal: " + err.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (help) {
|
||||
printUsageAndExit(clp);
|
||||
}
|
||||
|
||||
argWalk = clp.getRevWalkGently();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the usage line
|
||||
*
|
||||
* @param clp
|
||||
*/
|
||||
public void printUsageAndExit(final CmdLineParser clp) {
|
||||
printUsageAndExit("", clp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an error message and the usage line
|
||||
*
|
||||
* @param message
|
||||
* @param clp
|
||||
*/
|
||||
public void printUsageAndExit(final String message, final CmdLineParser clp) {
|
||||
System.err.println(message);
|
||||
System.err.print("jgit ");
|
||||
System.err.print(commandName);
|
||||
clp.printSingleLineUsage(System.err);
|
||||
System.err.println();
|
||||
|
||||
System.err.println();
|
||||
clp.printUsage(System.err);
|
||||
System.err.println();
|
||||
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the actions of this command.
|
||||
* <p>
|
||||
* This method should only be invoked by {@link #execute(String[])}.
|
||||
*
|
||||
* @throws Exception
|
||||
* an error occurred while processing the command. The main
|
||||
* framework will catch the exception and print a message on
|
||||
* standard error.
|
||||
*/
|
||||
protected abstract void run() throws Exception;
|
||||
|
||||
/**
|
||||
* @return the repository this command accesses.
|
||||
*/
|
||||
public Repository getRepository() {
|
||||
return db;
|
||||
}
|
||||
|
||||
ObjectId resolve(final String s) throws IOException {
|
||||
final ObjectId r = db.resolve(s);
|
||||
if (r == null)
|
||||
throw die("Not a revision: " + s);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param why
|
||||
* textual explanation
|
||||
* @return a runtime exception the caller is expected to throw
|
||||
*/
|
||||
protected static Die die(final String why) {
|
||||
return new Die(why);
|
||||
}
|
||||
|
||||
String abbreviateRef(String dst, boolean abbreviateRemote) {
|
||||
if (dst.startsWith(R_HEADS))
|
||||
dst = dst.substring(R_HEADS.length());
|
||||
else if (dst.startsWith(R_TAGS))
|
||||
dst = dst.substring(R_TAGS.length());
|
||||
else if (abbreviateRemote && dst.startsWith(R_REMOTES))
|
||||
dst = dst.substring(R_REMOTES.length());
|
||||
return dst;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (C) 2008-2009, Google Inc.
|
||||
* Copyright (C) 2009, Robin Rosenberg <robin.rosenberg@dewire.com>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
|
||||
@Command(common = false, usage = "Server side backend for 'jgit fetch'")
|
||||
class UploadPack extends TextBuiltin {
|
||||
@Option(name = "--timeout", metaVar = "SECONDS", usage = "abort connection if no activity")
|
||||
int timeout = -1;
|
||||
|
||||
@Argument(index = 0, required = true, metaVar = "DIRECTORY", usage = "Repository to read from")
|
||||
File srcGitdir;
|
||||
|
||||
@Override
|
||||
protected final boolean requiresRepository() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
final org.eclipse.jgit.transport.UploadPack rp;
|
||||
|
||||
if (new File(srcGitdir, ".git").isDirectory())
|
||||
srcGitdir = new File(srcGitdir, ".git");
|
||||
db = new Repository(srcGitdir);
|
||||
if (!db.getObjectsDirectory().isDirectory())
|
||||
throw die("'" + srcGitdir.getPath() + "' not a git repository");
|
||||
rp = new org.eclipse.jgit.transport.UploadPack(db);
|
||||
if (0 <= timeout)
|
||||
rp.setTimeout(timeout);
|
||||
rp.upload(System.in, System.out, System.err);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Google Inc.
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
@Command(common = true, usage = "Display the version of jgit")
|
||||
class Version extends TextBuiltin {
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
final Package pkg = getClass().getPackage();
|
||||
if (pkg == null || pkg.getImplementationVersion() == null)
|
||||
throw die("Cannot read package information.");
|
||||
|
||||
out.print("jgit version ");
|
||||
out.print(pkg.getImplementationVersion());
|
||||
out.println();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,212 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm.build;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.kohsuke.args4j.spi.MapOptionHandler;
|
||||
|
||||
/**
|
||||
* Combines multiple JAR and directory sources into a single JAR file.
|
||||
* <p>
|
||||
* This is a crude command line utility to combine multiple JAR files into a
|
||||
* single JAR file, without first needing to unpack the individual JARs.
|
||||
* <p>
|
||||
* The output ZIP stream is sent to standard out and can be redirected onto the
|
||||
* end of a shell script which starts the JRE.
|
||||
*/
|
||||
public class JarLinkUtil {
|
||||
/**
|
||||
* Combine multiple JARs.
|
||||
*
|
||||
* @param argv
|
||||
* the command line arguments indicating the files to pack.
|
||||
* @throws IOException
|
||||
* a source file could not be read.
|
||||
*/
|
||||
public static void main(final String[] argv) throws IOException {
|
||||
final JarLinkUtil util = new JarLinkUtil();
|
||||
final CmdLineParser clp = new CmdLineParser(util);
|
||||
try {
|
||||
clp.parseArgument(argv);
|
||||
} catch (CmdLineException e) {
|
||||
clp.printSingleLineUsage(System.err);
|
||||
System.exit(1);
|
||||
}
|
||||
util.run();
|
||||
}
|
||||
|
||||
@Option(name = "-include", required = true)
|
||||
private List<File> includes = new ArrayList<File>();
|
||||
|
||||
@Option(name = "-file", handler = MapOptionHandler.class)
|
||||
private Map<String, String> files = new HashMap<String, String>();
|
||||
|
||||
private final Map<String, File> chosenSources = new HashMap<String, File>();
|
||||
|
||||
private long creationTime;
|
||||
|
||||
private ZipOutputStream zos;
|
||||
|
||||
private JarLinkUtil() {
|
||||
// Command line utility only.
|
||||
}
|
||||
|
||||
private void run() throws IOException {
|
||||
for (final File src : includes) {
|
||||
if (src.isFile())
|
||||
scanJar(src);
|
||||
else
|
||||
scanDirectory(src, src, "");
|
||||
}
|
||||
for (final Map.Entry<String, String> e : files.entrySet())
|
||||
chosenSources.put(e.getKey(), new File(e.getValue()));
|
||||
|
||||
creationTime = System.currentTimeMillis();
|
||||
zos = new ZipOutputStream(System.out);
|
||||
zos.setLevel(9);
|
||||
|
||||
for (final File src : includes) {
|
||||
if (src.isFile())
|
||||
appendJar(src);
|
||||
else
|
||||
appendDirectory(src, src, "");
|
||||
}
|
||||
for (final String name : files.keySet())
|
||||
appendFile(chosenSources.get(name), name);
|
||||
|
||||
zos.close();
|
||||
}
|
||||
|
||||
private void scanJar(final File jarPath) throws IOException {
|
||||
final ZipFile zf = new ZipFile(jarPath);
|
||||
final Enumeration<? extends ZipEntry> e = zf.entries();
|
||||
while (e.hasMoreElements())
|
||||
chosenSources.put(e.nextElement().getName(), jarPath);
|
||||
zf.close();
|
||||
}
|
||||
|
||||
private void scanDirectory(final File rootPath, final File dirPath,
|
||||
final String pfx) throws IOException {
|
||||
final File[] entries = dirPath.listFiles();
|
||||
if (entries == null)
|
||||
return;
|
||||
for (final File e : entries) {
|
||||
if (e.getName().equals(".") || e.getName().equals(".."))
|
||||
continue;
|
||||
|
||||
if (e.isDirectory())
|
||||
scanDirectory(rootPath, e, pfx + e.getName() + "/");
|
||||
else
|
||||
chosenSources.put(pfx + e.getName(), rootPath);
|
||||
}
|
||||
}
|
||||
|
||||
private void appendJar(final File jarPath) throws IOException {
|
||||
final ZipFile zf = new ZipFile(jarPath);
|
||||
final Enumeration<? extends ZipEntry> e = zf.entries();
|
||||
while (e.hasMoreElements()) {
|
||||
final ZipEntry ze = e.nextElement();
|
||||
final String name = ze.getName();
|
||||
if (chosenSources.get(name) == jarPath)
|
||||
appendEntry(name, ze.getSize(), ze.getTime(), zf
|
||||
.getInputStream(ze));
|
||||
}
|
||||
zf.close();
|
||||
}
|
||||
|
||||
private void appendDirectory(final File rootDir, final File dirPath,
|
||||
final String pfx) throws IOException {
|
||||
final File[] entries = dirPath.listFiles();
|
||||
if (entries == null)
|
||||
return;
|
||||
for (final File e : entries) {
|
||||
if (e.getName().equals(".") || e.getName().equals(".."))
|
||||
continue;
|
||||
|
||||
if (e.isDirectory())
|
||||
appendDirectory(rootDir, e, pfx + e.getName() + "/");
|
||||
else if (chosenSources.get(pfx + e.getName()) == rootDir)
|
||||
appendFile(e, pfx + e.getName());
|
||||
}
|
||||
}
|
||||
|
||||
private void appendFile(final File path, final String name)
|
||||
throws IOException {
|
||||
final long len = path.length();
|
||||
final InputStream is = new FileInputStream(path);
|
||||
appendEntry(name, len, creationTime, is);
|
||||
}
|
||||
|
||||
private void appendEntry(final String name, final long len,
|
||||
final long time, final InputStream is) throws IOException {
|
||||
final ZipEntry ze = new ZipEntry(name);
|
||||
ze.setSize(len);
|
||||
ze.setTime(time);
|
||||
zos.putNextEntry(ze);
|
||||
try {
|
||||
final byte[] buf = new byte[4096];
|
||||
int n;
|
||||
while ((n = is.read(buf)) >= 0)
|
||||
zos.write(buf, 0, n);
|
||||
} finally {
|
||||
is.close();
|
||||
}
|
||||
zos.closeEntry();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Google Inc.
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm.debug;
|
||||
|
||||
import org.eclipse.jgit.dircache.DirCache;
|
||||
import org.eclipse.jgit.dircache.DirCacheTree;
|
||||
import org.eclipse.jgit.pgm.TextBuiltin;
|
||||
|
||||
class MakeCacheTree extends TextBuiltin {
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
final DirCache cache = DirCache.read(db);
|
||||
final DirCacheTree tree = cache.getCacheTree(true);
|
||||
show(tree);
|
||||
}
|
||||
|
||||
private void show(final DirCacheTree tree) {
|
||||
out.print("\"");
|
||||
out.print(tree.getPathString());
|
||||
out.print("\"");
|
||||
out.print(": ");
|
||||
out.print(tree.getEntrySpan());
|
||||
out.print(" entries");
|
||||
out.print(", ");
|
||||
out.print(tree.getChildCount());
|
||||
out.print(" children");
|
||||
out.println();
|
||||
|
||||
for (int i = 0; i < tree.getChildCount(); i++)
|
||||
show(tree.getChild(i));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Google Inc.
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm.debug;
|
||||
|
||||
import org.eclipse.jgit.dircache.DirCache;
|
||||
import org.eclipse.jgit.pgm.TextBuiltin;
|
||||
|
||||
class ReadDirCache extends TextBuiltin {
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
final int cnt = 100;
|
||||
final long start = System.currentTimeMillis();
|
||||
for (int i = 0; i < cnt; i++)
|
||||
DirCache.read(db);
|
||||
final long end = System.currentTimeMillis();
|
||||
out.println(" average " + ((end - start) / cnt) + " ms/read");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,313 @@
|
|||
/*
|
||||
* Copyright (C) 2009, Google Inc.
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm.debug;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
import org.eclipse.jgit.errors.ObjectWritingException;
|
||||
import org.eclipse.jgit.lib.Commit;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.LockFile;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.ObjectWriter;
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
import org.eclipse.jgit.lib.ProgressMonitor;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.RefUpdate;
|
||||
import org.eclipse.jgit.lib.RefWriter;
|
||||
import org.eclipse.jgit.lib.TextProgressMonitor;
|
||||
import org.eclipse.jgit.lib.Tree;
|
||||
import org.eclipse.jgit.pgm.TextBuiltin;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
|
||||
/**
|
||||
* Recreates a repository from another one's commit graph.
|
||||
* <p>
|
||||
* <b>Do not run this on a repository unless you want to destroy it.</b>
|
||||
* <p>
|
||||
* To create the input files, in the source repository use:
|
||||
*
|
||||
* <pre>
|
||||
* git for-each-ref >in.refs
|
||||
* git log --all '--pretty=format:%H %ct %P' >in.dag
|
||||
* </pre>
|
||||
* <p>
|
||||
* Run the rebuild in either an empty repository, or a clone of the source. Any
|
||||
* missing commits (which might be the entire graph) will be created. All refs
|
||||
* will be modified to match the input exactly, which means some refs may be
|
||||
* deleted from the current repository.
|
||||
* <p>
|
||||
*/
|
||||
class RebuildCommitGraph extends TextBuiltin {
|
||||
private final String REALLY = "--destroy-this-repository";
|
||||
|
||||
@Option(name = REALLY, usage = "approve destruction of repository")
|
||||
boolean really;
|
||||
|
||||
@Argument(index = 0, required = true, metaVar = "REFS", usage = "for-each-ref output")
|
||||
File refList;
|
||||
|
||||
@Argument(index = 1, required = true, metaVar = "DAG", usage = "log --all '--pretty=format:%H %ct %P' output")
|
||||
File graph;
|
||||
|
||||
private final ProgressMonitor pm = new TextProgressMonitor();
|
||||
|
||||
private Map<ObjectId, ObjectId> rewrites = new HashMap<ObjectId, ObjectId>();
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
if (!really && !db.getAllRefs().isEmpty()) {
|
||||
final StringBuilder m = new StringBuilder();
|
||||
m.append("fatal: ");
|
||||
m.append("This program will destroy the repository:");
|
||||
m.append("\n");
|
||||
m.append("fatal:\n");
|
||||
m.append("fatal: ");
|
||||
m.append(db.getDirectory().getAbsolutePath());
|
||||
m.append("\n");
|
||||
m.append("fatal:\n");
|
||||
m.append("fatal: ");
|
||||
m.append("To continue, add ");
|
||||
m.append(REALLY);
|
||||
m.append(" to the command line");
|
||||
m.append("\n");
|
||||
m.append("fatal:");
|
||||
System.err.println(m);
|
||||
throw die("Need approval to destroy current repository");
|
||||
}
|
||||
if (!refList.isFile())
|
||||
throw die("no such file: " + refList.getPath());
|
||||
if (!graph.isFile())
|
||||
throw die("no such file: " + graph.getPath());
|
||||
|
||||
recreateCommitGraph();
|
||||
detachHead();
|
||||
deleteAllRefs();
|
||||
recreateRefs();
|
||||
}
|
||||
|
||||
private void recreateCommitGraph() throws IOException {
|
||||
final RevWalk rw = new RevWalk(db);
|
||||
final Map<ObjectId, ToRewrite> toRewrite = new HashMap<ObjectId, ToRewrite>();
|
||||
List<ToRewrite> queue = new ArrayList<ToRewrite>();
|
||||
final BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(graph), Constants.CHARSET));
|
||||
try {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
final String[] parts = line.split("[ \t]{1,}");
|
||||
final ObjectId oldId = ObjectId.fromString(parts[0]);
|
||||
try {
|
||||
rw.parseCommit(oldId);
|
||||
// We have it already. Don't rewrite it.
|
||||
continue;
|
||||
} catch (MissingObjectException mue) {
|
||||
// Fall through and rewrite it.
|
||||
}
|
||||
|
||||
final long time = Long.parseLong(parts[1]) * 1000L;
|
||||
final ObjectId[] parents = new ObjectId[parts.length - 2];
|
||||
for (int i = 0; i < parents.length; i++) {
|
||||
parents[i] = ObjectId.fromString(parts[2 + i]);
|
||||
}
|
||||
|
||||
final ToRewrite t = new ToRewrite(oldId, time, parents);
|
||||
toRewrite.put(oldId, t);
|
||||
queue.add(t);
|
||||
}
|
||||
} finally {
|
||||
br.close();
|
||||
}
|
||||
|
||||
pm.beginTask("Rewriting commits", queue.size());
|
||||
final ObjectWriter ow = new ObjectWriter(db);
|
||||
final ObjectId emptyTree = ow.writeTree(new Tree(db));
|
||||
final PersonIdent me = new PersonIdent("jgit rebuild-commitgraph",
|
||||
"rebuild-commitgraph@localhost");
|
||||
while (!queue.isEmpty()) {
|
||||
final ListIterator<ToRewrite> itr = queue
|
||||
.listIterator(queue.size());
|
||||
queue = new ArrayList<ToRewrite>();
|
||||
REWRITE: while (itr.hasPrevious()) {
|
||||
final ToRewrite t = itr.previous();
|
||||
final ObjectId[] newParents = new ObjectId[t.oldParents.length];
|
||||
for (int k = 0; k < t.oldParents.length; k++) {
|
||||
final ToRewrite p = toRewrite.get(t.oldParents[k]);
|
||||
if (p != null) {
|
||||
if (p.newId == null) {
|
||||
// Must defer until after the parent is rewritten.
|
||||
queue.add(t);
|
||||
continue REWRITE;
|
||||
} else {
|
||||
newParents[k] = p.newId;
|
||||
}
|
||||
} else {
|
||||
// We have the old parent object. Use it.
|
||||
//
|
||||
newParents[k] = t.oldParents[k];
|
||||
}
|
||||
}
|
||||
|
||||
final Commit newc = new Commit(db);
|
||||
newc.setTreeId(emptyTree);
|
||||
newc.setAuthor(new PersonIdent(me, new Date(t.commitTime)));
|
||||
newc.setCommitter(newc.getAuthor());
|
||||
newc.setParentIds(newParents);
|
||||
newc.setMessage("ORIGINAL " + t.oldId.name() + "\n");
|
||||
t.newId = ow.writeCommit(newc);
|
||||
rewrites.put(t.oldId, t.newId);
|
||||
pm.update(1);
|
||||
}
|
||||
}
|
||||
pm.endTask();
|
||||
}
|
||||
|
||||
private static class ToRewrite {
|
||||
final ObjectId oldId;
|
||||
|
||||
final long commitTime;
|
||||
|
||||
final ObjectId[] oldParents;
|
||||
|
||||
ObjectId newId;
|
||||
|
||||
ToRewrite(final ObjectId o, final long t, final ObjectId[] p) {
|
||||
oldId = o;
|
||||
commitTime = t;
|
||||
oldParents = p;
|
||||
}
|
||||
}
|
||||
|
||||
private void detachHead() throws IOException {
|
||||
final String head = db.getFullBranch();
|
||||
final ObjectId id = db.resolve(Constants.HEAD);
|
||||
if (!ObjectId.isId(head) && id != null) {
|
||||
final LockFile lf;
|
||||
lf = new LockFile(new File(db.getDirectory(), Constants.HEAD));
|
||||
if (!lf.lock())
|
||||
throw new IOException("Cannot lock HEAD");
|
||||
lf.write(id);
|
||||
if (!lf.commit())
|
||||
throw new IOException("Cannot deatch HEAD");
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteAllRefs() throws Exception {
|
||||
final RevWalk rw = new RevWalk(db);
|
||||
for (final Ref r : db.getAllRefs().values()) {
|
||||
if (Constants.HEAD.equals(r.getName()))
|
||||
continue;
|
||||
final RefUpdate u = db.updateRef(r.getName());
|
||||
u.setForceUpdate(true);
|
||||
u.delete(rw);
|
||||
}
|
||||
}
|
||||
|
||||
private void recreateRefs() throws Exception {
|
||||
final Map<String, Ref> refs = computeNewRefs();
|
||||
new RefWriter(refs.values()) {
|
||||
@Override
|
||||
protected void writeFile(final String name, final byte[] content)
|
||||
throws IOException {
|
||||
final File file = new File(db.getDirectory(), name);
|
||||
final LockFile lck = new LockFile(file);
|
||||
if (!lck.lock())
|
||||
throw new ObjectWritingException("Can't write " + file);
|
||||
try {
|
||||
lck.write(content);
|
||||
} catch (IOException ioe) {
|
||||
throw new ObjectWritingException("Can't write " + file);
|
||||
}
|
||||
if (!lck.commit())
|
||||
throw new ObjectWritingException("Can't write " + file);
|
||||
}
|
||||
}.writePackedRefs();
|
||||
}
|
||||
|
||||
private Map<String, Ref> computeNewRefs() throws IOException {
|
||||
final RevWalk rw = new RevWalk(db);
|
||||
final Map<String, Ref> refs = new HashMap<String, Ref>();
|
||||
final BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(refList), Constants.CHARSET));
|
||||
try {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
final String[] parts = line.split("[ \t]{1,}");
|
||||
final ObjectId origId = ObjectId.fromString(parts[0]);
|
||||
final String type = parts[1];
|
||||
final String name = parts[2];
|
||||
|
||||
ObjectId id = rewrites.get(origId);
|
||||
if (id == null)
|
||||
id = origId;
|
||||
try {
|
||||
rw.parseAny(id);
|
||||
} catch (MissingObjectException mue) {
|
||||
if (!Constants.TYPE_COMMIT.equals(type)) {
|
||||
System.err.println("skipping " + type + " " + name);
|
||||
continue;
|
||||
}
|
||||
throw new MissingObjectException(id, type);
|
||||
}
|
||||
refs.put(name, new Ref(Ref.Storage.PACKED, name, id));
|
||||
}
|
||||
} finally {
|
||||
br.close();
|
||||
}
|
||||
return refs;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Google Inc.
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm.debug;
|
||||
|
||||
import org.eclipse.jgit.dircache.DirCache;
|
||||
import org.eclipse.jgit.dircache.DirCacheTree;
|
||||
import org.eclipse.jgit.pgm.TextBuiltin;
|
||||
|
||||
class ShowCacheTree extends TextBuiltin {
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
final DirCache cache = DirCache.read(db);
|
||||
final DirCacheTree tree = cache.getCacheTree(false);
|
||||
if (tree == null)
|
||||
throw die("no 'TREE' section in index");
|
||||
show(tree);
|
||||
}
|
||||
|
||||
private void show(final DirCacheTree tree) {
|
||||
out.print("\"");
|
||||
out.print(tree.getPathString());
|
||||
out.print("\"");
|
||||
out.print(": ");
|
||||
out.print(tree.getEntrySpan());
|
||||
out.print(" entries");
|
||||
out.print(", ");
|
||||
out.print(tree.getChildCount());
|
||||
out.print(" children");
|
||||
out.println();
|
||||
|
||||
for (int i = 0; i < tree.getChildCount(); i++)
|
||||
show(tree.getChild(i));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm.debug;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.pgm.Command;
|
||||
import org.eclipse.jgit.pgm.CommandCatalog;
|
||||
import org.eclipse.jgit.pgm.CommandRef;
|
||||
import org.eclipse.jgit.pgm.TextBuiltin;
|
||||
|
||||
@Command(usage = "Display a list of all registered jgit commands")
|
||||
class ShowCommands extends TextBuiltin {
|
||||
@Option(name = "--pretty", usage = "alter the detail shown")
|
||||
private Format pretty = Format.USAGE;
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
final CommandRef[] list = CommandCatalog.all();
|
||||
|
||||
int width = 0;
|
||||
for (final CommandRef c : list)
|
||||
width = Math.max(width, c.getName().length());
|
||||
width += 2;
|
||||
|
||||
for (final CommandRef c : list) {
|
||||
System.err.print(c.isCommon() ? '*' : ' ');
|
||||
System.err.print(' ');
|
||||
|
||||
System.err.print(c.getName());
|
||||
for (int i = c.getName().length(); i < width; i++)
|
||||
System.err.print(' ');
|
||||
|
||||
pretty.print(c);
|
||||
System.err.println();
|
||||
}
|
||||
System.err.println();
|
||||
}
|
||||
|
||||
static enum Format {
|
||||
/** */
|
||||
USAGE {
|
||||
void print(final CommandRef c) {
|
||||
System.err.print(c.getUsage());
|
||||
}
|
||||
},
|
||||
|
||||
/** */
|
||||
CLASSES {
|
||||
void print(final CommandRef c) {
|
||||
System.err.print(c.getImplementationClassName());
|
||||
}
|
||||
},
|
||||
|
||||
/** */
|
||||
URLS {
|
||||
void print(final CommandRef c) {
|
||||
final ClassLoader ldr = c.getImplementationClassLoader();
|
||||
|
||||
String cn = c.getImplementationClassName();
|
||||
cn = cn.replace('.', '/') + ".class";
|
||||
|
||||
final URL url = ldr.getResource(cn);
|
||||
if (url == null) {
|
||||
System.err.print("!! NOT FOUND !!");
|
||||
return;
|
||||
}
|
||||
|
||||
String rn = url.toExternalForm();
|
||||
if (rn.endsWith(cn))
|
||||
rn = rn.substring(0, rn.length() - cn.length());
|
||||
|
||||
System.err.print(rn);
|
||||
}
|
||||
};
|
||||
|
||||
abstract void print(CommandRef c);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Google Inc.
|
||||
* Copyright (C) 2008, Jonas Fonseca <fonseca@diku.dk>
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm.debug;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.eclipse.jgit.dircache.DirCache;
|
||||
import org.eclipse.jgit.dircache.DirCacheEntry;
|
||||
import org.eclipse.jgit.lib.FileMode;
|
||||
import org.eclipse.jgit.pgm.TextBuiltin;
|
||||
|
||||
class ShowDirCache extends TextBuiltin {
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
final SimpleDateFormat fmt;
|
||||
fmt = new SimpleDateFormat("yyyyMMdd,HHmmss.SSS");
|
||||
|
||||
final DirCache cache = DirCache.read(db);
|
||||
for (int i = 0; i < cache.getEntryCount(); i++) {
|
||||
final DirCacheEntry ent = cache.getEntry(i);
|
||||
final FileMode mode = FileMode.fromBits(ent.getRawMode());
|
||||
final int len = ent.getLength();
|
||||
final Date mtime = new Date(ent.getLastModified());
|
||||
|
||||
out.print(mode);
|
||||
out.format(" %6d", len);
|
||||
out.print(' ');
|
||||
out.print(fmt.format(mtime));
|
||||
out.print(' ');
|
||||
out.print(ent.getObjectId().name());
|
||||
out.print('\t');
|
||||
out.print(ent.getPathString());
|
||||
out.println();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Google Inc.
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm.debug;
|
||||
|
||||
import org.eclipse.jgit.dircache.DirCache;
|
||||
import org.eclipse.jgit.pgm.TextBuiltin;
|
||||
|
||||
class WriteDirCache extends TextBuiltin {
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
final DirCache cache = DirCache.read(db);
|
||||
if (!cache.lock())
|
||||
throw die("failed to lock index");
|
||||
cache.read();
|
||||
cache.write();
|
||||
if (!cache.commit())
|
||||
throw die("failed to commit index");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* Copyright (C) 2008-2009, Google Inc.
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm.opt;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.OptionDef;
|
||||
import org.kohsuke.args4j.spi.OptionHandler;
|
||||
import org.kohsuke.args4j.spi.Parameters;
|
||||
import org.kohsuke.args4j.spi.Setter;
|
||||
import org.eclipse.jgit.dircache.DirCache;
|
||||
import org.eclipse.jgit.dircache.DirCacheIterator;
|
||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.WindowCursor;
|
||||
import org.eclipse.jgit.treewalk.AbstractTreeIterator;
|
||||
import org.eclipse.jgit.treewalk.CanonicalTreeParser;
|
||||
import org.eclipse.jgit.treewalk.FileTreeIterator;
|
||||
|
||||
/**
|
||||
* Custom argument handler {@link AbstractTreeIterator} from string values.
|
||||
* <p>
|
||||
* Assumes the parser has been initialized with a Repository.
|
||||
*/
|
||||
public class AbstractTreeIteratorHandler extends
|
||||
OptionHandler<AbstractTreeIterator> {
|
||||
private final org.eclipse.jgit.pgm.opt.CmdLineParser clp;
|
||||
|
||||
/**
|
||||
* Create a new handler for the command name.
|
||||
* <p>
|
||||
* This constructor is used only by args4j.
|
||||
*
|
||||
* @param parser
|
||||
* @param option
|
||||
* @param setter
|
||||
*/
|
||||
public AbstractTreeIteratorHandler(final CmdLineParser parser,
|
||||
final OptionDef option,
|
||||
final Setter<? super AbstractTreeIterator> setter) {
|
||||
super(parser, option, setter);
|
||||
clp = (org.eclipse.jgit.pgm.opt.CmdLineParser) parser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int parseArguments(final Parameters params) throws CmdLineException {
|
||||
final String name = params.getParameter(0);
|
||||
|
||||
if (new File(name).isDirectory()) {
|
||||
setter.addValue(new FileTreeIterator(new File(name)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (new File(name).isFile()) {
|
||||
final DirCache dirc;
|
||||
try {
|
||||
dirc = DirCache.read(new File(name));
|
||||
} catch (IOException e) {
|
||||
throw new CmdLineException(name + " is not an index file", e);
|
||||
}
|
||||
setter.addValue(new DirCacheIterator(dirc));
|
||||
return 1;
|
||||
}
|
||||
|
||||
final ObjectId id;
|
||||
try {
|
||||
id = clp.getRepository().resolve(name);
|
||||
} catch (IOException e) {
|
||||
throw new CmdLineException(e.getMessage());
|
||||
}
|
||||
if (id == null)
|
||||
throw new CmdLineException(name + " is not a tree");
|
||||
|
||||
final CanonicalTreeParser p = new CanonicalTreeParser();
|
||||
final WindowCursor curs = new WindowCursor();
|
||||
try {
|
||||
p.reset(clp.getRepository(), clp.getRevWalk().parseTree(id), curs);
|
||||
} catch (MissingObjectException e) {
|
||||
throw new CmdLineException(name + " is not a tree");
|
||||
} catch (IncorrectObjectTypeException e) {
|
||||
throw new CmdLineException(name + " is not a tree");
|
||||
} catch (IOException e) {
|
||||
throw new CmdLineException("cannot read " + name + ": "
|
||||
+ e.getMessage());
|
||||
} finally {
|
||||
curs.release();
|
||||
}
|
||||
|
||||
setter.addValue(p);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultMetaVariable() {
|
||||
return "tree-ish";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm.opt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.IllegalAnnotationError;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.pgm.TextBuiltin;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevTree;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.eclipse.jgit.transport.RefSpec;
|
||||
import org.eclipse.jgit.treewalk.AbstractTreeIterator;
|
||||
|
||||
/**
|
||||
* Extended command line parser which handles --foo=value arguments.
|
||||
* <p>
|
||||
* The args4j package does not natively handle --foo=value and instead prefers
|
||||
* to see --foo value on the command line. Many users are used to the GNU style
|
||||
* --foo=value long option, so we convert from the GNU style format to the
|
||||
* args4j style format prior to invoking args4j for parsing.
|
||||
*/
|
||||
public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser {
|
||||
static {
|
||||
registerHandler(AbstractTreeIterator.class,
|
||||
AbstractTreeIteratorHandler.class);
|
||||
registerHandler(ObjectId.class, ObjectIdHandler.class);
|
||||
registerHandler(RefSpec.class, RefSpecHandler.class);
|
||||
registerHandler(RevCommit.class, RevCommitHandler.class);
|
||||
registerHandler(RevTree.class, RevTreeHandler.class);
|
||||
}
|
||||
|
||||
private final Repository db;
|
||||
|
||||
private RevWalk walk;
|
||||
|
||||
/**
|
||||
* Creates a new command line owner that parses arguments/options and set
|
||||
* them into the given object.
|
||||
*
|
||||
* @param bean
|
||||
* instance of a class annotated by {@link Option} and
|
||||
* {@link Argument}. this object will receive values.
|
||||
*
|
||||
* @throws IllegalAnnotationError
|
||||
* if the option bean class is using args4j annotations
|
||||
* incorrectly.
|
||||
*/
|
||||
public CmdLineParser(final Object bean) {
|
||||
this(bean, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new command line owner that parses arguments/options and set
|
||||
* them into the given object.
|
||||
*
|
||||
* @param bean
|
||||
* instance of a class annotated by {@link Option} and
|
||||
* {@link Argument}. this object will receive values.
|
||||
* @param repo
|
||||
* repository this parser can translate options through.
|
||||
* @throws IllegalAnnotationError
|
||||
* if the option bean class is using args4j annotations
|
||||
* incorrectly.
|
||||
*/
|
||||
public CmdLineParser(final Object bean, Repository repo) {
|
||||
super(bean);
|
||||
if (repo == null && bean instanceof TextBuiltin)
|
||||
repo = ((TextBuiltin) bean).getRepository();
|
||||
this.db = repo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseArgument(final String... args) throws CmdLineException {
|
||||
final ArrayList<String> tmp = new ArrayList<String>(args.length);
|
||||
for (int argi = 0; argi < args.length; argi++) {
|
||||
final String str = args[argi];
|
||||
if (str.equals("--")) {
|
||||
while (argi < args.length)
|
||||
tmp.add(args[argi++]);
|
||||
break;
|
||||
}
|
||||
|
||||
if (str.startsWith("--")) {
|
||||
final int eq = str.indexOf('=');
|
||||
if (eq > 0) {
|
||||
tmp.add(str.substring(0, eq));
|
||||
tmp.add(str.substring(eq + 1));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
tmp.add(str);
|
||||
}
|
||||
|
||||
super.parseArgument(tmp.toArray(new String[tmp.size()]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the repository this parser translates values through.
|
||||
*
|
||||
* @return the repository, if specified during construction.
|
||||
*/
|
||||
public Repository getRepository() {
|
||||
if (db == null)
|
||||
throw new IllegalStateException("No Git repository configured.");
|
||||
return db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the revision walker used to support option parsing.
|
||||
*
|
||||
* @return the revision walk used by this option parser.
|
||||
*/
|
||||
public RevWalk getRevWalk() {
|
||||
if (walk == null)
|
||||
walk = new RevWalk(getRepository());
|
||||
return walk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the revision walker used to support option parsing.
|
||||
* <p>
|
||||
* This method does not initialize the RevWalk and may return null.
|
||||
*
|
||||
* @return the revision walk used by this option parser, or null.
|
||||
*/
|
||||
public RevWalk getRevWalkGently() {
|
||||
return walk;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Copyright (C) 2009, Google Inc.
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm.opt;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.OptionDef;
|
||||
import org.kohsuke.args4j.spi.OptionHandler;
|
||||
import org.kohsuke.args4j.spi.Parameters;
|
||||
import org.kohsuke.args4j.spi.Setter;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
|
||||
/**
|
||||
* Custom argument handler {@link ObjectId} from string values.
|
||||
* <p>
|
||||
* Assumes the parser has been initialized with a Repository.
|
||||
*/
|
||||
public class ObjectIdHandler extends OptionHandler<ObjectId> {
|
||||
private final org.eclipse.jgit.pgm.opt.CmdLineParser clp;
|
||||
|
||||
/**
|
||||
* Create a new handler for the command name.
|
||||
* <p>
|
||||
* This constructor is used only by args4j.
|
||||
*
|
||||
* @param parser
|
||||
* @param option
|
||||
* @param setter
|
||||
*/
|
||||
public ObjectIdHandler(final CmdLineParser parser, final OptionDef option,
|
||||
final Setter<? super ObjectId> setter) {
|
||||
super(parser, option, setter);
|
||||
clp = (org.eclipse.jgit.pgm.opt.CmdLineParser) parser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int parseArguments(final Parameters params) throws CmdLineException {
|
||||
final String name = params.getParameter(0);
|
||||
final ObjectId id;
|
||||
try {
|
||||
id = clp.getRepository().resolve(name);
|
||||
} catch (IOException e) {
|
||||
throw new CmdLineException(e.getMessage());
|
||||
}
|
||||
if (id != null) {
|
||||
setter.addValue(id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
throw new CmdLineException(name + " is not an object");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultMetaVariable() {
|
||||
return "object";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm.opt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.kohsuke.args4j.OptionDef;
|
||||
import org.kohsuke.args4j.spi.OptionHandler;
|
||||
import org.kohsuke.args4j.spi.Parameters;
|
||||
import org.kohsuke.args4j.spi.Setter;
|
||||
import org.eclipse.jgit.treewalk.filter.PathFilter;
|
||||
import org.eclipse.jgit.treewalk.filter.PathFilterGroup;
|
||||
import org.eclipse.jgit.treewalk.filter.TreeFilter;
|
||||
|
||||
/**
|
||||
* Create a {@link TreeFilter} to patch math names.
|
||||
* <p>
|
||||
* This handler consumes all arguments to the end of the command line, and is
|
||||
* meant to be used on an {@link Option} of name "--".
|
||||
*/
|
||||
public class PathTreeFilterHandler extends OptionHandler<TreeFilter> {
|
||||
/**
|
||||
* Create a new handler for the command name.
|
||||
* <p>
|
||||
* This constructor is used only by args4j.
|
||||
*
|
||||
* @param parser
|
||||
* @param option
|
||||
* @param setter
|
||||
*/
|
||||
public PathTreeFilterHandler(final CmdLineParser parser,
|
||||
final OptionDef option, final Setter<? super TreeFilter> setter) {
|
||||
super(parser, option, setter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int parseArguments(final Parameters params) throws CmdLineException {
|
||||
final List<PathFilter> filters = new ArrayList<PathFilter>();
|
||||
for (int idx = 0;; idx++) {
|
||||
final String path;
|
||||
try {
|
||||
path = params.getParameter(idx);
|
||||
} catch (CmdLineException cle) {
|
||||
break;
|
||||
}
|
||||
filters.add(PathFilter.create(path));
|
||||
}
|
||||
|
||||
if (filters.size() == 0)
|
||||
return 0;
|
||||
if (filters.size() == 1) {
|
||||
setter.addValue(filters.get(0));
|
||||
return 1;
|
||||
}
|
||||
setter.addValue(PathFilterGroup.create(filters));
|
||||
return filters.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultMetaVariable() {
|
||||
return "path ...";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm.opt;
|
||||
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.OptionDef;
|
||||
import org.kohsuke.args4j.spi.OptionHandler;
|
||||
import org.kohsuke.args4j.spi.Parameters;
|
||||
import org.kohsuke.args4j.spi.Setter;
|
||||
import org.eclipse.jgit.transport.RefSpec;
|
||||
|
||||
/**
|
||||
* Custom argument handler {@link RefSpec} from string values.
|
||||
* <p>
|
||||
* Assumes the parser has been initialized with a Repository.
|
||||
*/
|
||||
public class RefSpecHandler extends OptionHandler<RefSpec> {
|
||||
/**
|
||||
* Create a new handler for the command name.
|
||||
* <p>
|
||||
* This constructor is used only by args4j.
|
||||
*
|
||||
* @param parser
|
||||
* @param option
|
||||
* @param setter
|
||||
*/
|
||||
public RefSpecHandler(final CmdLineParser parser, final OptionDef option,
|
||||
final Setter<? super RefSpec> setter) {
|
||||
super(parser, option, setter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int parseArguments(final Parameters params) throws CmdLineException {
|
||||
setter.addValue(new RefSpec(params.getParameter(0)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultMetaVariable() {
|
||||
return "refspec";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Copyright (C) 2009, Google Inc.
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm.opt;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.OptionDef;
|
||||
import org.kohsuke.args4j.spi.OptionHandler;
|
||||
import org.kohsuke.args4j.spi.Parameters;
|
||||
import org.kohsuke.args4j.spi.Setter;
|
||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevFlag;
|
||||
|
||||
/**
|
||||
* Custom argument handler {@link RevCommit} from string values.
|
||||
* <p>
|
||||
* Assumes the parser has been initialized with a Repository.
|
||||
*/
|
||||
public class RevCommitHandler extends OptionHandler<RevCommit> {
|
||||
private final org.eclipse.jgit.pgm.opt.CmdLineParser clp;
|
||||
|
||||
/**
|
||||
* Create a new handler for the command name.
|
||||
* <p>
|
||||
* This constructor is used only by args4j.
|
||||
*
|
||||
* @param parser
|
||||
* @param option
|
||||
* @param setter
|
||||
*/
|
||||
public RevCommitHandler(final CmdLineParser parser, final OptionDef option,
|
||||
final Setter<? super RevCommit> setter) {
|
||||
super(parser, option, setter);
|
||||
clp = (org.eclipse.jgit.pgm.opt.CmdLineParser) parser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int parseArguments(final Parameters params) throws CmdLineException {
|
||||
String name = params.getParameter(0);
|
||||
|
||||
boolean interesting = true;
|
||||
if (name.startsWith("^")) {
|
||||
name = name.substring(1);
|
||||
interesting = false;
|
||||
}
|
||||
|
||||
final int dot2 = name.indexOf("..");
|
||||
if (dot2 != -1) {
|
||||
if (!option.isMultiValued())
|
||||
throw new CmdLineException("Only one " + option.metaVar()
|
||||
+ " expected in " + name + "." + "");
|
||||
|
||||
final String left = name.substring(0, dot2);
|
||||
final String right = name.substring(dot2 + 2);
|
||||
addOne(left, false);
|
||||
addOne(right, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
addOne(name, interesting);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private void addOne(final String name, final boolean interesting)
|
||||
throws CmdLineException {
|
||||
final ObjectId id;
|
||||
try {
|
||||
id = clp.getRepository().resolve(name);
|
||||
} catch (IOException e) {
|
||||
throw new CmdLineException(e.getMessage());
|
||||
}
|
||||
if (id == null)
|
||||
throw new CmdLineException(name + " is not a commit");
|
||||
|
||||
final RevCommit c;
|
||||
try {
|
||||
c = clp.getRevWalk().parseCommit(id);
|
||||
} catch (MissingObjectException e) {
|
||||
throw new CmdLineException(name + " is not a commit");
|
||||
} catch (IncorrectObjectTypeException e) {
|
||||
throw new CmdLineException(name + " is not a commit");
|
||||
} catch (IOException e) {
|
||||
throw new CmdLineException("cannot read " + name + ": "
|
||||
+ e.getMessage());
|
||||
}
|
||||
|
||||
if (interesting)
|
||||
c.remove(RevFlag.UNINTERESTING);
|
||||
else
|
||||
c.add(RevFlag.UNINTERESTING);
|
||||
|
||||
setter.addValue(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultMetaVariable() {
|
||||
return "commit-ish";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright (C) 2009, Google Inc.
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm.opt;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.OptionDef;
|
||||
import org.kohsuke.args4j.spi.OptionHandler;
|
||||
import org.kohsuke.args4j.spi.Parameters;
|
||||
import org.kohsuke.args4j.spi.Setter;
|
||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.revwalk.RevTree;
|
||||
|
||||
/**
|
||||
* Custom argument handler {@link RevTree} from string values.
|
||||
* <p>
|
||||
* Assumes the parser has been initialized with a Repository.
|
||||
*/
|
||||
public class RevTreeHandler extends OptionHandler<RevTree> {
|
||||
private final org.eclipse.jgit.pgm.opt.CmdLineParser clp;
|
||||
|
||||
/**
|
||||
* Create a new handler for the command name.
|
||||
* <p>
|
||||
* This constructor is used only by args4j.
|
||||
*
|
||||
* @param parser
|
||||
* @param option
|
||||
* @param setter
|
||||
*/
|
||||
public RevTreeHandler(final CmdLineParser parser, final OptionDef option,
|
||||
final Setter<? super RevTree> setter) {
|
||||
super(parser, option, setter);
|
||||
clp = (org.eclipse.jgit.pgm.opt.CmdLineParser) parser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int parseArguments(final Parameters params) throws CmdLineException {
|
||||
final String name = params.getParameter(0);
|
||||
final ObjectId id;
|
||||
try {
|
||||
id = clp.getRepository().resolve(name);
|
||||
} catch (IOException e) {
|
||||
throw new CmdLineException(e.getMessage());
|
||||
}
|
||||
if (id == null)
|
||||
throw new CmdLineException(name + " is not a tree");
|
||||
|
||||
final RevTree c;
|
||||
try {
|
||||
c = clp.getRevWalk().parseTree(id);
|
||||
} catch (MissingObjectException e) {
|
||||
throw new CmdLineException(name + " is not a tree");
|
||||
} catch (IncorrectObjectTypeException e) {
|
||||
throw new CmdLineException(name + " is not a tree");
|
||||
} catch (IOException e) {
|
||||
throw new CmdLineException("cannot read " + name + ": "
|
||||
+ e.getMessage());
|
||||
}
|
||||
setter.addValue(c);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultMetaVariable() {
|
||||
return "tree-ish";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.pgm.opt;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.OptionDef;
|
||||
import org.kohsuke.args4j.spi.OptionHandler;
|
||||
import org.kohsuke.args4j.spi.Parameters;
|
||||
import org.kohsuke.args4j.spi.Setter;
|
||||
import org.eclipse.jgit.pgm.CommandCatalog;
|
||||
import org.eclipse.jgit.pgm.CommandRef;
|
||||
import org.eclipse.jgit.pgm.TextBuiltin;
|
||||
|
||||
/**
|
||||
* Custom Argument handler for jgit command selection.
|
||||
* <p>
|
||||
* Translates a single argument string to a {@link TextBuiltin} instance which
|
||||
* we can execute at runtime with the remaining arguments of the parser.
|
||||
*/
|
||||
public class SubcommandHandler extends OptionHandler<TextBuiltin> {
|
||||
/**
|
||||
* Create a new handler for the command name.
|
||||
* <p>
|
||||
* This constructor is used only by args4j.
|
||||
*
|
||||
* @param parser
|
||||
* @param option
|
||||
* @param setter
|
||||
*/
|
||||
public SubcommandHandler(final CmdLineParser parser,
|
||||
final OptionDef option, final Setter<? super TextBuiltin> setter) {
|
||||
super(parser, option, setter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int parseArguments(final Parameters params) throws CmdLineException {
|
||||
final String name = params.getParameter(0);
|
||||
final CommandRef cr = CommandCatalog.get(name);
|
||||
if (cr == null)
|
||||
throw new CmdLineException(MessageFormat.format(
|
||||
"{0} is not a jgit command", name));
|
||||
|
||||
// Force option parsing to stop. Everything after us should
|
||||
// be arguments known only to this command and must not be
|
||||
// recognized by the current parser.
|
||||
//
|
||||
owner.stopOptionParsing();
|
||||
setter.addValue(cr.create());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultMetaVariable() {
|
||||
return "command";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry excluding="**/*.idx|**/*.pack" kind="src" path="tst"/>
|
||||
<classpathentry kind="src" path="tst-rsrc"/>
|
||||
<classpathentry kind="src" path="exttst"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.jgit"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/>
|
||||
<classpathentry kind="lib" path="/org.eclipse.jgit/lib/jsch-0.1.37.jar" sourcepath="/org.eclipse.jgit/lib/jsch-0.1.37.zip"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1,3 @@
|
|||
bin
|
||||
tst/todopack
|
||||
trash
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.eclipse.jgit.test</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,6 @@
|
|||
#Sat Dec 20 21:21:24 CET 2008
|
||||
eclipse.preferences.version=1
|
||||
encoding//tst-rsrc/org/eclipse/jgit/patch/testGetText_BothISO88591.patch=ISO-8859-1
|
||||
encoding//tst-rsrc/org/eclipse/jgit/patch/testGetText_Convert.patch=ISO-8859-1
|
||||
encoding//tst-rsrc/org/eclipse/jgit/patch/testGetText_DiffCc.patch=ISO-8859-1
|
||||
encoding/<project>=UTF-8
|
|
@ -0,0 +1,3 @@
|
|||
#Mon Mar 24 18:55:56 EDT 2008
|
||||
eclipse.preferences.version=1
|
||||
line.separator=\n
|
|
@ -0,0 +1,320 @@
|
|||
#Tue Feb 05 00:01:29 CET 2008
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
|
||||
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
|
||||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
|
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
|
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.nullReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
|
||||
org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
|
||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedImport=error
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLabel=error
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLocal=error
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_field=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_header=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_html=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_source_code=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.comment.line_length=80
|
||||
org.eclipse.jdt.core.formatter.compact_else_if=true
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation=2
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
|
||||
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_empty_lines=false
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
|
||||
org.eclipse.jdt.core.formatter.indentation.size=4
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.lineSplit=80
|
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
|
||||
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
|
||||
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
|
||||
org.eclipse.jdt.core.formatter.tabulation.char=tab
|
||||
org.eclipse.jdt.core.formatter.tabulation.size=4
|
||||
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
|
@ -0,0 +1,10 @@
|
|||
#Thu Dec 20 01:31:04 CET 2007
|
||||
eclipse.preferences.version=1
|
||||
formatter_profile=_JGit
|
||||
formatter_settings_version=10
|
||||
internal.default.compliance=default
|
||||
org.eclipse.jdt.ui.ignorelowercasenames=true
|
||||
org.eclipse.jdt.ui.importorder=java;javax;org;com;
|
||||
org.eclipse.jdt.ui.ondemandthreshold=99
|
||||
org.eclipse.jdt.ui.staticondemandthreshold=99
|
||||
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates/>
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Google Inc.
|
||||
* Copyright (C) 2007-2008, Robin Rosenberg <robin.rosenberg@dewire.com>
|
||||
* Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.lib;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Base class for performance unit test.
|
||||
*/
|
||||
public abstract class SpeedTestBase extends TestCase {
|
||||
|
||||
/**
|
||||
* The time used by native git as this is our reference.
|
||||
*/
|
||||
protected long nativeTime;
|
||||
|
||||
/**
|
||||
* Reference to the location of the Linux kernel repo.
|
||||
*/
|
||||
protected String kernelrepo;
|
||||
|
||||
/**
|
||||
* Prepare test by running a test against the Linux kernel repo first.
|
||||
*
|
||||
* @param refcmd
|
||||
* git command to execute
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected void prepare(String[] refcmd) throws Exception {
|
||||
try {
|
||||
BufferedReader bufferedReader = new BufferedReader(new FileReader("kernel.ref"));
|
||||
try {
|
||||
kernelrepo = bufferedReader.readLine();
|
||||
} finally {
|
||||
bufferedReader.close();
|
||||
}
|
||||
timeNativeGit(kernelrepo, refcmd);
|
||||
nativeTime = timeNativeGit(kernelrepo, refcmd);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Create a file named kernel.ref and put the path to the Linux kernels repository there");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private static long timeNativeGit(String kernelrepo, String[] refcmd) throws IOException,
|
||||
InterruptedException, Exception {
|
||||
long start = System.currentTimeMillis();
|
||||
Process p = Runtime.getRuntime().exec(refcmd, null, new File(kernelrepo,".."));
|
||||
InputStream inputStream = p.getInputStream();
|
||||
InputStream errorStream = p.getErrorStream();
|
||||
byte[] buf=new byte[1024*1024];
|
||||
for (;;)
|
||||
if (inputStream.read(buf) < 0)
|
||||
break;
|
||||
if (p.waitFor()!=0) {
|
||||
int c;
|
||||
while ((c=errorStream.read())!=-1)
|
||||
System.err.print((char)c);
|
||||
throw new Exception("git log failed");
|
||||
}
|
||||
inputStream.close();
|
||||
errorStream.close();
|
||||
long stop = System.currentTimeMillis();
|
||||
return stop - start;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2008, Robin Rosenberg <robin.rosenberg@dewire.com>
|
||||
* Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.lib;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.textui.TestRunner;
|
||||
|
||||
public class T0005_ShallowSpeedTest extends SpeedTestBase {
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
prepare(new String[] { "git", "rev-list", "365bbe0d0caaf2ba74d56556827babf0bc66965d" });
|
||||
}
|
||||
|
||||
public void testShallowHistoryScan() throws IOException {
|
||||
long start = System.currentTimeMillis();
|
||||
Repository db = new Repository(new File(kernelrepo));
|
||||
Commit commit = db.mapCommit("365bbe0d0caaf2ba74d56556827babf0bc66965d");
|
||||
int n = 1;
|
||||
for (;;) {
|
||||
ObjectId[] parents = commit.getParentIds();
|
||||
if (parents.length == 0)
|
||||
break;
|
||||
ObjectId parentId = parents[0];
|
||||
commit = db.mapCommit(parentId);
|
||||
commit.getCommitId().name();
|
||||
++n;
|
||||
}
|
||||
assertEquals(12275, n);
|
||||
long stop = System.currentTimeMillis();
|
||||
long time = stop - start;
|
||||
System.out.println("native="+nativeTime);
|
||||
System.out.println("jgit="+time);
|
||||
// ~0.750s (hot cache), ok
|
||||
/*
|
||||
native=1795
|
||||
jgit=722
|
||||
*/
|
||||
// native git seems to run SLOWER than jgit here, at roughly half the speed
|
||||
// creating the git process is not the issue here, btw.
|
||||
long factor10 = (nativeTime*150/time+50)/100;
|
||||
assertEquals(3, factor10);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestRunner.run(T0005_ShallowSpeedTest.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2008, Robin Rosenberg <robin.rosenberg@dewire.com>
|
||||
* Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.lib;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.textui.TestRunner;
|
||||
|
||||
public class T0006_DeepSpeedTest extends SpeedTestBase {
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
prepare(new String[] { "git", "rev-list", "365bbe0d0caaf2ba74d56556827babf0bc66965d","--","net/netfilter/nf_queue.c" });
|
||||
}
|
||||
|
||||
public void testDeepHistoryScan() throws IOException {
|
||||
long start = System.currentTimeMillis();
|
||||
Repository db = new Repository(new File(kernelrepo));
|
||||
Commit commit = db.mapCommit("365bbe0d0caaf2ba74d56556827babf0bc66965d");
|
||||
int n = 1;
|
||||
for (;;) {
|
||||
ObjectId[] parents = commit.getParentIds();
|
||||
if (parents.length == 0)
|
||||
break;
|
||||
ObjectId parentId = parents[0];
|
||||
commit = db.mapCommit(parentId);
|
||||
TreeEntry m = commit.getTree().findBlobMember("net/netfilter/nf_queue.c");
|
||||
if (m != null)
|
||||
commit.getCommitId().name();
|
||||
++n;
|
||||
}
|
||||
|
||||
assertEquals(12275, n);
|
||||
long stop = System.currentTimeMillis();
|
||||
long time = stop - start;
|
||||
System.out.println("native="+nativeTime);
|
||||
System.out.println("jgit="+time);
|
||||
/*
|
||||
native=1355
|
||||
jgit=5449
|
||||
*/
|
||||
// This is not an exact factor, but we'd expect native git to perform this
|
||||
// about 4 times quicker. If for some reason we find jgit to be faster than
|
||||
// this the cause should be found and secured.
|
||||
long factor = (time*110/nativeTime+50)/100;
|
||||
assertEquals(4, factor);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestRunner.run(T0006_DeepSpeedTest.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,227 @@
|
|||
/*
|
||||
* Copyright (C) 2008, Google Inc.
|
||||
* and other copyright owners as documented in the project's IP log.
|
||||
*
|
||||
* This program and the accompanying materials are made available
|
||||
* under the terms of the Eclipse Distribution License v1.0 which
|
||||
* accompanies this distribution, is reproduced below, and is
|
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package org.eclipse.jgit.patch;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.util.MutableInteger;
|
||||
import org.eclipse.jgit.util.RawParseUtils;
|
||||
import org.eclipse.jgit.util.TemporaryBuffer;
|
||||
|
||||
public class EGitPatchHistoryTest extends TestCase {
|
||||
public void testParseHistory() throws Exception {
|
||||
final NumStatReader numstat = new NumStatReader();
|
||||
numstat.read();
|
||||
|
||||
final HashMap<String, HashMap<String, StatInfo>> stats = numstat.stats;
|
||||
assertEquals(1211, stats.size());
|
||||
|
||||
new PatchReader(stats).read();
|
||||
}
|
||||
|
||||
static class StatInfo {
|
||||
int added, deleted;
|
||||
}
|
||||
|
||||
static class PatchReader extends CommitReader {
|
||||
final HashSet<String> offBy1;
|
||||
|
||||
final HashMap<String, HashMap<String, StatInfo>> stats;
|
||||
|
||||
int errors;
|
||||
|
||||
PatchReader(final HashMap<String, HashMap<String, StatInfo>> s)
|
||||
throws IOException {
|
||||
super(new String[] { "-p" });
|
||||
stats = s;
|
||||
|
||||
offBy1 = new HashSet<String>();
|
||||
offBy1.add("9bda5ece6806cd797416eaa47c7b927cc6e9c3b2");
|
||||
}
|
||||
|
||||
@Override
|
||||
void onCommit(String cid, byte[] buf) {
|
||||
final HashMap<String, StatInfo> files = stats.remove(cid);
|
||||
assertNotNull("No files for " + cid, files);
|
||||
|
||||
final Patch p = new Patch();
|
||||
p.parse(buf, 0, buf.length - 1);
|
||||
assertEquals("File count " + cid, files.size(), p.getFiles().size());
|
||||
if (!p.getErrors().isEmpty()) {
|
||||
for (final FormatError e : p.getErrors()) {
|
||||
System.out.println("error " + e.getMessage());
|
||||
System.out.println(" at " + e.getLineText());
|
||||
}
|
||||
dump(buf);
|
||||
fail("Unexpected error in " + cid);
|
||||
}
|
||||
|
||||
for (final FileHeader fh : p.getFiles()) {
|
||||
final String fileName;
|
||||
if (fh.getChangeType() != FileHeader.ChangeType.DELETE)
|
||||
fileName = fh.getNewName();
|
||||
else
|
||||
fileName = fh.getOldName();
|
||||
final StatInfo s = files.remove(fileName);
|
||||
final String nid = fileName + " in " + cid;
|
||||
assertNotNull("No " + nid, s);
|
||||
int added = 0, deleted = 0;
|
||||
for (final HunkHeader h : fh.getHunks()) {
|
||||
added += h.getOldImage().getLinesAdded();
|
||||
deleted += h.getOldImage().getLinesDeleted();
|
||||
}
|
||||
|
||||
if (s.added == added) {
|
||||
//
|
||||
} else if (s.added == added + 1 && offBy1.contains(cid)) {
|
||||
//
|
||||
} else {
|
||||
dump(buf);
|
||||
assertEquals("Added diff in " + nid, s.added, added);
|
||||
}
|
||||
|
||||
if (s.deleted == deleted) {
|
||||
//
|
||||
} else if (s.deleted == deleted + 1 && offBy1.contains(cid)) {
|
||||
//
|
||||
} else {
|
||||
dump(buf);
|
||||
assertEquals("Deleted diff in " + nid, s.deleted, deleted);
|
||||
}
|
||||
}
|
||||
assertTrue("Missed files in " + cid, files.isEmpty());
|
||||
}
|
||||
|
||||
private static void dump(final byte[] buf) {
|
||||
String str;
|
||||
try {
|
||||
str = new String(buf, 0, buf.length - 1, "ISO-8859-1");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
System.out.println("<<" + str + ">>");
|
||||
}
|
||||
}
|
||||
|
||||
static class NumStatReader extends CommitReader {
|
||||
final HashMap<String, HashMap<String, StatInfo>> stats = new HashMap<String, HashMap<String, StatInfo>>();
|
||||
|
||||
NumStatReader() throws IOException {
|
||||
super(new String[] { "--numstat" });
|
||||
}
|
||||
|
||||
@Override
|
||||
void onCommit(String commitId, byte[] buf) {
|
||||
final HashMap<String, StatInfo> files = new HashMap<String, StatInfo>();
|
||||
final MutableInteger ptr = new MutableInteger();
|
||||
while (ptr.value < buf.length) {
|
||||
if (buf[ptr.value] == '\n')
|
||||
break;
|
||||
final StatInfo i = new StatInfo();
|
||||
i.added = RawParseUtils.parseBase10(buf, ptr.value, ptr);
|
||||
i.deleted = RawParseUtils.parseBase10(buf, ptr.value + 1, ptr);
|
||||
final int eol = RawParseUtils.nextLF(buf, ptr.value);
|
||||
final String name = RawParseUtils.decode(Constants.CHARSET,
|
||||
buf, ptr.value + 1, eol - 1);
|
||||
files.put(name, i);
|
||||
ptr.value = eol;
|
||||
}
|
||||
stats.put(commitId, files);
|
||||
}
|
||||
}
|
||||
|
||||
static abstract class CommitReader {
|
||||
private Process proc;
|
||||
|
||||
CommitReader(final String[] args) throws IOException {
|
||||
final String[] realArgs = new String[3 + args.length + 1];
|
||||
realArgs[0] = "git";
|
||||
realArgs[1] = "log";
|
||||
realArgs[2] = "--pretty=format:commit %H";
|
||||
System.arraycopy(args, 0, realArgs, 3, args.length);
|
||||
realArgs[3 + args.length] = "a4b98ed15ea5f165a7aa0f2fd2ea6fcce6710925";
|
||||
|
||||
proc = Runtime.getRuntime().exec(realArgs);
|
||||
proc.getOutputStream().close();
|
||||
proc.getErrorStream().close();
|
||||
}
|
||||
|
||||
void read() throws IOException, InterruptedException {
|
||||
final BufferedReader in = new BufferedReader(new InputStreamReader(
|
||||
proc.getInputStream(), "ISO-8859-1"));
|
||||
String commitId = null;
|
||||
TemporaryBuffer buf = null;
|
||||
for (;;) {
|
||||
String line = in.readLine();
|
||||
if (line == null)
|
||||
break;
|
||||
if (line.startsWith("commit ")) {
|
||||
if (buf != null) {
|
||||
buf.close();
|
||||
onCommit(commitId, buf.toByteArray());
|
||||
buf.destroy();
|
||||
}
|
||||
commitId = line.substring("commit ".length());
|
||||
buf = new TemporaryBuffer();
|
||||
} else if (buf != null) {
|
||||
buf.write(line.getBytes("ISO-8859-1"));
|
||||
buf.write('\n');
|
||||
}
|
||||
}
|
||||
in.close();
|
||||
assertEquals(0, proc.waitFor());
|
||||
proc = null;
|
||||
}
|
||||
|
||||
abstract void onCommit(String commitId, byte[] buf);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.jgit.test"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/org.eclipse.jgit.test"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=org.eclipse.jgit.test/exttst"/>
|
||||
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
|
||||
</launchConfiguration>
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.jgit.test"/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/org.eclipse.jgit.test"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=org.eclipse.jgit.test/exttst"/>
|
||||
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
|
||||
</launchConfiguration>
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/org.eclipse.jgit.test/tst"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="2"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=org.eclipse.jgit.test/tst"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.jgit.test"/>
|
||||
</launchConfiguration>
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.jgit.test"/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/org.eclipse.jgit.test"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=org.eclipse.jgit.test/tst"/>
|
||||
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
|
||||
</launchConfiguration>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
*.patch -crlf
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue