]> source.dussan.org Git - jgit.git/log
jgit.git
13 years agoRefactor IndexPack to use InputStream for inflation 63/2063/2
Shawn O. Pearce [Tue, 7 Dec 2010 20:45:52 +0000 (12:45 -0800)]
Refactor IndexPack to use InputStream for inflation

By inflating with an InputStream like API, it is possible to stream
through large objects rather than allocating the entire thing as
a byte[].  This change only refactors the inflation code within
IndexPack to use a streaming interface.

Change-Id: I5a84b486901c2cf63fa6a3306dd5fb5c53b4056b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
CC: Roberto Tyley <roberto.tyley@guardian.co.uk>
13 years ago[findbugs] Do not ignore exceptional return value 55/2055/4
Matthias Sohn [Mon, 6 Dec 2010 23:58:19 +0000 (00:58 +0100)]
[findbugs] Do not ignore exceptional return value

java.io.File.delete() reports failure as an exceptional
return value false. Fix the code which silently ignored
this exceptional return value. Also remove some duplicate
deletion helper methods.

Change-Id: I80ed20ca1f07a2bc6e779957a4ad0c713789c5be
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoProvide file utilities for file deletion 54/2054/4
Matthias Sohn [Mon, 6 Dec 2010 23:45:58 +0000 (00:45 +0100)]
Provide file utilities for file deletion

Provide file helper methods in a reusable utility class to
replace many local implementations. java.io.File has some
methods reporting failure by returning false. We prefer to
throw IOException on failure so that callers can't forget
checking the return value.

Change-Id: I430c77b5d2cffcf8b47584326ad4817a7291845e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoMerge "Clean up Init API"
Chris Aniszczyk [Tue, 7 Dec 2010 15:57:36 +0000 (10:57 -0500)]
Merge "Clean up Init API"

13 years agoClean up Init API 58/2058/1
Chris Aniszczyk [Tue, 7 Dec 2010 15:13:57 +0000 (09:13 -0600)]
Clean up Init API

Static accessors should come before a constructor.

Change-Id: Iee1051ce4f2038f19a08741e7a3a33f06a97a3c0
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoAvoid NPE in Init 57/2057/1
Chris Aniszczyk [Tue, 7 Dec 2010 15:10:07 +0000 (09:10 -0600)]
Avoid NPE in Init

We should grab the repository directory from the command to
avoid an NPE if no git directory is passed in via the CLI.

Change-Id: I649467c6d84bbc0d26a070d0d4ff1e6f81fd5bad
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoMerge "Rebase Interoperability third part: handle stop upon conflict"
Chris Aniszczyk [Tue, 7 Dec 2010 14:34:25 +0000 (09:34 -0500)]
Merge "Rebase Interoperability third part: handle stop upon conflict"

13 years agoMerge "Rebase Interoperability second part: fix "pop steps""
Chris Aniszczyk [Tue, 7 Dec 2010 14:19:35 +0000 (09:19 -0500)]
Merge "Rebase Interoperability second part: fix "pop steps""

13 years agoRebase Interoperability third part: handle stop upon conflict 86/1986/2
Mathias Kinzler [Tue, 7 Dec 2010 12:34:44 +0000 (13:34 +0100)]
Rebase Interoperability third part: handle stop upon conflict

There are some files that need to exist so that the CLI can continue
after the rebase has been stopped due to conflicts

Change-Id: I3cb4dc98609c059bf0cf9fd5f9e47a9c681cea2d
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
13 years agoMerge "LockFile.commit: retry renaming"
Shawn Pearce [Mon, 6 Dec 2010 23:55:18 +0000 (18:55 -0500)]
Merge "LockFile.commit: retry renaming"

13 years agoMerge "Update Init to use InitCommand"
Chris Aniszczyk [Mon, 6 Dec 2010 22:09:14 +0000 (17:09 -0500)]
Merge "Update Init to use InitCommand"

13 years agoMerge "Add InitCommand"
Chris Aniszczyk [Mon, 6 Dec 2010 22:08:55 +0000 (17:08 -0500)]
Merge "Add InitCommand"

13 years agoMerge "Add debugging toString to TreeFormatter"
Chris Aniszczyk [Mon, 6 Dec 2010 15:11:11 +0000 (10:11 -0500)]
Merge "Add debugging toString to TreeFormatter"

13 years agoMerge "Add insert(TreeFormatter) to ObjectInserter"
Chris Aniszczyk [Mon, 6 Dec 2010 15:10:58 +0000 (10:10 -0500)]
Merge "Add insert(TreeFormatter) to ObjectInserter"

13 years agoMerge "Add toByteArray to CommitBuilder, TreeBuilder"
Chris Aniszczyk [Mon, 6 Dec 2010 15:10:41 +0000 (10:10 -0500)]
Merge "Add toByteArray to CommitBuilder, TreeBuilder"

