Commit Graph

2644 Commits

Author SHA1 Message Date
Robin Rosenberg 06ab442b05 Merge "Fix CheckoutCommand not setting up tracking" 2014-08-11 16:23:38 -04:00
Shawn Pearce 2badedcbe0 Process most in-core merges without local temp files
Instead of always writing to disk use TemporaryBuffer.LocalFile to
store up to 10 MiB of merge result in RAM. Most source code will
fit into this limit, avoiding local disk IO for simple merges.

Larger files will automatically spool to a temporary file that
can be cleaned up in the finally, reducing the risk of leaving
them on disk and consuming space in /tmp.

Change-Id: Ieccbd9b354d4dd3d2bc1304857325ae7a9f34ec6
2014-08-08 17:53:49 -07:00
Shawn Pearce 2c33c725f9 ResolveMerger: push result file creation into updateIndex()
The only caller of writeMergedFile is updateIndex, and the only
user of this path object is the code within the method. This is
a no-op change that opens the door to refactoring the way temp
files are handled for inCore merges.

Change-Id: I863a303194689a806b667e55eb958e1decf046c1
2014-08-08 15:04:57 -07:00
Shawn Pearce 4bd28bc958 RecursiveMerger: do not insert virtual commits into repository
When merging common ancestors to create a single virtual common
ancestor the commit does not need to be inserted into the Git
repository. Instead just mock it out in memory as part of the
merger's RevWalk pool.

Make the author and committer stable and predictable for any
given pair of merge bases. It is not necessary for the caller's
name or email to be used as the commit will not be written out.

Change-Id: I88d5ee4de121950e1b032a5c10486c9d2c42656c
2014-08-08 11:31:24 -07:00
Yuxuan 'fishy' Wang 66ad4237be Fix non-relative remote defined in manifest xml.
Currently if the remote defined in repo manifest xml is non-relative (e.g.
"https://chromium.googlesource.com"), our code will break. This change fixed
that.

It also makes that remotes are ending with "/".

Change-Id: Icef46360b32227a9db1d9bb9e6d929c72aeaa8df
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-08-06 22:26:17 -07:00
Robin Stocker 544f65e655 Fix CheckoutCommand not setting up tracking
Instead of passing on the start point as is to CreateBranchCommand, the
resolved ObjectId was used. Given this, CreateBranchCommand did not set
up tracking.

This also fixes CreateBranchCommand with setStartPoint(null) to use HEAD
(instead of NPEing), as documented in the Javadoc.

Bug: 441153
Change-Id: I5ed82b4a4b4a32a81a7fa2854636b921bcb3d471
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-08-05 23:38:07 +10:00
Robin Rosenberg d97558fb1c Merge "Add isRebase to API of BranchConfig" 2014-08-03 07:33:28 -04:00
Robin Rosenberg b397e7b6e0 Merge "Use bitcheck to check for presence of OPT_FULL option" 2014-08-03 04:51:12 -04:00
Robin Stocker f5494c186f Add isRebase to API of BranchConfig
Change-Id: I9819f49410e30d32c2157db0556a0dd6a0bcc5a4
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-08-03 18:38:38 +10:00
Alexey Kuznetsov a4f560551d NetRC parser and credentials provider.
Adds default git command line behaviour of reading credentials
for https connections from .netrc file.

Bug: 428229
Change-Id: I88699ca5da6a20bdeaed24b7e3899cc1022b8e7c
Signed-off-by: Alexey Kuznetsov <axet@me.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-08-03 01:47:43 +02:00
Kevin Sawicki d2fa3987a0 Use bitcheck to check for presence of OPT_FULL option
Previously an equality check was performed so an exception would
be thrown if any other options were set.

Change-Id: I36b60e2c0a8aef9fcfe663055dba520192996872
2014-08-02 18:20:11 -04:00
Robin Stocker 93530625cf Enhance BranchConfig API to expose branch.* options
With these, more code can use BranchConfig instead of directly accessing
the raw configuration values.

Change-Id: I4b52f97ff0e3fc8f097512806f043c615a3d2594
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-08-03 00:06:14 +02:00
Christian Halstrick ddbf67e058 IndexDiffFilter should never filter entries with stage!=0
If the IndexDiffFilter is asked whether it should include or filter out
a certain path and for that path there is a dircache entry with a stage
different from 0, then the filter should never filter out this entry.
IndexDiffFilter is an optimized version of AnyDiffFilter and there is no
case where the index contains non-0 stages but we still don't see any
diff for that path.

Change-Id: I25915880f304090fe90584c79bddf021231227a2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-08-02 23:04:26 +02:00
Robin Rosenberg fd07ee54ef Merge "HistogramDiff: Convert stack recursion to heap managed queue" 2014-08-02 05:35:18 -04:00
Robin Stocker 66909cd7a6 Fix Javadoc errors with Java 8
Bug: 440414
Change-Id: Icce87bd23a3698513b76246677f1d45ddbcaab47
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-08-02 00:47:13 +02:00
Christian Halstrick adbf0541dc Fix API errors raised on ResolveMerger affecting API providers only
In change If45bc3d078b3d3de87b758e71d7379059d709603 a new parameter was
added to 3 protected methods of ResolveMerger. This breaks the code of
developers which have subclassed ResolveMerger. The API baseline check
in Eclipse reports this as API breakage.

