Commit Graph

2644 Commits

Author SHA1 Message Date
Shaul Zorea 17604c77a8 Archive: Add the ability to select one or more paths.
Previously, it was only possible to archive the entire repository.
This patch introduces the ability to select specific files and
directories to archive.
Archiving the entire repository remains the default behaviour.

org.eclipse.jgit.api.ArchiveCommand: Adding setPaths(String... paths)
method.

Change-Id: Iedcd40fbfd71238b0088174bbe2717fae196e047
Signed-off-by: Shaul Zorea <shaulzorea@gmail.com>
2014-05-14 18:42:29 +03:00
Christian Halstrick 292cfab10d Fix wrong Exception messages
In two places we threw an IOException and the message was built using
JGitText.couldNotWriteFile. We specified 2 parameters, but this pattern
expects only one parameter. In both places we tried to rename a file,
that's why we wanted two parameters (src and target) for the exception
text.

I changed it to use JGitText.renameFileFailed which accepts two
parameters and fits better.

Change-Id: Ib8c2cf78f2b26ca2b97754fe91fdb20b30392415
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-14 00:52:06 +02:00
Tomasz Zarna b13907f086 Fix javadoc errors caused by missing tags for declared exceptions
Change-Id: I587aae0ad217ed092f061682ffa66c724f221096
Signed-off-by: Tomasz Zarna <tomasz.zarna@tasktop.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-12 00:40:16 +02:00
Yuxuan 'fishy' Wang 0b15b48f74 Handle repo copyfile in bare repositories.
Change-Id: Ie06f0c3d1bc9b2123102efaa5542ec3c232b72cd
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-05-09 17:25:50 -07:00
Yuxuan 'fishy' Wang d998bc938a Handle the revision attribute in repo manifest.
Change-Id: I77fe073aeb13c58029551b7d6e1451a9b62dc766
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-05-09 17:25:41 -07:00
Yuxuan 'fishy' Wang 056135a148 Handle repo submodules for bare repositories.
Change-Id: Id028a7bc9600baf0f3e2316a1f4b99e53ccc746a
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-05-07 11:03:51 -07:00
Matthias Sohn 7f394cf162 Fix manifests of source bundles
- don't mark them as singleton to allow coexistence of multiple versions
  in the same installation
- add missing version qualifier to Eclipse-SourceBundle header

see
https://dev.eclipse.org/mhonarc/lists/cross-project-issues-dev/msg10524.html

Change-Id: Ie4e028038f5a1d3e18b0be06c3d2ea82e7f9068d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-07 11:32:42 +02:00
Dave Borowitz 79448bcf94 Merge changes I9ba0e70f,I1f38e055,Idb55a303
* changes:
  Do not rewrite parents in RevWalkTextBuiltins
  RevWalk: Allow disabling parent rewriting
  RevWalkTextBuiltin: Add -n to limit number of commits returned
2014-05-06 14:05:14 -04:00
Laurent Goubet 7424d58255 Allow callers to use different merging strategies
Signed-off-by: Laurent Goubet <laurent.goubet@obeo.fr>
Change-Id: I84e9d7b4b772b4ad7d3e7010aad78291d4d178fe
2014-05-06 16:30:34 +02:00
Dave Borowitz dbf922ce91 RevWalk: Allow disabling parent rewriting
Previously, setting any TreeFilter on a RevWalk triggered parent
rewriting, which in the current StartGenerator implementation ends up
buffering the entire commit history in memory. Aside from causing poor
performance on large histories, this does not match the default
behavior of `git rev-list`, which does not rewrite parent SHAs unless
asked to via --parents/--children.

Add a new method setRewriteParents() to RevWalk to disable this
behavior. Continue rewriting parents by default to maintain backwards
compatibility.

Change-Id: I1f38e05526071c75ca58095e312663de5e6f334d
2014-05-05 16:41:08 -07:00
Matthias Sohn 3a47e45c32 Prepare 3.4.0-SNAPSHOT builds
Change-Id: I5cf20c875c3e92e12c2b22465774ba42513b9add
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-06 00:04:09 +02:00
Matthias Sohn f6c42684d9 JGit v3.4.0.201405051725-m7
Change-Id: I8d941d22becdf019199a1c0fe28aa5835038647d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-05 23:33:03 +02:00
Robin Rosenberg f9c0783e7d Merge "Make the resolve merger slightly more sub-classable." 2014-05-05 15:09:03 -04:00
Shawn Pearce 561121e111 Merge "blame: Fix merges, where merge result differs only by whitespace" 2014-05-04 14:37:14 -04:00
Konrad Kügler d5ee5ede3e AbstractPlotRenderer: Make private methods static where applicable
Change-Id: Iaf02502b02b2420c059f04bbe09254941301c727
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
2014-05-03 23:08:10 +02:00
Konrad Kügler e5f7fdcf4f PlotLane: Use identity hashCode and equals
Using the lane position and other data for equals/hashCode is not
useful.

Change-Id: I7af151d8a84544a77a486474c8ac71dd80090c66
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
2014-05-03 23:08:09 +02:00
Konrad Kügler c2fb432cde blame: Fix merges, where merge result differs only by whitespace
When blaming a merge commit with "Ignore whitespace changes" enabled,
don't discard blame candidates for other parents when we encounter a
parent that only has whitespace changes compared to the merge result.

The algorithm early prepares parents for blaming, removing the
appropriate blame regions from the list of regions still to blame. Only
at the end, the prepared blame candidates are submitted for blaming.

When looking at a non-first parent which only differs in whitespace to
the merge result, it submitted that parent, but only to blame it for the
(usually few) lines not already prepared to blame on other parents. Due
to an early return the blame candidates for the previous parents were
forgotten, leaving many lines unannotated.

bug: 433024
Change-Id: I43c9caf2078b92b05e652dbed2192568907bf199
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
2014-05-03 15:17:08 +02:00
Jean-Jacques Lafay 8b65a4e6c6 Fix push to repo with non-fetched refs
When JGit uses bitmaps (which is the case after a gc), the push command
doesn't go through the code where MissingObjectExceptions are caught
for remote objects not found locally.

Fixed by removing earlier non-locally-found remote objects.

This was seen withing gerrit, see:
https://code.google.com/p/gerrit/issues/detail?id=2025

Bug: 426044
Change-Id: Ieda718a0530e3680036edfa0963ab88fdd1362c0
Signed-off-by: Jean-Jacques Lafay <jeanjacques.lafay@gmail.com>
Signed-off-by: Doug Kelly <dougk.ff7@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-04-30 17:43:44 -04:00
Matthias Sohn 8e4018390e Merge changes I2515a6ed,Ib6b24035
* changes:
  Fix ArrayIndexOutOfBoundsException in CreateBranchCommand
  Add methods to Repository to handle remote names
2014-04-27 09:34:02 -04:00
Robin Rosenberg 36f58ef867 Fix ArrayIndexOutOfBoundsException in CreateBranchCommand
If remote name contains / or there was a branch directly under the
refs/remotes namespace (wrong) the computation of remote name and
suggested local branch name would fail. Fix this by looking at the
configured remotes. A ref under refs/remotes that does not match a
remote configuration is not considered a remote tracking branch anymore.

This patch does not fix all similar errors in EGit/JGit.

Bug: 411002
Bug: 400414
Change-Id: I2515a6ed05f9104c387ce4e43b24dae942ae2473
2014-04-27 10:38:33 +02:00
Robin Rosenberg 6605255d99 Add methods to Repository to handle remote names
Instead of requiring the caller to know how to list remote
names or parse remote branch names, add a few utilities for
that.

Change-Id: Ib6b2403532f4abbce594a03c0b9da49d30b19f70
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2014-04-27 10:35:21 +02:00
Konrad Kügler ca207b938d Fix BlameResult.computeRange JavaDoc to exclude end index
Change-Id: Ifd7dd86e3848eb7a522ba5c49d5c216777484f3b
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
2014-04-26 14:31:47 +02:00
Bogdan Gheorghe 8923e67a16 Add API to permit the setting of additional HTTP headers
Signed-off-by: Bogdan Gheorghe <gheorghe@ca.ibm.com>
Change-Id: I1047f318bb5c63850f45ba85d73c97fe8bf70a6c
2014-04-25 19:01:58 -04:00
Shawn Pearce d8754aa4f4 Merge changes Ia4df9808,I83e8a321,Id0e7663b,Ib809b00c,I88a6ee07
* changes:
  Commit changes generated during repo command
  Added implementation of copyfile rule.
  Added groups support to repo subcommand.
  Added the command line of jgit repo.
  Implemented first part of the repo sub-command.
2014-04-25 14:01:06 -04:00
Yuxuan 'fishy' Wang dc4c673902 Commit changes generated during repo command
Change-Id: Ia4df9808294d2069dcc5973bcb69b4499c7dcacd
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-04-25 13:42:35 -04:00
Shawn Pearce 06af8f5cc2 Merge "Automatically reload known_hosts file" 2014-04-25 12:34:37 -04:00
Doug Kelly 44025d4c54 Automatically reload known_hosts file
JGit caches the contents of the known_hosts file within JSch when
first started, and never attempts to re-read it.  If the contents
change (such as when using Gerrit replication), the new host will
never be found.

On failures, try reloading the knonwn_hosts and retry the
connection, in addition to reloading the credentials.

Change-Id: I980c4f4003f2a48c71b9b47c51e640d1e7742f58
Signed-off-by: Doug Kelly <dougk.ff7@gmail.com>
2014-04-24 16:50:21 -04:00
Doug Kelly 62697c8d33 Remove streaming delta support from JGit
Streaming packed deltas is so slow that it never feasibly completes
(it will take hours for it to stream a few hundred megabytes on
relatively fast systems with a large amount of storage).  This
was indicated as a "failed experiment" by Shawn in the following
mailing list post:
http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg01674.html

Change-Id: Idc12f59e37b122f13856d7b533a5af9d8867a8a5
Signed-off-by: Doug Kelly <dougk.ff7@gmail.com>
2014-04-24 11:39:01 -07:00
Yuxuan 'fishy' Wang 51cccc9dae Added implementation of copyfile rule.
Change-Id: I83e8a3218be2984321342039fda507fdb1aa5f30
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-04-23 23:03:02 -07:00
Yuxuan 'fishy' Wang a44a687fed Added groups support to repo subcommand.
Change-Id: Id0e7663b6ac4f6938fdcacaf2158107b6285fc25
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-04-23 23:03:00 -07:00
Yuxuan 'fishy' Wang 1f3b75c9ee Added the command line of jgit repo.
Change-Id: Ib809b00c236a9c44422a872ae801b060f5b26808
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-04-23 22:59:49 -07:00
Yuxuan 'fishy' Wang 0ad8fa7b36 Implemented first part of the repo sub-command.
Currently the repo sub-command only "works", but the submodules will have .git
directories themselves, and lacks group support.

Change-Id: I88a6ee07109187c6c9bfd92a044775fcfb5befa6
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-04-23 22:48:51 -07:00
Shawn Pearce 2d76133ba2 blame: Reuse existing blameEntireRegionOnParent method
Skipping directly to the parent is already possible with an existing
helper method. Update the source path (to follow the rename) and then
use the existing code path to push the parent inside the current entry.

Change-Id: Icb1d49e53d14b599efc478990613625a9e058e09
2014-04-21 11:43:03 -07:00
Shawn Pearce 4d840fc6db blame: Remove unnecessary curly braces around single statement if
Change-Id: I8bcab44785fe08bbf3519c634e57ebfea8d3f0f9
2014-04-21 11:43:03 -07:00
Shawn Pearce 2ee4d4a2c7 blame: Allow candidate to manage its setup before output
Pass in the RevWalk and let the candidate decide how to prepare itself
for output. This removes the conditional for the missing sourceCommit,
as candidates missing a commit can override the method with a no-op.

Change-Id: I3fa19b8676dfd3c177583f8f42593b5000b5350d
2014-04-21 11:43:02 -07:00
Shawn Pearce 6afae79901 blame: Do not update candidate regionList during output
Instead of updating the candidate's regionList field to iterate
through the linked list of regions, use a special purpose field
in the BlameGenerator. This allows the candidate to be unmodified.

Change-Id: I2cda031b59220ab603ef82050e741ecbbaa1953f
2014-04-21 11:43:02 -07:00
Shawn Pearce 4db7e8f94d blame: Only use computeRange if -L was requested
The computeRange method is inefficient for computing the entire file.
If the entire file was selected ask for the entire file.

Change-Id: I8b2dbf635e875cc125443dac50be121208646540
2014-04-21 11:43:02 -07:00
Shawn Pearce 911b115772 Expose ReceiveCommand version of TrackingRefUpdate
If the caller uses a BatchRefUpdate to execute these (e.g. fetch)
there may be more detailed status information inside of the command
that was used to execute it. Allow the caller to obtain that status
data from the ReceiveCommand version of the TrackingRefUpdate.

Change-Id: I47209377fb8fcef0346d7678f1ab27f4790b49bc
2014-04-18 14:03:20 -07:00
Shawn Pearce c8dd915c45 Merge changes I483c40e8,Ib16d684d,I9fb25229,I5f7c4855,I36905959
* changes:
  diff: Optimize single line edits
  blame: Reduce running time ~4.5% by skipping common subtrees
  blame: Micro optimize blob lookup in tree
  blame: Automatically increase commit abbreviation length
  Blame correctly in the presence of conflicting merges
2014-04-18 15:23:07 -04:00
Shawn Pearce cbc7c5c03f diff: Optimize single line edits
If the header and trailer are identical up to a single line on both
sides, return that REPLACE edit as the only result.  No algorithm can
break down a REPLACE with height of 1.

Change-Id: I483c40e8790cc3e8b322ef6dfce2299491fd0ac7
2014-04-18 10:11:00 -07:00
Shawn Pearce 6de12836d7 blame: Reduce running time ~4.5% by skipping common subtrees
With this commit running blame on render_view_impl.cc[1] saves
about 644 ms over prior versions, reducing the time about 4.5%.

Large projects often contain strands of commits where no changes
are made to a particular subtree. Blame used to dive recursively
into these subtrees to look for the blob and check if its SHA-1
was changed. In chromium/src[1] only 20% of the commits modify
the content/renderer subtree relevant for the file.

The recursivePath is necessary to check for '/' and remember
if common subtree elimination should be attempted. When a file
lives within a subtree the extra cost to check for unmodified
subtrees saves time. However for files in the root tree the
extra work incurred by TreeWalk is not worthwhile and would
significantly increase overall running time.

Now typical running times from an otherwise idle desktop:

  real	0m13.387s  0m13.341s  0m13.443s
  user	0m15.410s  0m15.220s  0m15.350s

previously:

  real	0m14.085s  0m14.049s  0m13.968s
  user	0m15.730s  0m15.820s  0m15.770s

[1] 34d6e5c5b4/content/renderer/render_view_impl.cc

Change-Id: Ib16d684df7ffa034ee28def3fb22c797998d5b7b
2014-04-17 15:51:50 -07:00
Shawn Pearce 52500d3264 blame: Micro optimize blob lookup in tree
Avoid converting the raw mode to FileMode. This is an expensive
if-else-if sort of test to just check if the thing is a blob.
Instead test the bit mask directly, which is at least a few
instructions shorter.

The TreeWalk is already recursive and will auto-dive into any
subtrees found. isSubtree check is unnecessary, as is the loop,
as only one result will ever be returned by next().

Change-Id: I9fb25229ebed857469427bfbdf74aedebfddfac8
2014-04-17 15:51:50 -07:00
Shawn Pearce 5a4e34009b blame: Automatically increase commit abbreviation length
Ensure commit object names are unique by extending the default
abbreviation as long as necessary. This allows `jgit blame` to
more closely match the formatted output of `git blame` on large
histories like Gerrit Code Review's ReceiveCommits.java file.

Change-Id: I5f7c4855769ee9dcba973389df9e109005dcdb5b
2014-04-17 15:51:50 -07:00
Konrad Kügler 551f3a0fa5 Blame correctly in the presence of conflicting merges
Problem:
The BlameGenerator used the RevFlag SEEN to mark commits it had
already looked at (but not necessarily processed), to prevent
processing a commit multiple times. If a commit is a conflicting
merge that contains lines of the merge base, that have been deleted
in its first parent, either these lines or the lines untouched
since the merge base would not be blamed properly.