13 years agoMerge "Remove unused getTreeId from TreeFormatter"
Chris Aniszczyk [Mon, 6 Dec 2010 15:10:26 +0000 (10:10 -0500)]
Merge "Remove unused getTreeId from TreeFormatter"

13 years agoMerge "Remove result id from CommitBuilder, TagBuilder"
Chris Aniszczyk [Mon, 6 Dec 2010 15:09:59 +0000 (10:09 -0500)]
Merge "Remove result id from CommitBuilder, TagBuilder"

13 years agoLockFile.commit: retry renaming 49/2049/1
Jens Baumgart [Mon, 6 Dec 2010 12:40:07 +0000 (13:40 +0100)]
LockFile.commit: retry renaming

Currently the following can happen in LockFile.commit: deletion of the
original file succeeds but renaming fails afterwards. In this case the
original file (e.g. branch file in refs/heads) is lost.
To workaround the issue the same retry logic as for file deletion is
applied to file renaming.

Bug: 331890
Change-Id: I68620c07f2d3ab7f3279c71a91e184e8eac69832
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
13 years agoMerge "Honor GIT_SSH when opening SSH connections"
Chris Aniszczyk [Mon, 6 Dec 2010 01:14:46 +0000 (20:14 -0500)]
Merge "Honor GIT_SSH when opening SSH connections"

13 years agoUpdate Init to use InitCommand 48/2048/1
Chris Aniszczyk [Mon, 6 Dec 2010 01:03:34 +0000 (19:03 -0600)]
Update Init to use InitCommand

Change-Id: I3ff700a87dfa6ac255c1aaf3fe11a07264594aab
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoAdd InitCommand 14/2014/3
Chris Aniszczyk [Fri, 3 Dec 2010 02:10:08 +0000 (20:10 -0600)]
Add InitCommand

Adds git-init support to the Git API.

Change-Id: I1428b861f22cabe4d92cadf3d9114dddeec75b40
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoMerge "Ensure stable tag sort in PlotWalk"
Shawn O. Pearce [Sun, 5 Dec 2010 23:10:12 +0000 (18:10 -0500)]
Merge "Ensure stable tag sort in PlotWalk"

13 years agoMerge "Abstract SSH setup to support GIT_SSH"
Chris Aniszczyk [Sun, 5 Dec 2010 15:50:05 +0000 (10:50 -0500)]
Merge "Abstract SSH setup to support GIT_SSH"

13 years agoFix findGitDir() with no ceiling directories 35/2035/3
Shawn O. Pearce [Fri, 3 Dec 2010 21:51:39 +0000 (13:51 -0800)]
Fix findGitDir() with no ceiling directories

Bug: 322866
Change-Id: I64205bb0315a725dfa523ccff1796de50f465162
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
CC: Ketan Padegaonkar <KetanPadegaonkar@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoMerge "Correct CommitBuilder, TagBuilder method to be build()"
Matthias Sohn [Sun, 5 Dec 2010 13:19:58 +0000 (08:19 -0500)]
Merge "Correct CommitBuilder, TagBuilder method to be build()"

13 years agoMerge "Fix checking out large files"
Robin Rosenberg [Sat, 4 Dec 2010 08:49:11 +0000 (03:49 -0500)]
Merge "Fix checking out large files"

13 years agoEnsure stable tag sort in PlotWalk 32/2032/2
Shawn O. Pearce [Fri, 3 Dec 2010 21:19:15 +0000 (13:19 -0800)]
Ensure stable tag sort in PlotWalk

Because tags are more interesting here than local or remote branch
heads, tags get sorted earlier in the array than heads or remotes do.

Bug: 324939
Change-Id: Ifc3863461654df7f34fdecbd2abe1f4b5d2ffb8e
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
CC: Mathias Kinzler <mathias.kinzler@sap.com>
CC: Stefan Lay <stefan.lay@sap.com>
13 years agoFix checking out large files 33/2033/3
Shawn O. Pearce [Fri, 3 Dec 2010 21:35:46 +0000 (13:35 -0800)]
Fix checking out large files

DirCacheCheckout needs to use ObjectLoader.copyTo to avoid loading the
complete content of a large file into the JVM heap.

Bug: 321097
Change-Id: I967590b6f233fd1c83d873075db01d653208b3b9
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
CC: Chris Aniszczyk <caniszczyk@gmail.com>
CC: Christian Halstrick <christian.halstrick@sap.com>
13 years agoHonor GIT_SSH when opening SSH connections 37/2037/1
Shawn O. Pearce [Sat, 4 Dec 2010 00:33:46 +0000 (16:33 -0800)]
Honor GIT_SSH when opening SSH connections

If the environment variable GIT_SSH is set, use GIT_SSH for any remote
protocol connections, instead of the local JSch library.

Bug: 321062
Change-Id: Ia18ea49d58f3ed657430067f1f72ef788a2dae4c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoAbstract SSH setup to support GIT_SSH 36/2036/1
Shawn O. Pearce [Sat, 4 Dec 2010 00:14:46 +0000 (16:14 -0800)]
Abstract SSH setup to support GIT_SSH