Since this will break only providers but not consumers of the API this
should be allowed also in minor versions. According to OSGi semantic
versioning
http://www.osgi.org/wiki/uploads/Links/SemanticVersioning.pdf
breaking providers in a minor version update is ok.

Therefore silence these errors using API filter rules.

Bug: 440757
Change-Id: Icabbd0e1de7e877c66a5c4a2c8391473f992a1aa
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-07-31 00:02:17 +02:00
Matthias Sohn efce340474 Implement RepoCommand.Project.hashCode() since we override equals()
Bug: 440757
Change-Id: I16614c75b62b2fbef05419dd8667e3c50889abe4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-07-30 23:54:50 +02:00
Matthias Sohn 56fdbadc76 Remove @Override annotation illegal for interfaces on Java 5
Bug: 440757
Change-Id: I11897e8e680722313f28d9d241e23e92eddeb966
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-07-30 23:54:36 +02:00
Matthias Sohn 9b157c6dab Mark package org.eclipse.jgit.gitrepo.internal as x-internal
It's an internal package which isn't part of the API. Mark it x-internal
to silence @since tag warnings which are only raised for new API.

Bug: 440757
Change-Id: Id05deaca43f135cd1bfe83cf1f29787cbbdbecac
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-07-30 23:54:24 +02:00
Andrey Loskutov 3a161ac467 Small performance optimization for ignore rules/fnmatcher
- don't check empty segments generated by String.split()
 - don't continue to add segments if the matcher fails to match input
 - don't add empty heads
 - don't iterate over empty heads.

Bug: 440732
Change-Id: I7d04dccfe24d91275d17ba246662337d6dba66df
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-07-30 23:37:27 +02:00
Andrey Loskutov 0307123e5a Added toString() methods for better debugging of ignore rules
Change-Id: Ie31687faa2df47ecaacace2504c3b4e93f1ea809
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-07-30 23:17:43 +02:00
Maik Schreiber 7ff1e0d8f5 Fix RevertCommand to correctly revert multiple commits at once.
The fix is to move the new head commit to the newly-created revert
commit, so that additional revert commits will use the correct head.

Change-Id: I5de3a9a2a4c276e60af732e9c507cbbdfd1a4652
Signed-off-by: Maik Schreiber <blizzy@blizzy.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-07-30 16:20:08 +02:00
Shawn Pearce 7b0ee393ba Merge "Remove overlapping submodules from repo manifest." 2014-07-29 19:28:11 -04:00
Yuxuan 'fishy' Wang a9b9c5b324 Remove overlapping submodules from repo manifest.
Apparently repo allows projects overlapping, e.g. one project's path is "foo"
and another project's path is "foo/bar". This is not supported in git submodule.
At JGit repo side we'll skip all the submodules that are in subdirectories of
other submodules, and on repo side we'll make them submodules to resolve this
problem.

Change-Id: I6820c4ef400c530a36150b1228706adfcc43ef64
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-07-29 16:16:36 -07:00
Shawn Pearce 219b9045f4 Merge "Added the missing export in MANIFEST.MF." 2014-07-29 19:01:13 -04:00
Christian Halstrick 5171a1843a Merge "RecursiveMerger should not fail on content-merge conflicts of parents" 2014-07-29 03:46:52 -04:00
Yuxuan 'fishy' Wang 73d38bfb33 Strip trailing /s in repo base URI.
Change-Id: I71040db2cca69638cfad89acdc9179ee80592b27
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-07-28 16:13:50 -07:00
Christian Halstrick 3b031fe3dc RecursiveMerger should not fail on content-merge conflicts of parents
Previously when RecursiveMerger was trying to create a single virtual
common base for the merge it was failing when this lead to content-merge
conflicts. This is different from what native git is doing. When native
git's recursive merge algorithm creates a new common base it will merge
the multiple parents and simply take the merge result (potentially
including conflict markers) as common base. See my discussion with Shawn
here: http://www.spinics.net/lists/git/msg234959.html :

  > - How should workingtree, index (stage1,2,3) look like if during
that
  > merge of common ancestors a conflict occurs? Will I see in stage2
and
  > stage3 really see content of X1 and X2?

  Its done entirely in memory and never touches the working tree or
  index. When a conflict exists in the X1-X2 merge the conflict is
  preserved into the new virtual base.

There is still the possibility that the merge of parents lead to
conflicts. File/Folder conclicts, conflicts on filemodes. This commit
only fixes the situation for conflicts when merging content.

