]> source.dussan.org Git - jgit.git/log
jgit.git
14 years agoSimilarityRenameDetector: Only attempt to index large files once 90/1890/2
Shawn O. Pearce [Thu, 11 Nov 2010 22:25:01 +0000 (14:25 -0800)]
SimilarityRenameDetector: Only attempt to index large files once

If a file fails to index the first time the loop encounters it, the
file is likely to fail to index again on the next row.  Rather than
wasting a huge amount of CPU to index it again and fail, remember
which destination files failed to index and skip over them on each
subsequent row.

Because this condition is very unlikely, avoid allocating the BitSet
until its actually needed.  This keeps the memory usage unaffected
for the common case.

Change-Id: I93509b28b61a9bba8f681a7b4df4c6127bca2a09
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoSimilarityIndex: Don't overflow internal counter fields 98/1898/1
Shawn O. Pearce [Fri, 12 Nov 2010 19:56:40 +0000 (11:56 -0800)]
SimilarityIndex: Don't overflow internal counter fields

The counter portion of each pair is only 32 bits wide, but is part
of a larger 64 bit integer.  If the file size was larger than 4 GB
the counter could overflow and impact the key, changing the hash,
and later resulting in an incorrect similarity score.

Guard against this overflow condition by capping the count for each
record at 2^32-1.  If any record contains more than that many bytes
the table aborts hashing and throws TableFullException.

This permits the index to scan and work on files that exceed 4 GB
in size, but only if the file contains more than one unique block.
The index throws TableFullException on a 4 GB file containing all
zeros, but should succeed on a 6 GB file containing unique lines.

The index now uses a 64 bit accumulator during the common scoring
algorithm, possibly resulting in slower summations.  However this
index is already heavily dependent upon 64 bit integer operations
being efficient, so increasing from 32 bits to 64 bits allows us
to correctly handle 6 GB files.

Change-Id: I14e6dbc88d54ead19336a4c0c25eae18e73e6ec2
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoSimilarityIndex: Accept files larger than 8 MB 89/1889/2
Shawn O. Pearce [Thu, 11 Nov 2010 22:10:32 +0000 (14:10 -0800)]
SimilarityIndex: Accept files larger than 8 MB

Files bigger than 8 MB (2^23 bytes) tended to overflow the internal
hashtable, as the table was capped in size to 2^17 records.  If a
file contained 2^17 unique data blocks/lines, the table insertion
got stuck in an infinite loop as the able couldn't grow, and there
was no open slot for the new item.

Remove the artifical 2^17 table limit and instead allow the table
to grow to be as big as 2^30.  With a 64 byte block size, this
permits hashing inputs as large as 64 GB.

If the table reaches 2^30 (or cannot be allocated) hashing is
aborted.  RenameDetector no longer tries to break a modify file pair,
and it does not try to match the file for rename or copy detection.

Change-Id: Ibb4d756844f4667e181e24a34a468dc3655863ac
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoSimilarityIndex: Correct comment explaining the logic 97/1897/1
Shawn O. Pearce [Fri, 12 Nov 2010 19:50:38 +0000 (11:50 -0800)]
SimilarityIndex: Correct comment explaining the logic

This comment was wrong, due to a copy-and-paste error.  Here the
code is looking at records of dst that do not exist in src, and
are skipping past them to find another match.

Change-Id: I07c1fba7dee093a1eeffcf7e0c7ec85446777ffb
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoLazy load note subtrees from fanout levels 49/1849/4
Shawn O. Pearce [Fri, 5 Nov 2010 01:23:40 +0000 (18:23 -0700)]
Lazy load note subtrees from fanout levels

Instead of reading a note tree recursively up front when the NoteMap
is loaded, read only the root tree and load subtrees on demand when
they are accessed by the application.  This gives a lower latency
to read a note for the recent commits on a branch, as only the paths
that are needed get read.

Given a 2/38 style fanout, the tree will fully load when 256 objects
have been accessed by the application.  But unlike the prior version
of NoteMap, the NoteMap will load faster and answer lookups sooner,
as the loading time for all 256 levels is spread out across each of
the get() requests.

Given a 2/2/36 style fanout, the tree won't need to fully load until
about 65,536 objects are accessed.

To simplify the implementation we only support the flat layout (all
notes in the top level tree), or a 2/38, 2/2/36, 2/2/2/34, through
2/.../2 style fanout.  Unlike C Git we don't support reading the old
experimental 4/36 fanout.  This is sufficient because C Git won't
create the 4/36 style fanout when creating or updating a notes tree,
and there really aren't any in the wild today.

Change-Id: I6099b35916a8404762f31e9c11f632e43e0c1bfd
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoDefine NoteMap, a simple note tree reader 33/1833/5
Shawn O. Pearce [Fri, 5 Nov 2010 01:24:45 +0000 (18:24 -0700)]
Define NoteMap, a simple note tree reader

The NoteMap makes it easy to read a small notes tree as created by
the `git notes` command in C Git.  To make the initial implementation
simple a notes tree is read recursively into a map in memory.
This is reasonable if the application will need to access all notes,
or if there are less than 256 notes in the tree, but doesn't behave
well when the number of notes exceeds 256 and the application
doesn't need to access all of them.

We can later add support for lazily loading different subpaths,
thus fixing the large note tree problem described above.

Currently the implementation only supports reading.  Writing notes
is more complex because trees need to be expanded or collapsed at
the exact 256 entry cut-off in order to retain the same tree SHA-1
that C Git would use for the same content.  It also needs to retain
non-note tree entries such as ".gitignore" or ".gitattribute" files
that might randomly appear within a notes tree.  We can also add
writing support later.

