]> source.dussan.org Git - jgit.git/log
jgit.git
13 years agoExposed the constructor of Note class 04/2304/3
Sasa Zivkov [Fri, 21 Jan 2011 16:04:24 +0000 (17:04 +0100)]
Exposed the constructor of Note class

Additionally, defined the NoteMap.getNote method which returns a Note
instance.  These changes were necessary to enable implementation of
the NoteMerger interface (the merge method needs to instantiate a
Note) and to enable direct use of NoteMerger which expects instances
of Note class as its paramters.  Implementing creation of code review
summary notes in Gerrit [1] will make use of both of these features.

[1] https://review.source.android.com/#change,20045

Change-Id: I627aefcedcd3434deecd63fa1d3e90e303b385ac
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoMerge "Build http.server source JAR"
Chris Aniszczyk [Fri, 21 Jan 2011 15:32:22 +0000 (10:32 -0500)]
Merge "Build http.server source JAR"

13 years agoIntroduce metaData compare between working tree and index entries 99/2199/4
Christian Halstrick [Fri, 31 Dec 2010 13:42:41 +0000 (14:42 +0100)]
Introduce metaData compare between working tree and index entries

Instead of offering only a high-level isModified() method a new
method compareMetadata() is introduced which compares a working tree entry
and a index entry by looking at metadata only. Some use-cases
(e.g. computing the content-id in idBuffer()) may use this new method
instead of isModified().

Change-Id: I4de7501d159889fbac5ae6951f4fef8340461b47
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoAdd progress reporting to IndexDiff 63/2263/5
Robin Rosenberg [Fri, 21 Jan 2011 00:23:24 +0000 (01:23 +0100)]
Add progress reporting to IndexDiff

Change-Id: I4f05bdb0c58b039bd379341a6093f06a2cdfec6e
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoBuild http.server source JAR 92/2292/1
Shawn O. Pearce [Tue, 18 Jan 2011 23:59:15 +0000 (15:59 -0800)]
Build http.server source JAR

Change-Id: I459de081fd518abfa50dd812c68eed4d1c7f8a0b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoFix misc spelling errors in comments and method names 62/2262/1
Robin Rosenberg [Mon, 17 Jan 2011 21:04:14 +0000 (22:04 +0100)]
Fix misc spelling errors in comments and method names

Change-Id: I24552443710075856540696717ac4068dfe6a7f2
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
13 years agoMerge "File utility for creating a new empty file"
Matthias Sohn [Sun, 16 Jan 2011 17:22:46 +0000 (12:22 -0500)]
Merge "File utility for creating a new empty file"

13 years agoFile utility for creating a new empty file 05/2105/5
Matthias Sohn [Thu, 30 Dec 2010 22:10:55 +0000 (23:10 +0100)]
File utility for creating a new empty file

The java.io.File.createNewFile() method for creating new empty files
reports failure by returning false. To ease proper checking of return
values provide a utility method wrapping createNewFile() throwing
IOException on failure.

Change-Id: I42a3dc9d8ff70af62e84de396e6a740050afa896
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoMerge "ConfigConstants: expose some constants for user name and email."
Shawn Pearce [Wed, 12 Jan 2011 15:47:55 +0000 (10:47 -0500)]
Merge "ConfigConstants: expose some constants for user name and email."

13 years agoMerge "CheckoutCommand: fix reflog message"
Shawn Pearce [Wed, 12 Jan 2011 15:46:23 +0000 (10:46 -0500)]
Merge "CheckoutCommand: fix reflog message"

13 years agoMerge "Locate $HOME like C Git does on Windows"
Shawn Pearce [Wed, 12 Jan 2011 15:44:57 +0000 (10:44 -0500)]
Merge "Locate $HOME like C Git does on Windows"

13 years agoFix API ListBranchCommand for listmode 'all' 40/2240/1
Roberto Tyley [Wed, 12 Jan 2011 14:34:10 +0000 (14:34 +0000)]
Fix API ListBranchCommand for listmode 'all'

If remote branches are present they can not be added
to the RefMap from the local branches - the two RefMaps
have a different value of 'prefix' and consequently an
IllegalArgumentException is thrown.

13 years agoLocate $HOME like C Git does on Windows 37/2237/1
Robin Rosenberg [Wed, 12 Jan 2011 13:58:55 +0000 (14:58 +0100)]
Locate $HOME like C Git does on Windows

Java's user.home is not the same as $HOME so EGit did see the
same global configuration as C Git does.

Bug: 333269
Change-Id: Id54fc5292bf8c5a67177f9097ee692717a7df336
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
13 years agoCheckoutCommand: fix reflog message 36/2236/1
Mathias Kinzler [Wed, 12 Jan 2011 12:19:32 +0000 (13:19 +0100)]
CheckoutCommand: fix reflog message

There is a space missing between <from> and "to" in the reflog
message produced by the CheckoutCommand, which is of the form

moving from <from> to <to>

Change-Id: I3dc57ab0a6589292db77a17d9029ee9499dfc725
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
13 years agoConfigConstants: expose some constants for user name and email. 31/2231/2
Mathias Kinzler [Wed, 12 Jan 2011 07:50:12 +0000 (08:50 +0100)]
ConfigConstants: expose some constants for user name and email.

This is needed by a EGit change

http://egit.eclipse.org/r/#change,2232

Change-Id: I3d62f904b769fc2f1b7b8f0f24f7dd757fc9c379
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
13 years agoMerge "Using java.util.concurrent in NLSTest instead of handling threads directly."
Shawn Pearce [Mon, 10 Jan 2011 15:05:28 +0000 (10:05 -0500)]
Merge "Using java.util.concurrent in NLSTest instead of handling threads directly."