In order to honor GIT_SSH the TransportGitSsh class needs to run the
process named by the GIT_SSH environment variable and use that as the
pipes for connectivity to the remote peer.  Refactor the current
transport code to support a different type of pipe connectivity, so we
can later add GIT_SSH.

Bug: 321062
Change-Id: I9d8ee1a95f1bac5013b33a4a42dcf1f98f92172f
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoAdd missing license header 34/2034/1
Matthias Sohn [Fri, 3 Dec 2010 21:37:46 +0000 (22:37 +0100)]
Add missing license header

Change-Id: Ibfd17951606f02283660befcff53ff9b73405dd9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoAdd debugging toString to TreeFormatter 31/2031/1
Shawn O. Pearce [Fri, 3 Dec 2010 21:09:01 +0000 (13:09 -0800)]
Add debugging toString to TreeFormatter

Displaying the current tree in the ls-tree style output makes it
easier to see what entries are currently stored.

Change-Id: If17c414db0d2e8d84e65de8bbcba7fd1b79aa311
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Reviewed-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoAdd insert(TreeFormatter) to ObjectInserter 30/2030/1
Shawn O. Pearce [Fri, 3 Dec 2010 21:02:15 +0000 (13:02 -0800)]
Add insert(TreeFormatter) to ObjectInserter

This makes usage of a TreeFormatter more similar to a CommitBuilder or
a TagBuilder: populate the formatter and pass to the ObjectInserter.

Change-Id: I5a45ef3a35cc73f4905a34bc6f6228510df8eb2c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Reviewed-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoAdd toByteArray to CommitBuilder, TreeBuilder 29/2029/1
Shawn O. Pearce [Fri, 3 Dec 2010 20:57:07 +0000 (12:57 -0800)]
Add toByteArray to CommitBuilder, TreeBuilder

This better matches the existing API of TreeFormatter, but is just a
simple delegation to build().

Change-Id: I188f43acc34455e773d63836724b05e18f5c7a84
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Reviewed-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoRemove unused getTreeId from TreeFormatter 28/2028/1
Shawn O. Pearce [Fri, 3 Dec 2010 20:47:37 +0000 (12:47 -0800)]
Remove unused getTreeId from TreeFormatter

Change-Id: If5955757575d4c6053b6f8109e9dc2ecb0502446
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Reviewed-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoRemove result id from CommitBuilder, TagBuilder 27/2027/1
Shawn O. Pearce [Fri, 3 Dec 2010 20:38:31 +0000 (12:38 -0800)]
Remove result id from CommitBuilder, TagBuilder

These objects don't need to be updated with the resulting ObjectId of
the formatted content, callers can get that from the ObjectInserter on
their own.

Change-Id: Idc5f097de9f7beafc5e54e597383d82daf9d7db4
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Reviewed-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoCorrect CommitBuilder, TagBuilder method to be build() 26/2026/1
Shawn O. Pearce [Fri, 3 Dec 2010 20:23:39 +0000 (12:23 -0800)]
Correct CommitBuilder, TagBuilder method to be build()

The correct names for these is build(), as that is what a Java
developer will expect given the "builder" pattern.

Bug: 323541
Change-Id: I35042bdc95a955beeaee29e54bde10e4240b2a71
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Reviewed-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoFix jgit build broken by deabacc4 15/2015/1
Matthias Sohn [Fri, 3 Dec 2010 08:24:31 +0000 (09:24 +0100)]
Fix jgit build broken by deabacc4

Since 049827d7 MergeAlgorithm isn't static anymore.

Change-Id: I3d704f663a776bb57e59f28a8200753fae5e9d25
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoMerge "Rebase Interoperability first part: write "interactive" file"
Chris Aniszczyk [Fri, 3 Dec 2010 02:19:10 +0000 (21:19 -0500)]
Merge "Rebase Interoperability first part: write "interactive" file"

13 years agoMerge "Fixed Merge Algorithm regarding concurrent file creations"
Chris Aniszczyk [Fri, 3 Dec 2010 01:19:04 +0000 (20:19 -0500)]
Merge "Fixed Merge Algorithm regarding concurrent file creations"

13 years agoFixed Merge Algorithm regarding concurrent file creations 39/1939/3
Christian Halstrick [Thu, 2 Dec 2010 12:11:21 +0000 (13:11 +0100)]
Fixed Merge Algorithm regarding concurrent file creations

When in OURS and THEIRS a new file is created we want a conflict
when the two contents differ. If on two branches the same file
with the same content is created this should not be a conflict.
But: the current merge algorithm is throwing NPEs in this case.
Fix this by choosing an empty RawText as common base if the
base is empty.