Change-Id: I93704bd84ebf650d51de34da3f1577ef0f7a9144
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
14 years agoMerge "Add MutableObjectId setByte to modify a mutable id"
Chris Aniszczyk [Thu, 11 Nov 2010 15:52:37 +0000 (10:52 -0500)]
Merge "Add MutableObjectId setByte to modify a mutable id"

14 years agoMerge "Implement command line support for CredentialsProvider"
Chris Aniszczyk [Thu, 11 Nov 2010 15:28:56 +0000 (10:28 -0500)]
Merge "Implement command line support for CredentialsProvider"

14 years agoMerge "Support CredentialsProvider for SSH connections"
Chris Aniszczyk [Thu, 11 Nov 2010 15:27:52 +0000 (10:27 -0500)]
Merge "Support CredentialsProvider for SSH connections"

14 years agoMerge "Define a default CredentialsProvider"
Stefan Lay [Thu, 11 Nov 2010 14:36:34 +0000 (09:36 -0500)]
Merge "Define a default CredentialsProvider"

14 years agoMerge "Enable providing credentials for HTTP authentication"
Stefan Lay [Thu, 11 Nov 2010 14:35:43 +0000 (09:35 -0500)]
Merge "Enable providing credentials for HTTP authentication"

14 years agoImplement command line support for CredentialsProvider 81/1881/1
Shawn O. Pearce [Wed, 10 Nov 2010 22:41:10 +0000 (14:41 -0800)]
Implement command line support for CredentialsProvider

Instead of configuring the JSch session factory, configure a more
generic CredentialsProvider, which will work for other transport
types such as http, in addition to the existing ssh.

Change-Id: I22b13303c17e654ba6720edf4be2ef15fe29537a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoMerge "Add ObjectId getByte for random access"
Chris Aniszczyk [Wed, 10 Nov 2010 23:00:36 +0000 (18:00 -0500)]
Merge "Add ObjectId getByte for random access"

14 years agoSupport CredentialsProvider for SSH connections 80/1880/1
Shawn O. Pearce [Wed, 10 Nov 2010 22:18:46 +0000 (14:18 -0800)]
Support CredentialsProvider for SSH connections

When setting up an SSH connection, use the caller supplied
CredentialsProvider, if one has been given to the Transport
or was defined as the default.

The CredentialsProvider is re-wrapped as a JSch UserInfo,
allowing the connection to use this for user interactive
prompts.  This give a unified API for authentication on
any transport type.

Change-Id: Id3b4cf5bfd27a23207cdfb188bae3b78e71e02c0
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoDefine a default CredentialsProvider 79/1879/1
Shawn O. Pearce [Wed, 10 Nov 2010 22:15:50 +0000 (14:15 -0800)]
Define a default CredentialsProvider

This permits applications to set their preferred credentials UI
implementation once, rather than needing to define it on every
single Transport instance they open.

Change-Id: I010550de1a6becab27f7aa5a9901df5a1c7e74bd
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoEnable providing credentials for HTTP authentication 71/1671/3
Shawn O. Pearce [Wed, 10 Nov 2010 22:14:35 +0000 (14:14 -0800)]
Enable providing credentials for HTTP authentication

This change is based on http://egit.eclipse.org/r/#change,1652
by David Green. The change adds the concept of a CredentialsProvider
which can be registered for git transports and which is
responsible to return credential-related data like passwords and
usernames. Whenenver the transports detects that an authentication
with certain credentials has to be done it will ask the
CredentialsProvider for this data. Foreseen implementations for
such a Provider may be a EGitCredentialsProvider (caching
credential data entered e.g. in the Clone-Wizzard) or a NetRcProvider
(gathering data out of ~/.netrc file).

Bug: 296201
Change-Id: Ibe13e546b45eed3e193c09ecb414bbec2971d362
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
CC: David Green <dgreen99@gmail.com>
14 years agoMerge "Refactor tree entry formatting into a common class"
Chris Aniszczyk [Wed, 10 Nov 2010 22:53:35 +0000 (17:53 -0500)]
Merge "Refactor tree entry formatting into a common class"

14 years agoFix WWW-Authenticate auth-scheme comparison 76/1876/2
Stefan Lay [Wed, 10 Nov 2010 08:42:51 +0000 (09:42 +0100)]
Fix WWW-Authenticate auth-scheme comparison

