]> source.dussan.org Git - jgit.git/log
jgit.git
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 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 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

14 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>
14 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"

14 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"

14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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"

14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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"

14 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"

14 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"

14 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"

14 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"

14 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"

14 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"

14 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"

14 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"

14 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

14 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

14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 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>
14 years agoSimilarityRenameDetector: Only attempt to index large files once 90/1890/2
Shawn O. Pearce [Thu, 11 Nov 2010 22:25:01 +0000 (14:25 -0800)]
SimilarityRenameDetector: Only attempt to index large files once

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

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

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

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

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

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

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

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

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

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

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

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

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

Change-Id: I07c1fba7dee093a1eeffcf7e0c7ec85446777ffb
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoMerge "Fix null ref exception in DirCacheCheckout"
Shawn Pearce [Fri, 12 Nov 2010 16:29:32 +0000 (11:29 -0500)]
Merge "Fix null ref exception in DirCacheCheckout"

14 years agoUse capital L for long constants 95/1895/1
Robin Rosenberg [Mon, 4 Oct 2010 05:48:12 +0000 (07:48 +0200)]
Use capital L for long constants

Change-Id: Ib7b8c5f982dc72c68cf3d81e45a536c464837f7d
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
14 years agoRemember non-note tree entries when reading 50/1850/4
Shawn O. Pearce [Fri, 5 Nov 2010 00:06:48 +0000 (17:06 -0700)]
Remember non-note tree entries when reading

In order to safely edit a notes tree, NoteMap needs to retain any
non-note tree entries it read from the source tree and put them
back out into the modified tree when it commits a new version of
the note branch.

Remember any tree entries that didn't look like a note during
the parsing of the tree, so they can be put into a TreeFormatter
later when the tree writes to the repository.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

14 years agoFix null ref exception in DirCacheCheckout 77/1877/1
Lluis Sanchez [Wed, 10 Nov 2010 09:39:48 +0000 (10:39 +0100)]
Fix null ref exception in DirCacheCheckout

Added missing null check for getDirCacheEntry(). This method may
return null for example if the curernt entry is a subtree.

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

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

Change-Id: I635a94eb0a741abcb3e68195da6913753bdbd889
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
14 years agoSimplify LockFile write(ObjectId) case 82/1882/1
Shawn O. Pearce [Wed, 10 Nov 2010 03:12:24 +0000 (19:12 -0800)]
Simplify LockFile write(ObjectId) case

The ObjectId (for a ref) can be easily reformatted into a temporary
byte[] and then passed off to write(byte[]), removing the duplicated
code that existed in both write methods.

Change-Id: I09740658e070d5f22682333a2e0d325fd1c4a6cb
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoMerge "Fix broken MergeCommandTest"
Shawn Pearce [Tue, 9 Nov 2010 23:58:34 +0000 (18:58 -0500)]
Merge "Fix broken MergeCommandTest"

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

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

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

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

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

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

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

This reverts commit 1e510ec20e0391010419b17e9a9095ad54941d3c.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

We don't want to pool this String.

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

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

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

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

This is fixed by handling incoming deletions explicitly.

Bug: 328841
Change-Id: I7f4c94ab54138e1b2f3fcdf34fb803d68e209ad0
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>