Change-Id: I21cb23f852965b82fb82ccd66ec961c7edb3ac3d
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
13 years agoAvoid unnecessary decoding of length in PackFile 92/1992/1
Shawn O. Pearce [Wed, 1 Dec 2010 17:59:55 +0000 (09:59 -0800)]
Avoid unnecessary decoding of length in PackFile

If the object type is a whole object and all we want is the type,
there is no need to skip the length header.  The type is already known
and can be returned as-is.  Instead skip the length header only for
the two delta formats, where the delta base must itself be scanned.

Change-Id: I87029258e88924b3e5850bdd6c9006a366191d10
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoRemove unused 'shift' variable from PackFile 91/1991/1
Shawn O. Pearce [Wed, 1 Dec 2010 17:57:16 +0000 (09:57 -0800)]
Remove unused 'shift' variable from PackFile

This variable was not used for anything, but Eclipse's JDT failed to
notice because of the "shift += " operation within the body of the
while loop.  Here we don't need the shift because we do not decode the
length, but we do have to skip over the bytes that store the length to
locate the delta base.

Bug: 331319
Change-Id: I200a874fd7e39e3adf2640b8cd0f53dcf91ef4c9
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
CC: Remy Suen <remysuen@ca.ibm.com>
13 years agoRebase Interoperability second part: fix "pop steps" 85/1985/1
Mathias Kinzler [Wed, 1 Dec 2010 14:10:13 +0000 (15:10 +0100)]
Rebase Interoperability second part: fix "pop steps"

If the CLI stops a rebase upon conflict, the current
step is already popped from the git-rebase-todo and appended to the
"done" file. The current implementation wrongly pops the step only
after successful cherry-pick.

Change-Id: I8640dda0cbb2a5271ecf75fcbad69410122eeab6
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
13 years agoRebase Interoperability first part: write "interactive" file 84/1984/1
Mathias Kinzler [Wed, 1 Dec 2010 14:08:07 +0000 (15:08 +0100)]
Rebase Interoperability first part: write "interactive" file

The Repository is then in state "Rebase interactive".

Change-Id: I5d2de57f8670e1d4c71ed22509ab17f04e2561b5
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
13 years agoInclude list of assume unchanged files in IndexDiff 68/1968/4
Stefan Lay [Tue, 30 Nov 2010 10:33:54 +0000 (11:33 +0100)]
Include list of assume unchanged files in IndexDiff

The IndexDiff had not collected the info if the flag
"assume-unchanged" is set. This information is useful for clients
which may want to decide if specific actions are allowed on a file.

Bug: 326213
Change-Id: I14bb7b03247d6c0b429a9d8d3f6b10f21d8ddeb1
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
13 years agoUse the Set interface in declarations and as return value 71/1971/1
Stefan Lay [Tue, 30 Nov 2010 10:05:42 +0000 (11:05 +0100)]
Use the Set interface in declarations and as return value

Change-Id: Ib273c4980036f75bd4dad3ffe1c29a37b2df932a
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
13 years agoMerge "Check assume unchanged flag in Add command"
Shawn Pearce [Mon, 29 Nov 2010 23:21:08 +0000 (18:21 -0500)]
Merge "Check assume unchanged flag in Add command"

13 years agoMerge "Fix DiffConfig to understand "copy" resp. "copies" for diff.renames property."
Shawn Pearce [Mon, 29 Nov 2010 22:59:15 +0000 (17:59 -0500)]
Merge "Fix DiffConfig to understand "copy" resp. "copies" for diff.renames property."

13 years agoCheck assume unchanged flag in Add command 70/1970/2
Stefan Lay [Mon, 29 Nov 2010 16:58:38 +0000 (17:58 +0100)]
Check assume unchanged flag in Add command

When the assume unchanged flag is set the Add command must not update
the index for this file if any changes are present in the working
directory.

Bug: 331351
Change-Id: I255870f689225a1d88971182e0eb377952641b42
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
13 years agoFix DiffConfig to understand "copy" resp. "copies" for diff.renames property. 48/1948/3
Marc Strapetz [Fri, 26 Nov 2010 10:07:04 +0000 (11:07 +0100)]
Fix DiffConfig to understand "copy" resp. "copies" for diff.renames property.

Rename detection should be considered enabled if
diff.renames config property is set to "copy" or "copies", instead of
throwing IllegalArgumentException.

Change-Id: If55d955e37235d4d00f5b0febd6aa10c0e27814e

13 years agoRebaseCommand: trim line endings when reading files 40/1940/4
Mathias Kinzler [Fri, 26 Nov 2010 07:29:48 +0000 (08:29 +0100)]
RebaseCommand: trim line endings when reading files

In order to enable interoperability with the command line, we need to
remove line feeds when reading the files.

Change-Id: Ie2f5799037a60243bb4fac52346908ff85c0ce5d
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
13 years agoMerge "Change default diff algorithm to histogram and add tests"
Chris Aniszczyk [Fri, 26 Nov 2010 11:04:50 +0000 (06:04 -0500)]
Merge "Change default diff algorithm to histogram and add tests"