Bug: 438203
Change-Id: If45bc3d078b3d3de87b758e71d7379059d709603
2014-07-28 14:52:07 +02:00
Christian Halstrick 289b7c60a9 Fixed message for exception thrown during recursive merge
During recursive merge jgit potentially has to merge multiple
common ancestors. If this fails because there are conflicts then
the exception thrown for that should have a message which states
this clearly. Previously a wrong message was given ("More than 200
merge bases ...")

Change-Id: Ia3c058d5575decdefd50390ed83b63668d31c1d1
2014-07-28 14:43:22 +02:00
Shawn Pearce d11ca1b084 HistogramDiff: Convert stack recursion to heap managed queue
Each time the longest common substring is found the diff algorithm
recurses to reprocess the regions before and after the common string.

Large files with many edits can trigger StackOverflowError as the
algorithm attempts to process a deeply split tree of regions. This
is especially prone to happen in servers where the Java stack size
may have been limited to 1M or even 256K.

To keep edits produced in order a queue is used to process edits
in a depth-first strategy.

Change-Id: Iae7260c6934efdffac7c7bee4d3633a8208924f7
2014-07-25 10:04:23 -07:00
Christian Halstrick 0c4553d28a Fix RecursiveMerger's internal use of merge to find a merge base
When RecursiveMerger tried to determine a common base tree it was
recursively tried to merge multiple common bases. But these intermediate
merges which have just been done to determine a single common base for
the final merge already filled some important fields (toBeCheckedOut,
toBeDeleted, ...). These side effects of the intermediate merges led to
wrong results of the final merge. One symptom was that after a recursive
merge which should be succesful you could still see leftover files in
the worktree: files which existed in the (virtual) common base but which
don't exist anymore in the branches to be merged.

The solution is easy: Clear the appropriate fields after common base
determination and start the final merge with a clean state.

Change-Id: I644ea9e1cb15360f7901bc0483cdb9286308c226
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2014-07-25 03:32:38 -04:00
Christian Halstrick cf9b01b09a Handle initial checkout correctly
As described in native gits file "git-read-tree.txt" git has in a
special mode when doing the "initial" checkout. "Initial" means that the
index is empty before the checkout. This was not handled correctly in
JGit and is fixed in this commit. Also see
https://github.com/git/git/blob/master/Documentation/git-read-tree.txt#L181

Change-Id: I9b9d1bd9ebf349cfca420c891c7b099a18d07ba4
2014-07-25 03:31:31 -04:00
Yuxuan 'fishy' Wang c7adc0c91c Added the missing export in MANIFEST.MF.
This fixes bug 440352.

Change-Id: I4b1c63087a97b7b2f3d7bdb5e066424a84ef6cef
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-07-24 08:19:33 -07:00
Konrad Kügler 48544e27ae Preserve merges during pull if configured to do so
Setting branch.<name>.rebase or pull.rebase to 'preserve' will preserve
merges during rebase. Also, pull.rebase is now consulted if there is no
branch-specific configuration.

Bug: 429664
Change-Id: I345fa295c7e774e0d0a8e6aba30fbfc3552e0084
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
2014-07-15 19:08:19 -04:00
Konrad Kügler e0fbae5dc3 Rebase: Add --preserve-merges support
With --preserve-merges C Git re-does merges using the rewritten merge
parents, discarding the old merge commit. For the common use-case of
pull with rebase this is unfortunate, as it loses the merge conflict
resolution (and other fixes in the merge), which may have taken quite
some time to get right in the first place.

To overcome this we use a two-fold approach:
If any of the (non-first) merge parents of a merge were rewritten, we
also redo the merge, to include the (potential) new changes in those
commits.
If only the first parent was rewritten, i.e. we are merging a branch
that is otherwise unaffected by the rebase, we instead cherry-pick the
merge commit at hand. This is done with the --mainline 1 and --no-commit
options to apply the changes introduced by the merge. Then we set up an
appropriate MERGE_HEAD and commit the result, thus effectively forging a
merge.

Apart from the approach taken to rebase merge commits, this
implementation closely follows C Git. As a result, both Git
implementations can continue rebases of each other.

Preserving merges works for both interactive and non-interactive rebase,
but as in C Git it is easy do get undesired outcomes with interactive
rebase.

CommitCommand supports committing merges during rebase now.

Bug: 439421
Change-Id: I4cf69b9d4ec6109d130ab8e3f42fcbdac25a13b2
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
2014-07-15 19:00:58 -04:00
Konrad Kügler b9a0077062 Repository.writeMergeHeads to accept a list with subtypes of ObjectId
Allows to pass for example a List<RevCommit>.

Change-Id: I5522707060d7d3e0d848ba579956dc62f8fa0234
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
2014-07-14 14:54:52 -04:00
Konrad Kügler 0f679dbda5 Cherry-Pick: Support --no-commit
Change-Id: Ic4c313a8971a5aa15745518c49e2587a1a0fe8d4
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
2014-07-14 20:01:04 +02:00
Robin Rosenberg 89ad10ec27 Handle diff formatting when there is nothing to compare with
DiffFormatter now suports either side being null and the log program
will output the diff for the first commit.

Bug: 395791
Change-Id: I378957b57e9ad1f7195ba416f402178453f0ebd3
2014-07-06 18:45:48 +02:00
Robin Rosenberg a03bdcbbb4 Don't warn for methods that can be static
Making the methods static would gain little in performance,
make the code harder to change. Removing unncessary warnings
is more important.

Change-Id: If3e6aa9c1d92e58b4e7a8e246cf4aace237d7a7b
2014-07-02 00:36:38 +02:00
Robin Rosenberg 8032b64980 Add new default settings from Eclipse 4.4
These settings were added by Eclipse simply by touching
the project settings. Adding these makes it simpler to see
what local changes have been made.

Change-Id: Iab0aa62530312eb0c78b03b5c6a632742bcc4978
2014-07-02 00:34:41 +02:00
Robin Stocker 26e0c533d0 Clarify comments in message properties files (and fix grammar)
Bug: 438261
Change-Id: I7b98475886ef789ae7635d8c9e008fc1aa00d534
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-06-30 20:54:32 +10:00
Robin Rosenberg 844739baa1 Add a comment to the message properties files on how they are processed
Change-Id: I073f0c2c0729e6a5d3f1834203f0cfeb4c462eda
2014-06-29 15:55:53 +10:00
Robin Rosenberg 5054f36d4b Fix spelling error in error messgae
Change-Id: I5f712ba290592f7c5aa9ee865ff30383ad315247
2014-06-29 15:55:53 +10:00
Robin Rosenberg 350ba91585 Fix formatting errors in error messages
{} is plain wrong and is not accepted by MessageFormat, the other risk
becoming wrong if another single quote is introduced in the future and
sets a bad example.

Bug: 438261
Change-Id: I2948ca90c10f6ec2574f7f2b9be0a72821ea4daf
2014-06-29 15:55:53 +10:00
Matthias Sohn 64dde09b85 Merge branch 'stable-3.4'
* stable-3.4:
  Prepare 3.4.2-SNAPSHOT builds
  JGit v3.4.1.201406201815-r
  Allow retrying connecting SshSession in case of an exception

Change-Id: I7efb009b9e012637a16c57e2e93e074023b8e46c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-21 01:28:55 +02:00
Matthias Sohn 7865d7100e Prepare 3.4.2-SNAPSHOT builds
Change-Id: If88217d84b88cda6d04c159418d5bc86233fe28c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-21 00:57:43 +02:00
Matthias Sohn 03f6e83c40 JGit v3.4.1.201406201815-r
Change-Id: I4383a90fd91a243cd5ce5d0ae4e53874b36c1f47
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-21 00:16:29 +02:00
Stefan Lay 4b2b3294b8 Allow retrying connecting SshSession in case of an exception
Connecting to an SshSession may fail due to different reasons. Jsch for 
example often throws an com.jcraft.jsch.JschException: verify: false.[1]
The issue is still not fixed in JSch 0.1.51.
 
In such a case it is worth retrying to connect. The number of connection
attempts can be configured using ssh_config parameter
"ConnectionAttempts" [2].

Don't retry if the user canceled authentication.

[1] http://sourceforge.net/p/jsch/bugs/58/
[2] http://linux.die.net/man/5/ssh_config

Bug: 437656
Change-Id: I6dd2a3786b7d3f15f5a46821d8edac987a57e381
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-20 11:48:53 +02:00
Robin Rosenberg 79792c59b6 Remove no longer needed API breakage filters
Change-Id: I2ea2dec55c187b62662195bae810b3f0af8a2983
2014-06-15 23:34:59 +02:00
Robin Rosenberg 78cd2bb9e0 Remove an unnecessary semicolon
Change-Id: I6c5b085ae4a47d0026bd2b2341de76ab333936b9
2014-06-15 23:33:06 +02:00
Robin Rosenberg 447fd6a948 Remove an unnecessary $NON-NLS$ comment
Change-Id: I8335464061dac1c20de2b698f834e516ef78cf3d
2014-06-15 23:30:44 +02:00
Robin Rosenberg be025ff7d2 Merge "Enable NLS / TranslationBundle to be used in OSGi" 2014-06-15 15:58:29 -04:00
Dave Borowitz 7eb0b702fd Don't set REWRITE flag unless parent rewriting is requested
Change-Id: I65e3702ceb6c8854a2c358cfc2c2e3a9fb9486ff
2014-06-12 13:52:09 -07:00
Dave Borowitz eb69cef35c Rename RewriteTreeFilter to TreeRevFilter and make it public
The current behavior of passing a TreeFilter to RevWalk has limited
usefulness, since the RevFilter derived from the TreeFilter is always
ANDed together with any other RevFilters. It is also tied fairly
tightly to the parent rewriting mechanism.

Make TreeRevFilter a generic RevFilter that matches modified paths
against any TreeFilter. This allows for more complex logic like
(modified this path OR authored by this person).

Leave the rewrite flag logic in this class, since it's closely tied to
the parent comparison code, but hidden behind a protected constructor.

Change-Id: Ia72ef591a99415e6f340c5f64583a49c91f1b82f
2014-06-12 13:52:09 -07:00
Matthias Sohn 2a562b94d6 Add missing javadoc and since tag for RepoCommand.readFileFromRepo()
Change-Id: Ib0a98ce633e83c82a58b633c767e70d316b7254c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-12 10:50:03 +02:00
Matthias Sohn 126eb94f77 Prepare post 3.4.0 builds
Change-Id: I49f3741f3973b247a635f7c99b72309d2381a377
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-11 17:45:39 +02:00
Matthias Sohn d0daad884f JGit v3.4.0.201406110918-r
Change-Id: I56543234316f04bff4e45628bcb8286a6e52e31f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-11 15:20:26 +02:00
Yuxuan 'fishy' Wang afa2154e45 Refactor DefaultRemoteReader for easier code reuse
Change-Id: I7f326b4fc96198de7b424e15d8329bde7d7b39cf
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-06-10 16:21:42 -07:00
Robin Rosenberg 83846d1f6d Merge "Fixed the problem with calling LsRemoteCommand without a local repository over the ssh and git:// protocols." 2014-06-10 15:49:29 -04:00
Robin Rosenberg 79004dd42a Add missing @since to RepoCommand.setInputStream
Change-Id: I2fa1a5c28a1521a837aeaeb994e5cce8d7c4e645
2014-06-10 09:59:17 +02:00
Yuxuan 'fishy' Wang acd7ed5269 Added setInputStream to RepoCommand.
Sometimes an input stream is more useful than the filename of the xml manifest.

Change-Id: Icb09ac751b3d8d7eb14427ad1aac8cee0c371c5f
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-06-09 13:26:52 -04:00
Dave Borowitz c8ddac2a86 Merge "Better way to handle relative URLs in manifest XML" 2014-06-09 13:26:25 -04:00
Anton Bannykh f4943de29b Fixed the problem with calling LsRemoteCommand without a local repository over the ssh and git:// protocols.
Bug: 436695
Change-Id: Ifd69fbc04156fa4dacdcba6225768f43843eee97
Signed-off-by: Anton Bannykh <anton.bannykh@gmail.com>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2014-06-08 16:42:02 +02:00
Robin Rosenberg dc66469e11 LsRemoteCommand - internal execute need not be protected
Change-Id: I04d054d9f19e4ee200f72b25962be4759cfe5d7e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-08 01:32:17 +02:00
Robin Rosenberg 4dc3ba4327 Merge "Fix DeltaTask infinite loop" 2014-06-06 07:40:37 -04:00
Robin Rosenberg 926627fa41 Merge "Make JavaDoc validator happy by declaring GitAPIException on callAsMap" 2014-06-06 07:11:10 -04:00
Yuxuan 'fishy' Wang 39001eacc1 Better way to handle relative URLs in manifest XML
The old implementation will NOT strip the filename part from the baseUrl, e.g.
https://android.googlesource.com/platform/manifest with .. will be resolved to
https://android.googlesource.com/platform/, which is actually wrong. This
implementation will resolve it to https://android.googlesource.com/ to match the
behavior of repo.

Change-Id: Ia32c8b34e16eacdf37a0da7025bf0b5cc5f67ed2
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-06-05 17:40:37 -07:00
Hugo Arès d439c8dfe5 Fix DeltaTask infinite loop
DeltaTask$Block.partitionTask was doing an infinite loop if number of
threads was greater than the totalWeight. The weightPerThread was 0
which was causing the infinite loop. Set the weightPerThread to a
minimal value of one.

Bug: 420915
Change-Id: Ia8e3ad956d53d8193937b7fa1bc19aafde9767ff
Signed-off-by: Hugo Arès <hugo.ares@ericsson.com>
2014-06-05 15:20:04 -04:00
Robin Rosenberg 64b0531c35 Prepare 3.5.0-SNAPSHOT builds
Change-Id: I53bd500188e09ae2e007a58b3cd89aa0805d6f2a
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2014-06-04 18:23:29 -04:00
Matthias Sohn f449f6b1c9 Merge branch 'stable-3.4'
* stable-3.4:
  Prepare post 3.4 RC3 builds
  JGit v3.4.0.201406041058-rc3
  blame: Un-break isFile check in tree walk
  Prepare post 3.4.0 RC2 builds
  JGit v3.4.0.201405281120-rc2
  Fix authentication type names broken by 0b5441a8
  Update Luna target platform to Orbit release R20140525021250

Change-Id: I344f1bbb8939bda01d524ec1a3218aa32bcc62f5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-04 23:29:09 +02:00
Matthias Sohn 3b83e1a398 Prepare post 3.4 RC3 builds
Change-Id: I9730bb349d0295c811aa3a9ba0f67bd946e86d1e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-04 22:14:52 +02:00
Matthias Sohn dd06dcdcf2 JGit v3.4.0.201406041058-rc3
Change-Id: If0cfec023788cae7713dd1ccc250e221365ef984
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-06-04 16:58:04 +02:00
Jonathan Nieder 9b46a47fb7 blame: Un-break isFile check in tree walk
Originally, blame's walk to find a scapegoat to blame for a file
walking backward from a commit used the test

	treeWalk.getFileMode(0).getObjectType() != OBJ_BLOB

to throw out gitlink (submodule) entries.  Later, 52500d3264 (blame:
Micro optimize blob lookup in tree, 2014-04-17) changed that test to

	(treeWalk.getRawMode(0) & TYPE_FILE) != TYPE_FILE

These checks are not the same, though: the older test accepts files
and symlinks, while the newer one accepts files, symlinks, and gitlink
(submodule) entries.  This is particularly broken in the submodule
case --- trying to parse the referred-to commit as a blob produces

	caught an exception: GET /gerrit/+blame/master/plugins/reviewnotes HTTP/1.1
	org.eclipse.jgit.errors.MissingObjectException: Missing blob 61702414c046dd6b811c9137b765f9db422f83db

Stick to just (possibly executable) files instead.  Symlinks are not
line-oriented data so blame on a symlink is not likely to be useful.

A quick grep for '& TYPE_' doesn't find any other instances of this
bug.

Change-Id: Iebcc91f1bee3c91adda51dccd6372e8302bf23fe
Signed-off-by: Jonathan Nieder <jrn@google.com>
2014-06-04 10:26:01 -04:00
Robin Rosenberg 9e7fa6dd33 Make JavaDoc validator happy by declaring GitAPIException on callAsMap
Change-Id: I9caa559a3d4eb0ec93d90cf1e18aed785ef85a84
2014-06-04 10:36:58 +02:00
Rüdiger Herrmann 02baeab4c4 Enable NLS / TranslationBundle to be used in OSGi
TranslationBundle#load() used to load resource bundles through
ResourceBundle#getBundle() without explicitly specifying a class loader.
In this case, the class laoder of the calling class (TranslationBundle
here) is used. This approach fails in runtime environments like OSGi
where there are multiple class loaders.

This change enables loading resource bundles in multi class loaders
environments. The fix is to pass the class loader of the
TranslationBundle-derived class to ResourceBundle#getBundle().

Bug: 436232
Change-Id: I39db61e012dc93ebf388a71bf6088a3310a22bac
Signed-off-by: Rüdiger Herrmann <ruediger.herrmann@gmx.de>
2014-06-01 11:59:21 +02:00
Matthias Sohn 386dff2271 Prepare post 3.4.0 RC2 builds
Change-Id: Id8d784ba7b0aba7c6a00f459bf1ac54c1d36d061
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-28 17:41:20 +02:00
Matthias Sohn 314fade855 JGit v3.4.0.201405281120-rc2
Change-Id: Ifd376f58cf867fc84d39582c49e971d998abf63d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-28 17:19:39 +02:00
Dani Megert 0b9bef49f4 Remove unused import
Change-Id: I6f59539350ab28605e2e1fe1f30354cd68aa7740
Signed-off-by: Dani Megert <Daniel_Megert@ch.ibm.com>
2014-05-28 07:53:28 -04:00
Yuxuan 'fishy' Wang eb98ebcc27 Unit test for the updating behavior in RepoCommand API.
When update the manifest against a bare repository, RepoCommand will replace
every existing content from the repository with contents populated from the
manifest. Added note for that and a unit test to make sure this behavior.

Change-Id: I1d5960e84bca5aa2a4e86f424d2ddd4197894cdc
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-05-27 12:50:15 -07:00
Matthias Sohn f80b41fbc1 Fix authentication type names broken by 0b5441a8
0b5441a8 introduced an enum for authentication types and changed the
case of digest and basic authentication type names to all uppercase.
This broke digest authentication at least when using Gerrit as the git
server. 

According to RFC2617 [1] "Basic" and "Digest" is the literal to be used
in authentication headers and not "BASIC" [1] and "DIGEST" [2].
According to RFC4559 "Negotiate" [3] is used for SPNEGO based
authentication.

[1] http://tools.ietf.org/html/rfc2617#page-5
[2] http://tools.ietf.org/html/rfc2617#page-8
[3] http://tools.ietf.org/html/rfc4559#page-3

Bug: 435866
Change-Id: I6173aff9352d7def225cafe2d73e5176ad40dff0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-27 10:20:42 +02:00
Yuxuan 'fishy' Wang 30cd891a48 Adds a callAsMap() function to LsRemoteCommand.
The call() function of LsRemoteCommand returns Collection<Ref>, while its
internal is using Map<String, Ref> all the time. Sometimes the map is much more
useful to the caller so add a callAsMap() function to keep the API
compatibility.

Change-Id: Icb96b71277d5e2de59872aa777352dedc048c4e3
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-05-24 12:19:23 -07:00
Andreas Hermann 44f81d956b Allow to include untracked files in stash operations.
Unstashed changes are saved in a commit which is added as an additional
parent to the stash commit.
This behaviour is fully compatible with C Git stashing of untracked
files.

Bug: 434411
Change-Id: I2af784deb0c2320bb57bc4fd472a8daad8674e7d
Signed-off-by: Andreas Hermann <a.v.hermann@gmail.com>
2014-05-22 23:56:08 +02:00
Andreas Hermann b7e46c07f9 Fix for reflog corruption caused by multiline message
If a client passes a multiline message as argument to ReflogWriter.log()
the Reflog gets corrupted and cannot be parsed. ReflogWriter.log() is
invoked implicitly from various commands such as StashCreate, Rebase and
many more. However the message is not always filtered for line feeds.

Such an example is the StashCreateOperation of EGit which passes
unchecked user input as commit message. If a multiline comment is pasted
to the stash create dialog, the reflog gets corrupted.

ReflogWriter now replaces line endings in log message with spaces.

Bug: 435509
Change-Id: I3010cc902e13bee4d7b6696dfd11ab51062739d3
Signed-off-by: Andreas Hermann <a.v.hermann@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-22 22:58:44 +02:00
Konrad Kügler 7d6dcd4b34 Improve layout of branches in the commit graph
The aim of this change is to place all commits of a branch on the same
lane and commits of other (side) branches on different lanes.

The algorithm treats first parents of a commit specially by placing them
on the same lane as the commit itself. When a commit is the first parent
of multiple children it could be placed on any of these children's
lanes. In this case it is placed on the longest child lane, as this is
usually the lane of the branch the commit actually was made on.

Other (non-first) parents are placed on new lanes. This creates a layout
that should make it easier to see branches and merges and follow linear
branch histories.
This differs from the previous approach, which sometimes plotted the
commits of a side branch on the same lane as the base branch commits and
further commits on the base branch appeared on a different lane.
This made the base branch appear as if it was the side branch and
the side branch appears to be the base branch.

In addition to lane assignment, also the plotting code changed to start
drawing a branch lane from the commit where it forks out. Previously it
started only when the first commit on the branch appeared.

Active lanes are continued with every commit that is processed.
Previously lanes were only continued when the next commit on the lane
was encountered. This could produce (temporarily) dangling commits if
the next commit on the lane was not processed yet.

CQ: 8299
Bug: 419359
Bug: 434945
Change-Id: Ibe547aa24b5948ae264f7d0f56a492a4ef335608
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-22 22:34:22 +02:00
Konrad Kügler c4f3856b39 PlotCommitList: Remove handling of children that have no lane yet
Child commits always have a lane assigned when their parents are
processed, so this code is no longer necessary.

Children only assign themselves to parents in
PlotCommitList.setupChildren(), which is called from enter(), when the
child is processed. If the child leaves enter() it should always have a
lane assigned. As a result of this, when processing a parent, all its
known children already have lanes assigned. If the underlying RevWalk
emits a parent before one of its children (which it should not do), the
parent does not know of the child emitted later, because setupChildren()
has not been called for the child yet. So even in this case, no child
without a lane is encountered when processing a (parent) commit.

Change-Id: I982adc5c114370ecfd699d96221a76463de900ca
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-22 22:29:26 +02:00
Konrad Kügler 09f6b1878a PlotCommitList: Refactor lane creation and position allocation
This also properly removes the newly determinded lane position from the
freePositions set in handleBlockedLanes(). closeLane() does only recycle
active lanes, to avoid recycling lanes twice.

Change-Id: Icd019fcf7974441ed05686bb61d6de4e8bf4ab7c
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-22 22:28:50 +02:00
Matthias Sohn 18fdb5684f Add missing since tags
Change-Id: I6090b81aa963731af369babbe71b05ac817ee3dc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-21 22:34:17 +02:00
Matthias Sohn 1f1e93214b Remove usage of IOException(Throwable) not available on Java 5
Change-Id: I386aa77fb78bed3fb38a3ce46eaeb47df95fdde3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-21 22:32:58 +02:00
Matthias Sohn 0e13adb9cf Prepare post 3.4.0 RC1 builds
Change-Id: Ia8d29046439bc9134acdf7c88ab85ea49c4ddf47
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-21 22:04:43 +02:00
Matthias Sohn d2d56e9efb JGit v3.4.0.201405211411-rc1
Change-Id: Ia3834770b9719f64cbdfd0338034c392fa3ae5db
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-05-21 20:11:56 +02:00
Laurent Goujon 4cb0bd8a43 Adds support for SPNEGO
Adds support for Negotiate(SPNEGO) HTTP authentication method. This method
is set to have a higher priority as Digest HTTP authentication method.

Bug: 428836
Change-Id: Ib181096d39f538df1dd7d3f36516843777bf12ae
Signed-off-by: Laurent Goujon <lgoujon@twitter.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2014-05-21 11:00:26 -05:00
Laurent Goujon 0b5441a8ce Creates HttpAuthMethod type enum to support auth ordering
Refactors HttpAuthMethod to support more authentication methods,
still sorted by priority orders.

Bug: 428836
Change-Id: I049c1742e7afbc51f3f6033fa4d471b344813cfa
Signed-off-by: Laurent Goujon <lgoujon@twitter.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2014-05-21 10:48:35 -05:00
Laurent Goujon 0e7622a915 Detects background authentication and force use of jgit authentication
Sun HttpURLConnection is able to handle authentication like SPNEGO without
caller intervention. However, there are some restrictions:
- do not need user direct input (user,password for example)
- it doesn't work when request body is chunked/streamed (because it cannot be
replayed)