13 years agoMerge "Do not cherry-pick or revert commit more than once"
Matthias Sohn [Mon, 10 Jan 2011 14:00:30 +0000 (09:00 -0500)]
Merge "Do not cherry-pick or revert commit more than once"

13 years agoUsing java.util.concurrent in NLSTest instead of handling threads directly. 19/2219/2
Sasa Zivkov [Fri, 7 Jan 2011 12:38:28 +0000 (13:38 +0100)]
Using java.util.concurrent in NLSTest instead of handling threads directly.

A test in NLSTest was mixing the "old" and the "new" way of handling
concurrency. This change makes use of the java.util.concurrent facilities to
control concurrency and removes the code that was directly dealing with Thread
objects.

Change-Id: Ie7267776e988a48a5443f0f3fe4eb43e79eee4b1
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
13 years agoDo not cherry-pick or revert commit more than once 23/2223/1
Robin Rosenberg [Mon, 10 Jan 2011 07:47:14 +0000 (08:47 +0100)]
Do not cherry-pick or revert commit more than once

Instead just return success. In the case that no commit has been
cherry-picked or reverted, just return the old HEAD.

Bug: 333814
Change-Id: I67db2b77b52c43932436d22a8daa5a6556423484
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
13 years agoMerge "Use heap based stack for PackFile deltas"
Shawn O. Pearce [Mon, 10 Jan 2011 00:20:13 +0000 (19:20 -0500)]
Merge "Use heap based stack for PackFile deltas"

13 years agoMerge "Config: Preserve existing case of names in sections"
Shawn O. Pearce [Mon, 10 Jan 2011 00:19:08 +0000 (19:19 -0500)]
Merge "Config: Preserve existing case of names in sections"

13 years agoMerging Git notes 20/2120/10
Sasa Zivkov [Tue, 4 Jan 2011 14:27:26 +0000 (15:27 +0100)]
Merging Git notes

Merging Git notes branches has several differences from merging "normal"
branches. Although Git notes are initially stored as one flat tree the
tree may fanout when the number of notes becomes too large for efficient
access. In this case the first two hex digits of the note name will be
used as a subdirectory name and the rest 38 hex digits as the file name
under that directory. Similarly, when number of notes decreases a fanout
tree may collapse back into a flat tree. The Git notes merge algorithm
must take into account possibly different tree structures in different
note branches and must properly match them against each other.

Any conflict on a Git note is, by default, resolved by concatenating
the two conflicting versions of the note. A delete-edit conflict is, by
default, resolved by keeping the edit version.

The note merge logic is pluggable and the caller may provide custom
note merger that will perform different merging strategy.

Additionally, it is possible to have non-note entries inside a notes
tree. The merge algorithm must also take this fact into account and
will try to merge such non-note entries. However, in case of any merge
conflicts the merge operation will fail. Git notes merge algorithm is
currently not trying to do content merge of non-note entries.

Thanks to Shawn Pearce for patiently answering my questions related to
this topic, giving hints and providing code snippets.

Change-Id: I3b2335c76c766fd7ea25752e54087f9b19d69c88
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoFix IgnoreRule for directory-only patterns 16/2216/1
Marc Strapetz [Fri, 7 Jan 2011 11:52:42 +0000 (12:52 +0100)]
Fix IgnoreRule for directory-only patterns

Patterns containing only a trailing slash have to be treated
as "global" patterns. For example: "classes/" matches "classes"
as well as "dir/classes" directory.

13 years agoConfig: Preserve existing case of names in sections 14/2214/1
Shawn O. Pearce [Thu, 6 Jan 2011 18:45:25 +0000 (10:45 -0800)]
Config: Preserve existing case of names in sections

When an application asks for the names in a section, it may want to
see the existing case that was stored by the user.  For example,
Gerrit Code Review wants to store a configuration block like:

  [access "refs/heads/master"]
    label-Code-Review = group Developers

and although the name label-Code-Review is case-insensitive, it wants
to display the case as it appeared in the configuration file.

When enumerating section names or variable names (both of which are
case-insensitive), Config now keeps track of the string that first
appeared, and presents them in file order, permitting applications to
use this information.  To maintain case-insensitive behavior, the
contains() method of the returned Set<String> still performs a
case-insensitive compare.

This is a behavior change if the caller enumerates the returned
Set<String> and copies it to his own Set<String>, and then performs
contains() tests against that, as the strings are now the original
case from the configuration block.  But I don't think anyone actually
does this, as the returned sets are immutable and are cached.

Change-Id: Ie4e060ef7772958b2062679e462c34c506371740
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoUse heap based stack for PackFile deltas 05/2205/6
Shawn O. Pearce [Mon, 3 Jan 2011 00:42:44 +0000 (16:42 -0800)]
Use heap based stack for PackFile deltas

Instead of using the current thread's stack to recurse through the
delta chain, use a linked list that is stored in the heap.  This
permits the any thread to load a deep delta chain without running out
of thread stack space.

Despite needing to allocate a stack entry object for each delta
visited along the chain being loaded, the object allocation count is
kept the same as in the prior version by removing the transient
ObjectLoaders from the intermediate objects accessed in the chain.
Instead the byte[] for the raw data is passed, and null is used as a
magic value to signal isLarge() and enter the large object code path.

Like the old version, this implementation minimizes the amount of
memory that must be live at once.  The current delta instruction
sequence, the base it applies onto, and the result are the only live
data arrays.  As each level is processed, the prior base is discarded
and replaced with the new result.