13 years agoMerge "Do some more tests for rebase --abort"
Chris Aniszczyk [Fri, 26 Nov 2010 10:45:49 +0000 (05:45 -0500)]
Merge "Do some more tests for rebase --abort"

13 years agoChange default diff algorithm to histogram and add tests 58/1958/2
Christian Halstrick [Thu, 25 Nov 2010 23:44:05 +0000 (00:44 +0100)]
Change default diff algorithm to histogram and add tests

The referenced bug showed that JGit produced different merge results
compared to C Git. Unit test was added to reproduce the issue. The
problem can be solved by switching to histogram diff algorithm.

Bug: 331078
Change-Id: I54f30afb3a9fef1dbca365ca5f98f4cc846092e3
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
13 years agoMake diff algorithm configurable 57/1957/2
Christian Halstrick [Thu, 25 Nov 2010 23:30:08 +0000 (00:30 +0100)]
Make diff algorithm configurable

The diff algorithm which is used by Merge, Cherry-Pick, Rebase
should be configurable. A new configuration parameter "diff.algorithm"
is introduced which currently accepts the values "myers" or
"histogram". Based on this parameter for example the ResolveMerger
will choose a diff algorithm. The reason for this is bug 331078.
This bug shows that JGit is more compatible with C Git when
histogram diff is in place. But since histogram diff is quite new we
need an easy way to fall back to Myers diff.

Bug: 331078
Change-Id: I2549c992e478d991c61c9508ad826d1a9e539ae3
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
13 years agoDo some more tests for rebase --abort 53/1953/2
Stefan Lay [Thu, 25 Nov 2010 12:40:59 +0000 (13:40 +0100)]
Do some more tests for rebase --abort

Check for deletion of temporary files in .git folder.
Check for deletion and creation of files.

Change-Id: I60b0b2975724f2e3582e8674d9f876dcbf62b350
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
13 years agoAdd more tests for rebase and externalized missing Strings 38/1938/2
Christian Halstrick [Wed, 24 Nov 2010 08:43:38 +0000 (09:43 +0100)]
Add more tests for rebase and externalized missing Strings

Coverage tests showed that we are missing to test certain areas
in the rebase command. Add the missing tests.

Change-Id: Ia4a272d26cde7e1861dac30496e4b6799fc8187a
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
13 years agoAdd the Checkout command to the Git CLI 37/1937/1
Chris Aniszczyk [Mon, 15 Nov 2010 16:39:45 +0000 (10:39 -0600)]
Add the Checkout command to the Git CLI

The implementation delegates to the CheckoutCommand and
therefore only supports some of the options supported by
the CheckoutCommand.

Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoAdd CheckoutCommand 32/1832/5
Chris Aniszczyk [Sat, 30 Oct 2010 15:19:51 +0000 (10:19 -0500)]
Add CheckoutCommand

Add the ability to checkout a branch to the working tree.

Bug: 330860
Change-Id: Ie06b9e799a9e1be384da0b8996efa7209b32eac3
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoMerge "Fix bug regarding handling of non-versioned files during merge"
Matthias Sohn [Mon, 22 Nov 2010 21:43:43 +0000 (16:43 -0500)]
Merge "Fix bug regarding handling of non-versioned files during merge"

13 years agoFix bug regarding handling of non-versioned files during merge 29/1929/2
Christian Halstrick [Mon, 22 Nov 2010 21:41:25 +0000 (22:41 +0100)]
Fix bug regarding handling of non-versioned files during merge

There was a bug introduced by commit 0e815fe. For non-versioned files
the merge algorithm detected an incoming deletion from THEIRS.
Consequently such files were deleted. That's a severe bug which was
fixed by more precisely detecting incoming deletions.

Change-Id: I4385d3c990db11d62e371a385dc8ee89841db84a
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
13 years agoUpdate Rm in the JGit CLI 10/1910/2
Chris Aniszczyk [Mon, 22 Nov 2010 17:19:51 +0000 (11:19 -0600)]
Update Rm in the JGit CLI

Since we have the RmCommand API now, update Rm to use it.

Change-Id: I6e2cb37573cc8a29846f01e09e8c07e0dc279dbe
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoAdd RmCommand to Git API 09/1909/3
Chris Aniszczyk [Mon, 15 Nov 2010 19:57:04 +0000 (13:57 -0600)]
Add RmCommand to Git API

Bug: 330827
Change-Id: I0b74bb92254d0ee988139d25022d06d16ed89d58
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoInitial implementation of a Rebase command 64/1864/10
Mathias Kinzler [Mon, 22 Nov 2010 15:26:00 +0000 (16:26 +0100)]
Initial implementation of a Rebase command

This is a first iteration to implement Rebase. At the moment, this
does not implement --continue and --skip, so if the first
conflict is found, the only option is to --abort the command.

