Commit Graph

1158 Commits

Author SHA1 Message Date
Shawn O. Pearce 6af7e4d91a 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>
2010-11-09 14:36:01 -08:00
Shawn Pearce b087bba3bd Merge "Format merge commit messages like C Git" 2010-11-09 17:14:11 -05:00
Shawn O. Pearce 08a9682e32 Revert "[findBugs] Silence DM_STRING_CTOR on PacketLineIn"
This reverts commit 1e510ec20e.

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>
2010-11-08 15:34:47 -08:00
Shawn Pearce 6ed0501346 Merge "IndexDiff: support state [removed, untracked]" 2010-11-08 18:32:45 -05:00
Jens Baumgart 2dc2dd8b1b 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>
2010-11-08 15:32:03 -08:00
Shawn Pearce 09555c9853 Merge "Make Repository.shortenRefName static" 2010-11-08 17:42:21 -05:00
Christian Halstrick a28f33fa8c 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>
2010-11-08 13:56:07 -08:00
Chris Aniszczyk 5dc72352f5 Merge "CommitAndLogCommandTests: add a test for LogCommand.addRange()" 2010-11-08 07:50:43 -05:00
Chris Aniszczyk d6fec1988c Merge "[findBugs] Fix NP_LOAD_OF_KNOWN_NULL_VALUE" 2010-11-07 16:09:00 -05:00
Chris Aniszczyk 83019318c6 Merge "[findBugs] Silence DM_STRING_CTOR on PacketLineIn" 2010-11-07 16:07:43 -05:00
Chris Aniszczyk df037eb230 Merge "Implemented the git add commandline command." 2010-11-07 16:05:24 -05:00
Sasa Zivkov 1a7c918b66 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>
2010-11-07 21:30:56 +01:00
Matthias Sohn 1e510ec20e [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>
2010-11-07 21:22:23 +01:00
Matthias Sohn 220cd43482 [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>
2010-11-07 20:16:15 +01:00
Christian Halstrick 0e815fe8c5 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>
2010-11-07 14:59:01 +01:00
Robin Stocker 6290ca3a63 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
2010-11-06 13:48:11 +01:00
Robin Stocker 2fb0f5cfc0 Make Repository.shortenRefName static
The method has no reason to be non-static.

Change-Id: I1c09e074395d49cee0e6e53679b499d1f0c351ea
2010-11-06 13:41:06 +01:00
Shawn Pearce d1e8e97316 Merge "Add a test for merging deleted files" 2010-11-05 18:03:19 -04:00
Shawn Pearce 5835ad1a91 Merge changes I8d77cb59,I2beb4db5
* changes:
  Fixed merge algorithm regarding adjacent modifications
  Cleaned up MergeAlgorithmTest
2010-11-05 17:38:44 -04:00
Sasa Zivkov af4f6c5125 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>
2010-11-05 16:06:14 +01:00
Mathias Kinzler af31a97c82 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>
2010-11-05 12:26:56 +01:00
Shawn O. Pearce e488f1cacd 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>
2010-11-04 19:12:13 -07:00
Shawn O. Pearce b22a4e8488 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>
2010-11-04 19:12:13 -07:00
Shawn O. Pearce c27e1daa55 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>
2010-11-04 19:12:13 -07:00
Christian Halstrick f5076d8b04 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>
2010-11-03 13:37:45 +01:00
Christian Halstrick 99771f04bc 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>
2010-11-02 18:29:35 +01:00
Christian Halstrick e8642b538c 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>
2010-11-02 18:29:33 +01:00
Shawn Pearce 009507ca2e Merge "Exclude FindBugs warning about uninitialized read" 2010-11-01 17:24:20 -04:00
Shawn O. Pearce aa09599a3d 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>
2010-11-01 14:10:00 -07:00
Shawn O. Pearce d9b224aeb6 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>
2010-11-01 14:09:51 -07:00
Shawn O. Pearce b88b693a3d 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>
2010-11-01 14:08:45 -07:00
Robin Stocker b70d8853f8 Exclude FindBugs warning about uninitialized read
This gets rid of the "Uninitialized read of blockIndex" warning.

Change-Id: Ieb31b5059d7b9a6adff2251baf179bda5f82e7a5
2010-11-01 00:01:47 +01:00
Shawn O. Pearce 33ae28b482 Correct typo in HistogramDiffIndex Javadoc
Change-Id: I8bd2e81fcc14aa86919c504f1d0001944dea50b2
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-29 17:02:26 -07:00
Shawn Pearce b216c80255 Merge "Exclude FindBugs warnings about Cloneable" 2010-10-29 10:50:07 -04:00
Shawn Pearce a434172079 Merge "Remove two "Dead store to local variable" warnings" 2010-10-29 10:49:45 -04:00
Shawn Pearce 1572c9f4a7 Merge "Use entrySet() instead of keySet()" 2010-10-29 10:48:18 -04:00
Shawn Pearce 6bddae5775 Merge "Use readFully() instead of read()" 2010-10-29 10:47:26 -04:00
Shawn Pearce a8140e3c16 Merge "Use Character.valueOf instead of new Character" 2010-10-29 10:43:55 -04:00
Shawn Pearce 68f6c49ee2 Merge "Remove unnecessary null check" 2010-10-29 10:43:32 -04:00
Robin Stocker 8cbed3462e Make private final field static
It's used as a constant.

Change-Id: Ic267e8cb5b62228de15e134cd80725df592a0171
2010-10-29 15:27:10 +02:00
Robin Stocker d36c80fd04 Remove unnecessary null check
The field monitor is never null, it's a NullProgressMonitor when not
explicitly set.

Change-Id: I8ce703a32c28ce5c3455efeb7ed5f5c9a443cbef
2010-10-29 15:12:48 +02:00
Robin Stocker b52df1839a Use Character.valueOf instead of new Character
Otherwise a new Character is allocated each time instead of
using the cache.

Change-Id: I648d0b012f66ba9dc46a37a390986f9c61e5a19c
2010-10-29 15:04:27 +02:00
Robin Stocker 96bea14c7b 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
2010-10-29 14:52:52 +02:00
Robin Stocker 3b44b22609 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
2010-10-29 14:41:39 +02:00
Robin Stocker 3f78650c9a Remove two "Dead store to local variable" warnings
Change-Id: I950de82db15c4610dc5a94f304279971daef971e
2010-10-29 14:37:42 +02:00
Robin Stocker 90c11cbaeb 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
2010-10-29 14:26:33 +02:00
Shawn Pearce 7f939ba86e Merge "Fix Severe Bug in Merge Algorithm" 2010-10-28 15:54:36 -04:00
Christian Halstrick beeb1f6d08 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
0c017188b4 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>
2010-10-28 21:41:42 +02:00
Mathias Kinzler 7668a46282 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>
2010-10-28 09:18:02 -07:00
Shawn Pearce 0544c9af41 Merge "Fix FQCN of moved classes in FindBugsExcludeFilter.xml" 2010-10-28 11:47:44 -04:00