Unfortunately there is no real way to leverage HttpURLConnection authentication
work as the authentication header is stripped off the request before returning
to the caller. There's also no way to explicitly disable authentication in
HttpURLConnection (SPNEGO auth will always be attempted if a valid token can be
created by GSSAPI).

This is an issue for jgit since it is expected that the first request will be
used to detect authentication method, and reuse for the subsequent requests.

This patch modifies TransportHTTP to detect authentication done in the background
by HttpURLConnection and sets the jgit authentication method accordingly so it will
always work for future requests (assuming that the authentication method used by
HttpURLConnection is also supported by jgit).

Bug: 428836
Change-Id: I79f3b70ca2b8377e20da8e6a01914e43e96595ce
Signed-off-by: Laurent Goujon <lgoujon@twitter.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2014-05-21 10:29:57 -05:00
Laurent Goujon ff9c194b8a Adds GSSManager factory class, to be used for SPNEGO HTTP authentication
Adds a factory class for GSSManager. GSSManager is already a factory class but
it doesn't work well with SPNEGO HTTP authentication unless the
javax.security.auth.useSubjectCredsOnly system property is set to false.

On Sun JDK, Sun GSSManagerImpl can be configured directly for SPNEGO auth
(without setting any system property). For a better experience, the class
availability is detected by reflection and used instead.