Bug: 328217
Change-Id: I24d60c0214e71e5572955f8261e10a42e9e95298
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoMove WorkingTreeIterator inherited state into an object 26/1926/1
Shawn O. Pearce [Fri, 19 Nov 2010 01:04:10 +0000 (17:04 -0800)]
Move WorkingTreeIterator inherited state into an object

Instead of copying up to 4 fields from the parent iterator each time a
child iterator is initialized and used, construct a single state
object that contains the 4 fields, and pass that one state object
through to the child.  This makes it easier to add additional state
fields that must be inherited, at the slight expense of an extra
object allocation per TreeWalk, and an extra level of field
indirection whenever the options, nameEncoder, or read buffer is
required by the iterator.

Change-Id: Ic4603c33b772d7a45f9c81140537d51945688fcb
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoName TreeFilter and MergeFilter implementations 25/1925/1
Shawn O. Pearce [Fri, 19 Nov 2010 00:50:14 +0000 (16:50 -0800)]
Name TreeFilter and MergeFilter implementations

Naming these inner classes ensures that stack traces which contain
them will give us useful information about which filter is involved in
the trace, rather than the generated names $1, $2, etc.  This makes it
much easier to understand a stack trace at a glance.

Change-Id: Ia6a75fdb382ff6461e02054d94baf011bdeee5aa
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoAdd core.filemode to CoreConfig 06/1906/1
Chris Aniszczyk [Mon, 15 Nov 2010 00:54:36 +0000 (18:54 -0600)]
Add core.filemode to CoreConfig

Let CoreConfig cache the value of core.filemode so
clients like EGit can take advantage of it.

Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
13 years agoFixed checkouts when HEAD is ignored 88/1888/3
Christian Halstrick [Fri, 12 Nov 2010 22:31:55 +0000 (23:31 +0100)]
Fixed checkouts when HEAD is ignored

In the case where DirCacheCheckout was used to checkout a tree
without taking HEAD into account (e.g. during a clone or hard reset)
we didn't handle conflicts correctly. E.g. if there are conflicts
(entries with stage != 0) in the index and we tried to hard reset
we have been processing the conflicting pathes multiple times (once
for every stage). With this fix we will update the index with the
entry from the "merge" state (the state we want checkout) when we
detect existing conflicts.

Change-Id: Iffbddccaa588cf0d1460a5e44dabaf540d996e26
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
13 years agoMerge "Add simple unit tests for Base64"
Chris Aniszczyk [Sat, 13 Nov 2010 17:40:18 +0000 (12:40 -0500)]
Merge "Add simple unit tests for Base64"

13 years agoMerge "Base64: Reformat to match JGit style"
Chris Aniszczyk [Sat, 13 Nov 2010 17:40:05 +0000 (12:40 -0500)]
Merge "Base64: Reformat to match JGit style"

13 years agoMerge "Base64: Strip out code JGit doesn't use"
Chris Aniszczyk [Sat, 13 Nov 2010 17:39:48 +0000 (12:39 -0500)]
Merge "Base64: Strip out code JGit doesn't use"

13 years agoMerge "Remove unnecessary note fanout when removing notes"
Chris Aniszczyk [Sat, 13 Nov 2010 17:38:17 +0000 (12:38 -0500)]
Merge "Remove unnecessary note fanout when removing notes"

13 years agoMerge "Split note leaf buckets at 256 elements"
Chris Aniszczyk [Sat, 13 Nov 2010 17:37:30 +0000 (12:37 -0500)]
Merge "Split note leaf buckets at 256 elements"

13 years agoMerge "Add internal API for note iteration"
Chris Aniszczyk [Sat, 13 Nov 2010 17:32:59 +0000 (12:32 -0500)]
Merge "Add internal API for note iteration"

13 years agoMerge "Allow writing a NoteMap back to the repository"
Chris Aniszczyk [Sat, 13 Nov 2010 17:31:58 +0000 (12:31 -0500)]
Merge "Allow writing a NoteMap back to the repository"

13 years agoMerge "Add in-memory updating support to NoteMap"
Chris Aniszczyk [Sat, 13 Nov 2010 17:31:02 +0000 (12:31 -0500)]
Merge "Add in-memory updating support to NoteMap"

13 years agoMerge "Remember non-note tree entries when reading"
Chris Aniszczyk [Sat, 13 Nov 2010 17:29:31 +0000 (12:29 -0500)]
Merge "Remember non-note tree entries when reading"

13 years agoMerge branch 'rename-detection' 04/1904/1
Shawn O. Pearce [Sat, 13 Nov 2010 00:15:43 +0000 (16:15 -0800)]
Merge branch 'rename-detection'

* rename-detection:
  RenameDetector: Only scan deletes if adds exist
  SimilarityRenameDetector: Initialize sizes to 0
  SimilarityRenameDetector: Avoid allocating source index
  SimilarityRenameDetector: Only attempt to index large files once
  SimilarityIndex: Don't overflow internal counter fields
  SimilarityIndex: Accept files larger than 8 MB
  SimilarityIndex: Correct comment explaining the logic