The auth-scheme token (like "Basic" or "Digest") is not specified in a
case sensitive way. RFC2617 (http://tools.ietf.org/html/rfc2617) specifies
in section 1.2 the use of a "case-insensitive token to identify the
authentication scheme". Jetty, for example, uses "basic" as token.

Change-Id: I635a94eb0a741abcb3e68195da6913753bdbd889
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
14 years agoMerge "Fix broken MergeCommandTest"
Shawn Pearce [Tue, 9 Nov 2010 23:58:34 +0000 (18:58 -0500)]
Merge "Fix broken MergeCommandTest"

14 years agoMerge "Revert "[findBugs] Silence DM_STRING_CTOR on PacketLineIn""
Matthias Sohn [Tue, 9 Nov 2010 23:18:41 +0000 (18:18 -0500)]
Merge "Revert "[findBugs] Silence DM_STRING_CTOR on PacketLineIn""

14 years agoFix broken MergeCommandTest 75/1875/1
Matthias Sohn [Tue, 9 Nov 2010 23:11:12 +0000 (00:11 +0100)]
Fix broken MergeCommandTest

Test was broken by commit b087bba3 changing formatting of merge
commit messages.

Change-Id: I98b1b936b9b6cbaa50fbc59d243a43e66a6ee9f9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
14 years agoFix URIish parsing of absolute scp-style URIs 74/1874/1
Shawn O. Pearce [Tue, 9 Nov 2010 22:36:01 +0000 (14:36 -0800)]
Fix URIish parsing of absolute scp-style URIs

We stopped handling URIs such as "example.com:/some/p ath", because
this was confused with the Windows absolute path syntax of "c:/path".
Support absolute style scp URIs again, but only when the host name
is more than 2 characters long.

Change-Id: I9ab049bc9aad2d8d42a78c7ab34fa317a28efc1a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoMerge "Format merge commit messages like C Git"
Shawn Pearce [Tue, 9 Nov 2010 22:14:11 +0000 (17:14 -0500)]
Merge "Format merge commit messages like C Git"

14 years agoRevert "[findBugs] Silence DM_STRING_CTOR on PacketLineIn" 70/1870/1
Shawn O. Pearce [Mon, 8 Nov 2010 23:34:47 +0000 (15:34 -0800)]
Revert "[findBugs] Silence DM_STRING_CTOR on PacketLineIn"

This reverts commit 1e510ec20e0391010419b17e9a9095ad54941d3c.

Instead work around the warning by defining our constant by
constructing it through a StringBuilder.

Change-Id: If139509e769d649609c62eff359ebaea5dd286b2
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
CC: Matthias Sohn <matthias.sohn@sap.com>
CC: Chris Aniszczyk <caniszczyk@gmail.com>
14 years agoMerge "IndexDiff: support state [removed, untracked]"
Shawn Pearce [Mon, 8 Nov 2010 23:32:45 +0000 (18:32 -0500)]
Merge "IndexDiff: support state [removed, untracked]"

14 years agoIndexDiff: support state [removed, untracked] 67/1867/2
Jens Baumgart [Mon, 8 Nov 2010 15:18:57 +0000 (16:18 +0100)]
IndexDiff: support state [removed, untracked]

IndexDiff was extended to detect files which are both removed from the
index and untracked.  Before this change these files were only added
to the removed collection.

Change-Id: I971d8261d2e8932039fce462b59c12e143f79f90
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoMerge "Make Repository.shortenRefName static"
Shawn Pearce [Mon, 8 Nov 2010 22:42:21 +0000 (17:42 -0500)]
Merge "Make Repository.shortenRefName static"

14 years agoFixed help of Diff and ShowCommands commands 63/1863/2
Christian Halstrick [Sun, 7 Nov 2010 20:42:41 +0000 (21:42 +0100)]
Fixed help of Diff and ShowCommands commands

jgit.sh <command> --help was not working for the commands Diff
and ShowCommands because of missing metaVar information. Missing
information is added here.

Change-Id: I0ab7e35006b6aa7d4326a634309dddfcdb78f2a6
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
14 years agoMerge "CommitAndLogCommandTests: add a test for LogCommand.addRange()"
Chris Aniszczyk [Mon, 8 Nov 2010 12:50:43 +0000 (07:50 -0500)]
Merge "CommitAndLogCommandTests: add a test for LogCommand.addRange()"

14 years agoMerge "[findBugs] Fix NP_LOAD_OF_KNOWN_NULL_VALUE"
Chris Aniszczyk [Sun, 7 Nov 2010 21:09:00 +0000 (16:09 -0500)]
Merge "[findBugs] Fix NP_LOAD_OF_KNOWN_NULL_VALUE"

14 years agoMerge "[findBugs] Silence DM_STRING_CTOR on PacketLineIn"
Chris Aniszczyk [Sun, 7 Nov 2010 21:07:43 +0000 (16:07 -0500)]
Merge "[findBugs] Silence DM_STRING_CTOR on PacketLineIn"

14 years agoMerge "Implemented the git add commandline command."
Chris Aniszczyk [Sun, 7 Nov 2010 21:05:24 +0000 (16:05 -0500)]
Merge "Implemented the git add commandline command."

14 years agoImplemented the git add commandline command. 57/1857/2
Sasa Zivkov [Fri, 5 Nov 2010 14:18:00 +0000 (15:18 +0100)]
Implemented the git add commandline command.

Implementation delegates all work to the AddCommand class and,
therefore, supports only those options currently supported by the
AddCommand which means: --update and the filepattern... arguments.

Change-Id: I4827d37e08b4c988c2458d9ba60a61b6ad414d10
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
14 years ago[findBugs] Silence DM_STRING_CTOR on PacketLineIn 61/1861/2
Matthias Sohn [Sun, 7 Nov 2010 20:22:23 +0000 (21:22 +0100)]
[findBugs] Silence DM_STRING_CTOR on PacketLineIn

We don't want to pool this String.

Change-Id: I68bb1c57fac2e138eece4503ca5bda8f69261083
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
14 years ago[findBugs] Fix NP_LOAD_OF_KNOWN_NULL_VALUE 62/1862/1
Matthias Sohn [Sun, 7 Nov 2010 19:16:15 +0000 (20:16 +0100)]
[findBugs] Fix NP_LOAD_OF_KNOWN_NULL_VALUE

The code analyzer can't know that passing a value known to be null is
not a problem. Hence better pass null explicitly instead of the
parameters being null.

Change-Id: I8db6f8014de6c00dd95974d60f61ecc66191e6d4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
14 years agoFixed ResolveMerger regarding handling of deletions 46/1846/2
Christian Halstrick [Wed, 3 Nov 2010 13:13:56 +0000 (14:13 +0100)]
Fixed ResolveMerger regarding handling of deletions

There was a bug in ResolveMerger which is one reason for
bug 328841. If a merge was failing because of conflicts
deletions where not handled correctly. Files which have
to be deleted (because there was a non-conflicting deletion
coming in from THEIRS) are not deleted. In the
non-conflicting case we also forgot to delete the file but
in this case we explicitly checkout in the end these files
get deleted during that checkout.

This is fixed by handling incoming deletions explicitly.

Bug: 328841
Change-Id: I7f4c94ab54138e1b2f3fcdf34fb803d68e209ad0
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
14 years agoFormat merge commit messages like C Git 10/1810/3
Robin Stocker [Wed, 3 Nov 2010 20:36:29 +0000 (21:36 +0100)]
Format merge commit messages like C Git

The automatically generated commit message of a merge should have the
same structure as in C Git for consistency (as per git fmt-merge-msg).

Before this change:

  merging refs/heads/a into refs/heads/master

After:

  Merge branch 'a'

Plurals, "into" and joining by "," and "and" also work.

Change-Id: I9658ce2817adc90d2df1060e8ac508d7bd0571cb

14 years agoMake Repository.shortenRefName static 59/1859/1
Robin Stocker [Sat, 6 Nov 2010 12:41:06 +0000 (13:41 +0100)]
Make Repository.shortenRefName static

The method has no reason to be non-static.

Change-Id: I1c09e074395d49cee0e6e53679b499d1f0c351ea

14 years agoMerge "Add a test for merging deleted files"
Shawn Pearce [Fri, 5 Nov 2010 22:03:19 +0000 (18:03 -0400)]
Merge "Add a test for merging deleted files"

14 years agoMerge changes I8d77cb59,I2beb4db5
Shawn Pearce [Fri, 5 Nov 2010 21:38:44 +0000 (17:38 -0400)]
Merge changes I8d77cb59,I2beb4db5

* changes:
  Fixed merge algorithm regarding adjacent modifications
  Cleaned up MergeAlgorithmTest

14 years agoFixed the git init to properly set bare=true 58/1858/1
Sasa Zivkov [Fri, 5 Nov 2010 15:01:10 +0000 (16:01 +0100)]
Fixed the git init to properly set bare=true

When --git-dir=X is given JGit creates a bare repository in the
directory X. However, when the --bare option is not explicitly
given, this is not properly reflected in the X/config file i.e.
the bare=true is missing.  This change fixes this minor issue.

Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
14 years agoCommitAndLogCommandTests: add a test for LogCommand.addRange() 65/1865/1
Mathias Kinzler [Fri, 5 Nov 2010 11:26:56 +0000 (12:26 +0100)]
CommitAndLogCommandTests: add a test for LogCommand.addRange()

There were also some compiler warning due to empty catch blocks that
were fixed.

Change-Id: I165bcddcdfacd34f020d1b938a41954916eb106e
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
14 years agoAdd MutableObjectId setByte to modify a mutable id 48/1848/2
Shawn O. Pearce [Thu, 4 Nov 2010 02:01:53 +0000 (19:01 -0700)]
Add MutableObjectId setByte to modify a mutable id

This mirrors the getByte() API in ObjectId and allows the caller to
modify a single byte, which is useful when updating it as part of a
loop walking through 0x00..0xff inside of a range of objects.

Change-Id: I57fa8420011fe5ed5fc6bfeb26f87a02b3197dab
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoAdd ObjectId getByte for random access 47/1847/2
Shawn O. Pearce [Tue, 2 Nov 2010 23:29:39 +0000 (16:29 -0700)]
Add ObjectId getByte for random access

Processing git notes requires random access to part of the raw data
of each ObjectId... which isn't easy because ObjectIds are stored
with an internal representation of 5 ints.  Expose random access
to the individual data bytes through new methods, avoiding the
need to convert first to a byte[20].

Change-Id: I99e64700b27fc0c95aa14ef8ad46a0e8832d4441
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoRefactor tree entry formatting into a common class 44/1844/2
Shawn O. Pearce [Tue, 2 Nov 2010 21:12:00 +0000 (14:12 -0700)]
Refactor tree entry formatting into a common class

Instead of hiding this logic inside of DirCacheTree and the legacy
Tree type, pull it into a common place where we can reuse it by
creating tree records in a buffer that can be passed directly into
the ObjectInserter.  This allows us to avoid some copying, as the
inserter can be given the internal buffer of the formatter.

Because we trust these two callers to feed us records in the proper
order, without '/' in the names, and without duplicate names in the
same tree, we don't do any validation inside of the formatter itself.
To protect themselves from making ordering errors, developers should
continue to use DirCache to process edits to source code trees.

Change-Id: Idf7f10e736d4a44ccdf8afe060535d7b0554a92f
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoAdd a test for merging deleted files 45/1845/1
Christian Halstrick [Wed, 3 Nov 2010 12:32:54 +0000 (13:32 +0100)]
Add a test for merging deleted files

The JGit merge algorithm or the Merge Command may have problems with handling
deletions always correctly. Therefore one additional test is added to check
this.

Change-Id: Id6aa49136996b29047c340994fe7faba68858e8c
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
14 years agoFixed merge algorithm regarding adjacent modifications 43/1843/1
Christian Halstrick [Tue, 2 Nov 2010 16:39:59 +0000 (17:39 +0100)]
Fixed merge algorithm regarding adjacent modifications

JGit merge algorithm behaved differently from C Git when
we had adjacent modifications. If line 9 was modified by
OURS and line 10 by theirs then C Git will return a
conflict while JGit was seeing this as independent
modifications. This change is not only there to achieve
compatibility, but there where also some really wrong
merge results produced by JGit in the area of adjacent
modifications.

Change-Id: I8d77cb59e82638214e45b3cf9ce3a1f1e9b35c70
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
14 years agoCleaned up MergeAlgorithmTest 42/1842/1
Christian Halstrick [Tue, 2 Nov 2010 16:33:15 +0000 (17:33 +0100)]
Cleaned up MergeAlgorithmTest

Introduced similar helper methods than in AbstractDiffTestCase.
Then the test cases are much smaller and better understandable.

Change-Id: I2beb4db5a93bd8c0c1238d5d3039cbd6719eee90
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
14 years agoMerge "Exclude FindBugs warning about uninitialized read"
Shawn Pearce [Mon, 1 Nov 2010 21:24:20 +0000 (17:24 -0400)]
Merge "Exclude FindBugs warning about uninitialized read"

14 years agoFix ugly diff showing insertion of new method 31/1831/3
Shawn O. Pearce [Sat, 30 Oct 2010 01:35:43 +0000 (18:35 -0700)]
Fix ugly diff showing insertion of new method

When adding a new method near the end of the sequence we want to
show the full method inserted, and not tear the prior method due
to the common trailing curly brace being consumed as part of the
common end region of the sequences.

Bug: 328895
Change-Id: I233bc40445fb5452863f5fb082bc3097433a8da6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoDelete DiffPerformanceTest 30/1830/2
Shawn O. Pearce [Sat, 30 Oct 2010 01:04:10 +0000 (18:04 -0700)]
Delete DiffPerformanceTest

This test isn't that useful.  The better way to evaluate diff
algorithm performance is to run `jgit debug-diff-algorithms` over
real-world repositories, such as linux-2.6.git.  Whenever we modify
an algorithm we should manually verify that its runtime performance
doesn't get any worse than it already is.

Change-Id: I0beed3a5a8a537c958a5a6438a1283f97fa2097a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoFix broken HistogramDiff 29/1829/2
Shawn O. Pearce [Sat, 30 Oct 2010 00:50:26 +0000 (17:50 -0700)]
Fix broken HistogramDiff

HistogramDiff failed on cases where the initial element for the LCS
was actually very common (e.g. has 20 occurrences), and the first
element of the inserted region after the LCS was also common but
had fewer occurrences (e.g. 10), while the LCS also contained a
unique element (1 occurrence).

This happens often in Java source code.  The initial element for
the LCS might be the empty line ("\n"), and the inserted but common
element might be "\t/**\n", with the LCS being a large span of
lines that contains unique method declarations.  Even though "/**"
occurs less often than the empty line its not a better LCS if the
LCS we already have contains a unique element.

The logic in HistogramDiff would normally have worked fine, except I
tried to optimize scanning of B by making tryLongestCommonSequence
return the end of the region when there are matching elements
found in A.  This allows us to skip over the current LCS region,
as it has already been examined, but caused us to fail to identify
an element that had a lower occurrence count within the region.

The solution used here is to trade space-for-time by keeping a
table of A positions to their occurrence counts.  This allows the
matching logic to always use the smallest count for this region,
even if the smallest count doesn't appear on the initial element.

The new unit test testEdit_LcsContainsUnique() verifies this new
behavior works as expected.

Bug: 328895
Change-Id: Id170783b891f645b6a8cf6f133c6682b8de40aaf
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoExclude FindBugs warning about uninitialized read 23/1823/2
Robin Stocker [Fri, 29 Oct 2010 13:25:19 +0000 (15:25 +0200)]
Exclude FindBugs warning about uninitialized read

This gets rid of the "Uninitialized read of blockIndex" warning.

Change-Id: Ieb31b5059d7b9a6adff2251baf179bda5f82e7a5

14 years agoCorrect typo in HistogramDiffIndex Javadoc 28/1828/1
Shawn O. Pearce [Sat, 30 Oct 2010 00:02:26 +0000 (17:02 -0700)]
Correct typo in HistogramDiffIndex Javadoc

Change-Id: I8bd2e81fcc14aa86919c504f1d0001944dea50b2
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoMerge "Exclude FindBugs warnings about Cloneable"
Shawn Pearce [Fri, 29 Oct 2010 14:50:07 +0000 (10:50 -0400)]
Merge "Exclude FindBugs warnings about Cloneable"

14 years agoMerge "Remove two "Dead store to local variable" warnings"
Shawn Pearce [Fri, 29 Oct 2010 14:49:45 +0000 (10:49 -0400)]
Merge "Remove two "Dead store to local variable" warnings"

14 years agoMerge "Use entrySet() instead of keySet()"
Shawn Pearce [Fri, 29 Oct 2010 14:48:18 +0000 (10:48 -0400)]
Merge "Use entrySet() instead of keySet()"

14 years agoMerge "Use readFully() instead of read()"
Shawn Pearce [Fri, 29 Oct 2010 14:47:26 +0000 (10:47 -0400)]
Merge "Use readFully() instead of read()"

14 years agoMerge "Use Character.valueOf instead of new Character"
Shawn Pearce [Fri, 29 Oct 2010 14:43:55 +0000 (10:43 -0400)]
Merge "Use Character.valueOf instead of new Character"

14 years agoMerge "Remove unnecessary null check"
Shawn Pearce [Fri, 29 Oct 2010 14:43:32 +0000 (10:43 -0400)]
Merge "Remove unnecessary null check"

14 years agoMake private final field static 24/1824/1
Robin Stocker [Fri, 29 Oct 2010 13:27:10 +0000 (15:27 +0200)]
Make private final field static

It's used as a constant.

Change-Id: Ic267e8cb5b62228de15e134cd80725df592a0171

14 years agoRemove unnecessary null check 22/1822/1
Robin Stocker [Fri, 29 Oct 2010 13:12:48 +0000 (15:12 +0200)]
Remove unnecessary null check

The field monitor is never null, it's a NullProgressMonitor when not
explicitly set.

Change-Id: I8ce703a32c28ce5c3455efeb7ed5f5c9a443cbef

14 years agoUse Character.valueOf instead of new Character 21/1821/1
Robin Stocker [Fri, 29 Oct 2010 13:04:27 +0000 (15:04 +0200)]
Use Character.valueOf instead of new Character

Otherwise a new Character is allocated each time instead of
using the cache.

Change-Id: I648d0b012f66ba9dc46a37a390986f9c61e5a19c

14 years agoUse readFully() instead of read() 20/1820/1
Robin Stocker [Fri, 29 Oct 2010 12:52:52 +0000 (14:52 +0200)]
Use readFully() instead of read()

Fixes the "Method ignores results of InputStream.read()" warning.

This is the only place where read() was used instead of readFully()
and the return value was not checked. So it was either an oversight
or should be documented. This change assumes it was an oversight.

Change-Id: I859404a7d80449c538a552427787f3e57d7c92b4

14 years agoUse entrySet() instead of keySet() 19/1819/1
Robin Stocker [Fri, 29 Oct 2010 12:41:39 +0000 (14:41 +0200)]
Use entrySet() instead of keySet()

The value was accessed every time in the loop body with get(),
so use the more efficient entrySet().

Change-Id: I91d90cbd0b0d03ca4a3db986c58b8d80d80f40a4

14 years agoRemove two "Dead store to local variable" warnings 18/1818/1
Robin Stocker [Fri, 29 Oct 2010 12:32:55 +0000 (14:32 +0200)]
Remove two "Dead store to local variable" warnings

Change-Id: I950de82db15c4610dc5a94f304279971daef971e

14 years agoExclude FindBugs warnings about Cloneable 17/1817/1
Robin Stocker [Fri, 29 Oct 2010 12:26:33 +0000 (14:26 +0200)]
Exclude FindBugs warnings about Cloneable

This was already disabled in the Eclipse preferences for the project.
With this, Hudson should also ignore it.

Change-Id: I7a6b9a20451dc5ba9a61553248b5f4b6c6c7a78b

14 years agoMerge "Fix Severe Bug in Merge Algorithm"
Shawn Pearce [Thu, 28 Oct 2010 19:54:36 +0000 (15:54 -0400)]
Merge "Fix Severe Bug in Merge Algorithm"

14 years agoFix Severe Bug in Merge Algorithm 09/1809/3
Christian Halstrick [Wed, 27 Oct 2010 20:12:46 +0000 (22:12 +0200)]
Fix Severe Bug in Merge Algorithm

As described in Bug 328551 there was a bug that the merge algorithm
was not always reporting conflicts when the same line was deleted
and modified. This problem was introduced during commit
0c017188b4d41cc80c297e35097095026734b3d4 when reported conflicts have
been checked for common pre- and suffixes.

This was fixed here by better determining whether after stripping
off common prefixes and suffixes from a conflicting region there
is still some conflicting part left.
I also added a unit test to test this situation.

Bug: 328551
Change-Id: Iec6c9055d00e5049938484a27ab98dda2577afc4
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
14 years agoPullCommand: support upstream configuration for local branches 47/1747/4
Mathias Kinzler [Tue, 19 Oct 2010 06:54:28 +0000 (08:54 +0200)]
PullCommand: support upstream configuration for local branches

When creating a local branch based on another local branch, the
upstream configuration contains "." as origin and the source branch
as "merge". The PullCommand should support this by skipping the
fetch step altogether and use the base branch to merge with.

Change-Id: I260a1771aeeffca5b0161d1494fd63c672ecc2a6
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
14 years agoMerge "Fix FQCN of moved classes in FindBugsExcludeFilter.xml"
Shawn Pearce [Thu, 28 Oct 2010 15:47:44 +0000 (11:47 -0400)]
Merge "Fix FQCN of moved classes in FindBugsExcludeFilter.xml"

14 years agoMerge "Make AbbreviatedObjectId serializable"
Shawn Pearce [Thu, 28 Oct 2010 15:47:06 +0000 (11:47 -0400)]
Merge "Make AbbreviatedObjectId serializable"

14 years agoMerge "Fix oddness check in MyersDiff for negative numbers"
Shawn Pearce [Thu, 28 Oct 2010 15:46:41 +0000 (11:46 -0400)]
Merge "Fix oddness check in MyersDiff for negative numbers"

14 years agoMake AbbreviatedObjectId serializable 12/1812/1
Robin Stocker [Thu, 28 Oct 2010 15:40:15 +0000 (17:40 +0200)]
Make AbbreviatedObjectId serializable

AmbiguousObjectException contains an AbbreviatedObjectId and is
supposed to be serializable, so it should be serializable as well.

Change-Id: I8056e78aee20fdd3cb9600b52cd8ed988544293d

14 years agoFix FQCN of moved classes in FindBugsExcludeFilter.xml 11/1811/1
Robin Stocker [Thu, 28 Oct 2010 15:38:16 +0000 (17:38 +0200)]
Fix FQCN of moved classes in FindBugsExcludeFilter.xml

FindBugs would generate warnings for these even though they should
be ignored.

Change-Id: Ieccadbf11fd55853541c04857d8e79a4db014cb4

14 years agoFix oddness check in MyersDiff for negative numbers 13/1813/1
Robin Stocker [Thu, 28 Oct 2010 15:37:21 +0000 (17:37 +0200)]
Fix oddness check in MyersDiff for negative numbers

It's probably not possible that these numbers are negative in the
algorithm, but it's cleaner this way and gets rid of three more
FindBugs warnings.

Change-Id: Ifbce4e2c787fb9a7cd309c605e8d86211ef8a352

14 years agoFix FindBugs and Eclipse warnings in org.eclipse.jgit.ui 14/1814/1
Robin Stocker [Thu, 28 Oct 2010 14:37:49 +0000 (16:37 +0200)]
Fix FindBugs and Eclipse warnings in org.eclipse.jgit.ui

Change-Id: Ie6b3ff7d470cc9b7044fd6288cbf86dcc58220eb

14 years agoMerge "Call ProgressMonitor.update() from main thread"
Shawn O. Pearce [Wed, 27 Oct 2010 15:37:55 +0000 (11:37 -0400)]
Merge "Call ProgressMonitor.update() from main thread"

14 years agoCall ProgressMonitor.update() from main thread 07/1707/5
Shawn O. Pearce [Thu, 14 Oct 2010 20:06:54 +0000 (13:06 -0700)]
Call ProgressMonitor.update() from main thread

Don't permit transient worker threads to access the underlying output
stream of a ProgressMonitor, as they might get marked as the stream's
writer thread.  Instead proxy update events from the workers back onto
the application's real work thread.  This ensures that the stream only
sees a single thread, and its the thread that will remain alive for
the entire life cycle of the operation.

This fixes IOException("Write end dead") during local repository fetch
when threaded delta search is enabled.  One of the transient delta
search threads became the designated writer for the pipe, and when it
terminated the reader end thought the writer was dead, even though the
main writer thread was still executing in PackWriter.

Bug: 326557
Change-Id: I01d1b20a3d7be1c0b480c7fb5c9773c161fe5c15
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoPrevent endless loop of events fired by RefsDirectory 04/1804/1
Christian Halstrick [Wed, 27 Oct 2010 08:37:05 +0000 (10:37 +0200)]
Prevent endless loop of events fired by RefsDirectory

RefsDirectory fires a RefsChangedEvent when it detect that one
ref changed (new, modified, deleted). But there was a potential
of wrong events beeing fired leading to a endless loop in EGit.
Problem is that when calling getRefs(ALL) we don't want to report
additional refs and by that we remove the additional refs from
the list of "refs reported upwards last time". We fire an
RefsChangedEvent because we think that the special refs are not
there anymore.
I fixed this by removing eventing for the additional refs. Another
alternative would be to always scan also for additional refs and
put them in the list of refs. But getRefs(ALL) would then remove
the additional refs again. I didn't do that for performance reasons
and also because I am not sure whether we want evnting for
additional refs.

Change-Id: Icb9398b55a8c6bbf03e38f6670feb67754ce91e0
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
14 years agoOptimize DirCacheCheckout 82/1782/4
Lluis Sanchez [Tue, 26 Oct 2010 09:18:18 +0000 (11:18 +0200)]
Optimize DirCacheCheckout

When checking out a tree, files that are identical to the file in
the current index and working directory don't need to be updated.

Change-Id: I9e025a53facd42410796eae821baaeff684a25c5
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
14 years agoAdd option to select diff algorithm for diff command 03/1803/1
Christian Halstrick [Tue, 26 Oct 2010 16:04:35 +0000 (18:04 +0200)]
Add option to select diff algorithm for diff command

The diff command in the pgm package was enhanced to allow
choosing the diff algorithm (currently myers or histogram)

Change-Id: I72083e78fb5c92868eb5d8ec512277d212a39349
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
14 years agoMerge "[findbugs] Respect exclude filter in maven build"
Shawn Pearce [Mon, 25 Oct 2010 15:06:15 +0000 (11:06 -0400)]
Merge "[findbugs] Respect exclude filter in maven build"

14 years agoMerge "Allow setting a filter in IndexDiff"
Christian Halstrick [Mon, 25 Oct 2010 12:37:59 +0000 (08:37 -0400)]
Merge "Allow setting a filter in IndexDiff"

14 years agoAllow setting a filter in IndexDiff 79/1779/3
Jens Baumgart [Mon, 25 Oct 2010 11:00:13 +0000 (13:00 +0200)]
Allow setting a filter in IndexDiff

IndexDiff now allows to set an additional filter. This can be used
e.g. for restricting the tree walk to a given set of files.

Change-Id: I642de17e74b997fa0c5878c90631f6640ed70bdd
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
14 years agoAdd support for special symref FETCH_HEAD and MERGE_HEAD 72/1772/3
Christian Halstrick [Wed, 20 Oct 2010 15:39:19 +0000 (17:39 +0200)]
Add support for special symref FETCH_HEAD and MERGE_HEAD

The RefDirectory class was not returning FETCH_HEAD and
MERGE_HEAD when trying to get all refs via getRefs(RefDatabase.ALL).
This fix adds constants for FETCH_HEAD and ORIG_HEAD and adds a
new getter getAdditionalRefs() to get these additional refs.
To be compatible with c git the getRefs(ALL) method will not return
FETCH_HEAD, MERGE_HEAD and ORIG_HEAD.

Change-Id: Ie114ca92e9d5e7d61d892f4413ade65acdc08c32
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
14 years ago[findbugs] Fix illegal format specifier 85/1785/2
Matthias Sohn [Sat, 23 Oct 2010 21:56:06 +0000 (23:56 +0200)]
[findbugs] Fix illegal format specifier

For integral arguments the precision is not applicable, would cause a
runtime exception when executed, see
http://download.oracle.com/javase/1.5.0/docs/api/java/util/Formatter.html#syntax

Change-Id: I4738c64c1153a8d4ef5430e15d0fe54f0a37949f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
14 years ago[findbugs] Respect exclude filter in maven build 86/1786/1
Matthias Sohn [Sat, 23 Oct 2010 21:29:25 +0000 (23:29 +0200)]
[findbugs] Respect exclude filter in maven build

Change-Id: Ic29310dc14f120ebdb49d33cbf4bd6d380ae1393
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
14 years ago[findbugs] Static comparator made final 84/1784/1
Matthias Sohn [Sat, 23 Oct 2010 20:25:29 +0000 (22:25 +0200)]
[findbugs] Static comparator made final

Fixing FindBugs warning MS_SHOULD_BE_FINAL.

Change-Id: Ic69e6f6425e0a8950ce809eb3894f48a33e860aa
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
14 years agoAdd FindBugs and CPD to the build. 70/1770/5
Chris Aniszczyk [Thu, 14 Oct 2010 16:26:46 +0000 (09:26 -0700)]
Add FindBugs and CPD to the build.

We need to use findbugs-maven-plugin:2.3.2-SNAPSHOT
since otherwise build fails with maven-3.0 [1], [2].
We should switch to the release version as soon
as this becomes available.

[1] http://www.sonatype.com/people/2010/10/maven-3-0-has-landed/
[2] http://jira.codehaus.org/browse/MFINDBUGS-122

Bug: 327799
Change-Id: I1c57f81cf6f0450e56411881488c4ee754e458e3
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
14 years agoMake ObjectDirectory getPacks() work the first time 58/1758/3
Shawn O. Pearce [Tue, 19 Oct 2010 22:51:44 +0000 (00:51 +0200)]
Make ObjectDirectory getPacks() work the first time

If an object hasn't been accessed yet the pack list for a repository
may not have been scanned from disk.  If an application (e.g. the dumb
transport servlet support code) asks for the pack list for an
ObjectDirectory, we should load it immediately.

Change-Id: I93d7b1bca422d905948e8e83b2afa83c8894a68b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
14 years agoUpdate CachedObjectDirectory when inserting objects 60/1760/1
Shawn O. Pearce [Mon, 18 Oct 2010 06:10:47 +0000 (23:10 -0700)]
Update CachedObjectDirectory when inserting objects

If an ObjectInserter is created from a CachedObjectDirectory, we need
to ensure the cache is updated whenever a new loose object is actually
added to the loose objects directory, otherwise a future read from an
ObjectReader on the CachedObjectDirectory might not be able to open
the newly created object.

We mostly had the infrastructure in place to implement this due to the
injection of unpacked large deltas, but we didn't have a way to pass
the ObjectId from ObjectDirectoryInserter to CachedObjectDirectory,
because the inserter was using the underlying ObjectDirectory and not
the CachedObjectDirectory.  Redirecting to CachedObjectDirectory
ensures the cache is updated.

Change-Id: I1f7bdfacc7ad77ebdb885f655e549cc570652225
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoIndexPack: Make translated progress messages non-static 59/1759/1
Shawn O. Pearce [Mon, 18 Oct 2010 05:21:38 +0000 (22:21 -0700)]
IndexPack: Make translated progress messages non-static

These messages may need to change depending on the current
thread's configured locale, and thus cannot be static.

Change-Id: I96751a63852ec9c4bf6c47edadcf8752700543df
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoMerge "Allow pgm Main to be extended"
Matthias Sohn [Sun, 17 Oct 2010 22:21:49 +0000 (18:21 -0400)]
Merge "Allow pgm Main to be extended"

14 years agoFix possible NPE in DirCacheCheckout 55/1755/2
Christian Halstrick [Fri, 15 Oct 2010 12:51:52 +0000 (14:51 +0200)]
Fix possible NPE in DirCacheCheckout

There was a chance that we hit a NPE which doing a checkout
with DirCacheCheckout when there is no HEAD (e.g. initial
checkout). This is fixed here.

Change-Id: Ie3b8cae21dcd90ba8352823ea94a700f8ee9221a
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
14 years agoAllow pgm Main to be extended 57/1757/2
Shawn O. Pearce [Sun, 17 Oct 2010 04:33:06 +0000 (21:33 -0700)]
Allow pgm Main to be extended

3rd party packages that use repository types other than FileRepository
may wish to extend our pgm package and implement their own resolution
scheme for repository "names" that are passed in by the --git-dir
command line option.  Make that possible by allowing the package to
extend the Main class and override the lookup.

This is primarily useful when developing new storage implementations
and trying to experiment with the results, without linking all of it
into the core JGit package.

Change-Id: Id30e168da16341e5da43365688a63aa30c7b7e2c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoAdd Cherry-Pick command 34/1734/3
Christian Halstrick [Fri, 8 Oct 2010 13:39:04 +0000 (15:39 +0200)]
Add Cherry-Pick command

Implemented the initial version of a cherry-pick command.
A correct error handling is missing (what happens if the
checkout fails, the cherry-pick leads to conflicts etc).
But straightforward cherry-picks works.

Change-Id: I235c0eb3a7a2d5bdfe40400f1deed06f29d746e1
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
14 years agoAdd getString utility functions to RawText 44/1744/1
Shawn O. Pearce [Thu, 14 Oct 2010 02:05:52 +0000 (19:05 -0700)]
Add getString utility functions to RawText

These routines can be useful when debugging, because we can add an
expression to the Eclipse "Expressions" panel to show the text that
appears on a line.  Gerrit Code Review also uses these in its own
subclass of RawText in order to format patch files, so pulling it up
to be part of core JGit may help other applications too.

Change-Id: I20a6b112e3403ecfc1c2715ae75dcecc1a85b167
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoRemove dead RawText(RawTextComparator) constructor 43/1743/1
Shawn O. Pearce [Thu, 14 Oct 2010 03:47:08 +0000 (20:47 -0700)]
Remove dead RawText(RawTextComparator) constructor

Since the introduction of HashedSequence we no longer need to supply
the RawTextComparator at the time of constructing a RawText.  Drop the
definition from the constructor, because it doesn't make sense as part
of our public API.

Change-Id: Iaab34611d60eee4a2036830142b089b2dae81842
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoFix RawTextComparator reduceCommonStartEnd at empty lines 42/1742/1
Shawn O. Pearce [Thu, 14 Oct 2010 03:43:11 +0000 (20:43 -0700)]
Fix RawTextComparator reduceCommonStartEnd at empty lines

When an empty line was inserted at the beginning of the common end
part of a RawText the comparator incorrectly considered it to be
common, which meant the DiffAlgorithm would later not even have it be
part of the region it examines.  This would cause JGit to skip a line
of insertion, which later confused Gerrit Code Review when it tried to
match up the pre and post RawText files for a difference that had this
type of insertion.

Define two new unit tests to check for this insertion of a blank line
condition and correct for it by removing the LF from the common region
when the condition is detected.

Change-Id: I2108570eb2929803b9a56f9fb9c400c758e7156b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>