Detection is only done once, and fallbacks to org.ietf.jgss.GSSManager.

Bug: 428836
Change-Id: Idb9123d1f4013966919db43043ec959d4b133ae2
Signed-off-by: Laurent Goujon <lgoujon@twitter.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2014-05-21 10:15:42 -05:00
Shawn Pearce 6d724dcd33 blame: Revert common subtree elimination "optimization"
This partially reverts 6de12836d7.

Performing a TreeWalk over 2 trees to identify and skip unmodified
subtrees to pass all blame onto an ancestor appears to be a micro
optimization that works for a very limited number of files.  In the
general case the 2 tree walk is slowing down blame more than it helps
to speed it up.

I keep coming up with files in multiple repositories where 6de128 is
making things worse, not better, and only one example where it
actually improved performance, render_view_impl.cc in chromium
as described in the commit message.

Change-Id: Ic6d5fff22acb5ab6485614a07bdb388e8c336679
2014-05-19 15:45:43 -04:00
Robin Rosenberg a5ee6fe904 Merge "Cherry-Pick: Support --mainline to pick merges" 2014-05-19 15:43:22 -04:00
Konrad Kügler b84057ad62 Cherry-Pick: Support --mainline to pick merges
By specifying a mainline parent, a merge is cherry picked as if this
parent was its only parent. If no mainline parent is given, cherry
picking merges is not allowed, as before.

Change-Id: I391cb73bf8f49e2df61428c17b40fae8c86a8b76
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
2014-05-17 19:18:07 +02:00
Robin Rosenberg 1a9f122773 Fix a number of failing conflict situations
Adds further tests where the working tree is dirty (differs from
index) and where we have staged but uncommitted changes.

Fixed the test case 9 for file/directory conflicts.

Bug: 428819
Change-Id: Ie44a288b052abe936ebb74272d0fefef3b218a7a
Signed-off-by: Axel Richard <axel.richard@obeo.fr>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2014-05-17 19:06:07 +02:00
Robin Rosenberg f7ac527ca7 Merge "Archive: Add the ability to select one or more paths." 2014-05-17 13:00:26 -04:00
Konrad Kügler 1350d27e90 Rebase: Write an empty "quiet" file to make C Git happy
C git tries to read this file from the rebase state directory and
complains about it not being there for rebases started by JGit. An empty
'quiet' file represents the (verbose) default.

Change-Id: I1844ccbf8d35442d7a8918b57b67eb9b9efd6352
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
2014-05-16 09:01:23 +02:00
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