13 years agoMerge branch 'fs-fsync' 03/1903/1
Shawn O. Pearce [Sat, 13 Nov 2010 00:12:27 +0000 (16:12 -0800)]
Merge branch 'fs-fsync'

* fs-fsync:
  Remove unnecessary flush calls from LockFile
  Remove unnecessary region locking from LockFile
  Support core.fsyncRefFiles option
  Support core.fsyncObjectFiles option
  Simplify LockFile write(ObjectId) case

13 years agoAdd simple unit tests for Base64 02/1902/1
Shawn O. Pearce [Sat, 13 Nov 2010 00:01:34 +0000 (16:01 -0800)]
Add simple unit tests for Base64

Change-Id: I22ef1eb63ae8ddb9884526099013979856ab7bd9
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoBase64: Reformat to match JGit style 01/1901/1
Shawn O. Pearce [Fri, 12 Nov 2010 23:11:30 +0000 (15:11 -0800)]
Base64: Reformat to match JGit style

Rewrite the initialization of the encoding tables to be more clear,
but slightly slower to setup.  We generally perfer a clear definition
of the data over a slightly slower class load time.

Change-Id: I0c7f89b6ab82dcf71525ffb69a388c312c195913
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoBase64: Strip out code JGit doesn't use 00/1900/1
Shawn O. Pearce [Fri, 12 Nov 2010 22:51:06 +0000 (14:51 -0800)]
Base64: Strip out code JGit doesn't use

Since we have already modified this class to localize an error
message, we might as well strip it down to contain only the
functionality we need, or might ever use.

To keep this simple to review we don't adjust formatting right
away, so code that was buried inside of an if or else block whose
condition was removed might not have the correct indentation anymore.
We can fix this with a later reformatting change.

Change-Id: I2996aaa704e9d6182e5500c7a63240d5e9d722cc
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoAdded one-tree constructor to DirCacheCheckout 99/1899/1
Christian Halstrick [Fri, 12 Nov 2010 23:42:01 +0000 (00:42 +0100)]
Added one-tree constructor to DirCacheCheckout

When DirCacheCheckout should be used to checkout only one
tree (reset --hard, clone) then we had to use the standard
constructor and specify null as value for head. This change
adds explicit constructors not taking HEAD and documents
that.

Bug: 330021
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
13 years agoRemove unnecessary note fanout when removing notes 55/1855/4
Shawn O. Pearce [Fri, 5 Nov 2010 02:01:51 +0000 (19:01 -0700)]
Remove unnecessary note fanout when removing notes

Fanout level notes trees are combined back together into a flat leaf
level tree if during a removal of a subtree there are less than 3/4 of
the fanout subtrees still existing, and the size of the combined leaf
is under the 256 split limit noted above.

This rule is used because deletes are less common than insertions, and
SHA-1's relatively uniform distribution suggests that with only 192
subtrees existing in the fanout, there should be approximately 192
names in the combined replacement leaf tree.

Change-Id: Ia9d145ffd5454982509fc40906bc4dbbf2b13952
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoSplit note leaf buckets at 256 elements 54/1854/4
Shawn O. Pearce [Fri, 5 Nov 2010 01:56:40 +0000 (18:56 -0700)]
Split note leaf buckets at 256 elements

Leaf level notes trees are split into a new fan-out tree if an
insertion occurs and the tree already contains >= 256 notes in it.

The splitting may occur multiple times if all of the notes have the
same prefix; in the worst case this produces a tree path such as
"00/00/00/00/00/00/00/00/00/00/00/00/00/00/00/00/00/00/00/be" if all
of the notes begin with zeros.

Change-Id: I2d7d98f35108def9ec49936ddbdc34b13822a3c7
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoAdd internal API for note iteration 53/1853/4
Shawn O. Pearce [Fri, 5 Nov 2010 01:46:19 +0000 (18:46 -0700)]
Add internal API for note iteration

Some algorithms need to be able to iterate through all notes within a
particular bucket, such as when splitting or combining a bucket.
Exposing an Iterator<Note> makes this traversal possible.

For a LeafBucket the iteration is simple, its over the sorted array of
elements.  For FanoutBucket its a bit more complex as the iteration
needs to union the iterators of each fanout bucket, lazily loading any
buckets that aren't already in-memory.

Change-Id: I3d5279b11984f44dcf0ddb14a82a4b4e51d4632d
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoAllow writing a NoteMap back to the repository 52/1852/5
Shawn O. Pearce [Fri, 5 Nov 2010 01:14:00 +0000 (18:14 -0700)]
Allow writing a NoteMap back to the repository

This is necessary to allow applications to wrap the note tree in
a commit and update the note branch with the new state.

Change-Id: Idbd7ead4a1b16ae2b64a30a4a01a29cfed548cdf
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoAdd in-memory updating support to NoteMap 51/1851/5
Shawn O. Pearce [Fri, 5 Nov 2010 00:50:48 +0000 (17:50 -0700)]
Add in-memory updating support to NoteMap