Each Delta frame on the stack is slightly larger than the standard
ObjectLoader.SmallObject type that was used before, however the Delta
instances should be smaller than the old method stack frames, so total
memory usage should actually be lower with this new implementation.

Change-Id: I6faca2a440020309658ca23fbec4c95aa637051c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoNoteMap implements Iterable<Note> 07/2207/3
Sasa Zivkov [Mon, 3 Jan 2011 15:03:49 +0000 (16:03 +0100)]
NoteMap implements Iterable<Note>

We will need to iterate over all notes of a NoteMap, at least this will be
needed for testing purposes. This change also implied making the Note class
public.

Change-Id: I9b0639f9843f457ee9de43504b2499a673cd0e77
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
13 years agoCleanup configuration of Maven JUnit runner 04/2204/1
Shawn O. Pearce [Sun, 2 Jan 2011 22:35:04 +0000 (14:35 -0800)]
Cleanup configuration of Maven JUnit runner

Set the plugin version in the top-level pom, not the unit test pom.
This ensures the same plugin is used for all JUnit tests within the
overall project.

Drop the include **/*Test.java definition, as its no longer necessary
with the JUnit 4 based test suite.  All of the test classes now end
with "Test" and include @Test annotations on the test methods.

Change-Id: Ib2c180bf531e1a97e31979fcc281fa0fc5a1abb3
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoFix NLSTest and RootLocalTest for JUnit 4 03/2203/1
Shawn O. Pearce [Sun, 2 Jan 2011 22:30:55 +0000 (14:30 -0800)]
Fix NLSTest and RootLocalTest for JUnit 4

These test classes needed new @Test annotations to be found by the
JUnit 4 test runner.

Change-Id: I61b6a8ebd468fa2d13fad5bf9cbd8f81a6f67e41
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMerge "Implement a revert command"
Shawn Pearce [Sun, 2 Jan 2011 22:21:58 +0000 (17:21 -0500)]
Merge "Implement a revert command"

13 years agoImplement a revert command 01/2201/1
Robin Rosenberg [Sun, 2 Jan 2011 21:05:13 +0000 (22:05 +0100)]
Implement a revert command

This is almost reverted cherry-pick, and the implementation is
almost identical. It orders the input to merge differently to get
the effect and produces a different commit message with the
default author, rather than the original author.

Change-Id: I39970091d9f7406ae7168b8efaab23a5e2c16bad
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
13 years agoRequire the hamcrest packaging that comes with Eclipse 00/2200/3
Robin Rosenberg [Sat, 1 Jan 2011 18:05:00 +0000 (19:05 +0100)]
Require the hamcrest packaging that comes with Eclipse

The other one gets installed with SWTBot, but you do not
need it if you do not hack EGit. Using import-package
instead of require-bundle fixes the dependency. Actually
we do not need hamcrest at this time, but JUnit wants it.

Change-Id: I59873618f86d02e8439d40c1f322ea8e5c4fe3fc
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
13 years agoMerge "[findbugs] Make CheckoutResult constants final"
Shawn Pearce [Fri, 31 Dec 2010 22:08:23 +0000 (17:08 -0500)]
Merge "[findbugs] Make CheckoutResult constants final"

13 years agoDrop unneccessary @SuppressWarnings 98/2198/2
Robin Rosenberg [Fri, 31 Dec 2010 10:44:55 +0000 (11:44 +0100)]
Drop unneccessary @SuppressWarnings

Change-Id: I3a5b877efd3a58ad463c47bb663d073baea81dda
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
13 years agoFix TestTranslationBundle 97/2197/2
Robin Rosenberg [Fri, 31 Dec 2010 10:44:54 +0000 (11:44 +0100)]
Fix TestTranslationBundle

The test was never run from maven, because its name did not end
in a way that was recognized by the pom. After rename it failed
because it did not find its resources.

Rename test class and move resources to the resources folder

Change-Id: I74a7ef1373cd902e1d05ff6ea38f8648b5fc5700
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
13 years agoConvert all JGit unit tests to JUnit 4 96/2196/3
Robin Rosenberg [Fri, 31 Dec 2010 10:44:54 +0000 (11:44 +0100)]
Convert all JGit unit tests to JUnit 4

Eclipse has some problem re-running single JUnit tests if
the tests are in Junit 3 format, but the JUnit 4 launcher
is used. This was quite unnecessary and the move was not
completed. We still have no JUnit4 test.

This completes the extermination of JUnit3. Most of the
work was global searce/replace using regular expression,
followed by numerous invocarions of quick-fix and organize
imports and verification that we had the same number of
tests before and after.

- Annotations were introduced.
- All references to JUnit3 classes removed
- Half-good replacement for getting the test name. This was
  needed to make the TestRngs work. The initialization of
  TestRngs was also made lazily since we can not longer find
  out the test name in runtime in the @Before methods.
- Renamed test classes to end with Test, with the exception
  of TestTranslateBundle, which fails from Maven
- Moved JGitTestUtil to the junit support bundle

Change-Id: Iddcd3da6ca927a7be773a9c63ebf8bb2147e2d13
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMerge "Add support for getting the system wide configuration"
Shawn Pearce [Fri, 31 Dec 2010 21:13:33 +0000 (16:13 -0500)]
Merge "Add support for getting the system wide configuration"

13 years agoAdd support for getting the system wide configuration 77/2177/4
Robin Rosenberg [Tue, 28 Dec 2010 16:15:18 +0000 (17:15 +0100)]
Add support for getting the system wide configuration

These settings are stored in <prefix>/etc/gitconfig. The C Git
binary is installed in <prefix>/bin, so we look for the C Git
executable to find this location, first by looking at the PATH
environment variable and then by attemting to launch bash as
a login shell to find out.

Bug: 333216
Change-Id: I1bbee9fb123a81714a34a9cc242b92beacfbb4a8
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
13 years agoMerge "IndexPack: Use stack-based recursion for delta resolution"
Shawn Pearce [Fri, 31 Dec 2010 00:52:47 +0000 (19:52 -0500)]
Merge "IndexPack: Use stack-based recursion for delta resolution"

13 years agoIndexPack: Use stack-based recursion for delta resolution 72/2172/5
roberto [Thu, 30 Dec 2010 23:08:31 +0000 (23:08 +0000)]
IndexPack: Use stack-based recursion for delta resolution

Replace 'method' with 'heap'-based recursion for resolving deltas.

Git packfile delta-chain depth can exceed 50 levels in certain files
(the packfile of the JGit project itself has >800 objects with
chain-length >50). Using method-based recursion on such packfiles will
quickly throw a StackOverflowError on VMs with constrained stack.

Benefits:

* packfile delta-resolution no longer limited by the maximum number
  of stack frames permitted on the current thread.

* slight performance improvement
  (3% speed increase on the packfile of the JGit project)

Change-Id: I1d9b3a8ba3c6d874d83cb93ebf171c6ab193e6cc
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years ago[findbugs] Make CheckoutResult constants final 95/2195/1
Matthias Sohn [Thu, 30 Dec 2010 22:04:43 +0000 (23:04 +0100)]
[findbugs] Make CheckoutResult constants final

Change-Id: I9117f212e2ad7051fdc6e7417ebc7c2d15b357a8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoRefactor exec of a command and reading one line into utility 76/2176/3
Robin Rosenberg [Tue, 28 Dec 2010 16:15:12 +0000 (17:15 +0100)]
Refactor exec of a command and reading one line into utility

Change-Id: Ia9e5afe7f29c3e5e74b8d226441ed429fb229c82
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
13 years agoRefactor search for a file within a PATH 75/2175/3
Robin Rosenberg [Tue, 28 Dec 2010 16:15:08 +0000 (17:15 +0100)]
Refactor search for a file within a PATH

Change-Id: I785ab6bf1823d174394b1d2b25c5bb202535e943

13 years agoMerge "Add launchers for the JGit HTTP package test"
Shawn Pearce [Thu, 30 Dec 2010 20:32:33 +0000 (15:32 -0500)]
Merge "Add launchers for the JGit HTTP package test"

13 years agoMerge "Enable JUnit4 in the jgit.http package too"
Shawn Pearce [Thu, 30 Dec 2010 20:31:40 +0000 (15:31 -0500)]
Merge "Enable JUnit4 in the jgit.http package too"

13 years agoMerge "Fix FileSnapShot"
Shawn Pearce [Thu, 30 Dec 2010 20:31:06 +0000 (15:31 -0500)]
Merge "Fix FileSnapShot"

13 years agoMerge "Enable use of JUnit 4 with maven"
Shawn Pearce [Thu, 30 Dec 2010 20:27:26 +0000 (15:27 -0500)]
Merge "Enable use of JUnit 4 with maven"

13 years agoAdd launchers for the JGit HTTP package test 85/2185/2
Robin Rosenberg [Thu, 30 Dec 2010 00:37:04 +0000 (01:37 +0100)]
Add launchers for the JGit HTTP package test

Change-Id: I8bb5cb5342ab86fbc586d879dc56f70f4c0e6ace
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
13 years agoEnable JUnit4 in the jgit.http package too 84/2184/1
Robin Rosenberg [Thu, 30 Dec 2010 00:25:18 +0000 (01:25 +0100)]
Enable JUnit4 in the jgit.http package too

There are currently no JUnit4 tests here, but since we made JUnit4
the default for maven, it should be for Eclipse builds too.

Change-Id: Ic910df1705fa8d6ac26e97a41947cb8e5526d334
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
13 years agoFix FileSnapShot 74/2174/2
Robin Rosenberg [Tue, 28 Dec 2010 18:01:46 +0000 (19:01 +0100)]
Fix FileSnapShot

We cannot use SystemReader to get the time, unless we do that consistently,
which is harder to do and be sure we are really testing what we want.

Then we need to update our lastRead variable whenever we conclude that
our file is not racily clean according to lastRead. It may well be clean,
but we do not know that until we check the system clock again.

Finally add a test for this class.

Change-Id: I1894b032b9bd359d1b5325e5472d48e372599e4c
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
13 years agoEnable use of JUnit 4 with maven 83/2183/1
Robin Rosenberg [Thu, 30 Dec 2010 00:02:21 +0000 (01:02 +0100)]
Enable use of JUnit 4 with maven

Change-Id: If1948232ae73bc9cf1ce6ce1e953172e0a8bcee6
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
13 years agoMerge "CheckoutResult: return paths instead of Files"
Shawn Pearce [Wed, 29 Dec 2010 19:29:49 +0000 (14:29 -0500)]
Merge "CheckoutResult: return paths instead of Files"

13 years agoEnable use of JUnit 4 with the jgit.test project 73/2173/1
Robin Rosenberg [Tue, 28 Dec 2010 16:14:32 +0000 (17:14 +0100)]
Enable use of JUnit 4 with the jgit.test project

Some enablement was done earlier, but we need to add the org.junit package
and hamcrest to make it work.

junit.textui removed, probably a mistake at some time in the past.

Change-Id: I6922a2f40eb0c077a8ade5ed073ecf0e90425544

13 years agoFix ArrayIndexOutOfBoundsException in DirCacheIterator 68/2168/1
Shawn O. Pearce [Wed, 22 Dec 2010 22:11:18 +0000 (14:11 -0800)]
Fix ArrayIndexOutOfBoundsException in DirCacheIterator

If the 'TREE' extension contains an invalid subtree that has
been removed, DirCacheIterator still tried to access it due to
an invalid childCnt field within the parent DirCacheTree object.
This is easy for a user to do, they just need to move all files
out of a subdirectory.

For example, the input for the JUnit test case for this bug was
built using the following C Git sequence:

  mkdir -p a/b
  touch a/b/c q
  git add a/b/c q
  git write-tree
  git mv a/b/c a/a

After the last step, the subdirectory a/b is empty, as its only
file was moved into the parent directory.  Because of the earlier
`git write-tree` operation, there is a 'TREE' extension present, but
the a and a/b subdirectories have been marked invalid by the rename.

When JGit tried to iterate over the a tree, it tried to correct
childCnt to be zero as a/b no longer exists, but it failed to
update childCnt.

Change-Id: I7a0f78fc48a36b1a83252d354618f6807fca0426
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoDirCacheIteratorTest: Use newInCore instead of disk 67/2167/1
Shawn O. Pearce [Wed, 22 Dec 2010 21:39:38 +0000 (13:39 -0800)]
DirCacheIteratorTest: Use newInCore instead of disk

Avoid the dependency on the local filesystem by using only an in-core
DirCache instance.  Each test case builds up the index from scratch
anyway through a DirCacheBuilder.

Change-Id: I5decf6bffc3ed35bf1d3e4ad5cc095891c80b772
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoCorrect GIT_INDEX_FILE environment variable 66/2166/1
Shawn O. Pearce [Wed, 22 Dec 2010 19:26:33 +0000 (11:26 -0800)]
Correct GIT_INDEX_FILE environment variable

This is GIT_INDEX_FILE, not GIT_INDEX.

Change-Id: Ib3af28ba196f74c8cb4d318b57ea346bb90f9a1e
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoCheckoutResult: return paths instead of Files 61/2161/1
Mathias Kinzler [Tue, 21 Dec 2010 09:06:19 +0000 (10:06 +0100)]
CheckoutResult: return paths instead of Files

As discussed in

http://egit.eclipse.org/r/#change,2127

we should use paths relative the working directory instead of Files to
notify the caller about conflicts and nondeleted files.

Change-Id: I034c7bd846f0df78d97bc246f38d411f29713dde
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
13 years agoMerge "FileBasedConfig: Use FileSnapshot for isOutdated()"
Chris Aniszczyk [Mon, 20 Dec 2010 17:06:00 +0000 (12:06 -0500)]
Merge "FileBasedConfig: Use FileSnapshot for isOutdated()"

13 years agoFix CheckoutCommandTest 59/2159/1
Mathias Kinzler [Mon, 20 Dec 2010 15:54:41 +0000 (16:54 +0100)]
Fix CheckoutCommandTest

Change-Id: Ieacae01de20d7729ef34e6e6a1523fbaf9db41a8
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
13 years agoFix JDK 6 Usage of String.getBytes(Charset) 58/2158/1
Mathias Kinzler [Mon, 20 Dec 2010 15:52:52 +0000 (16:52 +0100)]
Fix JDK 6 Usage of String.getBytes(Charset)

Change-Id: I619b00d8a3b0770c9fd1dc3314794f915ea80604
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
13 years agoCheckout: fix handling if name does not refer to a local branch 39/2139/5
Mathias Kinzler [Mon, 20 Dec 2010 09:35:10 +0000 (10:35 +0100)]
Checkout: fix handling if name does not refer to a local branch

The CheckoutCommand does not handle names other than local branch
names properly; it must detach HEAD if such a name is encountered (for
example a commit ID or a remote tracking branch).

Change-Id: I5d55177f4029bcc34fc2649fd564b125a2929cc4
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoclone: Use DirCacheCheckout 34/2134/2
Shawn O. Pearce [Thu, 16 Dec 2010 00:14:19 +0000 (16:14 -0800)]
clone: Use DirCacheCheckout

This simple change lets us get rid of WorkDirCheckout from JGit,
and all of its supporting code.

Change-Id: I1a5aabe9ab4a2b156fd37cc7e9ededb4ed70f53a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoMerge "Extract pack directory last modified check code"
Chris Aniszczyk [Mon, 20 Dec 2010 15:27:33 +0000 (10:27 -0500)]
Merge "Extract pack directory last modified check code"

13 years agoRemove deprecated WriteTree from tests 33/2133/2
Shawn O. Pearce [Thu, 16 Dec 2010 00:39:28 +0000 (16:39 -0800)]
Remove deprecated WriteTree from tests

These tests doesn't need to use WriteTree anymore.  There are
other means of creating tree objects in the repository that aren't
deprecated, so use those instead.

Change-Id: I89cd8ab54c66964a5fddc0a045f1c0f1c7c49055
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoCheckout: expose a CheckoutResult 27/2127/3
Mathias Kinzler [Mon, 20 Dec 2010 09:21:49 +0000 (10:21 +0100)]
Checkout: expose a CheckoutResult

This is needed by callers to determine checkout conflicts and
possible files that were not deleted during the checkout so that they
can present the end user with a better Exception description and retry
to delete the undeleted files later, respectively.

Change-Id: I037930da7b1a4dfb24cfa3205afb51dc29e4a5b8
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
13 years agoFix wrong javadoc comment in Repository 53/2153/1
Robin Rosenberg [Sun, 19 Dec 2010 10:02:13 +0000 (11:02 +0100)]
Fix wrong javadoc comment in Repository

Change-Id: I9fc084b48418884ce1ccf16d56e800f1d3594885
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
13 years agoMerge "Move TransferConfig to transport package"
Robin Rosenberg [Sat, 18 Dec 2010 15:43:26 +0000 (10:43 -0500)]
Merge "Move TransferConfig to transport package"

13 years agoQualify post 0.10 builds 49/2149/1
Matthias Sohn [Fri, 17 Dec 2010 14:49:30 +0000 (15:49 +0100)]
Qualify post 0.10 builds

Change-Id: Ifcb8fdea95286779c8aea6bf4d7647e8c1c98d63
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoMerge branch 'stable-0.10' 48/2148/1
Matthias Sohn [Fri, 17 Dec 2010 14:41:27 +0000 (15:41 +0100)]
Merge branch 'stable-0.10'

13 years agoQualify post 0.10.1 builds 45/2145/1 stable-0.10
Matthias Sohn [Fri, 17 Dec 2010 14:23:14 +0000 (15:23 +0100)]
Qualify post 0.10.1 builds

Change-Id: I320f1f739f3689daf11d532a55ae1133785aec8e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoJGit 0.10.1 42/2142/2 v0.10.1
Matthias Sohn [Fri, 17 Dec 2010 00:38:13 +0000 (01:38 +0100)]
JGit 0.10.1

Change-Id: I4a46d35d354193e5d4f28ef7dfae75944be8ffcf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoDirCacheCheckout: fix getToBeDeleted() 37/2137/1
Mathias Kinzler [Thu, 16 Dec 2010 07:41:36 +0000 (08:41 +0100)]
DirCacheCheckout: fix getToBeDeleted()

This wrongly returns the same as getConflicts()
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Change-Id: Id37c625458fc5a9b3987f05b684620e24fdfe852

13 years agoMove TransferConfig to transport package 32/2132/1
Shawn O. Pearce [Thu, 16 Dec 2010 01:02:50 +0000 (17:02 -0800)]
Move TransferConfig to transport package

This doesn't belong in the main lib package.

Change-Id: Idb20bf5849138b34a7277250fe0795c2a1f22447
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoMerge "Do not rely on filemode differences in case of symbolic links"
Shawn Pearce [Wed, 15 Dec 2010 23:55:59 +0000 (18:55 -0500)]
Merge "Do not rely on filemode differences in case of symbolic links"

13 years agoFileBasedConfig: Use FileSnapshot for isOutdated() 17/2117/3
Shawn O. Pearce [Mon, 13 Dec 2010 22:19:02 +0000 (14:19 -0800)]
FileBasedConfig: Use FileSnapshot for isOutdated()

Relying only on the last modified time for a file can be tricky.
The "racy git" problem may cause some modifications to be missed.

Use the new FileSnapshot code to track when a configuration file
has been modified, and needs to be reloaded in memory.

Change-Id: Ib6312fdd3b2403eee5af3f8ae711294b0e5f9035
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoExtract pack directory last modified check code 14/2114/2
Shawn O. Pearce [Mon, 13 Dec 2010 20:23:07 +0000 (12:23 -0800)]
Extract pack directory last modified check code

Pulling the last modified checking logic out of ObjectDirectory
makes it possible to reuse this code for other files, such as
the $GIT_DIR/config or $GIT_DIR/packed-refs files.

Change-Id: If2f27a89fc3b7adde7e65ff40bbca5d55b98b772
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoSave StoredConfig after modifications 16/2116/2
Shawn O. Pearce [Mon, 13 Dec 2010 22:18:42 +0000 (14:18 -0800)]
Save StoredConfig after modifications

When the Config is changed, it should be saved back to its local
file.  This ensure that a future call to getConfig() won't wipe
out the edits that were just made.

Change-Id: Id46d3f85d1c9b377f63ef861b72824e1aa060eee
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoReduce calls to Repository.getConfig 15/2115/2
Shawn O. Pearce [Mon, 13 Dec 2010 22:18:05 +0000 (14:18 -0800)]
Reduce calls to Repository.getConfig

Each time getConfig() is called on FileRepository, it checks the
last modified time of both ~/.gitconfig and $GIT_DIR?config.  If
$GIT_DIR/config appears to have been modified, it is read back in
from disk and the current config is wiped out.

When mutating a configuration file, this may cause in-memory edits
to disappear.  To avoid that callers need to avoid calling getConfig
until after the configuration has been saved to disk.

Unfortunately the API is still horribly broken.  Configuration should
be modified only while a lock is held on the configuration file, very
similar to the way a ref is updated via its locking protocol.  But our
existing API is really broken for that so we'll have to defer cleaning
up the edit path for a future change.

Change-Id: I5888dd97bac20ddf60456c81ffc1eb8df04ef410
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoSupport GIT_SSH=tortoiseplink 30/2130/1
Shawn O. Pearce [Wed, 15 Dec 2010 18:17:57 +0000 (10:17 -0800)]
Support GIT_SSH=tortoiseplink

The tortoiseplink command does not understand -batch, even though
it smells like the putty plink command that does use it.  Don't add
-batch if GIT_SSH is tortoiseplink.

Change-Id: I638532a02faa2caf8c39d482094e7ff4f4ec7e78
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoCorrect plink -batch option 29/2129/1
Shawn O. Pearce [Wed, 15 Dec 2010 18:17:01 +0000 (10:17 -0800)]
Correct plink -batch option

When GIT_SSH is set to use plink, the correct option name is "-batch"
and not "--batch".  This was a typo introduced when we added support
for plink via GIT_SSH.

Change-Id: I391660e38f5d208bba11e3f2a8f25922de2af878
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoDo not rely on filemode differences in case of symbolic links 09/2109/2
Philipp Thun [Tue, 14 Dec 2010 10:31:41 +0000 (11:31 +0100)]
Do not rely on filemode differences in case of symbolic links

When checking whether a file in the working tree has been modified -
WorkingTreeIterator.isModified() - we should not trust the filemode
in case of symbolic links, but check the timestamp and also the
content, if requested. Without this fix symlinks will always be shown
in EGit as modified files on Windows systems.

Change-Id: I367c807df5a7e85e828ddacff7fee7901441f187
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
13 years agoRemove remaining uses of FileWriter 12/2112/2
Shawn O. Pearce [Mon, 13 Dec 2010 18:57:26 +0000 (10:57 -0800)]
Remove remaining uses of FileWriter

FileWriter uses the platform default encoding, which might not
be UTF-8.  JGit prefers UTF-8 everywhere for string encodings,
so make the unit tests more predictable by ensuring use of UTF-8.

Change-Id: I75bb9f962ee230b73ca3a942bffd7a8a28674ba5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoSimplify NoteParser use of prefix.length() 11/2111/2
Shawn O. Pearce [Mon, 13 Dec 2010 18:21:04 +0000 (10:21 -0800)]
Simplify NoteParser use of prefix.length()

Sasa pointed out we only ever use the length here, so instead of
holding onto the AbbreviatedObjectId, lets just hold onto the length
as a primitive int.

Change-Id: I2444f59f9fe5ddcaea4a3537d3f1064736ae3215
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
CC: Sasa Zivkov <zivkov@gmail.com>
13 years agoFix HTTP digest authentication 10/2110/1
Shawn O. Pearce [Mon, 13 Dec 2010 18:09:14 +0000 (10:09 -0800)]
Fix HTTP digest authentication

JGit's internal implementation of the HTTP digest authentication
method wasn't conforming to RFC 2617 (HTTP Authentication: Basic
and Digest Access Authentication), resulting in authentication
failures when connecting to a digest protected site.

The code now more accurately matches section 3.2.2 (The Authorization
Request Header) from the standards document.

Change-Id: If41b5c2cbdd59ddd6b2dea143f325e42cd58c395
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoFile utilities for creating directories 01/2101/5
Matthias Sohn [Fri, 10 Dec 2010 20:48:09 +0000 (21:48 +0100)]
File utilities for creating directories

The java.io.File methods for creating directories report failure by
returning false. To ease proper checking of return values provide
utility methods wrapping mkdir() and mkdirs() which throw IOException
on failure.

Also fix the tests to store test data under a trash folder and cleanup
after test.

Change-Id: I09c7f9909caf7e25feabda9d31e21ce154e7fcd5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoDiffFormatter: Use IndexDiffFilter to speed up working tree 83/2083/2
Shawn O. Pearce [Wed, 8 Dec 2010 20:05:48 +0000 (12:05 -0800)]
DiffFormatter: Use IndexDiffFilter to speed up working tree

If DiffFormatter is asked to compare the index to the working tree,
it can go faster by using the cached stat information to compare
the two entries rather than relying on SHA-1 computation alone.

Change-Id: Icb21c15b8279ee8cee382e5e179e0cf8903aee4d
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoRebase: abort on unknown/unsupported command in git-rebase-todo 02/2102/1
Mathias Kinzler [Fri, 10 Dec 2010 08:44:51 +0000 (09:44 +0100)]
Rebase: abort on unknown/unsupported command in git-rebase-todo

This is needed to ensure interoperability with the command line: if
the git-rebase-todo file was created manually (by git rebase -i in the
command line), and any commands other than pick are used (reword,
edit, fixup, squash) JGit must abort as it does not understand these
commands yet.
The same is true if an unknown command is found (e.g. due to a typo);
this is the same behavior as shown by the command line.

Change-Id: I2322014f69460361f7fc09da223e8a5c31f100dd
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
13 years agoMerge "IndexPack: Remove blob-streaming size threshold"
Shawn Pearce [Fri, 10 Dec 2010 00:33:58 +0000 (19:33 -0500)]
Merge "IndexPack: Remove blob-streaming size threshold"

13 years agoIndexPack: Remove blob-streaming size threshold 00/2100/1
roberto [Thu, 9 Dec 2010 23:40:34 +0000 (23:40 +0000)]
IndexPack: Remove blob-streaming size threshold

Always use streaming (for SHA-checksum & collision detection)
when indexing whole blobs, regardless of their size.

Positives:
* benefits of bugfix #312868 will apply to all runtimes, without
  additional conf for mem-constrained JVMs (5MB huge for some)
* no byte array allocation
  (re-uses readBuffer instead of allocating new full-size array)
* mildly better overall performance
  (given the usual blob-does-not-need-collision-checking case)
* removes unnecessary code

Negative:
* doubles the disk IO for a blob comparision
  (comparitively rare occurance)

I perf-tested a range of threshold sizes against a random selection
of packfiles I found on my harddrive, the results are here:

https://spreadsheets.google.com/ccc?key=tLCQElyyd2RKN9QevfvgwGQ&hl=en_GB#gid=1

My interpretation of the results is that the streaming size threshold
isn't beneficial (actually seems to be very slightly detrimental) -so
we should just get rid of it. This tallies with some of the comments
Shawn & I had for the default value of streamFileThreshold in the
review for I862afd4c:

http://egit.eclipse.org/r/#patch,sidebyside,2040,2,org.eclipse.jgit/src/org/eclipse/jgit/transport/IndexPack.java

The perf-test code is here: https://gist.github.com/735402
It's a bit scruffy but basically does 10 runs (in randomised order)
for each threshold size on various packfiles, waiting a second
between each pack-indexing to allow GC to catch up. I know it's not
perfect - proper perf testing is hard to do :-)

13 years agoMerge "Add option to skip deletion of non-existing files"
Chris Aniszczyk [Thu, 9 Dec 2010 23:31:48 +0000 (18:31 -0500)]
Merge "Add option to skip deletion of non-existing files"

13 years agoMerge "Add further unit tests for IndexDiffFilter"
Chris Aniszczyk [Thu, 9 Dec 2010 23:31:04 +0000 (18:31 -0500)]
Merge "Add further unit tests for IndexDiffFilter"

13 years agoMerge "Simplify logic in StrategySimpleTwoWayInCore"
Chris Aniszczyk [Thu, 9 Dec 2010 23:30:41 +0000 (18:30 -0500)]
Merge "Simplify logic in StrategySimpleTwoWayInCore"

13 years agoAdd option to skip deletion of non-existing files 99/2099/2
Matthias Sohn [Thu, 9 Dec 2010 23:21:23 +0000 (00:21 +0100)]
Add option to skip deletion of non-existing files

For convenience provide an option to skip deletion of non-existing
files. Also add some tests for deletion methods in FileUtils.

Change-Id: I33e355cfcdc19367d50208150ee49a4a06394890
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoAdd further unit tests for IndexDiffFilter 97/2097/1
Philipp Thun [Thu, 9 Dec 2010 19:34:53 +0000 (20:34 +0100)]
Add further unit tests for IndexDiffFilter

This change contains a bunch of unit tests for the newly introduced
IndexDiffFilter. With these tests the code coverage of
IndexDiffFilter.include() is now 100%, i.e. every special case is
tested at least once.

Change-Id: Ib248d1cd16084f9c8e099006af151814c63c5941
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
13 years agoSimplify logic in StrategySimpleTwoWayInCore 96/2096/1
Shawn O. Pearce [Thu, 9 Dec 2010 18:54:01 +0000 (10:54 -0800)]
Simplify logic in StrategySimpleTwoWayInCore

Sasa and I were reviewing this code today and Sasa pointed out we
can simplify the conflict logic, as the two cases (subtree and file)
are logically identical.

Change-Id: Ie0d40b2dd15605785eff453a846b1d20a2d021fc
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Reviewed-by: Sasa Zivkov <zivkov@gmail.com>
13 years agoRebase: fix wrong update if original HEAD after Merge+Skip 95/2095/1
Mathias Kinzler [Thu, 9 Dec 2010 18:22:11 +0000 (19:22 +0100)]
Rebase: fix wrong update if original HEAD after Merge+Skip

Rebase would update the original HEAD to the wrong commit when
"skipping" the last commit after a merged commit.

Includes a test for the specific situation.

Change-Id: I087314b1834a3f11a4561f04ca5c21411d54d993
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
13 years agoAdd a performance optimized variant of the ANY_DIFF filter 66/2066/5
Christian Halstrick [Thu, 9 Dec 2010 17:24:52 +0000 (18:24 +0100)]
Add a performance optimized variant of the ANY_DIFF filter

If a treewalk walks also over index and the workingtree then the
IndexDiffFilter filter can be used which works much faster then
the semantically equivalent ANY_DIFF filter. This is because this
filter can better avoid computing SHA-1 ids over the content of
working-tree files which is very costly.

This fix will significantly improve the performance of e.g.
EGit's commit dialog.

Change-Id: I2a51816f4ed9df2900c6307a54cd09f50004266f
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
13 years agoImplement rebase --continue and --skip 81/2081/3
Mathias Kinzler [Thu, 9 Dec 2010 15:10:21 +0000 (16:10 +0100)]
Implement rebase --continue and --skip

For --continue, the Rebase command asserts that there are no unmerged
paths in the current repository. Then it checks if a commit is needed.
If yes, the commit message and author are taken from the author_script
and message files, respectively, and a commit is performed before the
next step is applied.
For --skip, the workspace is reset to the current HEAD before applying
the next step.

Includes some tests and a refactoring that extracts Strings in the
code into constants.

Change-Id: I72d9968535727046e737ec20e23239fe79976179
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
13 years agoJGit Build: use jetty 7.1.6 93/2093/1
Jens Baumgart [Thu, 9 Dec 2010 09:42:05 +0000 (10:42 +0100)]
JGit Build: use jetty 7.1.6

Jetty 7.1.6 is used because this version is also available in P2.

Change-Id: I410fbca8592cac6e58c651c4d086573820e777a5
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
13 years agoIndexDiff: Remove unnecessary changesExist flag 75/2075/2
Shawn O. Pearce [Wed, 8 Dec 2010 03:11:05 +0000 (19:11 -0800)]
IndexDiff: Remove unnecessary changesExist flag

Instead of setting a boolean when a difference record is found, return
false from diff() only if all of the collections are empty.  When all
of them are empty, no difference was found.

Change-Id: I555fef37adb764ce253481751071c53ad12cf416
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoIndexDiff: Use isModified() when comparing index-worktree 74/2074/2
Shawn O. Pearce [Wed, 8 Dec 2010 03:08:02 +0000 (19:08 -0800)]
IndexDiff: Use isModified() when comparing index-worktree

The isModified() is more efficient because it can skip over files that
are stat clean, without needing to scan them.

This is useful to efficently work on paths that were already staged
and thus differ between HEAD and the index, but not between the index
and the working tree.

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