This happens for example if a file is modified on a main branch in an
earlier commit M and on a side branch in a later commit S. For this
example, M deletes some lines relative to the common base commit B,
and S modifies a subset of these lines, leaving some other of these
lines untouched.

Then side is merged into main, creating a conflict for these
lines. The merge resolution shall carry over some unmodified lines
from B that would otherwise be deleted by M. The route to blame
these lines is via S to B. They can't be blamed via M, as they
don't exist there anymore.

    Q
    |\
    | \
    | S
    | |
    M |
    | /
    |/
    B

Blaming the merged file first blames via S, because that is the
most recent commit. Doing so, it also looks at B to blame the
unmodified lines of B carried over by S into the merge result. In the
course of this, B is submitted for later processing and marked SEEN.

Later M is blamed. It notices that its parent commit B has been
SEEN and aborts processing for M. B is blamed after that, but only
for the lines that survived via S.

As a result, only the lines contributed by S or by B via S are
blamed. All the other lines that were unchanges by both M and S,
which should have been blamed to B via M, are not blamed.

Solution:
Don't abort processing when encountering a SEEN commit. Rather add the
new region list of lines to be blamed to those of the already SEEN and
enqueued commit's region list. This way when the B commit of the
above example is processed, it will blame both the lines of M and S,
yielding a complete blame result.

Bug: 374382
Change-Id: I369059597608022948009ea7708cc8190f05a8d3
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
Signed-off-by: Shawn Pearce <spearce@spearce.org>
2014-04-17 14:05:51 -07:00
Jonathan Nieder d5110c32f9 Allow ArchiveCommand.registerFormat to be called twice
This should make it possible for the gitiles plugin to register its
archive formats after gerrit has already registered them.

Signed-off-by: Jonathan Nieder <jrn@google.com>
Change-Id: Icb80a446e583961a7278b707d572d6fe456c372c
2014-04-16 11:52:02 -07:00
Matthias Sohn 7388955319 Merge branch 'stable-3.3'
* stable-3.3:
  Ensure that stored credentials aren't reset too early

Change-Id: Idcd57e12f5fe905952be49edb4f82db6b7ed469f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-04-14 01:20:18 +02:00
Matthias Sohn a53a18e988 Ensure that stored credentials aren't reset too early
Some commands are started without showing a dialog allowing to enter
credentials if needed. Hence we need to tolerate one failing HTTP
authentication to trigger loading credentials from the secure store.
Hence we should not immediately reset the stored credentials if the
first attempt to authenticate fails.

Bug: 431209
Change-Id: I1b9fa34c3d70be226bb1c59c9ebe995998d29bc8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-04-14 00:42:05 +02:00
Robin Rosenberg 6654baddae Merge changes Id9a641dd,If2ee1f42
* changes:
  Added TestCase for 7d5e1f Fixed RevWalk.isMergedInto()
  Fixed RevWalk.isMergedInto() returning wrong results
2014-04-09 16:14:28 -04:00
Robin Rosenberg fe397ad90f Don't use package private classes when overriding a public interface
Change-Id: If8522d4e02254766e3310a70e42badafa5ab9768
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2014-04-05 08:39:19 -04:00
Shawn Pearce ffb0f05d02 Mark getParent deprecated in CanonicalTreeParser
@deprecated in Javadoc must be accompanied by @Deprecated annotation
on the class member.

Change-Id: Ifdf787f496ff3ffd6ffe8f3321d56320cb08454f
2014-04-03 12:08:07 -07:00
Shawn Pearce 94330d9cb5 Fix ObjectChecker when normalization is enabled
When safeForMacOS is enabled the checker verifies a name does not
match against another name in the same tree after normalization to
NFC. The check was incorrect and failed when the first name was put
in, rejecting simple trees containing only one file like "F".

Add a test for this simple tree to verify it is accepted.
Fix the test for NFC normalization to actually normalize
and have a collision.

Change-Id: I39e7d71150948872bff6cd2b06bf8dae52aa3c33
2014-04-03 11:15:25 -07:00
Shawn Pearce 39904d6ad4 Abbreviate SHA-1s when reporting invalid objects
The full 40 digit name is rather long. In most cases an abbreviated
name should be sufficient.

Change-Id: Id16a37c6c745ede1fa0d97c5bc390491799500bc
2014-04-03 11:12:01 -07:00
Shawn Pearce 8924d4e0a0 Throw CorruptObjectException when a bad object is found
This makes it easier to identify higher in the call stack.

Change-Id: I829431c38c71fa1899e33916252b75f09db8ecbd
2014-04-03 11:12:01 -07:00
Matthias Sohn 90d743f834 Merge "Add missing space to invalid object error messages" 2014-04-03 13:54:15 -04:00
Shawn Pearce 8254c76025 Add missing space to invalid object error messages
"Invalid tree aa6f10291050a00de83b4630783030b9e3b969ec:duplicate entry names"

is hard to read. A space after the object name and before the message
makes the message more readable.

Change-Id: I96406100dbef8e4bc8fe2047d102681194dc8847
2014-04-03 10:13:30 -07:00
Robin Rosenberg 32ff57a2b2 Cleanup javadocs so they pass the java8 doclint checks
Bug: 431552
Change-Id: I469316f5645205016e1fa6b0fbd2ff3b509b14bc
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-03-29 18:34:41 +01:00
Stefan Lay e56d50a94b Interactive rebase: Fix order of commit messages on squash
Bug: 431214
Change-Id: I295bfdc5751545b046d7fe7efc3f8b39ab4f5415
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Robin Rosennberg <robin.rosenberg@dewire.com>
2014-03-27 16:11:15 -04:00
Stefan Lay 6995069464 Fix missing NON-NLS tag in RebaseCommand
Change-Id: Ied3e7ec0d825416226cacb2f14d5bca003af36da
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2014-03-27 14:38:29 +01:00
Christian Halstrick 16436ef6d9 Fix GarbageCollection not to pack HEAD
When working on a non-bare repository with a detached HEAD jgit's GC was
packing the ref named "HEAD" into the packed-refs file and deleted the
loose ref (the file .git/HEAD!). This made the repo unusable for native
git. This is fixed by telling jgit to only pack refs starting from
"refs/"