NoteMap now supports editing in-memory, allowing applications to
modify the NoteMap once it has been loaded from the branch.  The
ability to write the branch back to tree objects is not yet done,
so the edits are strictly transient.

Change-Id: I63448954abfca2a8e3e95369cd84c0d1176cdb79
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoRemove unnecessary flush calls from LockFile 86/1886/2
Shawn O. Pearce [Thu, 11 Nov 2010 01:30:43 +0000 (17:30 -0800)]
Remove unnecessary flush calls from LockFile

Change-Id: I144af9db4714acabd796880be73bd50d84b92efe
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoRemove unnecessary region locking from LockFile 85/1885/2
Shawn O. Pearce [Thu, 11 Nov 2010 01:28:14 +0000 (17:28 -0800)]
Remove unnecessary region locking from LockFile

The lock file protocol relies on the atomic creation of a standardized
name in the parent directory of the file being updated.  Since the
creation is atomic, at most one thread in any process can succeed on
this creation, and all others will fail.  While the lock file exists,
that file is private to the thread that is writing it, and no others
will attempt to read or modify the file.

Consequently the use of the region level locks around the file are
unnecessary, and may actually reduce performance when using NFS, SMB,
or some other sort of remote filesystem that supports locking.

Change-Id: Ice312b6fb4fdf9d36c734c3624c6d0537903913b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoSupport core.fsyncRefFiles option 84/1884/2
Shawn O. Pearce [Thu, 11 Nov 2010 01:24:16 +0000 (17:24 -0800)]
Support core.fsyncRefFiles option

If core.fsyncRefFiles is set to true, fsync is used whenever a
reference file is updated, ensuring the file contents are also
written to disk.  This can help to prevent empty ref files after
a system crash when using a filesystem such as HFS+ where data
writes may be delayed.

Change-Id: Ie508a974da50f63b0409c38afe68772322dc19f1
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoSupport core.fsyncObjectFiles option 83/1883/3
Shawn O. Pearce [Wed, 10 Nov 2010 02:58:36 +0000 (18:58 -0800)]
Support core.fsyncObjectFiles option

Some repositories may be on really unstable filesystems, but still
want to have good reliability when objects are written to disk.  If
core.fsyncObjectFiles is set to true, request the JVM to ensure the
data is written before returning success to the caller of insert.

The option defaults to false because it should be useless on any
filesystem that orders writes and metadata, such as ext3 mounted with
data=ordered (or data=journal).  But it may be useful on some systems
(especially HFS+) where file content may flush to the disk
independently of filesystem structure changes.

Because FileChannel.force(boolean) only claims to ensure data is
written if it was written using the write(ByteBuffer) method of
FileChannel, redirect all writes when using fsyncObjectFiles to go
through the FileChannel interface instead of through the older style
OutputStream interface.  This may not be necessary on all JVMs, but
its more portable to follow the definition than the common behavior.

Change-Id: I57f6b6bb7e403c07fbae989dbf3758eaf5edbc78
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoRenameDetector: Only scan deletes if adds exist 93/1893/2
Shawn O. Pearce [Thu, 11 Nov 2010 23:02:57 +0000 (15:02 -0800)]
RenameDetector: Only scan deletes if adds exist

If there are only deletes, don't need perform rename or copy
detection.  There are no adds (aka destinations) for the deletes
to match against.

Change-Id: I00fb90c509fa26a053de561dd8506cc1e0f5799a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoSimilarityRenameDetector: Initialize sizes to 0 92/1892/2
Shawn O. Pearce [Thu, 11 Nov 2010 22:43:22 +0000 (14:43 -0800)]
SimilarityRenameDetector: Initialize sizes to 0

Setting the array elements to -1 is more expensive than relying on
the allocator to zero the array for us first.  Shifting the code to
always add 1 to the size (so an empty file is actually 1 byte long)
allows us to detect an unloaded size by comparing to 0, thus saving
the array fill calls.

Change-Id: Iad859e910655675b53ba70de8e6fceaef7cfcdd1
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 years agoSimilarityRenameDetector: Avoid allocating source index 91/1891/2
Shawn O. Pearce [Thu, 11 Nov 2010 22:29:11 +0000 (14:29 -0800)]
SimilarityRenameDetector: Avoid allocating source index

If the only file added is really small, and all of the deleted
files are really big, none of the permutations will match up due
to the sizes being too far apart to fit the current rename score.

Avoid allocating the really big deleted SimilarityIndex by deferring
its construction until at least one add along that row has a
reasonable chance of matching it.

This avoids expending a lot of CPU time looking at big deleted
binary files when a small modified text file was broken due to a
high percentage of changed lines.

Change-Id: I11ae37edb80a7be1eef8cc01d79412017c2fc075
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
13 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>
13 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>
13 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>
13 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>