Change-Id: I50018aa006f18b244d2cae2ff78b5ffe1b821d63
2014-03-26 15:27:48 +01:00
Dave Borowitz 27473d8e66 Fix NameRevCommand when repo has no annotated tags
Previously, calling addAnnotatedTags() did not modify any state when
there were no annotated tags in the repository. This caused the code
to assume no addFoo() methods had been called, and fell back to the
default of adding refs/*. Instead, use null to indicate neither
addRefs() nor addAnnotatedTags() was called.

Add a test for this behavior.

Change-Id: I9926e5ac17e1a983cd399798993031c72bd79c2c
2014-03-25 18:39:48 -07:00
Matthias Sohn 5c1736a8d8 Merge branch 'stable-3.3'
* stable-3.3:
  Prepare 3.3.2-SNAPSHOT builds
  JGit v3.3.1.201403241930-r
  Retry to call credentials provider if http authentication failed
  Ensure that ssh authentication is retried only in JGit
  [findBugs] Ensure streams are closed in a finally block
  Update com.jcraft.jsch to 0.1.50 also in pom dependencies

Change-Id: I45b48a3f2dc8c7708e9518645d72bc5645002836
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-25 11:04:29 +01:00
Matthias Sohn 5073000c3f Prepare 3.3.2-SNAPSHOT builds
Change-Id: I48271980a258acd0ada7c418b24c61c1bf0a0cd2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-25 09:19:36 +01:00
Matthias Sohn f3f2060b5c JGit v3.3.1.201403241930-r
Change-Id: Ib317903898095d205f0b6ed4cead62ff6eabd894
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-25 00:36:03 +01:00
Gustaf Lundh 7d5e1f8497 Fixed RevWalk.isMergedInto() returning wrong results
Under certain circumstances isMergedInto() returned
false even though base is reachable from the tip.
This will hinder pushes and receives by falsely
detecting "non fast forward" merges.

      o---o---o---o---o
      /                 \
     /   o---o---A---o---M
    /   /
---2---1-

if M (tip) was compared to 1 (base), the method
isMergedInto() could still return false, since
two mergeBases will be detected and the return
statement will only look at one of them:

  return next() == base;

In most cases this would pass, but if "A" is
a commit with an old timestamp, the Generator
would walk down to "2" before completing the
walk pass "A" and first finding the other
merge base "1". In this case, the first call to
next() returns 2, which compared to base evaluates
as false.

This is fixed by iterating merge bases and
returning true if base is found among them.

Change-Id: If2ee1f4270f5ea4bee73ecb0e9c933f8234818da
Signed-off-by: Gustaf Lundh <gustaf.lundh@sonymobile.com>
Signed-off-by: Sven Selberg <sven.selberg@sonymobile.com>
2014-03-24 18:41:48 +01:00
Matthias Sohn 8598fe3d2b Retry to call credentials provider if http authentication failed
If the user provided wrong credentials or credentials changed we
shouldn't give up immediately but retry to get valid credentials from
the credentials provider. Reset the credentials provider if
authentication failed to avoid it reuses wrong credentials in
case it stored them in a persistent store.

Bug: 338048
Bug: 342592
Bug: 427735
Change-Id: Ibd62ef3da17be6454991c43f524c8bbc7ca3c37e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-20 00:56:21 +01:00
Christian Halstrick fc9b1fbf6b Ensure that ssh authentication is retried only in JGit
JGit wants to control retries during ssh authentication. But JSch by
default already retries 6 times. Hence disable retries in JSch. Without
this the credentials provider isn't reset if e.g. wrong credentials are
specified.

Bug: 430210
Change-Id: I6fa726a14a84b06411e7010608c7a1e2bfb8bfe8
2014-03-15 04:27:53 -04:00
Matthias Sohn f43b7d6075 Merge "Fix text alignment in history plot renderer" 2014-03-13 18:56:40 -04:00
Rüdiger Herrmann 24921e12d0 Fix text alignment in history plot renderer
When more than one lane is drawn, some commits are vertically misaligned
(off by two pixels). This change fixes the alignment.

Bug: 426047
Change-Id: Icbe7ce9f5a6b281b2aaab66e4d76dfc1010b2fb5
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
Signed-off-by: Rüdiger Herrmann <ruediger.herrmann@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-13 23:39:36 +01:00
Shawn Pearce f716ad6d54 Fix StackOverflowError in RevCommit.carryFlags on deep side graphs
Copying flags through a graph with deep side branches can cause
StackOverflowError. The recursive step to visit the 2nd parent of
a merge commit can overflow the stack if these are themselves very
deep histories with many branches.

Rewrite the loop to iterate up to 500 recursive steps deep before
unwinding the stack and running the remaining parts of the graph
using a dynamically allocated FIFORevQueue.

This approach still allows simple graphs that mostly merge short
lived topic branches into master to copy flags with no dynamic
memory allocation, relying only on temporary stack extensions.
Larger more complex graphs only pay the allocation penalities
if copying has to extend outwards "very far" in the graph, which
is unlikely for many coloring based algorithms.

Change-Id: I1882e6832c916e27dd5f6b7602d9caf66fb39c84
2014-03-13 12:59:46 -07:00
Shawn Pearce 4c3e7931ed Display progress while checking connectivity on push
Verifying 100 new objects are fully connected to the existing DAG
is usually very cheap. Checking the entire Linux kernel history is
fully connected when pushing it to a new repository can take 30-60
seconds. Display a progress counter during this time so the client
knows the server is still working.

Change-Id: Iababe3ee1d35cb82f2bef2f12da7a2ecd03282b0
2014-03-12 23:19:12 -04:00
Shawn Pearce 088e80315b Merge changes I1a225c1b,Ie4d5f082,I41f24363,I9440dd25,I170b6f64,I02e964d1,Iec6ce9e6,Ic700ea8f,Ic3042444,I90a1eaf2,I66eaee5c,Ib921dfd7
* changes:
  Allow configuration of receive pack's ObjectChecker through fsck.*
  Correct fetch to use fetch.fsckObjects and transfer.fsckObjects
  Default receive.fsckObjects to transfer.fsckObjects
  Allow ReceivePack callers to configure their own ObjectChecker
  Check for duplicate names after folding case in ObjectChecker
  Change DirCacheCheckout to verify path using ObjectChecker
  Reject mixed case .git on Mac OS in ObjectChecker
  Reject special Windows device names in ObjectChecker
  Allow an ObjectChecker to reject special characters for Windows
  Reject '.git' as a tree name in ObjectChecker
  Extract path segment check function in ObjectChecker
  Permit ObjectChecker to optionally accept leading '0' in trees
2014-03-12 23:18:32 -04:00
Shawn Pearce 3d412827e5 Allow configuration of receive pack's ObjectChecker through fsck.*
fsck.allowLeadingZeroFileMode may be set true to permit pushing
broken trees with leading '0' in the file mode.

fsck.safeForWindows may be set true to require new trees to have
only file names that are safe on the Windows platform.

fsck.safeForMacOS may be set true to require new trees to have
only file names that do not cause collisions or confusion on the
Mac OS platform.

Change-Id: I1a225c1b3cd13c0d1a0d43fffe79355c501f49b7
2014-03-12 17:15:42 -07:00
Shawn Pearce ced58a7cff Correct fetch to use fetch.fsckObjects and transfer.fsckObjects
git-core configures fsck during fetch using these two variables.
JGit use of fsck in fetch predates the usage in git-core and had
reused receive.fsckobjects, which does not match behavior.

Change-Id: Ie4d5f082258c4b2928c7ecc3780c6363fa587f34
2014-03-12 17:15:41 -07:00
Shawn Pearce a1a5218032 Default receive.fsckObjects to transfer.fsckObjects
ReceivePack should configure itself with receive.fsckObjects,
and if not defined, transfer.fsckObjects. This is the order
used by git-core.

Change-Id: I41f243633dacb606dbcc3132972f63bbaba174d1
2014-03-12 17:15:35 -07:00
Shawn Pearce d300609495 Allow ReceivePack callers to configure their own ObjectChecker
PackParser permits supplying a specific ObjectChecker instance.
Allow this to be passed through ReceivePack, giving the caller
more flexibility to configure the implementation.

Change-Id: I9440dd25588008626222f33bfd697f57c05b439e
2014-03-12 16:36:07 -07:00
Shawn Pearce 0aa682fc68 Check for duplicate names after folding case in ObjectChecker
Mac OS X and Windows filesystems are generally case insensitive and
will fold 'a' and 'A' to the same directory entry. If the checker is
enforcing safe semantics for these platforms, track all names and
look for duplicates after folding case and normalizing to NFC.

Change-Id: I170b6f649a72d6ef322b7254943d4c604a8d25b9
2014-03-12 16:06:10 -07:00
Shawn Pearce e2f6378847 Change DirCacheCheckout to verify path using ObjectChecker
Reuse the generic logic in ObjectChecker to examine paths.
This required extracting the scanner loop to check for bad
characters within the path name segment.

Change-Id: I02e964d114fb544a0c1657790d5367c3a2b09dff
2014-03-12 16:06:10 -07:00
Shawn Pearce ed3879e389 Reject mixed case .git on Mac OS in ObjectChecker
Most Mac OS X systems use a case insensitive HFS+ volume. Like
Windows ".git" and ".GIT" are the same path and can confuse a Git
program into expecting a repository where one does not exist.

Change-Id: Iec6ce9e6c2872f8b0850cc6aec023fa0fcb05ae4
2014-03-12 16:06:08 -07:00
Shawn Pearce ba0f89b421 Reject special Windows device names in ObjectChecker
If Windows rejection is enabled reject special device names like
NUL and PRN, including NUL.txt. This prevents a tree that might
be used on a Windows client from referencing a confusing name.

Change-Id: Ic700ea8fa68724509e0357d4b758a41178c4d70c
2014-03-12 15:53:30 -07:00
Shawn Pearce 5019471ccb Allow an ObjectChecker to reject special characters for Windows
Repositories that are frequently checked out on Windows platforms
may need to ensure trees do not contain strange names that cause
problems on those systems. Follow the MSDN guidelines and refuse
to accept a tree containing a special character, or names that end
with " " (space) or "." (dot).

Since Windows filesystems are usually case insensitive, also reject
mixed case versions of the reserved ".git" name.

Change-Id: Ic3042444b1e162c6d01b88c7e6ea39b2a73c4eca
2014-03-12 15:43:38 -07:00
Shawn Pearce 09f513cb37 Reject '.git' as a tree name in ObjectChecker
Using .git as a name in a tree is invalid for most Git repositories.
This can confuse clients into thinking there is a submodule or another
repository deeper in the tree, which is incorrect.

Change-Id: I90a1eaf25d45e91557f3f548b69cdcd8f7cddce1
2014-03-12 15:43:38 -07:00
Shawn Pearce 77cd1c8cdc Extract path segment check function in ObjectChecker
Start pulling out the path segment checking. This will be used
later to support DirCacheCheckout verification of paths, after
folding that logic into this location.

Change-Id: I66eaee5c988eb7d425fb7a708ef6f5419ab77348
2014-03-12 15:43:38 -07:00
Shawn Pearce 2f1bd3618d Permit ObjectChecker to optionally accept leading '0' in trees
The leading '0' is a broken mode that although incorrect in the
Git canonical tree format was created by a couple of libraries
frequently used on a popular Git hosting site. Some projects have
these modes stuck in their ancient history and cannot easily
repair the damage without a full history rewrite. Optionally permit
ObjectChecker to ignore them.

Bug: 307291
Change-Id: Ib921dfd77ce757e89280d1c00328a88430daef35
2014-03-12 15:43:20 -07:00
Shawn Pearce 62b538d891 Cleanup catch Exception when making Java7FSFactory
Catching Exception and rethrowing as Error when the Java7 factory was
not available threw an unexpected error to the caller, but then
confused things by still setting the factory to the default Java
5 version.  A second call to FS.detect(Boolean) would succeed.

Do not throw to the caller. Instead always default to the Java5
factory if the Java7 one is not loading.

Change-Id: I6e9edb257b404d213ff08c44560fdb1672a5c80b
2014-03-11 14:57:27 -07:00
Matthias Sohn 1bdfd3b3aa [findBugs] Ensure streams are closed in a finally block
Change-Id: I3137eba00d6eba96ca9051b6687fcf62e0871bcc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-11 17:34:17 -04:00
Konrad Kügler efd91ef8a7 Take core.autocrlf into account for blame annotations
Blaming with core.autocrlf set to 'true' - even for freshly checked out
files - showed all lines as being locally modified. For autocrlf = true
the line breaks of the local file will be converted to LF for blaming.
This results in useful diffs and therefor in the desired blame
annotations.

For autocrlf = input no conversion takes place to cope with CRLF line
breaks in the repository, in addition to the usual LF. For autocrlf =
true CRLF line breaks in the repo can't be supported without additional
effort. In that case the whole local file will be blamed as being
locally modified.

Change-Id: If020dcca54d16b2fb79210a070b8480aec82e58e
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2014-03-10 12:22:57 +01:00
Robin Rosenberg 7aa3358c40 Add missing break
It does not really matter functionally, but it looked bad,

Change-Id: Icb5b73b38fcaa19f7d1c5a0235c3e8dd125b888b
2014-03-09 10:39:28 +01:00
Robin Rosenberg f3cf8fae76 Remove a redundant semi-colon
Change-Id: Id9a1d0036e3fb33aad8b5cb342197457f33febca
2014-03-08 16:20:31 -05:00
Robin Rosenberg 27191e7e22 Add @since tag to new DirCache#findEntry
Change-Id: Ia58efd178a4571c013bf1104d1da956a86fd7029
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-08 22:19:08 +01:00
Matthias Sohn 0401d3eb47 Fix some wrong @since 3.3 tags which should be @since 3.4
Change-Id: Idafe6e041cc40a00ac52eb4ba88753c49db86988
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-07 21:30:58 +01:00
Laurent Goubet ab0983377e Make the resolve merger slightly more sub-classable.
Change-Id: I7d2a90288696ee66887cc01d8a3ec2f6f28a0339
Signed-off-by: Laurent Goubet <laurent.goubet@obeo.fr>
2014-03-06 09:55:29 +01:00
Matthias Sohn effc2f34b8 [findBugs] Declare some private methods of WorkingTreeIterator static
Change-Id: I09cd39c367f408b5a963ff004f235f558990f338
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-05 19:01:38 -05:00
Matthias Sohn 47207e98d4 Prepare 3.4.0-SNAPSHOT builds
Change-Id: I907c6f1834c06b8ab4d3e0f76dde475faea7b4a5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-05 02:20:38 +01:00
Matthias Sohn 71b90400bb Merge branch 'stable-3.3'
* stable-3.3:
  Update scripts to deploy jgit on Maven central
  Prepare 3.3.1-SNAPSHOT builds
  JGit v3.3.0.201403021825-r
  Fix merge/cherry-picking in CRLF mode
  Expose the received pack size in ReceivePack
  Revert "Add getPackFile to ReceivePack to make PostReceiveHook more usable"
  Avoid an NPE after 7b01a53692
  Add a launcher for Java 7 tests
  Remove obsolete getRepositoryMethod from WorkingTreeIterator
  Fix NPE when WorkingTreeIterator does not have a repository set
  Add getPackFile to ReceivePack to make PostReceiveHook more usable
  Possibility to limit the max pack size on receive-pack
  Package httpclient and httpcore in o.e.j.http.apache.feature

Change-Id: I814a150980854bbaabd767f97b062d247af6cb50
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-05 02:02:16 +01:00
Matthias Sohn c1fee1d16b Prepare 3.3.1-SNAPSHOT builds
Change-Id: If15560f2731e54dbf9db88d8a308b4c25ce27e8e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-05 00:34:15 +01:00
Robin Rosenberg b640e3ab31 Merge "Add setContains to ListBranchCommand (branch --contains)" 2014-03-03 18:10:44 -05:00
Robin Rosenberg 1328bfdfeb Merge "DirCache.findEntry(byte[], in) made public" 2014-03-03 17:56:10 -05:00
Shawn Pearce fc8ff50e1a Add missing @Deprecated to deprecated fields and methods
Java spec requires the @Deprecated annotation on any deprecated
field or method. Add the missing annotation to fields and methods
already declared deprecated in the javadoc.

Change-Id: Ic0ef24b43cfd99ac947e771ef5a28e493c304274
2014-03-03 10:37:06 -08:00
Matthias Sohn 3d855dbfc6 JGit v3.3.0.201403021825-r
Change-Id: Iaf3da455f7d6f691617299e881154ff8185a9d46
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-03 00:26:54 +01:00
Robin Rosenberg fd62a45649 Fix merge/cherry-picking in CRLF mode
This fixes a case where we have CRLF in the repo but
LF in the worktree and are in autocrlf mode.

Change-Id: I0388270c1cf0fd22dfd513bcaa404eb97268d39d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-02 20:30:42 +01:00
Robin Rosenberg 31aeaa0931 Merge "Expose the received pack size in ReceivePack" into stable-3.3 2014-03-02 08:17:18 -05:00
Robin Rosenberg 8c82872354 Merge "Revert "Add getPackFile to ReceivePack to make PostReceiveHook more usable"" into stable-3.3 2014-03-02 08:14:14 -05:00
Saša Živkov 835ab30743 Expose the received pack size in ReceivePack
PostReceiveHooks can make use of this information to, for example,
update a cached size of the Git repository.

Change-Id: I2bf1200959a50531e2155a7609c96035ba45b10d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-02 01:52:06 +01:00
Saša Živkov ef3d864b1e Revert "Add getPackFile to ReceivePack to make PostReceiveHook more
usable"

This reverts commit 2670fd427c.

By returning an instance of File from the ReceivePack.getPackFile the
abstraction of the persistence implementation was broken.

Change-Id: I28e3ebf3a659a7cbc94be51bba9e1ad338f2b786
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-03-02 01:52:04 +01:00
Robin Rosenberg abff667d40 Avoid an NPE after 7b01a53692
While fixing an NPE, I introduced another one in a deprecated isModified
method. It cannot avoid NPE's entirely, which is the reason the method
is deprecated

Change-Id: I5147c1c94621586dd84bd11e6090a954523b6c1c
2014-03-01 13:02:06 +01:00
Robin Rosenberg 9508df3979 Remove obsolete getRepositoryMethod from WorkingTreeIterator
The method was added for symlink support, but isn't needed anymore.
Since it was added for this release it's like it never existed.

Change-Id: I422cd1dcdfa40b25ba3d6e08b112159dae9a4353
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-28 10:56:52 +01:00
Robin Rosenberg 7b01a53692 Fix NPE when WorkingTreeIterator does not have a repository set
It's strange that we have that member since it is not so clear
when it it set or not.

Change-Id: I53903a264f46866d249901a3cd9f9295028aa6bd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-28 10:44:54 +01:00
Christian Halstrick 83c743e6e2 Merge "Don't raise checkout conflict for file missing in working tree" 2014-02-27 16:17:56 -05:00
Christian Halstrick 73c8e70797 Don't raise checkout conflict for file missing in working tree
During a checkout we want to prevent to overwrite unsaved local file
content. Jgit was therefore checking whether the file to overwrite is
dirty or missing and would raise a conflict if this was the case. That
was wrong. It should only check if the file is dirty. It's ok to
"overwrite" a missing/non-existing file.

Change-Id: I63c3a94f663c87f09170fdf8b1b1bf4ed5246fc5
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2014-02-26 15:35:05 +01:00
Matthias Sohn df4aca2166 Merge "Add a missing @since tag" 2014-02-26 08:50:42 -05:00
Matthias Sohn a6828b9b73 Merge "Files should be deleted with "retry" option" 2014-02-26 08:49:17 -05:00
Christian Halstrick 8c8bbda3fb Add a missing @since tag
Change-Id: Ie34a4a9c4c47c2f27579094d74a7849fc26a323b
2014-02-26 14:31:29 +01:00
Marc Strapetz 59a2dc801c Files should be deleted with "retry" option
Some of our Windows users have reported sporadic file system access
problems related to ObjectDirectory(Inserter) file deletion code in
combination with antiviral/firewall tools. For one of these users the
problem was fairly reproducible and changing deletion to RETRY solved
his problem.

Change-Id: I1e4001d5557fca693b7bac401268599467cb0c9e
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>‌
2014-02-26 05:53:56 -05:00
Marc Strapetz c5dfc2317c DirCacheEntry: access to raw path
Change-Id: I5d1f6c4b5b3d7a971367cdd0cc9fa4022dff5b85
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>‌
2014-02-26 05:21:35 -05:00
Saša Živkov 2670fd427c Add getPackFile to ReceivePack to make PostReceiveHook more usable
Having access to the pack file that was created by the ReceivePack
may be useful for post receive hooks. For example, a hook may want
to check the size of the received pack and the created index.

Change-Id: I4d51758e4565d32c9f8892242947eb72644b847d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-25 18:14:39 +01:00
Saša Živkov 0d05e5d26c Possibility to limit the max pack size on receive-pack
The maxPackSizeLimit, when set, will reject a pack if it exceeds
that limit.

This feature is intended to provide a mechanism to control disk space
quota on Git repositories.

Change-Id: I83d8db670875c395f8171461b402083323e623a5
CQ: 7896
2014-02-25 14:20:31 +01:00
Marc Strapetz ea16c2afff Fix possible NPE in Repository.resolve
Change-Id: I9b19cd90b338a4c3cae5661c658526b7e98c95d1
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>‌
2014-02-24 18:39:38 +01:00
Marc Strapetz 21498aec83 DirCache.findEntry(byte[], in) made public
Change-Id: Ice64e3b0e5d67a39690aa24e41c954b8ce312d49
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>‌
2014-02-24 18:29:27 +01:00
Matthias Sohn 3d3df3942a Move Apache httpclient based HTTP support to a separate bundle
This move avoids that all consumers of org.eclipse.jgit depend on Apache
httpclient. Also add another feature to make this optional for OSGi
consumers as well.

Change-Id: I5ef5e00c53678b9e1d7cfd54bbca3ff6f1c1c967
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-20 23:57:21 +01:00
Matthias Sohn 3cebf9c466 Prepare post 3.3.0RC1 builds
Change-Id: I0d808f8733a490b75bbcaacedb4b095e05fab32e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-20 01:04:07 +01:00
Matthias Sohn 8bf45c23df JGit v3.3.0.201402191814-rc1
Change-Id: Ida3a0417ae646ce37214153f49a85de2be3dd4fd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-20 00:14:45 +01:00
Shawn Pearce f2f24a304d Fix diff header on renamed or copied files
When git-core renames or copies a file and the mode differs the
header shows the mode change first, then the rename or copy data:

  diff --git a/COPYING b/LICENSE
  old mode 100644
  new mode 100755
  similarity index 92%
  rename from COPYING
  rename to LICENSE
  index d645695..54863be
  --- a/COPYING
  +++ b/LICENSE
  @@ -56,20 +56,6 @@

JGit relies on this ordering inside of FileHeader. Parsing "new file
mode NNN" after "copy from/to" or "rename from/to" resets the change
type to be ADD, losing the COPIED or RENAMED status and old path.

This fixes a 4 year old bug in Gerrit Code Review that prevents
opening a file for review if the file was copied from another file,
modified in this change, and the mode was updated (e.g. execute
bit was added).

Change-Id: If4c9ecd61ef0ca8e3e1ea857301f7b5c948efb96
[ms: added test case]
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-18 22:08:07 +01:00
Christian Halstrick 2290516ddb Add an implementation for HttpConnection using Apache HttpClient
This change implements the http connection abstraction with the help of
org.apache.http.client.HttpClient. The default implementation used by
JGit is still the JDK HttpURLConnection. But now JGit users have the
possibility to switch completely to org.apache.httpclient. The reason
for this is that in certain (e.g. cloud) environments you are forced to
use the org.apache classes.

Change-Id: I0b357f23243ed13a014c79ba179fa327dfe318b2
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-18 21:04:17 +01:00
Christian Halstrick 38c4f35d8b Introduce an abstraction for HTTP connections
Previously all HTTP communication was done with the help of
java.net.HttpUrlConnection. In order to make JGit usable in environments
where the direct usage of such connections is not allowed but where the
environment provides other means to get network connections an
abstraction for connections is introduced. The idea is that new
implementations of this interface will be introduced which will not use
java.net.HttpUrlConnection but use e.g.
org.apache.client.http.HttpClient to provide network connections.

One example: certain cloud infrastructures don't allow that components
in the cloud communicate directly with HttpUrlConnection. Instead they
provide services where a component can ask for a connection (given a
symbolic name for the destination) and where the infrastructure returns
a preconfigured org.apache.http.client.HttpClient. In order to allow
JGit to be running in such environments we need the abstraction
introduced in this commit.

Change-Id: I3b06629f90a118bd284e55bb3f6465fe7d10463d
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-18 21:04:10 +01:00
Shawn Pearce f08fde3eeb Remove dead isBinary method from DiffFormatter
This method always returns false and is private so it cannot be
overridden at runtime by a subclass. Drop the method and the branch
that can never be taken.

Change-Id: I4d3edbf469c6739dca191e62ea580bdb534b67a4
2014-02-17 22:15:55 +01:00
Shawn Pearce 3fc5791778 Add missing static qualifier in DiffFormatter
These methods do not touch instance members and can avoid the
implicit "this" argument.

Change-Id: I01c30bb22266eed1c9db18bdf9f90c1c1590e3ec
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-17 22:15:51 +01:00
Matthias Sohn 1eae309723 Allow programmatic remote configuration for PullCommand
Also imply remoteBranchName to match current branch name if it wasn't
configured in branch configuration.

Bug: 424812
Change-Id: Id852cedaefb2a537b6aa3c330b9861efad052f11
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-14 16:10:59 +01:00
James Yonan 7bb7299e8a Fix a NullPointerException if properties file doesn't exist
For example with following URL,

  amazon-s3://.jgit@mybucket/foo.git

if ~/.jgit is missing, jgit command will throw a NullPointerException.

With this patch, a reasonable error message will be emitted:

  fatal: Cannot read file /Users/jamesyonan/.jgit

Change-Id: I1d366f2d55e170d2972715c657c8e2d10c8d87d2
Signed-off-by: James Yonan <james@openvpn.net>
2014-02-13 18:58:03 -05:00
Konrad Kügler 48e36d8cb3 Use branch.<x>.mergeoptions and merge.ff as defaults for merging
Read options that control squashing, whether or not to commit the merge
and regarding fast forwarding from the configuration and use them if no
explicit values for these options have been provided to MergeCommand.

Change-Id: Ifdaed4b5e4adc142657c03c8e78b709a99eeddbd
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-14 00:34:01 +01:00
Roberto Tyley 2b722815c9 Non-Fast-Forward Ref-Updates: Omit isMergedInto() calls
When the caller specifies to JGit in advance that a ref-update is a
non-fast-forward update, and that those are permitted, we should never
need to call the potentially expensive isMergedInto() check. Re-checking
that the older commit is /not/ reachable from the newer is superfluous.

http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg02258.html

Change-Id: I4bbf593de4dcea6b6f082881c1a33cb3a6a7fb89
Signed-off-by: Roberto Tyley <roberto.tyley@gmail.com>
2014-02-13 18:05:03 -05:00
Roberto Tyley 47f47ffc07 Initialise ReceiveCommand status to NOT_ATTEMPTED for all constructors
Formerly the 4-arg constructor did not do this, which was unfortunate
as that constructor's the only way for an external user of JGit to set
the /type/ of the ref-update - which you might want to do to indicate
that the update is expected to be a UPDATE_NONFASTFORWARD, and thus does
not require expensive isMergedInto() calculations:

http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg02258.html

Change-Id: I84c5e4927131e105bed93e31a62da6367c78de32
Signed-off-by: Roberto Tyley <roberto.tyley@gmail.com>
2014-02-13 17:45:41 -05:00
Konrad Kügler 420cb50cc2 Use fetch.prune and remote.<name>.prune to set prune mode when fetching
When no explicit value is set via FetchCommand.setRemoveDeletedRefs()
checks if pruning is enabled in the configuration.

The following commit introduced the prune config to C Git:
737c5a9cde

Change-Id: Ida79d335218e1c9f5c6e2ce03386ac8a1c0b212e
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-13 00:16:33 +01:00
Robin Rosenberg 5a51779e84 Normalize paths on OS X
Java normalizes paths to NFC, but other source may not, e.g Eclipse.

Bug: 413390
Change-Id: I08649ac58c9b3cb8bf12794703e4137b1b4e94d5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-12 23:00:36 +01:00
Robin Rosenberg b434241e73 Recognize symlinks in the FileTreeIterator
We did this for the Eclipse Platform in the ContainerTreeIterator.

Change-Id: I80d8157cc0dd99d57e2ed5d7cd8b13525a0c62b1
2014-02-12 11:09:24 +01:00
Robin Rosenberg 0b3a5ab817 Add special case to WorkingTreeIterator for matching unnormalized symlinks
If there is an unnormalized symbolic link in the index, lie that it
matches a normalized link in the working tree. This does not make the
case completely invisible everywhere though, but it helps to some
degree.

Change-Id: I599fb71648c41fa2310049d0e0040b3c9f09386b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-12 11:01:32 +01:00
Robin Rosenberg 14cd43e6df Use fileAttributes to get more attributes in one go
On Windows the length reported by FileAttributes is the size
of the target file (a bug, I guess) rather than the link,
so we read the linke and look at the length of the link instead.

Bug: 353771
Change-Id: I834b06d0447f84379612b8c9190fa77093617595
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-12 01:35:25 +01:00
Robin Stocker 2852b6a07d Fix RevWalkUtils.findBranchesReachableFrom not finding some branches
The "cut off" optimization causes it to not include branches that
contain the specified commit but happen to share commits with a branch
that does not contain the commit.

An example:

      -B foo
        \
    -A---C master

findBranchesReachableFrom for commit A with both branches as input may
not return master (depending on the order of the input). The reason is
that A is not contained in foo, and therefore the old code would put B
in the cutOff set. When then walking the master commits and B is
checked, it is found in the cutOff set and the walk is aborted, causing
master not to be returned even though it should.

Bug: 425674
Change-Id: I2c0c406ce5fcc9a03538b483473af930d4895d30
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-11 22:43:35 +01:00
Robin Rosenberg 7c19c45544 Add delete support to FS
Change-Id: Ib6f6fd5ef4a0c9b2062445ac4a0c9d1131e401bf
2014-02-10 23:29:24 +01:00
Robin Rosenberg 078a9f6066 Add symlink support to JGit
The change includes comparing symbolic links between disk and index,
adding symbolic links to the index, creating/modifying links on
checkout. The behavior is controlled by the core.symlinks setting, just
as C Git does. When a new repository is created core.symlinks will be
set depending on the capabilities of the operating system and Java
runtime.

If core.symlinks is set to true, the assumption is that symlinks are
supported, which may result in runtime errors if this turns out not to
be the case.

Measuring the cost of jgit status on a repository with ~70000 files,
of which ~30000 are tracked reveals a penalty of about 10% for using
the Java7 (really NIO2) support module.

Bug: 354367
Change-Id: I12f0fdd9d26212324a586896ef7eb1f6ff89c39c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-10 22:53:33 +01:00
Robin Rosenberg 5ef6d69532 Use the new FS.exists method in commonly occuring places
Allegedly this should improve performance, but I could not see it.

Change-Id: Id2057cb2cfcb46e94ff954483ce23f9c4a7edc5e
2014-02-10 11:26:57 +01:00
Robin Rosenberg 239f237be2 Fix deprecated WTI#isModified
We should really pass the forceContentCheck parameter to
the real method.

Change-Id: I9ea439cf6340a18d0e931edde3b9e3486cafde93
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-10 11:26:53 +01:00
Robin Rosenberg ff83f54d29 Failing to delete a directory with untracked content is actually ok
We had a test, but it was wrong.

Bug: 424630 
Change-Id: I926e0954c8623a323a50fe8be3ebe5e0ac6944c8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-10 11:25:02 +01:00
Robin Rosenberg e03f18941f Ban dangerous ref names in Windows
Bug: 423551 
Change-Id: I3e71ef1b4a8181f46d2902c9169859f150cd6ad0
Also-By: Robin Stocker <robin@nibor.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-05 10:47:12 +01:00
Matthias Sohn 08fd639c0d Merge "Reset internal state canonical length in WorkingTreeIterator when moving" 2014-02-04 03:03:27 -05:00
Shawn Pearce 8ae6295007 Merge "Fix MissingObjectException race in ObjectDirectory" 2014-02-03 18:05:39 -05:00
Shawn Pearce d1aacc415a Fix MissingObjectException race in ObjectDirectory
Johannes Carlsson identified a race condition[1] that can lead to
spurious MissingObjectExceptions at read time. If two threads are
active inside of ObjectDirectory looking for a packed object and the
packList is currently the empty NO_PACKS list, thread A will find
no object and eventually consider tryAgain1(). If thread A is put
to sleep and this point and thread B also does not find the object,
loads the packs, when thread A wakes up its tryAgain1 would return
false and the thread never considers the packs.

Rework the internal API of ObjectDirectory to keep a handle on the
exact PackList that was iterated by thread A, allowing it to always
retry walking through the packs if the new PackList is different.

This had some ripple effect into the CachedObjectDirectory and
the shared FileObjectDatabase interface. The new code should be
slightly easier to follow, especially from the perspective of the
CachedObjectDirectory trying to minimize the number of open system
calls it makes to files matching "$GIT_DIR/objects/??/?x{38}".

[1] http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg02401.html

Change-Id: I9a1c9d6ad6cb38404b7b9178167b714077561353
2014-02-03 14:19:32 -08:00
Robin Rosenberg 871ee53b52 Reset internal state canonical length in WorkingTreeIterator when moving
Bug: 426514
Change-Id: Ifb75a4fa12291aeeece3dda129a65f0c1fd5e0eb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-02-03 14:51:11 +01:00
Robin Rosenberg 5404e70dc6 Fix for core.autocrlf=input resulting in modified file
This version does not attempt to unsmudge, unlike the first attempt
in Idafad150553df14827eccfde2e3b95760e16a8b6.

Bug: 372834
Change-Id: I9300e735cb16d6208e1df963abb1ff69f688155d
Also-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-02-02 13:16:19 +01:00
Christian Halstrick 8352d1729c Add a missing since tag
Otherwise you get errors if you want to edit JGit in Eclipse

Change-Id: I840d4388f159e2db27845a17030b511fc5708f43
2014-01-30 15:23:56 +01:00
Shawn Pearce abadbabdc5 Merge "Fix serving fetch of existing shallow client" 2014-01-29 14:56:20 -05:00
Shawn Pearce b0174a089c Fix serving fetch of existing shallow client
In certain cases a JGit server updating an existing shallow client
selected a common ancestor that was behind the shallow edge of
the client. This allowed the server to assume the client had some
objects it did not have and allowed creation of pack deltas the
client could never inflate.

Any commit the client has advertised as shallow must be treated
by UploadPack server as though it has no parents. With no parents
the walker cannot visit graph history the client does not have,
and PackWriter cannot consider delta base candidates the client
is lacking.

Change-Id: I4922b9354df9f490966a586fb693762e897345a2
2014-01-28 17:29:00 -08:00
Matthias Sohn b9a06212e1 Add missing @since tags
Change-Id: I16d82499d7d000096de6bd4bd08e406073557162
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-01-20 09:29:10 +01:00
Matthias Sohn 75b31767c4 Do not report ignored directories as untracked
Change-Id: I7e3f6b9fb1ac4b99d2cc9a78c63aad86f4fa5744
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-01-19 00:20:42 +01:00
SATO taichi 2f425cf30c Add git checkout --orphan implementation
Change-Id: I7bb583674641efed210d3cd5b86af27d7bb48e97
Signed-off-by: SATO taichi <ryushi@gmail.com>
2014-01-17 15:37:39 +09:00
Stefan Lay 3db6e05e52 Fix fast forward rebase with rebase.autostash=true
The folder .git/rebase-merge was not removed in this case. The
repository was then still in rebase state, but neither abort nor
continue worked.

Bug: 425742
Change-Id: I43cea6c9e5f3cef9d6b15643722fddecb40632d9
2014-01-15 13:23:49 +01:00
Robin Stocker c096b42e3e Add setContains to ListBranchCommand (branch --contains)
To correspond to the behavior of "git branch", also return HEAD in case
it is detached.

Bug: 425678
Change-Id: Ie615731434d70b99bd18c7a02e832c0a2c3ceef3
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-01-14 17:45:50 +01:00
Tomasz Zarna 0a38e08c1c fix link to EWAHCompressedBitmap in javadoc of SimpleDataInput/Output
Change-Id: Iaa07bb23f163b75e222bc6a5ce3acc91ffef435e
Signed-off-by: Tomasz Zarna <tomasz.zarna@tasktop.com>
2014-01-14 10:19:50 +01:00
Colby Ranger ce5fd525be Upgrade javaewah to version 0.7.9
Package was renamed, so I had to update the imports. Also, I verified
bitmap serialization was still compatible.

Change-Id: I161ad3875b963b56001beab477ef8d072accee4f
2014-01-13 11:47:58 -08:00
Robin Rosenberg 4ceb25b602 Tag som non-localizable strings with NON-NLS
Change-Id: I6882c98c2785f38241a81ba5b93892aab79690a5
2014-01-10 14:06:50 +01:00
Robin Rosenberg ed7e1eff07 Suppport the GIT_CONFIG_NOSYSTEM environment variable
Change-Id: If3cc05931683d396b5ae2ea8952adceeb9a82ab9
2014-01-06 18:49:37 +01:00
Jonathan Nieder 8a4cf2e0f8 archive: Use an empty directory for submodules
When encountering a submodule entry, "jgit archive" tries to write its
content verbatim as an entry to the archive, which fails with a
JGitInternalException wrapping a MissingObjectException because the
submodule repository commits are typically not part of the
superproject.

When a subproject is available (for example because it has been
checked out as a subdirectory of a superproject worktree), it would be
nice to recurse into it and make one archive recording the state of
the entire project.  Unfortunately sometimes the subproject is not
available or it can be hard to find (e.g., it can be on another
server).  Even when some subprojects are available, "jgit archive"
should not produce different output for the same tree depending on
which subprojects it has easy access to, so there is no obvious good
default behavior that recurses without relying on access to all
subprojects.

Instead, replace each submodule entry with a placeholder empty
directory.  "git archive" does the same.

Change-Id: I1295086037b77fc948b3f93c21d47341e25483e5
Signed-off-by: Jonathan Nieder <jrn@google.com>
2013-12-27 09:02:53 -08:00
Jonathan Nieder 2ecc27db92 archive: Include entries for directories
Entries for directories are optional and mostly wasted space in most
archive formats (except as a place to hang ownership and filesystem
permissions), but "git archive" includes them.  Follow suit.

This will make it easier in a later change to include empty
directories as placeholders for missing submodules.

Change-Id: I1810c686bcc9eb4d73498e4d3e763e18787b088a
Signed-off-by: Jonathan Nieder <jrn@google.com>
2013-12-27 08:55:39 -08:00
Jonathan Nieder f2abbd0ea9 archive: Prepend a specified prefix to all entry filenames
Common practice when distributing tarballs is to prefix all entries
with a single directory name so when the tarball is extracted it all
falls neatly into a single directory.  Add a setPrefix() method to
ArchiveCommand to support this.

Change-Id: I16b2832ef98c30977f6b77b646728b83d93c196f
Signed-off-by: Jonathan Nieder <jrn@google.com>
2013-12-17 11:22:46 -08:00
Matthias Sohn aad7dee3ef Merge branch 'stable-3.2'
* stable-3.2:
  Canonicalize worktree path in BaseRepositoryBuilder if set via config
  Add missing @since tags for new public methods in Config
  Don't use API exception in RebaseTodoLine
  Fix aborting rebase with detached head
  Add recursive variant of Config.getNames() methods
  Prepare post 3.2.0-m3 builds
  JGit v3.2.0.201311130903-m3

Change-Id: Iad6e284e0fe2c7950f156372b334e47ebd82f3f7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-12-13 12:55:59 +01:00
Robin Stocker 0ce61caefb Canonicalize worktree path in BaseRepositoryBuilder if set via config
This is the case for submodules in .git/modules, which typically have a
worktree config of "../../../dir". This can confuse callers, which e.g.
try to call Repository.stripWorkDir with it.

Bug: 423644
Change-Id: I0c00953f73f9316a66d0fc10eab52d8779c88f00
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-12-12 02:21:41 +01:00
Matthias Sohn be7942f2ba Add missing @since tags for new public methods in Config
Change-Id: I3b7937577c897a7e298ee431bd8c052cdb293dd9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-12-11 23:27:36 +01:00
Christian Halstrick ea04d2329d Don't use API exception in RebaseTodoLine
This came up while testing the proposed buck build for jgit. With buck
we can introduce smaller modules to allow for more concurrency during
build and to better control inner structure of jgit. Trying to put the
porcelain API into a different module than lower level implementation
classes failed since RebaseTodoLine used a porcelain API exception
causing a dependency cycle on the proposed modules. Using an exception
defined on the same abstraction level fixes this problem.

Change-Id: I26a5353e1a8fc23e67d8ce61309bd964f7665bcb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2013-12-11 23:27:36 +01:00
Robin Rosenberg 3a063a0ed4 Merge "Fix aborting rebase with detached head" into stable-3.2 2013-12-10 16:15:55 -05:00
Stefan Lay e90438c0e8 Fix aborting rebase with detached head
Bug: 423670 
Change-Id: Ia6052867f85d4974c4f60ee5a6c820501e8d2427
2013-12-10 15:54:48 +01:00
Matthias Sohn 2e0d178855 Add recursive variant of Config.getNames() methods
These methods allow to find all configuration entry names for a given
section or section/subsection searching recursively through all base
configurations of the given configuration.

These methods are needed to calculate the names for the effective
configuration of a git repository which combines the configuration entry
names found in the repository, global and system configuration files

Bug: 396659
Change-Id: Ie3731b5e877f8686aadad3f1a46b2e583ad3b7c6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-12-06 14:27:42 +01:00
Matthias Sohn b14a939718 Prepare 3.3.0-SNAPSHOT builds
Change-Id: I7c7e7c1beec0c5d15b96c14c73ce93e3f09855c8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-12-05 22:42:47 +01:00
Stefan Lay f86a488e32 Implement rebase.autostash
This feature was introduced in native git with version 1.8.4.

Bug: 422951
Change-Id: I42f194174d64d7ada6631e2156c2a7bf93b5e91c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-12-04 22:02:22 +01:00
Christian Halstrick 77432969d3 Merge "More helpful InvalidPathException messages (include reason)" 2013-12-04 03:23:56 -05:00
Robin Stocker e0502ebb03 More helpful InvalidPathException messages (include reason)
Instead of just a generic "Invalid path: $path", add a reason for the
cases where it's not obvious what the problem is (e.g. "aux" being
reserved on Windows).

Bug: 413915
Change-Id: Ia6436bd2560e4f049c92d9aac907cb87348605e0
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-12-03 23:10:05 +01:00
Robin Stocker f4dae204a6 Fix IgnoreRule#isMatch returning wrong result due to missing reset
The matcher has to be reset before using it, as was already done in the
other cases.

Bug: 423039
Change-Id: I87abaa7ad7f0aac8651db6e88d41427cacb4d776
Also-by: Ondrej Vrabec <ovrabec@netbeans.org>
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-12-03 22:30:14 +01:00
Robin Stocker 7dc8a4f089 Fix exception on conflicts with recursive merge
When there are conflicts with a recursive merge, the conflicting paths
are stored in unmergedPaths (field in ResolveMerger). Later, when the
MergeResult is constructed in MergeCommand, getBaseCommit is called,
which computes the merge base a second time.

In case of RecursiveMerger, getBaseCommit merges the multiple merge
bases into one. It does this not by creating a new ResolveMerger but
instead calling mergeTrees. The problem with mergeTrees is that at the
end, it checks if unmergedPaths is non-empty and returns false in that
case.

Because unmergedPaths was already non-empty because of the real merge,
it thinks that there were conflicts when computing the merge base again,
when there really were none.

This can be fixed by storing the base commit when computing it and then
returning that instead of computing it a second time.

Note that another possible fix would be to just use a new ResolveMerger
for merging the merge bases instead. This would also remove the need to
remember the old value of dircache, inCore and workingTreeIterator (see
RecursiveMerger#getBaseCommit).

Bug: 419641
Change-Id: Ib2ebf4e177498c22a9098aa225e3cfcf16bbd958
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-12-03 21:05:37 +01:00
John Ross 99608f0b9a Fix broken symbolic links on Cygwin.
Bad files from symbolic links were being generated on Cygwin and
required resolution by the appropriate FS. Pass FS to getSymRef and call
FS.resolve before asking if the file is absolute.

Bug: 419494
Change-Id: I74aa7a285954cade77f41df6f813b6dafb5d6cd7
Signed-off-by: John Ross <jwross@us.ibm.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-12-02 16:31:45 +01:00
Stefan Lay 591998c2d6 Do not allow non-ff-rebase if there are uncommitted changes
With this change jgit checks for uncommitted changes before a rebase is
started. This is also done by native git. One reason is that an abort
would override such changes. The check is skipped for a non-interactive
rebase when it will result in a fast-forward. In this case there can be
only checkout conflicts but no merge conflicts, so there cannot be an
abort which overrides uncommitted changes.

Bug: 422352
Change-Id: I1e0b59b2a4d80a686b67a6729e441924362b1236
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-12-02 09:45:15 +01:00
Christian Halstrick af40635aba Fix handling of file/folder conflicts during a checkout
JGit was not handling certain file/folder conflicts during a checkout
correctly. This was reported by Axel Richard in
http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg02358.html.
This commit fixes this problem.

Still JGit behaves intentionally different than native git.
If HEAD contains a tree, and workingtree, Index and Merge contain a file
with same content ... then JGit allows a conflict free checkout of
Merge. Native git always complains that it doesn't want to overwrite
local changes. But there is no need to update the working tree because
Index and Merge are already equal.

A shell script which shows how native git behaves can be found here.
https://gist.github.com/chalstrick/7694959#file-gistfile1-sh

Change-Id: Ifd6a68974d61cd4fa23bc575f3a40773db66cafc
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2013-11-29 22:32:36 +01:00
Robin Stocker 53c8ac0c60 Mention null return in Javadoc of Config#getString
Change-Id: Ibf09395fb3ac4d5d8f47872ed8f239c821bbee7a
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-11-29 17:16:23 +01:00
Stefan Lay dcd0dd4d9e Fix applying stash on other commit
Applying a stash on another commit failed because the merge base for the
cherry-pick of the stashed index state was not corectly set.

Bug: 422684
Change-Id: I9355352b2b9a7abefa3248ca3c17a9301177d0d6
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2013-11-29 10:36:53 -05:00
Stefan Lay ec0d78d093 Use static factory methods instead of overloaded constructors
Change-Id: Ib10e0798dcfb9f1b611caec393926c95eff4c2a2
2013-11-29 09:34:03 +01:00
Matthias Sohn 7f7dd171df Cache SimpleDateFormat in GitDateParser per locale
Otherwise switching to another locale yields wrong results when parsing
date strings in GitDateParser. Since the MockSystemReader explicitly
uses english locale the tests need to specify the locale to be used when
parsing date strings.

Bug: 420772
Change-Id: I313ef6b1e9ef3bfb43d929ce34712ebd21f2cd9c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-11-23 22:06:08 -05:00
Stefan Lay 8339a07e83 Fix FIXUP error for blank lines in interactive rebase
Empty lines of discarded commit messages were added to the commit
message because they were not commented out properly.

Bug: 422246
Change-Id: I263e8a6b30a3392d8b4f09c0695505068a0a485d
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2013-11-22 16:50:44 -05:00
Stefan Lay 4feace2b9e Fix parsing Rebase todo lines when commit message is missing
Bug: 422253
Change-Id: I9739b16c91d2df31a481360a712d3479a4eeee2e
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2013-11-21 14:47:24 +01:00
Christian Halstrick 7dce16018e Add close() method to API
The API in org.eclipse.jgit.api does allow to open repositories but it
did not allow to close them. This commit fixes this and allows
API users to close a repository without having to use lower-level
classes.

Bug: 420502
Change-Id: I866225cc8534ae5916113fa24eb1c7513fd4472e
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-11-20 00:16:39 +01:00
Robin Rosenberg 216d9981f5 Merge "Don't delete .idx file if .pack file can't be deleted" 2013-11-17 23:50:41 -05:00
Robin Stocker 97b8115be4 Document that path parameters should use '/' as separator
Bug: 421600
Change-Id: I505d994518aa608aaa797252433b6c97e2def5b4
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-11-15 19:20:02 +01:00
Robin Stocker 04f19353fd Improve Javadoc for typeHint parameter
Link to an example type constant.

Change-Id: I214ab834fa02901a38e6048a94a5224b30c5d93f
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-11-14 11:12:29 +01:00
Colby Ranger f3b80f1a74 Do not update the ref hot bit when checking isIndexLoaded
DfsPackFile.isIndexLoaded() uses the DfsBlockCache.Ref.get() method
to check if the index loaded. However, using the get() method marks
a hot bit in the cache, which can cause the index to never be unloaded
and seem hotter than it really is. Add a has() method which only
checks if the value is not null and does not update the hot bit.

Change-Id: I7e9ed216f6e273e8f5d79ae573973197654419b4
2013-11-13 15:19:03 -08:00
Christian Halstrick 8da939221c Don't delete .idx file if .pack file can't be deleted
If during an garbage collection old packfiles are deleted it could
happen that on certain platforms the index file can be deleted but the
packfile can't be deleted (because someone locked the file). This led
to repositories with packfiles without corresponding index files. Those
zombie-packfiles potentially consume a lot of space on disk and it is
never tried to delete them again. Try to avoid this situation by
deleting packfiles first and don't try to delete the other files if we
can't delete the packfile. This gives us the chance to delete the
packfile during next GC.

This commit only improves the situation - there is still the chance for
orphan files during packfile deletion. We don't have an atomic delete
of multiple files .

Change-Id: I0a19ae630186f07d0cc7fe9df246fa1cedeca8f6
2013-11-13 08:59:43 +01:00
Matthias Sohn 05f308af48 Merge "Add missing @since tags" 2013-11-12 18:09:02 -05:00
Matthias Sohn b41b5d723e Add uses directives to ensure OSGi wires jgit bundles correctly
See
http://spring.io/blog/2008/10/20/understanding-the-osgi-uses-directive/

Bug: 420903
Change-Id: I3706a2b8f695d4ce0ee2333722ed7b8d31032f1e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-11-12 23:11:16 +01:00
Matthias Sohn 2765cc1871 Grant access to internal jgit package to org.eclipse.jgit.junit
This silences some discouraged access warnings issued since
TestRepository uses PackWriter which is in an internal package.

Change-Id: Ic9c4631e237c2fe1996c518328ecc2a9ab5c348b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-11-10 15:59:41 -05:00
Matthias Sohn d4a42f472a Remove duplicate package export
Change-Id: I185610f12069cd4ce1b27650581375b6b3019d2f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-11-10 15:59:04 -05:00
Matthias Sohn 7cae388118 Add missing @since tags
Change-Id: Ic4fabec818d6fe336d3256ddc95934271272914a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-11-09 01:16:46 +01:00
Stefan Lay 979e346711 Interactive Rebase: Do actions if there were conflicts
If a commit was marked for edit, reword, squash or fixup, but the
interactive rebase stopped because of a conflict, the step was not done
after conflict resolution. This is done now.

Change-Id: If8e7ccc50469165744f2b8a53d180f9ba0f72330
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-11-08 23:43:11 +01:00
Stefan Lay 18069ffe8c Rebase interactive should finish if last step is edit
When the last step was an edit step, rebase interactive did not finish
after continuing the rebase. Instead, it returned with the status
FAST_FORWARD.

Change-Id: Ib19857474ac089dfeaae665ad5e95c66c21099b0
2013-11-06 09:43:31 +01:00
Matthias Sohn 34fbd814d4 Merge changes I40f2311c,I3c419094
* changes:
  Add additional RebaseResult for editing commits
  Add Squash/Fixup support for rebase interactive in RebaseCommand
2013-11-05 17:03:35 -05:00
Shawn Pearce b8eac43c0f Merge changes I85470d1d,I43711486,Ie6ade781,Ic9ab2b6e,Iebe50933,Id6fac253,Ia6becf30,I2af8b0ac
* changes:
  Use absolute paths for file:// URIs in tests
  Use getPath() in FileResolverTest
  Extract protocol constants to a common class
  Move repeat() to utility class for tests
  Remove hardcoded target/trash from test cases
  Remove dependency on StatusCommandTest
  Remove dependency on DiffFormatterReflowTest
  Remove unnecessary import of BaseConnection in MessageWriter
2013-11-05 12:41:12 -05:00
Stefan Lay cce2561e9f Add additional RebaseResult for editing commits
With the new RebaseResult.EDIT a client can now distinguish if rebase
stopped due to a conflict or because the commit was marked for edit in
an interactive rebase.

Change-Id: I40f2311cf43ed5f290dcda65a7bd85ba770a85f5
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2013-11-05 18:05:03 +01:00
Tobias Pfeifer 765896febb Add Squash/Fixup support for rebase interactive in RebaseCommand
The rebase command now supports squash and fixup. Both actions are not
allowed as the first step of the rebase.

In JGit, before any rebase step is performed, the next commit is
already cherry-picked. This commit keeps that behaviour. In case of
squash or fixup a soft reset to the parent is perfomed afterwards.

CQ: 7684
Bug: 396510
Change-Id: I3c4190940b4d7f19860e223d647fc78705e57203
Signed-off-by: Tobias Pfeifer <to.pfeifer@web.de>
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-11-05 18:05:02 +01:00
Matthias Sohn 6e3e5e4809 Declare that org.eclipse.jgit.transport uses com.jcraft.jsch
This should prevent class cast problems caused by jgit and egit bundles
wiring to different versions of com.jcraft.jsch.

Bug: 420903
Change-Id: Icabe40209ea07369e2b7eee31952d131aef3fbf1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-11-05 10:39:10 +01:00
Christian Halstrick b686fa45b6 Merge "testMaliciousPathEmpty fails on Windows" 2013-11-04 07:39:43 -05:00
Shawn Pearce b0dbb78e7d Extract protocol constants to a common class
This avoids the server from referencing the client code directly.

Change-Id: Ie6ade781b5a689646ad8b0b2988ef2b544412195
2013-11-01 19:57:47 -07:00
Shawn Pearce 3bc289bcfe Remove unnecessary import of BaseConnection in MessageWriter
Change-Id: I2af8b0ac0f9fbf2814eca23990ae527baf040539
2013-11-01 19:57:47 -07:00
Tobias Pfeifer da9db6b20c Enable to prepare interactive rebase and then start it explicitly
Add Operation.PROCESS_STEPS to RebaseCommand to enable starting
interactive rebase explicitly after rebase steps have been configured.

Change-Id: I2d6f0de82010ea6523fbce6fb4501e847bdcdddc
Signed-off-by: Tobias Pfeifer <to.pfeifer@web.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-11-01 23:43:59 +01:00
Robin Rosenberg 98bc384d2b testMaliciousPathEmpty fails on Windows
Checking of spaces at the end of the file name caused the
test to fail for Windows only.

Bug: 396662
Change-Id: I47bcccb0fa32ce606276c3f30d454851d115ca11
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2013-11-01 16:43:46 +01:00
Tobias Pfeifer baab84836a Parse commitId and shortMessage of a commented out line in rebase todo
A rebase todo file consists of regular non-comment action lines and
comment lines. In case that a regular action line has been commented out
(i.e. prefixed with a hash '#'), the RebaseTodoLine that is representing
this line should hold the values for commitId and shortMessage even
though it's a comment line. This allows to switch between comment and
non-comment easily even after the file has been persisted and reread.

Change-Id: I56ec2ba08eaf3772e2d74d937dd496209a744d4b
Signed-off-by: Tobias Pfeifer <to.pfeifer@web.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-10-31 14:25:29 +01:00
Christian Halstrick c3873b584f Enhance reading of git-rebase-todo formatted files
Reading and writing files formatted like the git-rebase-todo files was
hidden in the RebaseCommand. Certain constructs (like leading tabs and
spaces) have not been handled as in native git. Also the upcoming
rebase interactive feature in EGit needs reading/writing these files
independently from a RebaseCommand.

Therefore reading and writing those files has been moved to the
Repository class. RebaseCommand gets smaller because of that and doesn't
have to deal with reading/writing files.

Additional tests for empty todo-list files, or files containing comments
have been added.

Change-Id: I323f3619952fecdf28ddf50139a88e0bea34f5ba
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Also-by: Tobias Pfeifer <to.pfeifer@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-10-31 14:22:20 +01:00
Michael Nelson 9e9f00df9e Support extension of TransportHttp
This allows subclasses to configure the HTTP connection (for example,
to add headers to the request).

Bug: 400724
Change-Id: I6f9d699e158a7b9d813c8fa8d273992a28994e41
Signed-off-by: Michael Nelson <michael.nelson@tasktop.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2013-10-26 18:20:27 -04:00
Matthias Sohn 72c7618571 Add / fix @since tags
Change-Id: I1e5bea968b3c79df4f600b75fde5b547ebadde36
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-10-24 08:32:47 +02:00
Robin Stocker 09711a4bb9 Make sure SystemReader is reset after test is run
Otherwise the MockSystemReader from the test setup is active for other
tests.

Change-Id: I7caf693bd692d06936e29efd4dc4aabb48c1c39b
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-10-22 00:37:56 +02:00
Matthias Sohn b15c617d0f Describe HEAD if no explicit target was set
Change-Id: I5a5a238709df813ec07278bb3b4f9ea5c85c0883
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-10-11 00:12:44 +02:00
Matthias Sohn 3c2c8b47ff Allow to set target of DescribeCommand
Change-Id: I04805ce20cc203f5e491406c39b71e7017553b37
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-10-11 00:11:00 +02:00
Colby Ranger 06ddee1c3f Fix ServiceMayNotContinueException constructors for Java 1.5
IOException did not add a (String, Throwable) constructor until 1.5.
Instead use the String super constructor and initCause to initialize
the exception.

Fixes bug 418889

Change-Id: Ide735ecfc7d04884981b79b57a4275863ce17006
2013-10-08 10:16:45 -07:00
Colby Ranger a27529c822 Add constructors that take Throwable to ServiceMayNotContinueException.
ServiceMayNotContinueException usually wraps an underlying exception.
Add convenience constructors that take Throwable. In the case a
string is not provided, the message defaults to "internal server error",
since it may be reported to the client.

Change-Id: I15dc20306826c352f69e88afb7ed6927c12b6c1f
2013-10-07 17:31:06 -04:00
Colby Ranger 5218f7b33a Propagate IOException where possible when getting refs.
Currently, Repository.getAllRefs() and Repository.getTags() silently
ignores an IOException and instead returns an empty map. Repository
is a public API and as such cannot be changed until the next major
revision change. Where possible, update the internal jgit APIs to
use the RefDatabase directly, since it propagates the error.

Change-Id: I4e4537d8bd0fa772f388262684c5c4ca1929dc4c
2013-10-07 11:32:54 -07:00
Matthias Sohn 7995d87713 Prepare 3.2.0-SNAPSHOT builds
Change-Id: Iac6cf7a5bb6146ee3fe38abe8020fc3fc4217584
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-10-03 18:21:31 +02:00
Matthias Sohn fdc80f7cad Merge branch 'stable-3.1'
* stable-3.1:
  Prepare post 3.1.0 builds
  JGit v3.1.0.201310021548-r
  Fix order of commits in rebase todo file header
  Prepare post 3.1.0 RC1 builds
  JGit v3.1.0.201309270735-rc1
  Attempt to fix graph layout when new heads are introduced
  Prepare re-signing pgm's ueberjar to avoid SecurityException
  Use full branch name when getting ref in BranchTrackingStatus

Change-Id: Ida30175d0c058048cbe4b563aae7f85cd008db29
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-10-03 17:39:33 +02:00
Matthias Sohn da6e87bc37 Prepare post 3.1.0 builds
Change-Id: I306a3d40c6ddb88a16d17f09a60e3d19b0716962
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-10-03 17:29:00 +02:00
Matthias Sohn 16ca725b35 JGit v3.1.0.201310021548-r
Change-Id: I2170b13047d5eab7565f47f9feb1680e03b1ba09
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-10-02 22:09:19 +02:00
Matthias Sohn 0be59ab033 Merge "Added the git-describe implementation" 2013-10-02 15:45:22 -04:00
Stefan Lay c6aba99668 Fix order of commits in rebase todo file header
Change-Id: I0e41d89bbd4fc01ad3b3d05a45ee60af853bfae7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-09-29 22:17:44 +02:00
Matthias Sohn 5a2a2222ef Prepare post 3.1.0 RC1 builds
Change-Id: I060f2082ccd0c91905b6b29a49cc633a0b51a1f2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-09-27 15:54:40 +02:00
Matthias Sohn 6f0681eb9f JGit v3.1.0.201309270735-rc1
Change-Id: I48202dd461110da25f9bc159c938311fff0669e0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-09-27 13:34:51 +02:00
Kohsuke Kawaguchi f045a68a78 Added the git-describe implementation
CQ: 7609
Bug: 339246
Change-Id: I689bc0578ce3a430b9800ad84122e221c69829f4
Signed-off-by: Kohsuke Kawaguchi <kk@kohsuke.org>
Also-By: Robin Stocker<robin@nibor.org>
Also-By: Matthias Sohn <matthias.sohn@sap.com>
Also-By: Christian Halstrick <christian.halstrick@sap.com>
2013-09-27 12:37:36 +02:00
Robin Rosenberg a065a06c2a Attempt to fix graph layout when new heads are introduced
Sometime the new commit is no allocated onto a new lane leading to
the commit being drawn on the wrong branch and something that looks
like a merge.

The drawback is that this also changes existing valid graphs.

Bug: 368927
Change-Id: Ic8a8247c8a53be802c1be83850ed766b902ca646
2013-09-26 14:06:39 +02:00
Jonathan Nieder 8a51c4453d Do not close ArchiveOutputStream on error
If we encounter an I/O error while writing an archive (for example due
to the reader of an HTTP stream closing the connection), the result is
an archive with unclosed entries, causing
TarArchiveOutputStream.finish() to throw IOException("This archives
contains unclosed entries"), hiding the IOException that caused the
early termination.

The unclosed entries are fine: the same exception that occured in the
first place will probably prevent closing the entries before finishing
this partial archive that should be discarded anyway.

It would be nicer to call TarArchiveOutputStream.finish and leave the
underlying OutputStream unclosed --- all callers close it already ---
but that would be a more invasive change so we hold off for now.

Change-Id: I328ced19aa8a1888e5353cdbb6106a85fd72d5d7
Signed-off-by: Jonathan Nieder <jrn@google.com>
2013-09-23 17:31:27 -07:00
Robin Stocker aa4bbc67b3 Use full branch name when getting ref in BranchTrackingStatus
In case there is both a tag and branch called "foo", the tag is returned
if calling getRef with the short name. By using refs/heads/foo, the
branch is returned.

Bug: 417158
Change-Id: I86b4f83955586bb24774fd621f5012499cf67909
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-09-20 14:48:55 +02:00
Colby Ranger 570bba5e7a Ignore bitmap indexes that do not match the pack checksum
If `git gc` creates a new pack with the same file name, the
pack checksum may not match that in the .bitmap. Fix the PackFile
implementaion to silently ignore invalid bitmap indexes.

Fixes Issue https://code.google.com/p/gerrit/issues/detail?id=2131

Change-Id: I378673c00de32385ba90f4b639cb812f9574a216
2013-09-19 14:53:01 -07:00
Colby Ranger 7dc6c553c0 Remove unneeded packs when compacting with no new objects
Previously, the DfsPackCompactor exited without pruning the existing
packs, when no new packs were created.

Change-Id: I5e3b6f8c789706c7a982e6ae93cf7c3d4346797c
2013-09-16 11:56:02 -07:00
Robin Stocker 02bd26e5a6 ResetCommand: Allow reset on unborn branch when ref not specified
In C Git 1.8.2, "git reset" now also works on an unborn branch (no HEAD
yet) if no explicit ref was specified. In that case, it is treated as a
reset to an empty tree.

This can be useful for callers because "unborn branch" no longer has to
be special-cased to "git rm --cached".

Bug: 414870
Change-Id: Ied750116f767518ae4d48823cf00752b049a8477
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-09-13 15:13:12 +02:00
Matthias Sohn 4b8a848a47 Merge branch 'stable-3.0'
* stable-3.0:
  Prepare post 3.0.2 builds
  JGit v3.0.2.201311090911-r

Change-Id: I99a7d1072285646f7fcd4169225c1fd249ad5e37
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-09-11 23:30:05 +02:00
Matthias Sohn 3af38b4fee Prepare post 3.0.2 builds
Change-Id: Ie1bd951a2cb35d069c94dab4a62507115913764f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-09-11 16:54:32 +02:00
Matthias Sohn da3041ae73 JGit v3.0.2.201311090911-r
Change-Id: Ifaae2e3e2f1bb0504bf9e6d59983086ac19a540b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-09-11 15:15:00 +02:00
Robin Stocker 52ab578cd7 Don't treat "/" as valid ignore pattern
This matches the behavior of C Git.

Bug: 415767
Change-Id: Ifa6500f3f6a033da40c48287630b77c47b15f4a0
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-09-09 17:05:17 -04:00
Shawn Pearce c2a9f9e742 Merge "Remove unnecessary inflate stride in DfsBlock" 2013-09-04 19:13:55 -04:00
Shawn Pearce aa8d5ac26c Remove unnecessary inflate stride in DfsBlock
OpenJDK 7 does not benefit from using an inflate stride on the input
array. The implementation of java.util.zip.Inflater supplies the
entire input byte[] to libz, with no regards for the bounds supplied.
Slicing at 512 byte increments in DfsBlock no longer has any benefit.

In OpenJDK 6 the native portion of Inflater used GetByteArrayRegion
to obtain a copy of the input buffer for libz. In this use case
supplying a small stride made sense, it avoided allocating space
for and copying data past the end of the object's compressed stream.

In OpenJDK 7 the native code uses GetPrimitiveArrayCritical,
which tries to avoid copying by freezing Java garbage collection
and accessing the byte[] contents in place. On OpenJDK 7 derived
JVMs it is likely more efficient to supply the entire DfsBlock.

Since OpenJDK 5 and 6 are deprecated and replaced by OpenJDK 7
it is reasonable to suggest any consumers running JGit with DFS
support use an OpenJDK 7 derived JVM. However, JGit still targets
local filesystem support on Java 5, so it is still not reasonble to
apply this same simplification to the internal.storage.file package.

See: JDK-6751338 (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6751338)
Change-Id: Ib248b6d383da5c8aa887d9c355a0df6f3e2247a5
2013-09-04 14:54:50 -07:00
Matthias Sohn ff09a3633d Merge branch 'stable-3.0'
* stable-3.0:
  Prepare post 3.0.2-rc2 builds
  JGit v3.0.2.201309041250-rc2
  Uncomment eclipse-jar-signer plugin
  Update build to use CBI jarsigner plugin
  Update maven plugins
  Update to Orbit Kepler SR1 release R20130827064939

Change-Id: Iaa8bba21c300dd1de2b91a77cddf6727fbc66340
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-09-04 22:45:53 +02:00
Matthias Sohn 4eefa881b3 Prepare post 3.0.2-rc2 builds
Change-Id: I0e4020326c6443ba7157c18b345160cf9e1e88a7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-09-04 19:34:56 +02:00
Matthias Sohn 7c37177952 JGit v3.0.2.201309041250-rc2
Change-Id: Ie18ced75f573f140969af2a7d9edb45c76523715
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-09-04 18:55:13 +02:00
Matthias Sohn b97a35d7cf Update build to use CBI jarsigner plugin
The dash signing plugin has been retired hence we need to update our
build to use the CBI jarsigner plugin for signing build results.

Pack test classes to enable signing them.

Also re-enable pack200 for bundle org.eclipse.jgit.

WORKAROUND: there is no easy way to run tests with maven-surefire-plugin
from signed test-jar so for a quick workaround we will have to add a
build step on Hudson so that we can run tests before signing:
- first step will do "clean, verify" to compile and run tests
- second step will do "install, deploy" with profile "eclipse-sign" and
  use -DskipTests=true to skip tests since they would hit a
  SecurityException when unsigned test classes are in same package as
  signed classes under test
- third step will do "clean, install, deploy" on packaging reactor to
  build features and p2 repository with profile "eclipse-sign" to sign
  and pack200 all bundles.

TODO: Tycho doesn't suport picking up pack200 artifacts via
pomDependencies hence we need to find a way to copy them manually and
use tycho-extra's tycho-p2-extras-plugin:publish-features-and-bundles
to generate the missing p2 metadata.

Change-Id: Iec2c5ab3027a3e3f9ecc0d2f99193385177d9025
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-09-04 16:06:02 +02:00
Robin Stocker f68ffb48eb LogCommand: Remove outdated TODO and improve docs
Change-Id: I368be12e7bdc3c711e9f474ead312006513764b7
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-08-25 10:42:40 -04:00
Robin Rosenberg 99d981ce35 Update reflog like C Git during rebase (non-interactive)
Bug: 346350
Change-Id: I119766a00bc52a810c51cffaa19207cb8555ca22
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2013-08-21 14:44:48 +02:00
Christian Halstrick bd57789735 Make sure checkout is not deleting folders outside the workingtree
There was a chance that jgit deletes symbolic links which point to the
folder on top of the working tree. Make sure not to touch these
resources.

Thanks to Cedric Darloy who reported this bug on
http://www.eclipse.org/forums/index.php/m/776910/#msg_776910 and to
Ondrej Vrabec who reported bug 412489.

Bug: 412489
Change-Id: I81735ba0394ef6794e9b2b8bdd8bd7e8b9c6460f
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-08-21 14:44:47 +02:00
Robin Stocker c128100800 Fix bugs in TreeWalk#isPathSuffix used by PathSuffixFilter
* It didn't check the first character in the pattern due to a off-by-one
  error. Spotted by James Roper.
* It returned true even when pattern was longer than current path, e.g.
  it returned that ".txt" is suffix of "txt".

Bug: 411999
Change-Id: I9fbcd68a11fb57cc49956b70c387a47271a0424f
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-08-21 14:44:47 +02:00
Hiroshi Tomita 781b0b5735 Check parentFile is not null
parentFile becomes null when f is relative path, such as ".".

This patch avoids NullPointerException in such case.

Change-Id: I4752674b1daab6eedd7c3650c7749462810eaffd
Signed-off-by: Hiroshi Tomita <tomykaira@gmail.com>
2013-08-21 14:44:47 +02:00
Hiroshi Tomita 27c1c51079 Update HEAD in cherry-picking several commits
Without update, index is wrongly detected to be dirty
when picking the second commit.

Change-Id: Idf47ecb33e8bd38340d760806d629f67be92d2d5
Signed-off-by: Hiroshi Tomita <tomykaira@gmail.com>
Bug: 411963
2013-08-21 14:44:47 +02:00
Alex Rukhlin 81db591034 Fix HTTP response processing for WWW-Authenticate headers
The original code was able to process only one WWW-Authenticate
header in an HTTP response, and if this header was not one of
two expected, authentication failed regardless of that there
could be other headers in the response.

All WWW-Authenticate headers in an HTTP response have to be
browsed to find one of supported, i.e. Basic or Digest.
By that if both are present, the Digest one should be used
as more preferable.

Bug: 357719
Change-Id: Icf601a41fec63f7d40308f3c85aaa4f71a7c095b
Signed-off-by: Alex Rukhlin <arukhlin@microsoft.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-08-21 14:44:47 +02:00
Dave Borowitz bbea37a9e3 Don't skip want validation when the client sends no haves
Change-Id: I5e80b3befca5cf1dcb06075862d6d48e6491cc0f
2013-08-21 14:44:46 +02:00
Robin Rosenberg ec2202f563 Recognize CRLF when parsing the short message of a commit or tag
Bug: 400707
Change-Id: I9b09bb88528af465018fc0278f5441f7e6b75986
2013-08-21 14:44:46 +02:00
Matthias Sohn fdd1ac930e Prepare 3.0.2-SNAPSHOT builds
Change-Id: I3287609a90f068017cc62f4fd7738651e0663081
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-08-19 01:39:41 +02:00
Robin Stocker 9b26e4bffb Enable LsRemoteCommand to work without local repository
It's supported by C Git and can be useful.

Bug: 413388
Change-Id: I12c6c10e791cc09ee271d89eb8b8d32f53e385db
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-08-13 00:04:37 +02:00
Robin Stocker 6fb8d2345b Add missing @since tag for replaceLineBreaksWithSpace
Change-Id: Ibd9d9ba609a2cd7707b985cdb07405dce0422aab
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-08-12 21:34:50 +02:00
Matthias Sohn 7baeffc581 Allow the command line bundle to access internal jgit packages
Change-Id: Id1e11a21fdcbd8cb0f2f8c22e7ab253e8df65d2f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-08-11 00:51:42 +02:00
Robin Rosenberg c58405b0c3 Merge "Recognize CRLF when parsing the short message of a commit or tag" 2013-08-10 18:31:01 -04:00
Robin Rosenberg b6e5189c4e Merge "Added characters to be escaped in file name patterns" 2013-08-10 17:32:20 -04:00
Lars Vogel 594408e522 Add missing @since tags
Change-Id: I9754e2124c0fe6ad2dbde5597c3ed10f1c3efef5
Signed-off-by: Lars Vogel <Lars.Vogel@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-08-10 01:23:27 +02:00
Colby Ranger ae1f46989c Advertise capabilities with no refs in upload service.
With reference hiding, it is possible for a repository to appear
empty when all refs are hidden. This causes capabilities to not be
advertised either, since they are published with the first reference,
breaking fetch by SHA1 support.

Always advertise the capabilites by publishing the symbolic capabilities
reference when the repository has no references to advertise (similar to
the receive service).

Change-Id: I8060e430ee03571dc51239e702864c85e888505c
2013-08-08 11:10:40 -04:00
Shawn Pearce 15adcefb73 Allow UploadPack requests with no options
UploadPack can be invoked with no capabilities selected by the
client if the client is an ancient version of Git that nobody in
their right mind should still be using. Or if the client is very
broken and does not want to use any of the newer features added to
the protocol since its inception.

Change-Id: I3baa6f90e6a41a37a8eab8449a3cc41f4efcb91a
2013-08-07 15:44:02 -07:00
Colby Ranger 69761dbcdd Send no-progress option with NullProgressMonitor.
The NullProgressMonitor does not report progress anywhere. Inform the
server not to send progress by enabling the no-progress capability.

Change-Id: Id18dbc754c814d1a5534a284c947030bf201c569
2013-08-05 14:56:17 -07:00
Shawn Pearce ffb2600dd5 Merge "Change RequestValidator parameter to ObjectId list" 2013-08-02 18:15:19 -04:00
Greg Hill 1471fb4e0f Change RequestValidator parameter to ObjectId list
Instead of RevObject list, this allows a custom request validator to be called
on SHA-1's corresponding to objects that may not exist in repository storage

Change-Id: I19bb667beff0d0c144150a61d7a1dc6c9703be7f
Signed-off-by: Greg Hill <greghill@google.com>
2013-08-02 12:42:54 -07:00
Christian Trutz f677b07b98 Add setter for ProgressMonitor to StatusCommand
This is useful if Git.status() is a long running command.

Change-Id: I6bdbf347a688043d549c1f091fb4a264a6c7024e
Signed-off-by: Christian Trutz <christian.trutz@gmail.com>
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-07-28 16:01:46 +02:00
Robin Stocker a76a4acf87 Implement open(URIish) for TransportLocal
Can be used for listing remote refs for a repository on the file system
without having a local repository.

Bug: 413400
Change-Id: I397f5092c5eafb62236e9f9e74d9183f56903cc6
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2013-07-21 22:27:46 -05:00
Robin Stocker 8b6bbf094f Fix NPE in openFetch on Transport without local repository
Setting the walk and other fields to null will result in NPEs when the
user e.g. calls fetch on the connection, but at least the advertised
refs can be read like that without having a local repository.

Bug: 413389
Change-Id: I39c8363e81a1c7e6cb3412ba88542ead669e69ed
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2013-07-21 22:15:31 -05:00
Robin Rosenberg a2b33a8ac3 Add NON-NLS comments for some obviously untranslatable strings
Change-Id: I2d1076b46695dac84961b8ae663bfc5cb123b3a3
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2013-07-21 22:06:34 -05:00
Robin Rosenberg 60e01cff2f Update reflog like C Git during rebase (non-interactive)
Bug: 346350
Change-Id: I119766a00bc52a810c51cffaa19207cb8555ca22
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2013-07-21 21:54:41 -05:00
Robin Stocker 7033179440 Improve documentation of PathSuffixFilter
Change-Id: I1077dbb1f10c7cc687c0d1b8a8e8f763ca96977c
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2013-07-21 21:47:00 -05:00
Christian Halstrick 06dd0e9e27 Add path option to StatusCommand
Allow filtering of the status. Only files which match given paths are
inspected and only their state is reported.

Change-Id: I3c4b1b46bf297cd4ebdb4997cfa14c8752a36411
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2013-07-21 21:39:53 -05:00
Robin Stocker f5be93d003 Fix MERGED_NOT_COMMITTED toString
It had a typo (commited) and was not in the style of the others.

Change-Id: Ia1be1c70b13bb2f3da80c8e8239c5f254070fe60
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-07-18 20:05:29 +02:00
Matthias Sohn 459fd7d4bb Merge "Add missing @since tags" 2013-07-12 18:09:22 -04:00
Christian Halstrick de00ec94d8 Merge "Fix bugs in TreeWalk#isPathSuffix used by PathSuffixFilter" 2013-07-11 02:32:37 -04:00
Matthias Sohn 58a5b6d0c6 Add missing @since tags
Change-Id: I6f672249d7ca014c63fb939cd0836689eb27ab90
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-07-11 00:18:48 +02:00
Christian Halstrick f45288e7c4 Add tests for DirCacheCheckout and symlinks
DirCacheCheckout had a bug when the parentdirectory of a worktree was a
symlink. DirCacheCheckout was deleting those symlinks under certain
conditions. This was fixed in I81735ba0394ef6794e9b2b8bdd8bd7e8b9c6460f
without a test because previously it was hard to setup tests containing
symlinks.

BUG: 412489
Change-Id: I2513166af519d6fc01d1eae3976ad6cff6f98530
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-07-10 23:12:31 +02:00
Dave Borowitz 4af82ed04c Merge changes If386fe25,I52a17499,Id12e7f00,I264e028a,I0d52af8a,I0d0cc4f8
* changes:
  UploadPack: allow custom RequestValidator instances
  UploadPack: refactor want validation
  UploadPack: set RefFilter from TransportConfig
  UploadPack: configure RequestPolicy with TransportConfig
  UploadPack: advertise allow-tip-sha1-in-want
  Add RequestPolicy.TIP to allow fetching non-advertised ref tips
2013-07-10 14:50:41 -04:00
Christian Halstrick 4b1f368033 Make sure checkout is not deleting folders outside the workingtree
There was a chance that jgit deletes symbolic links which point to the
folder on top of the working tree. Make sure not to touch these
resources.

Thanks to Cedric Darloy who reported this bug on
http://www.eclipse.org/forums/index.php/m/776910/#msg_776910 and to
Ondrej Vrabec who reported bug 412489.

Bug: 412489
Change-Id: I81735ba0394ef6794e9b2b8bdd8bd7e8b9c6460f
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-07-10 11:38:03 +02:00
Robin Stocker 56ee811780 Fix bugs in TreeWalk#isPathSuffix used by PathSuffixFilter
* It didn't check the first character in the pattern due to a off-by-one
  error. Spotted by James Roper.
* It returned true even when pattern was longer than current path, e.g.
  it returned that ".txt" is suffix of "txt".

Bug: 411999
Change-Id: I9fbcd68a11fb57cc49956b70c387a47271a0424f
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-07-08 10:53:50 +02:00
Hiroshi Tomita 8e307cde56 Check parentFile is not null
parentFile becomes null when f is relative path, such as ".".

This patch avoids NullPointerException in such case.

Change-Id: I4752674b1daab6eedd7c3650c7749462810eaffd
Signed-off-by: Hiroshi Tomita <tomykaira@gmail.com>
2013-07-05 09:09:04 +09:00
Dave Borowitz 360d8624ca UploadPack: allow custom RequestValidator instances
Make the existing concrete implementations public as well so custom
implementations may delegate to them where appropriate. Treat all custom
implementations as providing allow-tip-sha1 in want.

Change-Id: If386fe25c0d3b4551a97c16a22350714453b03e9
2013-07-03 15:44:42 -07:00
Dave Borowitz 68ccc5d213 UploadPack: refactor want validation
Associate each RequestPolicy with an implementation of a
RequestValidator interface that contains the validation logic. The
checkWants method is only called if there are wants that were not
advertised, since clients may always request any advertised want
according to the git protocol. Calling the method only once at the
end of parsing the want list also means policy implementations can be
stateful, unlike the previous switch statement inside a loop.

For the special handling of unidirectional pipes, simply check
isBiDirectional() and delegate to other implementations if necessary.

Change-Id: I52a174999ac3a5aca46d3469cb0b81edd1710580
2013-07-03 15:14:29 -07:00
Dave Borowitz e74751769e UploadPack: set RefFilter from TransportConfig
Teach TransportConfig to respect uploadpack.hiderefs, which is new in
C git 1.8.2.

Change-Id: Id12e7f00b9a60258e996410f67fa10616459f53f
2013-07-03 15:10:39 -07:00
Dave Borowitz e599af1900 UploadPack: configure RequestPolicy with TransportConfig
C git 1.8.2 supports setting the equivalent of RequestPolicy.TIP with
uploadpack.allowtipsha1. Parse this into TransportConfig and use it
from UploadPack. An explicitly set RequestPolicy overrides the config,
and the policy may still be upgraded on a unidirectional connection to
avoid races.

Defer figuring out the effective RequestPolicy to later in the
process. This is a minor semantic change to fix a bug: previously,
calling setRequestPolicy(ADVERTISED) _after_ calling
setBiDirectionalPipe(true) would have reintroduced the race condition
otherwise fixed by 01888db892.

Change-Id: I264e028a76574434cecb34904d9f5944b290df78
2013-07-03 15:09:55 -07:00
Dave Borowitz b4b84a84bd UploadPack: advertise allow-tip-sha1-in-want
This protocol capability, new in C git 1.8.2, corresponds to
RequestPolicy.TIP, so advertise it if that request policy was set.

Change-Id: I0d52af8a7747e951a87f060a5124f822ce1b2b26
2013-07-03 15:09:55 -07:00
Dave Borowitz fee679b587 Add RequestPolicy.TIP to allow fetching non-advertised ref tips
Users of UploadPack may set a custom RefFilter or AdvertisedRefsHook
that limits which refs are advertised, but clients may learn of a
SHA-1 that the server should have as a ref tip through some
alternative means. Support serving such objects from the server side
with a new RequestPolicy.

As with ADVERTISED, we need a special relaxed RequestPolicy to allow
commits reachable from the set of valid tips for unidirectional
connections.

Change-Id: I0d0cc4f8ee04d265e5be8221b9384afb1b374315
2013-07-03 15:09:55 -07:00
Robin Stocker 21b3a16ab7 Merge "Update HEAD in cherry-picking several commits" 2013-07-02 07:12:32 -04:00
Colby Ranger 6cc532a43c Use a bucket sort for PackReverseIndex.
Previously it took 1200ms to create a reverse index (sorted by offset).
Using a simple bucket sort algorithm, that time is reduced to 450ms.
The bucket index into the offset array is kept, in order to decrease
the binary search window.

Don't keep a copy of the offsets. Instead, use nth position
to lookup the offset in the PackIndex.

Change-Id: If51ab76752622e04a4430d9a14db95ad02f5329d
2013-07-01 09:23:29 -07:00
Hiroshi Tomita 6845bb5b3e Update HEAD in cherry-picking several commits
Without update, index is wrongly detected to be dirty
when picking the second commit.

Change-Id: Idf47ecb33e8bd38340d760806d629f67be92d2d5
Signed-off-by: Hiroshi Tomita <tomykaira@gmail.com>
Bug: 411963
2013-07-01 22:37:48 +09:00
Colby Ranger 903fb9c739 Implement get nth offset in PackIndex.
Currently, the offset can only be retrieved by ObjectId or iterating all
of the entries. Add a method to lookup the offset by position in the
index sorted by SHA1.

Change-Id: I45e9ac8b752d1dab47b202753a1dcca7122b958e
2013-06-28 15:36:20 -07:00
Matthias Sohn a2e5653d5a Merge "Add missing @since tag" 2013-06-26 19:35:42 -04:00
Alex Rukhlin 98dd6e6abd Fix HTTP response processing for WWW-Authenticate headers
The original code was able to process only one WWW-Authenticate
header in an HTTP response, and if this header was not one of
two expected, authentication failed regardless of that there
could be other headers in the response.

All WWW-Authenticate headers in an HTTP response have to be
browsed to find one of supported, i.e. Basic or Digest.
By that if both are present, the Digest one should be used
as more preferable.

Bug: 357719
Change-Id: Icf601a41fec63f7d40308f3c85aaa4f71a7c095b
Signed-off-by: Alex Rukhlin <arukhlin@microsoft.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-06-23 23:45:42 +02:00
Dave Borowitz 84d2738ff2 Don't skip want validation when the client sends no haves
Change-Id: I5e80b3befca5cf1dcb06075862d6d48e6491cc0f
2013-06-21 16:14:30 -07:00
Matthias Sohn d66dad2a94 Add missing @since tag
Change-Id: I80cfc3e81d5cebf810f36ddf2760aee955c6f50a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-06-20 09:52:11 +02:00
Dave Borowitz b646578d89 Add a method to DfsOutputStream to read as an InputStream
Change-Id: I0ec1f17a88bc14f22c10f9bc8d6f5b5118410e3a
2013-06-19 09:36:10 -07:00
Robin Stocker 01ebfa6c17 Disable warning about assigning to parameter
See change I08bed4275af9ec52aa4d7054067ac82f6a3c9781, where fixing such
warning lead to complaints.

If fixing is not wanted, disable it instead.

Change-Id: If31d4028fa1c6377a11e83ed5688b45701cec68b
2013-06-15 15:11:54 +02:00
Robin Rosenberg b0ffacf122 Recognize CRLF when parsing the short message of a commit or tag
Bug: 400707
Change-Id: I9b09bb88528af465018fc0278f5441f7e6b75986
2013-06-14 19:52:29 -04:00
Matthias Sohn c693a232b0 Add missing @since tags
Change-Id: I7f2c155cab4b5be55f7e849ff2595c8c5d804f05
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-06-15 01:10:33 +02:00
Matthias Sohn 6b9c0d1232 Prepare 3.1.0-SNAPSHOT builds
Change-Id: I7490a7c9558423c03e3c167ad55b9a98be9d99d9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-06-13 16:13:32 +02:00
Matthias Sohn 01f6d91476 Prepare post 3.0.0.201306101825-r builds
Change-Id: I299cf1addc0987ffe39140d2216ab6a98e95ce52
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-06-13 15:48:41 +02:00
Matthias Sohn f384644774 JGit v3.0.0.201306101825-r
Change-Id: Ie8deab94c6263b5198f0bcb4533b1cfb3f5724b1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-06-11 00:56:27 +02:00
Matthias Sohn 06ba0f6df1 Fix warnings in ArchiveCommand
- remove unnecessary imports
- fix NLS warnings
- add missing Javadoc tag

Bug: 410354
Change-Id: I2b78a2c0e92c740bed80558b17a2100c1c884416
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-06-10 22:15:29 +02:00
Jonathan Nieder 56cb2d925c Pick default archive format based on filename suffix
Introduce a setFilename() method for ArchiveCommand so callers can
specify the intended filename of the produced archive.  If the
filename ends with .tar, the format will default to tar; if .zip, zip;
if .tar.gz, gzip-compressed tar; and so on.

This doesn't affect "jgit archive" because it doesn't support the
--output=<file> option yet.  A later patch might do that.

Change-Id: Ic0236a70f7aa7f2271c3ef11083b21ee986b4df5
2013-06-06 18:39:04 -07:00
Matthias Sohn bf388c2e32 Prepare post 3.0.0 RC3 builds
Change-Id: I008d55e2ef0aac9d1877b05ba73e3cf26335d430
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-06-04 13:54:39 +02:00
Matthias Sohn a898836eac JGit v3.0.0.201306040240-rc3
Change-Id: I8b782e9ebe03e5f72611a21a76d80c6b20cb7845
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-06-04 09:02:36 +02:00
Jonathan Nieder 659cadf06d Add missing javadoc for archive code
Document archive formats, the archive format interface, and the
parameters of the GitAPIException constructors.  Noticed by eclipse.

Reported-by: Dani Megert <Daniel_Megert@ch.ibm.com>
Change-Id: I22b5f9d4c0358bbe867c1906feec7c279e214273
2013-05-29 12:36:36 -07:00
Jonathan Nieder dbf8d95daa Drop unnecessary "throws" clauses in archive code
Noticed by eclipse.

Change-Id: I730b290556066038efeaf2436de95415b175f351
2013-05-29 12:35:12 -07:00
Matthias Sohn 658401c8ef Merge branch 'stable-3.0'
* stable-3.0:
  Prepare post 3.0.0-rc2 builds
  JGit v3.0.0.201305281830-rc2
  Support refspecs with wildcard in middle (not only at end)
  Fix multiple bugs in RawSubStringPattern used by MessageRevFilter
  Handle short branch/tag name for setBranch in CloneCommand
  Add missing Bundle-Localization header
  Apply tree filter marks when pairing DiffEntry for renames
  Improve feature names to become understandable by end users
  Update kepler orbit version to R20130517111416
  Fix BatchRefUpdate progress-monitoring so it doesn't count twice
  Fix AnyObjectId's generic type declaration of Comparable
  Fix DiffFormatter NPEs for DiffEntry without content change
  Fix CommitCommand not to destroy repo
  Fix the parameters to an exception
  Prepare post 3.0.0 M7 builds
  JGit v3.0.0.201305080800-m7

Change-Id: Ia8441c9796f01497e0d90e672c0aaf60520a0098
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-29 12:28:10 +02:00
Matthias Sohn 0603519aad Prepare post 3.0.0-rc2 builds
Change-Id: Ic46832bcde80d0bf74c16cb094abd76b00552d14
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-29 10:37:17 +02:00
Jonathan Nieder 7f2f59734c Add tgz and txz archive formats
Change-Id: I347e8a9a112d142ccef91cba1d6e997d645ca70a
2013-05-28 16:51:39 -07:00
Matthias Sohn 30fad6758f JGit v3.0.0.201305281830-rc2
Change-Id: I490ad8cc7590f70783d3fbd6dd6f0e0446ae5afe
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-29 00:49:12 +02:00
Robin Stocker a51899c203 Support refspecs with wildcard in middle (not only at end)
The following refspec, which can be used to fetch GitHub pull requests,
is supported by C Git but was not yet by JGit:

  +refs/pull/*/head:refs/remotes/origin/pr/*

The reason is that the wildcard in the source is in the middle.

This change also includes more validation (e.g. "refs//heads" is not
valid) and test cases.

Bug: 405099
Change-Id: I9bcef7785a0762ed0a98ca95a0bdf8879d5702aa
2013-05-28 05:33:03 -04:00
Robin Stocker ec97912762 Fix multiple bugs in RawSubStringPattern used by MessageRevFilter
* Match at end of input was not handled correctly.
* When more than one character matched but not all, the next character
  was not considered as a match start (e.g. pattern "abab" didn't match
  input "abaabab").

Bug: 409144
Change-Id: Ia44682c618bfbb927f5567c194227421d222a160
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-28 01:40:13 +02:00
Robin Stocker 7bb2a1b844 Handle short branch/tag name for setBranch in CloneCommand
Before, it was not clear from the documentation what kind of branch name
was accepted. Users specifying "branch" (instead of "refs/heads/branch")
got no error message and ended up with a repository without HEAD and no
checkout.

With this, CloneCommand now tries "$branch", then "refs/heads/$branch"
and then "refs/tags/$branch". C Git only does the last two, but for
compatibility we should still allow "refs/heads/branch".

Bug: 390994
Change-Id: I4be13144f2a21a6583e0942f0c7c40da32f2247a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-26 01:25:10 +02:00
Jonathan Nieder f99fa9d23e Release ArchiveCommand's ObjectReader in call()
Make call() release all private resources so instead of using a
pattern like

	ArchiveCommand cmd = git.archive();
	try {
		cmd.setTree(tree)
			. ...
			.call();
	} finally {
		cmd.release();
	}

callers can just use git.archive().setTree(tree)....call() directly.

This involves pushing more work out of parameter setters and into
call() so the ObjectReader is not allocated and potentially leaked
before then.

Change-Id: I699f703c6302696e1cc276d7ab8ee597d82f2c5d
2013-05-24 18:28:37 -07:00
Jonathan Nieder 56276d053f Move ArchiveCommand into standard porcelain API
Allow use of ArchiveCommand without depending on the jgit command-line
tools.

To avoid complicating the process of installing and upgrading JGit,
this does not add a dependency by the org.eclipse.jgit bundle on
commons-compress.  Instead, the caller is responsible for registering
any formats they want to use by calling ArchiveCommand.registerFormat.

This patch puts functionality that requires an archiver into a
separate org.eclipse.jgit.archive bundle for people who want it.  One
can use it by calling ArchiveCommand.registerFormat directly to
register its formats or by relying on OSGi class loading to load
org.eclipse.jgit.archive.FormatActivator, which takes care of
registration automatically.

Once the appropriate formats are registered, you can make a tar or zip
from a git tree object as follows:

	ArchiveCommand cmd = git.archive();
	try {
		cmd.setTree(tree).setFormat(fmt).setOutputStream(out).call();
	} finally {
		cmd.release();
	}

Change-Id: I418e7e7d76422dc6f010d0b3b624d7bec3b20c6e
2013-05-24 17:30:18 -07:00
Robin Stocker ade8af729c Apply tree filter marks when pairing DiffEntry for renames
When using a RenameDetector to generate new DiffEntries after using
DiffEntry.scan, the treeFilterMarks of the original entries were lost.
Now it combines the marks from src and dst.

See EGit bug 335082 where this is used.

Change-Id: I72b34b10ca12e3a6bd10ce44f4fa05b193fc52cc
2013-05-24 11:32:31 -04:00
Jonathan Nieder d4932620e0 ArchiveCommand: make archive formats non-inner classes
First step toward making ArchiveCommand itself format-agnostic.

Change-Id: I3cff5fce28fa7a19e34f8291cfb5b62f16429713
2013-05-23 18:08:35 -07:00
Shawn Pearce f7157a6221 Remove unused import in UploadPack
Change-Id: I9304cb3a6502ceb0cba21eb841e466f932ab3c01
2013-05-23 13:10:03 -07:00
Shawn Pearce 557471da2e Use NullOutputStream not DisabledOutputStream in UploadPack
The stream should not throw IllegalStateException if it is off.
Flush the stream after the hook runs, in case any messages need
to be sent ahead of the pack.

Change-Id: I21c7a0258ab1308406d226293fa0e7da69b4f57b
2013-05-23 13:07:03 -07:00
Shawn Pearce 6e896ba66b Allow PreUploadHook.onSendPack to send messages to the client
Before transmitting to the client a hook may want to send along
a text message ahead of the pack, such as a "message of the day".
Enable this usage by mirroring the message sending API from
ReceivePack on the UploadPack instance, using the side band.

Change-Id: I31cd254a4ddb816641397a3e9c2c20212471c37f
2013-05-22 12:14:08 -07:00
Roberto Tyley b4b3999f82 Fix BatchRefUpdate progress-monitoring so it doesn't count twice
I was seeing output like this while running The BFG:

Updating references:    200% (374/187)

...issue sneaked in with 5cf53fda I think.

The update call is also moved to the end of the loop, as update() is
only supposed to be called after work has been done ("Denote that some
work units have been completed").

Change-Id: I1620fa75be16dc80df44745d0e123ea512762e31
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-05-19 13:20:47 +02:00
Matthias Sohn 84ad4957c6 Merge "Fix DiffFormatter NPEs for DiffEntry without content change" into stable-3.0 2013-05-16 18:41:52 -04:00
Roberto Tyley e7fc19fc0c Fix AnyObjectId's generic type declaration of Comparable
If you look at any implementation of Comparable in the JDK, you'll see
that the type parameter for Comparable is supposed to be the type of
the implementing class:

http://docs.oracle.com/javase/6/docs/api/java/lang/Comparable.html

The current type signature of Comparable<Object> is pretty awful, at the
very least because you can not, in fact, successfully compare
AnyObjectId with any random subclass of Object. It also causes problems
with type-inference and the scala.math.Ordering trait in Scala.

In order to compile, this change *does* require removing the
AnyObjectId.ompareTo(Object) method - which actually only ever cast
to AnyObjectId in any case. Nothing in the JGit test suite requires this
method, but it might constitute a breaking API change, so it would be
best if it can be added in time for JGit 3.0.

Change-Id: I3b549a5519ccd6785f98e444da76d2363bcbe41a
2013-05-16 15:44:41 +01:00
Robin Stocker 92189b2df4 Fix DiffFormatter NPEs for DiffEntry without content change
DiffEntry.getOldId() returns null for a diff without an index line (e.g.
only mode changed, rename without content change).

Bug: 407743
Change-Id: I42eac87421f2a53c985af260a253338f578492bc
2013-05-15 12:23:40 +02:00
Christian Halstrick c93a593302 Fix CommitCommand not to destroy repo
There was a severe bug in CommitCommand which could corrupt
repos. When merging an annotated tag the JGit MergeCommand writes
correctly the ID of the tag (and not the id of the commit the tag was
pointing to) into MERGE_HEAD. Native git does the same. But
CommitCommand was reading this file and trusting blindly that it will
contain only IDs of commits. Then the CommitCommand created a
commit which has as parent a non-commit object (the tag object). That's
so corrupt that even native git gives up when you call "git log" in
such a repo.

To reproduce that with EGit simply right-click on a tag in the
Repository View and select Merge. The result was a corrupt repo!

Bug: 336291
Change-Id: I24cd5de19ce6ca7b68b4052c9e73dcc6d207b57c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-11 22:45:29 +02:00
Robin Rosenberg a62770a3dd Fix the parameters to an exception
A parenthesis was in the wrong place passing arguments to the wrong
format call. Also fix formatting of enclosing switch statement.

Change-Id: I4cb9642f08b58c39033c3a81dab4bd56bebf4fd2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-10 21:37:51 +02:00
Matthias Sohn 4800ac50f9 Prepare post 3.0.0 M7 builds
Change-Id: I062c44529c7ae2f960d3c64a0923a45d2dc8a863
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-08 22:26:47 +02:00
Matthias Sohn 00108d01ff JGit v3.0.0.201305080800-m7
Change-Id: I377b174993862918a117f54e6cba4733dfc2307c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-08 13:58:26 +02:00
Matthias Sohn e27993f1f8 Add missing @since tags
Change-Id: I9657125765716c874bb6ecf8844c34749cb3b069
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-06 23:48:27 +02:00
Shawn Pearce 75e1bdb3c1 Merge "URIish: Allow multiple slashes in paths" 2013-05-05 12:51:44 -04:00
Dave Borowitz b0326235e1 Remove unused repository field from RevWalk
The comment about legacy Tag and Object types no longer applies,
though prior to Idb273d5a92849b42935ac14eed73b796b80aad50 the field
was still being used by RewriteTreeFilter.

Change-Id: I9ee5da8f8a3b61c9cf543817c03117ee0609dd8f
2013-05-05 11:48:41 -04:00
Shawn Pearce a626f9fd66 Merge "Require a DiffConfig when creating a FollowFilter" 2013-05-05 11:47:53 -04:00
Dave Borowitz 0bdf030b26 Require a DiffConfig when creating a FollowFilter
The various rename detection options are an inherent part of the
filter, similar to the path being followed.

This fixes a potential NPE when a RevWalk with a FollowFilter is
created without a Repository, since the old code path tried to get
the DiffConfig from the RevWalk's possibly-missing repository.

Change-Id: Idb273d5a92849b42935ac14eed73b796b80aad50
2013-05-05 08:41:09 -07:00
Robin Rosenberg dd3181603e Extend the FS class for Java7
The most important difference is that in Java7 we have symbolic links
and for most operations in the work tree we want to operate on the link
itself rather than the link target, which the old File methods generally
do.

We also add support for the hidden attribute, which only makes sense
on Windows and exists, just since there are claims that Files.exists
is faster the File.exists.

A new bundle is only activated when run with a Java7 execution
environment. It is implemented as a fragment.

Tycho currently has no way to conditionally include optional features
based on the java version used to run the build, this means with this
change the jgit packaging build always needs to be run using java 7.

Change-Id: I3d6580d6fa7b22f60d7e54ab236898ed44954ffd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-05-04 02:01:56 +02:00
Robin Rosenberg b8e763fc19 TagCommand should be able to create unannotated tags too
Using the low level API's is just too cumbersome.

Change-Id: Id5b9f560ee095d6db0b2ea5b26aef3e53021626e
Signed-off-by: Robin Stocker <robin@nibor.org>
2013-05-03 15:36:27 +02:00
Robin Rosenberg 9d9cdd780c Merge "Fix warnings about assigning paramter in util.io" 2013-05-02 17:19:38 -04:00
Robin Stocker 252b1dd5c2 Fix warnings about assigning paramter in util.io
Change-Id: I08bed4275af9ec52aa4d7054067ac82f6a3c9781
2013-05-01 16:48:14 +02:00
Robin Stocker f448d62d29 Update tags on fetch if --tags or tag refspec specified
When either --tags or a tag ref is explicitly specified on fetch, C Git
updates existing local tags if they are different.

Before this change, JGit returned REJECTED in such a case. Now it
updates it and returns FORCED.

Example:

    % mkdir a
    % cd a
    % git init -q
    % touch test.txt
    % git add test.txt
    % git commit -q -m 'Initial'
    % git tag v1
    % cd ..
    % git clone -q a b
    % cd a
    % echo Test > test.txt
    % git commit -q -a -m 'Second'
    % git tag -f v1
    Updated tag 'v1' (was bc85c08)
    % cd ../b
    % git fetch --tags
     - [tag update]      v1         -> v1

Bug: 388095
Change-Id: I5d5494c2ad1a2cdb8e9e614d3de445289734edfe
2013-05-01 16:02:01 +02:00
Robin Stocker 68b378a4b5 Only fetch tags that do not exist locally with auto-follow
This corresponds to what C Git does, quoting from the fetch man page:

  This is done by first fetching from the remote using the given
  <refspec>s, and if the repository has objects that are pointed by
  remote tags that it does not yet have, then fetch those missing tags.

Before, JGit would also fetch tags that exist locally but point to a
different object, resulting in REJECTED results for these.

Also add some test cases to cover more cases.

Bug: 388095
Change-Id: Ib03d2d82e9c4b60179d626cfd5174be1da6388b2
Also-by: Stefan Lay <stefan.lay@sap.com>
2013-05-01 16:00:42 +02:00
Robin Stocker 8bd1e86bb7 Abort before delete in FileUtils.delete EMPTY_DIRECTORIES_ONLY|RECURSIVE
Depending on the order in which items are traversed for RECURSIVE, an
empty directory may come first before detecting that there is a file and
aborting.

This fixes it by traversing files first.

Bug: 405558
Change-Id: I638b7da58e33ffeb0fee172b96f4c823943d29e9
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-04-29 01:00:35 +02:00
Robin Rosenberg 687b887c68 Merge "Make the Reflog a public API again" 2013-04-27 08:56:37 -04:00
Robin Rosenberg a5e78a3f06 Merge "Remove unused logger from RecursiveMerger" 2013-04-27 08:55:32 -04:00
Robin Stocker 23e3fb135b URIish: Allow multiple slashes in paths
It's also allowed by C Git.

Change-Id: Ie0a0d1f57d84e70fd5ef50b7844d22fea43d0e08
2013-04-27 14:35:12 +02:00
Robin Stocker 664d738c9f Refer to getEntryPathLength in docs of getEntryPathBuffer
Change-Id: Icca41d80bd0791cd2d4bf03297795d161afbee70
2013-04-27 14:18:59 +02:00
Alex Blewitt 37f0e324b5 Allow deletions to occur when there is no HEAD
If the HEAD is not present in a repository, then there is a
NullPointerException thrown in the delete code. Since this only
exists to verify if the deletion is not the HEAD reference, then
skip this check if the HEAD cannot be found.

Bug: 406722
Change-Id: I882497202d986096513a4d791cd07fa935a3f9e4
Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
2013-04-27 11:42:58 +01:00
Jonathan Nieder 31d79ae0af Remove unused logger from RecursiveMerger
JGit doesn't currently use java.util.logging.Logger.  Remove this
never-used Logger introduced in ab99b78ca0 (Implement recursive
merge strategy, 2013-02-21) to make that easier to see.

Change-Id: I92c578e7f3617085a667de7c992174057be3eb71
2013-04-26 10:16:09 -07:00
Robin Rosenberg 9dcd8c2c90 Make the Reflog a public API again
Change-Id: I8ced7098da5b345fd9af2fdfafd1ef6a44ccee0d
2013-04-26 00:57:17 +02:00
Robin Rosenberg 2af9a4c7b1 Merge "status: Print conflict description for unmerged paths" 2013-04-25 17:45:35 -04:00
Robin Stocker 3699ea648e Document RevTag#getObject() that returned object is unparsed
Change-Id: I238d388e40362721eecf37f64ad7d48a399ff129
2013-04-22 18:22:18 +02:00