Commit Graph

1650 Commits

Author SHA1 Message Date
Matthias Sohn 755dfdb409 Prepare 2.0.0-SNAPSHOT builds
Change-Id: I946e315af04227727ac937ebe9d70ae1ea4e8936
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-16 00:49:49 +01:00
Matthias Sohn 42b0fb4679 Merge branch 'stable-1.3'
* stable-1.3:
  Prepare post 1.3.0.201202151440-r build
  JGit 1.3.0.201202151440-r
  Generate conflicts and index updates on file mode changes

Change-Id: Ie99780ef5cdea7b3ea1ea076282fe0a25f14f469
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-16 00:44:47 +01:00
Matthias Sohn f70b24a601 Prepare post 1.3.0.201202151440-r build
Change-Id: I4d695273e3151c22f2df9a58725cc7ba21ab6043
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-16 00:42:34 +01:00
Matthias Sohn e4ee677dea JGit 1.3.0.201202151440-r
Change-Id: I663208919f297836a9c16bf458e4a43ffaca4c12
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-15 20:56:06 +01:00
Christian Halstrick ed7b322186 Generate conflicts and index updates on file mode changes
Handle more cases for file mode changes. Especially make sure that the
following cases are handled correctly.

Case 1)

  An entry in the working tree, HEAD tree, and merge tree have
  different modes and different content.

  Prior Outcome:
    Dirty working tree content is replaced and file mode
    changes are lost.

  New Outcome:
    Conflict is generated.

Case 2)

  An entry in the index and merge tree have the same content
  but different modes but both modes are file type modes.

  Prior Outcome:
    File mode in working tree is not updated and the working
    directory is dirty.

  New Outcome:
    Index is updated and the working directory is clean.

Bug: 363772
Change-Id: I224602d68228eb419813986807f1eeab77e9c302
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Also-by: Kevin Sawicki <kevin@github.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-13 09:39:05 +01:00
Matthias Sohn de48250da5 Merge branch 'stable-1.3'
* stable-1.3:
  Prepare post 1.3.0.201202121842-rc4 builds
  JGit 1.3.0.201202121842-rc4
  Support gitdir references in working tree .git file
  Support committing submodule updates
  Update iplog tool's README

Change-Id: Id70f4d4b059b03d4fa6fbd9137b81a337e9c48e8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-13 07:34:18 +01:00
Matthias Sohn 3b358ce514 Prepare post 1.3.0.201202121842-rc4 builds
Change-Id: I50e0e6c2bccab5f3da62cbfe976f065169426906
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-13 07:30:00 +01:00
Matthias Sohn 53917539f8 JGit 1.3.0.201202121842-rc4
Change-Id: I82c6c0c175ab6fb4e2113101f36c8d2ddf4a13c1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-13 00:57:43 +01:00
Robin Rosenberg ad9033e43a Revert non-sense logic in IO.readFully
This was introduced in alleged support for autocrlf, but the
logic makes no sense here.

Change-Id: If37f3b90f21f875cee7165e17a17adfda446384d
2012-02-12 20:42:47 +01:00
Kevin Sawicki 2f79cf9900 Support gitdir references in working tree .git file
A '.git' file in a repository's working tree root is now parsed
as a ref to a folder located elsewhere.  This supports submodules
having their repository location outside of the parent repository's
working directory such as in the parent repository's '.git/modules'
directory.

This adds support to BaseRepositoryBuilder for repositories created
with the '--separate-git-dir' option specified to 'git init'.

Change-Id: I73c538f6d845bdbc0c4e2bce5a77f900cf36e1a9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-08 23:10:28 +01:00
Tomasz Zarna f1945cac1d Add getters for old and new prefixes in DiffFormatter
Bug: 370318
Change-Id: Iaf9282ba55ee3bb4e2c27fb71c598b308771bf57
2012-02-02 11:59:28 +01:00
Kevin Sawicki 7bde08e1d4 Support committing submodule updates
Use the submodule object id provided by the working
tree iterator

Change-Id: Ibf82f56c04cb9c91b2b309cf0cfa3f638539e23c
2012-01-30 13:37:40 -08:00
Robin Rosenberg 96acc4e5cf Really close output stream when core.autocrlf is true
Change-Id: I8a0d91e908145168c32589600bd1598826511ae3
2012-01-23 00:57:39 +01:00
Kevin Sawicki 97210fd6db Add command support for listing stashed commits
Bug: 309355
Change-Id: I34a8c251b89abcdb67565ca49bee02e5e2113593
Signe-off-by: Chris Aniszczyk <zx@twitter.com>
2012-01-20 09:00:13 -08:00
Matthias Sohn ea56a1ddb2 Merge "Support relative submodule URLs on init/add/sync" 2012-01-18 16:26:42 -05:00
Kevin Sawicki b57845c0cc Support relative submodule URLs on init/add/sync
Interpret submodule URLs that start with './' or '../' as
relative to either the configured remote for the HEAD branch,
or 'origin', or the parent repository working directory if no
remote URL is configured

Bug: 368536
Change-Id: Id4985824023b75cd45cd64a4dd9d421166391e10
2012-01-17 09:35:29 -08:00
Robin Stocker 14cc47ea1a Add BranchTrackingStatus for getting remote tracking status
This is used by EGit change I1e1caca561d1b0a0c194bfc42e64b698f42c6e6a to
show branch status in decoration.

It can also be used for providing the same output as C Git in "git
status".

Change-Id: I8d2b108c89905c3f0496f3d517879596740787c0
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-16 22:33:03 +01:00
Robin Stocker c0f4880e61 Add BranchConfig helper for access to branch config section
Getting the name of the remote-tracking branch given a branch is not so
easy to get right. This class provides a way to do that and could be
used for more branch config related things (e.g. in PullCommand).

Change-Id: I896a2384217936c8b672df8b81c9599f5c350458
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-16 22:18:54 +01:00
Robin Stocker 69d7d1b0b6 Add RevWalkUtils with count(start, end) method
It returns the number of commits that are in start and not in end.
Useful for calculating how much a branch is ahead of another one.

Change-Id: I09f7d9b049beea417da7ff32c9f8bf0d4ed46a7f
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-16 22:05:20 +01:00
Christian Halstrick a9892fba46 Merge "Support more of AutoCRLF" 2012-01-16 10:53:13 -05:00
Robin Rosenberg 03b5416a35 Fix resolution of tree when path is empty
Revision strings that end with a ':' with no trailing path
should return the tree associated with the current ref parsed

Bug: 368370
Change-Id: I7c7617a77bd418bad4e570be2d1e9002ad280762
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2012-01-15 23:56:37 +01:00
Robin Rosenberg e875c905d3 Make sure all bytes are written to files on close, or get an error.
Java's BufferedOutputStream swallows any errors that occur when flushing
the buffer in close().

This class overrides close to make sure an error during the final
flush is reported back to the caller.

Change-Id: I74a82b31505fadf8378069c5f6554f1033c28f9b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-15 11:22:52 +01:00
Robin Rosenberg 02729810f9 Merge "Resolve ~ with no trailing number as the first parent commit" 2012-01-14 20:28:52 -05:00
Matthias Sohn b8830d7bbb Throw API exception when LsRemoteCommand fails with TransportException
In many cases applications want to handle TransportException hence
expose it as an API exception.

Change-Id: I64b885ecfb1a35bd93c89026c6298d1820ba69d0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-15 01:38:25 +01:00
Kevin Sawicki c963e7aacf Resolve ~ with no trailing number as the first parent commit
This would previously throw a RevisionSyntaxException

Change-Id: I42b4988c7f6c6454e2ebda13914260e25ac1a889
2012-01-14 15:34:18 -08:00
Robin Rosenberg d5c890e0fd Cannot commit -o file with only file permission change
Bug 345076
Change-Id: Ie64039793ab6ba4748731320399f03301b6282ec
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-13 11:24:31 +01:00
Robin Rosenberg 76dd9d1d46 Support more of AutoCRLF
This patch introduces CRLF handling to the DirCacheCheckout and
WorkingTreeIterator supporting the AutoCRLF for add, checkout
reset and status and hopefully some other places that depende
on the underlying logic of the affected API's.

The patch includes test cases for the Status command provided by
Tomasz Zarna for bug 353867.

The core.eol and core.safecrlf options are not yet supported.

Bug: 301775
Bug: 353867
Change-Id: I2280a2dc0698829475de6a662a6c6e80b1df7663
2012-01-10 23:15:52 +01:00
Matthias Sohn 6a582970bf Merge "Provide helper for unlocking a file" 2012-01-10 12:24:49 -05:00
Kevin Sawicki aebfc70cc8 Provide helper for unlocking a file
This will allow recovery from a LockFailedException where
the file associated with an exception is passed to FileUtils.unlock
to attempt an unlock on the file so the operation can be retried

Change-Id: I580166d386126bfb54a318a65253070a6e325936
2012-01-09 08:46:13 -08:00
Tomasz Zarna f78e52b645 Add setter for ProgressMonitor to DiffCommand
Change-Id: I34f8b77a461e165d7d624dbd9a6944feadc57b8e
2012-01-09 15:48:16 +01:00
Stefan Lay 8f742cdd10 Merge "Add options for setting context lines and prefixes to DiffCommand" 2012-01-09 07:06:59 -05:00
Tomasz Zarna 69a5683b82 Add options for setting context lines and prefixes to DiffCommand
Change-Id: I539f3531e94c11c0f0a3e7096c0eb1b1c309898a
2012-01-09 12:13:30 +01:00
Christian Halstrick 885a389832 Merge "Add helper for determining if status is clean" 2012-01-09 06:13:12 -05:00
Matthias Sohn 0f15d656f2 Narrow exceptions declared by LsRemoteCommand
API commands either throw GitAPIException or JGitInternalException.

Also add missing javadoc and reduce nesting of catch blocks.

Change-Id: I9a3b302e1b3f373ee11a977a0e3d6213bfbd3cdf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Kevin Sawicki <kevin@github.com>
2012-01-08 17:15:05 -08:00
Robin Rosenberg 0806c803a9 Merge "Retain executable mode of existing files on Windows" 2012-01-08 16:34:28 -05:00
Matthias Sohn f9726423ab Merge "Use constants from ConfigConstants in CoreConfig" 2012-01-05 10:15:55 -05:00
Kevin Sawicki 3d15298011 Add helper for determining if status is clean
This checks if all collections that Status exposes are
empty or not

Change-Id: I0c342ab70dc36c1fd70acb4f8a924bb207d62f47
2012-01-03 16:48:01 -08:00
Kevin Sawicki 69451b8302 Provide file mode of paths in index from IndexDiff
Change-Id: I1d543e2f721987114cc1e1cb0848c234470df794
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-04 00:27:56 +01:00
Kevin Sawicki 6c959f7702 Use constants from ConfigConstants in CoreConfig
Change-Id: Ic1253498ecdd7545c6b1f114f4c83a3b77273874
2012-01-03 15:24:55 -08:00
Kevin Sawicki c15c46e41e Retain executable mode of existing files on Windows
Currently files in a repository marked as executable will have
that mode unset when modified and committed on systems that
do not support detection of this mode since the working tree
iterator will never report this mode for any entries.

This change updates WorkingTreeIterator to be able
to determine the target file mode to be used for the index
through consideration of the configured WorkingTreeOptions.

Bug: 364956
Change-Id: Iae496baa011b8a59d9329ec73615482b03d34a5a
2012-01-03 15:07:02 -08:00
Kevin Sawicki d57c00e036 Add support for cloning submodules to CloneCommand
Change-Id: Ib1f82206fa14be75e2080f95db9f2d178e876453
2012-01-02 17:32:41 -08:00
Kevin Sawicki dea4511572 Extend TransportCommand in submodule add/update commands
This allows all the settings of a TransportCommand to be
configured on the clone commands that are run by submodule
add/update

Change-Id: I93bfe5a91d430200de8c7f1e32a60cb990aa58ea
2012-01-02 09:40:53 -08:00
Kevin Sawicki 287d17f601 Add submodule command helpers to Git class
Change-Id: I649d96617072db68ab15aa2569836fa783577424
2012-01-02 09:34:25 -08:00
Tomasz Zarna 1a2ca5b811 Skip a number commits before starting to show the commit output
Change-Id: Id2666d897d29b6371f7a6cf241cfda02964b4971
Signed-off-by: Kevin Sawicki <kevin@github.com>
2012-01-02 08:40:02 -08:00
Tomasz Zarna 5d95cd9418 Add constant for default name for the Git repo configuration
Change-Id: I5a6ef686c444fb1e46c9f784bad01165471ef372
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-02 13:24:36 +01:00
Tomasz Zarna 617c5d91da Sort translation bundle keys in alphabetical order.
Change-Id: I83e26531ea924178ba43fa82b3c1fe02afd23eca
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-02 12:59:05 +01:00
Kevin Sawicki 92c6f2f97b Add comand support for git-submodule
Adds the following commands:
    - Add
    - Init
    - Status
    - Sync
    - Update

This also updates AddCommand so that file patterns added that
are submodules can be staged in the index.

Change-Id: Ie5112aa26430e5a2a3acd65a7b0e1d76067dc545
Signed-off-by: Kevin Sawicki <kevin@github.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2011-12-28 10:33:14 -06:00
Kevin Sawicki 3c7dceec1a Add commit id and parent count to exception message
Bug: 357312
Change-Id: I2f85cf88650594eca7df6aa0e26bea329674f08e
2011-12-27 13:37:42 -08:00
Shawn Pearce 80c5210409 Merge "Only print stack trace to Sytem.err when debug flag is set" 2011-12-27 16:24:36 -05:00
Tomasz Zarna 8f8e43b741 Fix typo in RebaseResult#mySatus
Change-Id: I88d34eec8307231f89343ead06858d1df4ac0886
2011-12-27 21:47:44 +01:00
Kevin Sawicki 2de1d9fb64 Only print stack trace to Sytem.err when debug flag is set
Bug: 362100
Change-Id: Id18de9660f0dc2fb6c30db9770f31f26c874022d
2011-12-27 09:20:03 -08:00
Matthias Sohn 067ccbfda7 Merge branch 'stable-1.2'
* stable-1.2:
  JGit v1.2.0.201112221803-r
  Expose unmerged paths when revert fails
  Enforce the use of Java5 API:s only (with a few exceptions)

Change-Id: Ib18d41a65e68cc47fb63114fcce27a16820d0692
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-12-26 23:52:32 +01:00
Robin Rosenberg 64a3bf1dcb Merge "Limit the number of commits in LogCommand output" 2011-12-23 13:28:21 -05:00
Tomasz Zarna 248959146a Limit the number of commits in LogCommand output
Bug: 316680
Change-Id: I88cf7aac6b5763cc94421433dd4bbd42f81e0e69
2011-12-23 13:38:07 +01:00
Tomasz Zarna acd8aee98a DiffFormatter#format(List) fails unless #scan(ATI, ATI) is called first
Bug: 354919
Change-Id: I710394fe6675e0e5aa66d9118c5b10d433aa30ea
2011-12-23 13:05:31 +01:00
Robin Rosenberg 160ffc9df1 Merge "Support getting specific entry number in reflog" 2011-12-22 18:49:04 -05:00
Matthias Sohn a069e90fa9 JGit v1.2.0.201112221803-r
Change-Id: Icc0b09324f205d93929af8cf522a99ad00cf7591
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-12-23 00:19:02 +01:00
Christian Halstrick 200d3f5aaf Refactor ResolveMerger
The places where ResolveMerger was doing content merges have been
refactored. The goal was to have one single method where content merge
was done and to factor out other topics (updating the index, updating
the working tree) into own methods. This was done to allow adding
pluggable content mergers in change
I7817e2123d254f3eeb315b47a61d2c55bd202c12

Change-Id: I8529697b197372a284bcd5ab2c9ba1adb925a520
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-12-20 10:17:42 +01:00
Kevin Sawicki 52507ee2e7 Expose unmerged paths when revert fails
Change-Id: I02678aeb31a62668ae2b0342a6dae721e043dc5e
2011-12-19 22:46:20 +01:00
Kevin Sawicki 1dcb76739c Support getting specific entry number in reflog
The number specified is interpreted as relative to the
last entry in the reflog.

Change-Id: Ie4dd03370bb0d475a0e89d3015113ca98920100f
2011-12-19 09:14:47 -08:00
Kevin Sawicki 656461a991 Add exception class for when locking a file fails
This will allows calling classes to handle lock failures
without checking against the message and will also provide
access to the file that could not be locked.

Change-Id: I95bc59e1330a7af71ae3b0485c4516299193f504
2011-12-18 14:40:42 -08:00
Kevin Sawicki dc4c06e7ac Support resolving integer-based reflog revisions
Revision strings such as 'master@{0}' can now be resolved
by Repository.resolve by reading the reflog for the ref and
returning the commit for the entry number specified.

This still throws an exception for cases not supported
such as 'master@{yesterday}'.

Change-Id: I6162777d6510e083565a77cac4545cda5a9aefb3
2011-12-16 17:05:47 -08:00
Robin Rosenberg 29fc8fffc1 Merge "Report diff entries for files that only change mode" 2011-12-16 10:30:24 -05:00
Matthias Sohn f1019b9738 Merge branch 'stable-1.2'
* stable-1.2:
  Add API checking using clirr
  Fix MergeCommandTest to pass if File.executable is not supported
  Fix ResolveMerger not to add paths with FileMode 0

Change-Id: I86e7194a40acd6dfa3d433f1d17c01bdf5bb0d9c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-12-16 08:50:49 +01:00
Robin Rosenberg 0ca105a502 Enforce the use of Java5 API:s only (with a few exceptions)
This only works with Eclipse 3.6 and newer and requires installation
of new package. Documentation is not very good, but there is a blog
about it here:
http://eclipseandjazz.blogspot.com/2011/10/of-invalid-references-to-system.html

API checking is especially useful on OS X where Java5 is not readily
available.

Change-Id: I3c0ad460874a21c073f5ac047146cbf5d31992b4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-12-16 01:01:36 +01:00
Matthias Sohn e178ba20d0 Add API checking using clirr
In order to generate API reports run: mvn clirr:clirr

The reports are generated to the folder
target/site/clirr-report.html under the respective
project.

In order to check API compatibility and fail the build
on incompatible changes run: mvn clirr:check

For now we compare the API against the latest release
1.1.0.201109151100-r.

Bug: 336849
Change-Id: I21baaf3a6883c5b4db263f712705cc7b8ab6d888
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-12-15 15:50:46 -08:00
Kevin Sawicki 78bc526d9b Report diff entries for files that only change mode
This also updates DiffFormatter to not write path lines
for entries that have the same object id

Bug: 361570
Change-Id: I830a78e2babf472503630a7aa020ebfd5c7e69c6
2011-12-14 17:51:42 -08:00
Dave Borowitz 84c80be1dc Fire DfsPacksChangedEvents when committing packs.
Once a pack has been committed with commitPack(), we know that the pack
list has changed but we don't re-scan the underlying storage.

Change-Id: Ia7b35df4442a5f5dfe7e817edcc77b44b5410d08
2011-12-13 11:04:30 -08:00
Tomasz Zarna 9f66137716 StatusCommand#setWorkingTreeIt should return 'this'
All setters for JGit API commands return the command instance, follow
the builder pattern.

Change-Id: Id2bbc3f1300bb179887c4d2d6dd72925bde55f24
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-12-12 09:21:15 -08:00
Christian Halstrick 3c544647b7 Fix ResolveMerger not to add paths with FileMode 0
When ResolveMerger finds a path where it has to do a content merge it
will try the content merge and if that succeeds it'll add the newly
produced content to the index. For the FileMode of this new index entry
it blindly copies the FileMode it finds for that path in the common base
tree. If by chance the common base tree does not contain this path it'll
try to add FileMode 0 (MISSING) to the index.

One could argue that this can't happen: how can the ResolveMerger
successfully (with no conflicts) merge two contents if there is no
common base? This was due to another bug in ResolveMerger. It failed to
find out that for two files which differ only in the FileMode (e.g. 644
vs. 755) it should not try a content merge.

Change-Id: I7a00fe1a6c610679be475cab8a3f8aa4c08811a1
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-12-11 01:05:13 +01:00
Matthias Sohn 7fded4d14f Prepare 1.3.0 builds
Change-Id: I7a1ae73783c95041b59f047a7330e62e7f642149
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-12-10 01:07:16 +01:00
Matthias Sohn e11af56828 Merge branch 'stable-1.2'
* stable-1.2:
  Fix version.sh
  Throw API exception when MergeCommand hits checkout conflicts
  Add methods for configuring platform emulation
  Fix history rendering not to occupy too many lanes
  Fix History rendering

Change-Id: If71cc760423ae2b76c7435ca4830edc1745556de
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-12-10 01:06:47 +01:00
Shawn Pearce d1dd3403ac Merge "Add simple chain implementations of transport hooks and loggers" 2011-12-09 12:23:23 -05:00
Dave Borowitz 629c61513c Add simple chain implementations of transport hooks and loggers
Allows callers to effectively run multiple hooks and loggers without
modifying the UploadPack/ReceivePack interface.

Change-Id: I5b388816b63036ffff08ef3a9b857ccb764cb8c4
2011-12-09 09:05:40 -08:00
Shawn Pearce 32263d310c Merge changes I9f1842c2,Ie139133b
* changes:
  Throw invalid ref exception instead of invalid remote exception
  Use constant for logs directory
2011-12-09 10:04:03 -05:00
Shawn Pearce 1291e834df Merge "Add a no-op UploadPackLogger and use it by default" 2011-12-08 21:44:18 -05:00
Matthias Sohn 26b5738629 Throw API exception when MergeCommand hits checkout conflicts
When MergeCommand hit checkout conflicts it did throw an internal JGit
exception org.eclipse.jgit.errors.CheckoutConflictException instead of
org.eclipse.jgit.api.errors.CheckoutConflictException which it
declares to throw. Hence translate the internal exception to the
exception declared in the API.

Bug: 327573
Change-Id: I1efcd93a43ecbf4a40583e0fc9d8d53cffc98cae
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-12-08 23:33:53 +01:00
Kevin Sawicki 4535a9e2a3 Throw invalid ref exception instead of invalid remote exception
ReflogCommand command was throwing an incorrect exception type
when an IOException was wrapped and rethrown from the underlying
ReflogReader.  The IOException cause is now provided to the thrown
exception as well.

Change-Id: I9f1842c2d414d3e9c658843f9b448bc18891748e
2011-12-08 11:36:05 -08:00
Kevin Sawicki 47d1616374 Use constant for logs directory
Change-Id: Ie139133bcbe1ca61c85e86b3484f858bc065821f
2011-12-08 11:36:05 -08:00
Shawn Pearce 4e92ae1656 Merge "Set expected old object id to all zeros when head id is null" 2011-12-08 13:09:02 -05:00
Shawn Pearce 580def2a23 Merge "Use System.arraycopy to copy parent object id array" 2011-12-08 13:07:21 -05:00
Shawn Pearce 4c24203e77 Merge "[findBugs] Implement Serializable interface in PlotLane" 2011-12-08 13:06:03 -05:00
Tomasz Zarna eb5df588d8 Add toString() to HunkHeader
Since FileHeader provides toString() method (via DiffEntry) we could add
a similar method to HunkHeader.

Change-Id: I7886e5b8f775fa8e8478ac5af37d90b6ef677d8b
2011-12-08 18:11:01 +01:00
Kevin Sawicki 60563b3478 [findBugs] Implement Serializable interface in PlotLane
This class is referenced by PlotCommit which is Serializable

Change-Id: If79b6a593dc53fbb7c4f0a69a9d0dca02a8cb63c
2011-12-08 08:41:10 -08:00
Dave Borowitz d6172dc0de Add a no-op UploadPackLogger and use it by default
This matches the behavior of the hooks in UploadPack.

Change-Id: I21277e52ee9452237d87084f06bb140dfa6bf608
2011-12-08 08:26:08 -08:00
Kevin Sawicki eb2cfd4552 Use System.arraycopy to copy parent object id array
Change-Id: Iee475584f0a65b8b77610cd277f15295b68dfe80
2011-12-07 10:21:41 -08:00
Kevin Sawicki 2539b1ee09 Set expected old object id to all zeros when head id is null
This will be the case on the initial commit to a repository
and the ref update should expect a non-existent ref

Change-Id: Iaa06e47e6e8cc4a0281c7683b367d4806dd980ea
2011-12-06 18:02:30 -08:00
Christian Halstrick 251bc02840 Fix history rendering not to occupy too many lanes
There was a bug in history rendering which caused jgit to use too
many lanes in case lanes get repositioned. Looking at commit
90c11cbaeb in JGit was one example. Vadim
Dmitriev found the problem and the solution.

Bug: 365460
Change-Id: I6024265b7a593dcfd4fc612d0baf6652a0092ff4
Also-by: Vadim Dmitriev <dmgloss@mail.ru>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-12-06 23:10:03 +01:00
Tomasz Zarna 2b3d48acc2 Stream left open in WorkingTreeIterator#filterClean
Change-Id: I17c2709f2613536c02c9ea2977d936b87029ac0d
2011-12-06 10:45:33 +01:00
Christian Halstrick 9e1b64bd3e Fix History rendering
There was the possibility that during history rendering we draw a lane
"trough" a passed commit. Vadim Dmitriev found that out in bug 335818. 
I added the needed check to that block of code where it was missing.

Bug: 335818
Change-Id: Ic944193b2aca55ff3eb0235d46afa60b7896aa0f
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-12-04 18:16:08 +01:00
Shawn Pearce 9fc04272e6 Merge "Fix History rendering" 2011-12-02 10:02:49 -05:00
Shawn Pearce e0f2be968b Merge "Add percent-encoding of reserved characters in URIish" 2011-12-02 10:01:22 -05:00
Robin Rosenberg 00514bde50 Add percent-encoding of reserved characters in URIish
We do this for the the names that have an explicit scheme and
do it both ways. The URIish is parsed before decoding. Only
a few special characters are encoded for the path part of the
URI, i.e. space, non-ASCII and control characters. The percent
encoding is assumed to be a stream encoding so we interpret it
as UTF-8.

Change-Id: I82d1910df9472e21d7212a2b984ff7d8fb2cbf0f
2011-12-02 15:50:09 +01:00
Christian Halstrick df8511eeea Fix History rendering
There was the possibility that during history rendering we draw a lane
"trough" a passed commit. Vadim Dmitriev found that out in bug 335818. 
I added the needed check to that block of code where it was missing.

Bug: 335818
Change-Id: Ic944193b2aca55ff3eb0235d46afa60b7896aa0f
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-12-02 14:27:51 +01:00
Christian Halstrick 2238fc9358 Merge "RepositoryState: add method canAmend" 2011-11-30 04:55:58 -05:00
Shawn Pearce e9f20c982a Merge "Always checkout master when it matches the advertised HEAD" 2011-11-28 21:59:52 -05:00
Shawn Pearce 5e5640ff62 Merge "Implement Serializable interface in ReflogEntry" 2011-11-28 21:50:40 -05:00
Kevin Sawicki b4ff1e1e03 Remove calls to printStackTrace in catch blocks
Change-Id: I7a4179f10a4841e80b6546e1e7662cab71eac5e9
2011-11-28 18:07:52 -08:00
Kevin Sawicki 7ed1ef953c Implement Serializable interface in ReflogEntry
Change-Id: Idf798dd3981bef3dc9e17c13c12809f89089e96f
2011-11-28 16:14:21 -08:00
Kevin Sawicki 899114f63c Always checkout master when it matches the advertised HEAD
This parallels the CGit behavior of always using refs/heads/master
when it matches the remote advertised HEAD commit.

Change-Id: I5a5cd1516b58d116e334056aba1ef7990697ec30
2011-11-28 11:00:15 -08:00
Jens Baumgart 99ec987e68 RepositoryState: add method canAmend
The method canAmend was added to RepositoryState. It returns true if
amending the HEAD commit is allowed in the current repository state.

Change-Id: Idd0c4eea83a23c41340789b7b877959b457d951e
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
2011-11-28 10:46:16 +01:00
Shawn Pearce d497c2ac2d Merge "Reset SSH connection and credentials on "Auth fail"" 2011-11-26 19:24:09 -05:00
Matthias Sohn 430395a669 Reset SSH connection and credentials on "Auth fail"
When SSH user/password authentication failed this may have been caused
by changed credentials on the server side. When the SSH credentials of a
user change the SSH connection needs to be re-established and
credentials which may have been stored by the credentials provider
need to be reset in order to enable prompting for the new credentials.

Bug: 356233
Change-Id: I7d64c5f39b68a9687c858bb68a961616eabbc751
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-11-27 01:16:49 +01:00
Kevin Sawicki 241e03be9d Don't iterate over advertised refs when HEAD is null
Moves the check from inside the loop to outside the loop
and returns immediately if the HEAD advertisded ref is null

Change-Id: I539da6cafb4f73610b8e00259e32bd4d57f4f4cc
2011-11-26 14:47:21 -08:00
Robin Stocker 8456cb3f2b Adapt merge message to C Git for remote-tracking branch
Commit 13931236b9ee2895a98ffdbdacbd0f895956d8a8 in C Git (2011-11-02)
changed the message format:

-Merge remote branch 'origin/foo'
+Merge remote-tracking branch 'origin/foo'

This change does the same in EGit to be consistent.

Change-Id: I7d9c5afa95771dbfe6079b5f89a10b248fee0172
Signed-off-by: Robin Stocker <robin@nibor.org>
2011-11-23 17:03:21 +01:00
Kevin Sawicki c3fe50bb18 Guard against null branch in PullCommand
Throw a NoHeadException when Repository.getFullBranch
returns null

Bug: 351543
Change-Id: I666cd5b67781508a293ae553c6fe5c080c8f4d99
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-11-22 16:29:28 -08:00
Kevin Sawicki 900bdbac5b Support adding all refs to LogCommand
Bug: 353310
Change-Id: Ifa2e7ed58c7f2bdfe3aafbd500b5a38c1f94c2ec
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-11-22 16:14:30 -08:00
Shawn Pearce d8497abe78 Merge "Provide merge result when revert command fails" 2011-11-22 14:26:08 -05:00
Sasa Zivkov 1fbe688f51 maxObjectSizeLimit for receive-pack.
ReceivePack (and PackParser) can be configured with the
maxObjectSizeLimit in order to prevent users from pushing too large
objects to Git. The limit check is applied to all object types
although it is most likely that a BLOB will exceed the limit.  In all
cases the size of the object header is excluded from the object size
which is checked against the limit as this is the size of which a BLOB
object would take in the working tree when checked out as a file.
When an object exceeds the maxObjectSizeLimit the receive-pack will
abort immediately.

Delta objects (both offset and ref delta) are also checked against the
limit. However, for delta objects we will first check the size of the
inflated delta block against the maxObjectSizeLimit and abort
immediately if it exceeds the limit. In this case we even do not know
the exact size of the resolved delta object but we assume it will be
larger than the given maxObjectSizeLimit as delta is generally only
chosen if the delta can copy more data from the base object than the
delta needs to insert or needs to represent the copy ranges. Aborting
early, in this case, avoids unnecessary inflating of the (huge) delta
block.

Unfortunately, it is too expensive (especially for a large delta) to
compute SHA-1 of an object that causes the receive-pack to abort.
This would decrease the value of this feature whose main purpose is to
protect server resources from users pushing huge objects.  Therefore
we don't report the SHA-1 in the error message.

Change-Id: I177ef24553faacda444ed5895e40ac8925ca0d1e
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-11-22 17:43:00 +01:00
Kevin Sawicki 2d63c481f7 Provide merge result when revert command fails
This allows callers to determine why the revert
did not complete successfully

Change-Id: Ie44bb8523cac388b63748bc69ebdd3c3a3665d06
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-11-21 17:14:11 -08:00
Shawn Pearce 3ee3811afb Merge "Add missing '' characters around quoted variables" 2011-11-18 19:11:47 -05:00
Shawn O. Pearce 2fbf296fda Fix duplicate objects in "thin+cached" packs from DFS
The DfsReader must offer every representation of an object that
exists on the local repository when PackWriter asks for them. This
is necessary to identify objects in the thin pack part that are also
in the cached pack that will be appended onto the end of the stream.

Without looking at all alternatives, PackWriter may pack the same
object twice (once in the thin section, again in the cached base
pack). This may cause the command line C version to go into an
infinite loop when repacking the resulting repository, as it may see
a delta chain cycle with one of those duplicate copies of the object.

Previously the DfsReader tried to avoid looking at packs that it
might not care about, but this is insufficient, as all versions
must be considered during pack generation.

Change-Id: Ibf4a3e8ea5c42aef16404ffc42a5781edd97b18e
2011-11-18 15:55:52 -08:00
Shawn O. Pearce 60e51251db Do not write edge objects to the pack stream
Consider two objects A->B where A uses B as a delta base, and these
are in the same source pack file ordered as "A B".

If cached packs is enabled and B is also in the cached pack that
will be appended onto the end of the thin pack, and both A, B are
supposed to be in the thin pack, PackWriter must consider the fact
that A's base B is an edge object that claims to be part of the
new pack, but is actually "external" and cannot be written first.

If the object reuse system considered B candidates fist this bug
does not arise, as B will be marked as edge due to it existing in
the cached pack. When the A candidates are later examined, A sees a
valid delta base is available as an edge, and will not later try to
"write base first" during the writing phase.

However, when the reuse system considers A candidates first they
see that B will be in the outgoing pack, as it is still part of
the thin pack, and arrange for A to be written first. Later when A
switches from being in-pack to being an edge object (as it is part
of the cached pack) the pointer in B does not get its type changed
from ObjectToPack to ObjectId, so B thinks A is non-edge.

We work around this case by also checking that the delta base B
is non-edge before writing the object to the pack. Later when A
writes its object header, delta base B's ObjectToPack will have
an offset == 0, which makes isWritten() = false, and the OBJ_REF
delta format will be used for A's header. This will be resolved by
the client to the copy of B that appears in the later cached pack.

Change-Id: Ifab6bfdf3c0aa93649468f49bcf91d67f90362ca
2011-11-18 15:55:52 -08:00
Shawn O. Pearce 1421106d76 Use long for more object counts in PackWriter
Packs can contain up to 2^32-1 objects, which exceeds the range of a
Java int. Try harder to accept higher object counts in some cases by
using long more often when we are working with the object count value.

This is a trivial refactoring, we may have to make even more changes
to the object handling code to support more than 2^31-1 objects.

Change-Id: I8cd8146e97cd1c738ad5b48fa9e33804982167e7
2011-11-18 15:55:52 -08:00
Shawn O. Pearce 41a18d57bc Search for annotated tag reuse first
Annotated tags are relatively rare and currently are scheduled in a
pack file near the commits, decreasing the time it takes to resolve
client requests reading tags as part of a history traversal.

Putting them first before the commits allows the storage system to
page in the tag area, and have it relatively hot in the LRU when
the nearby commit area gets examined too. Later looking at the
tree and blob data will pollute the cache, making it more likely
the tags are not loaded and would require file IO.

Change-Id: I425f1f63ef937b8447c396939222ea20fdda290f
2011-11-18 15:55:52 -08:00
Shawn O. Pearce 29997ab084 Correct progress monitor on "Getting sizes:" phase
This counter always was running 1 higher, because it incremented
after the queue was exhausted (and every object was processed). Move
increments to be after the queue has provided a result, to ensure
we do not show a higher in-progress count than total count.

Change-Id: I97f815a0492c0957300475af409b6c6260008463
2011-11-18 15:55:51 -08:00
Shawn O. Pearce 4b84186b64 Refactor DfsReader selection of cached packs
Make the code more clear with a simple refactoring of the boolean
logic into a method that describes the condition we are looking
for on each pack file. A cached pack is possible if there exists
a tips collection, and the collection is non-empty.

Change-Id: I4ac42b0622b39d159a0f4f223e291c35c71f672c
2011-11-18 15:55:51 -08:00
Kevin Sawicki 1b472a7954 Add missing '' characters around quoted variables
Double ' characters are needed for variables to appear in
single quotes.  Variables surrounded with a s single ' will
not be replaced when formatted

Change-Id: I0182c1f679ba879ca19dd81bf46924f415dc6003
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-11-18 13:22:57 -08:00
Shawn Pearce ce02c82b82 Merge changes I366435e2,I64577f8f
* changes:
  [findBugs] Silence returning null for StringUtils.toBooleanOrNull()
  [findBugs] Prefer short-cut logic as it's more performant
2011-11-18 16:05:27 -05:00
Matthias Sohn c0780bcb99 [findBugs] Silence returning null for StringUtils.toBooleanOrNull()
As the method name and its javadoc clearly state that this method can
return null we can ignore this FindBugs warning.

Change-Id: I366435e26eda5d910f5d1a907db51f08efd4bb8c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-11-16 20:55:34 +01:00
Matthias Sohn afebe7880d [findBugs] Prefer short-cut logic as it's more performant
Change-Id: I64577f8fd19ee0d2d407479cc70e521adc367f37
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-11-16 20:54:40 +01:00
Dave Borowitz 2b584b9216 Keep track of a static collection of all PackWriter instances
Stored in a weak concurrent hash map, which we clean up while iterating.
Usually the weak reference behavior should not be necessary because
PackWriters should be released with release(), but we still want to
avoid leaks when dealing with broken client code.

Change-Id: I337abb952ac6524f7f920fedf04065edf84d01d2
2011-11-14 10:27:45 -08:00
Dave Borowitz f26b79d044 Estimate the amount of memory used by a PackWriter
Memory usage is dominated by three terms:
 - The maximum memory allocated to each delta window.
 - The maximum size of a single file held in memory during delta search.
 - ObjectToPack instances owned by the writer.

For the first two terms, rather than doing complex instrumentation of
the DeltaWindows, we just overestimate based on the config parameters
(though we may underestimate if the maximum size is not set).

For the ObjectToPack instances, we do some rough byte accounting of the
underlying Java object representation.

Change-Id: I23fe3cf9d260a91f1aeb6ea22d75af8ddb9b1939
2011-11-14 10:27:45 -08:00
Dave Borowitz 16b8ebf2d1 Add an object encapsulating the state of a PackWriter
Exposes essentially the same state machine to the programmer as is
exposed to the client via a ProgressMonitor, using a wrapper around
beginTask()/endTask().

Change-Id: Ic3622b4acea65d2b9b3551c668806981fa7293e3
2011-11-14 10:27:45 -08:00
Christian Halstrick e7ec5e1473 Merge "Implement DirCacheEntry.toString() to ease debugging" 2011-11-11 03:21:29 -05:00
Jens Baumgart 53ef3e5114 Add detection of untracked folders to IndexDiffFilter
Decorators need to know whether folders in the working tree contain only
untracked files. This change enhances IndexDiffFilter to report such
folders. This works only together with treewalks which operate in
default traversal mode. For treewalks which process entries in
postorder mode (files are walked before their parent folder is walked)
this detection doesn't work.

Bug: 359264
Change-Id: I9298d1e3ccac0aec8bbd4e8ac867bc06a5c89c9f
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2011-11-10 11:15:26 -08:00
Carsten Pfeiffer 92752f6b50 [blame] Fix blame following renames in non-toplevel directories
Mark the treeWalk as recursive; otherwise following renames only works
for toplevel files.

Bug: 302549
Change-Id: I70867928eadf332b0942f8bf6877a3acb3828c87
Signed-off-by: Carsten Pfeiffer <carsten.pfeiffer@gebit.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2011-11-10 11:06:03 -08:00
Kevin Sawicki da901c4968 Support a configured credentials provider in LsRemoteCommand
Refactored the three common transport configuration options:
credentials provider, timeout, and transport config callback
into a new TransportCommand base class which is now extended
by all commands that use a Transport object during execution.

Bug: 349188
Change-Id: I90c2c14fb4e3cc4712905158f9047153a0c235c2
Signed-off-by: Kevin Sawicki <kevin@github.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2011-11-10 10:57:47 -08:00
Matthias Sohn 899a3ccf6d Implement DirCacheEntry.toString() to ease debugging
Change-Id: I9aa1b5817a18fb340411f47b25b6711d533590fd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-11-10 13:34:59 +01:00
Robin Rosenberg c0392381ee Merge changes Ibb3467f7,I2af99903
* changes:
  Always use try/finally around DfsBlockCache.clockLock
  DfsBlockCache: Fix NPE when evicting empty cell
2011-11-10 02:07:04 -05:00
Robin Rosenberg 6e9fdce9b9 Kill GitIndex
A few places were still using GitIndex. Replacing it was fairly
simple, but there is a difference in test outcome in
ReadTreeTest.testUntrackedConflicts. I believe the new behavior
is good, since we do not update neither the index, not the worktree.

Change-Id: I4be5357b7b3139dded17f77e07a140addb213ea7
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-11-09 09:16:50 +01:00
Robin Rosenberg 83c172f0f7 Deprecate GitIndex more by using only DirCache internally.
This includes merging ReadTreeTest into DirCacheCheckoutTest and
converting IndexDiffTest to use DirCache only. The GitIndex specific
T0007GitIndex test remains.

GitIndex is deprecated. Let us speed up its demise by focusing the
DirCacheCheckout tests to using DirCache instead.

This also add explicit deprecation comments to methods that depend
on GitIndex in Repository and TreeEntry. The latter is deprecated in
itself.

Change-Id: Id89262f7fbfee07871f444378f196ded444f2783
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-11-09 09:05:24 +01:00
Shawn O. Pearce 9652f16a47 Always use try/finally around DfsBlockCache.clockLock
Any RuntimeException or Error in this block will leave the lock
held by the caller thread, which can later result in deadlock or
just cache requests hanging forever because they cannot get to
the lock object.

Wrap everything in try/finally to prevent the lock from hanging,
even though a RuntimeException or Error should never happen in
any of these code paths.

Change-Id: Ibb3467f7ee4c06f617b737858b4be17b10d936e0
2011-11-08 12:24:30 -08:00
Shawn O. Pearce a6677ef28a DfsBlockCache: Fix NPE when evicting empty cell
The cache starts with a single empty Ref that has no data, as the
clock list does not support being empty. When this Ref is removed,
the size has to be decremented from the associated DfsPackKey,
which was previously null. Make it always be non-null.

Change-Id: I2af99903e8039405ea6d67f383576ffa43839cff
2011-11-08 12:23:44 -08:00
Shawn Pearce 00235c77d6 Merge "Do not resolve path using cygwin unless told to" 2011-11-04 18:09:56 -04:00
Shawn Pearce 2f2c018819 Merge changes Icea2572d,I2633e472,I207c0c93,I10cee76c,Ifd78e8ce,I890b5fcc,Ia0b01f5d,Iec524abd
* changes:
  DfsBlockCache: Update hits to not include contains()
  Add a listener for changes to a DfsObjDatabase's pack files
  Expose the reverse index size in the DfsPackDescription
  Add a DfsPackFile method to get the number of cached bytes
  Expose the list of pack files in the DfsBlockCache
  Add a DFS repository description and reference it in each pack
  Clarify the docstring of DfsBlockCache.reconfigure()
  DFS: A storage layer for JGit
2011-11-04 18:06:30 -04:00
Colby Ranger f70ecabb30 DfsBlockCache: Update hits to not include contains()
Also expose the underlying hit and miss counters, in
addition to the hit ratio.

Change-Id: Icea2572d62e59318133b0a88848019f34ad70975
2011-11-04 11:14:32 -07:00
Dave Borowitz 0f8e486a4d Add a listener for changes to a DfsObjDatabase's pack files
Intended for cross-request use, so only refers to
DfsRepositoryDescriptions rather than DfsRepositorys.

Change-Id: I2633e472c9264d91d632069f608d53d4bdd0fc09
2011-11-04 11:14:32 -07:00
Dave Borowitz d55eb35106 Expose the reverse index size in the DfsPackDescription
This is analogous to the getPackSize() and getIndexSize() methods.

Change-Id: I207c0c93f9145826d84b3610eb4319fca074ee0d
2011-11-04 11:14:32 -07:00
Dave Borowitz 4fc1af6850 Add a DfsPackFile method to get the number of cached bytes
The counter is actually stored in the DfsPackKey so it can be
manipulated by the cache.

Change-Id: I10cee76c92d65c68d1aa1a9dd0c4fd7173c4cede
2011-11-04 11:14:32 -07:00
Dave Borowitz dff9d56b94 Expose the list of pack files in the DfsBlockCache
Callers may want to inspect the contents of the cache, which this allows
them to do in a read-only fashion without any locking.

Change-Id: Ifd78e8ce34e26e5cc33e9dd61d70c593ce479ee0
2011-11-04 11:14:32 -07:00
Dave Borowitz 35d72ac806 Add a DFS repository description and reference it in each pack
Just as DfsPackDescription describes a pack but does not imply it is
open in memory, a DfsRepositoryDescription describes a repository at a
basic level without it necessarily being open.

Change-Id: I890b5fccdda12c1090cfabf4083b5c0e98d717f6
2011-11-04 11:14:32 -07:00
Dave Borowitz 5a38e5b440 Clarify the docstring of DfsBlockCache.reconfigure()
The docstring was copied from the local filesystem cache code, which
actually attempted to reconfigure the cache on the fly. The DFS cache is
designed to be "reconfigured" exactly once.

Change-Id: Ia0b01f5d6b6b3d3a68d65a5c229ff67c1cede5bc
2011-11-04 11:14:32 -07:00
Shawn O. Pearce fa4cc2475f DFS: A storage layer for JGit
In practice the DHT storage layer has not been performing as well as
large scale server environments want to see from a Git server.

The performance of the DHT schema degrades rapidly as small changes
are pushed into the repository due to the chunk size being less than
1/3 of the pushed pack size.  Small chunks cause poor prefetch
performance during reading, and require significantly longer prefetch
lists inside of the chunk meta field to work around the small size.

The DHT code is very complex (>17,000 lines of code) and is very
sensitive to the underlying database round-trip time, as well as the
way objects were written into the pack stream that was chunked and
stored on the database.  A poor pack layout (from any version of C Git
prior to Junio reworking it) can cause the DHT code to be unable to
enumerate the objects of the linux-2.6 repository in a completable
time scale.

Performing a clone from a DHT stored repository of 2 million objects
takes 2 million row lookups in the DHT to locate the OBJECT_INDEX row
for each object being cloned. This is very difficult for some DHTs to
scale, even at 5000 rows/second the lookup stage alone takes 6 minutes
(on local filesystem, this is almost too fast to bother measuring).
Some servers like Apache Cassandra just fall over and cannot complete
the 2 million lookups in rapid fire.

On a ~400 MiB repository, the DHT schema has an extra 25 MiB of
redundant data that gets downloaded to the JGit process, and that is
before you consider the cost of the OBJECT_INDEX table also being
fully loaded, which is at least 223 MiB of data for the linux kernel
repository.  In the DHT schema answering a `git clone` of the ~400 MiB
linux kernel needs to load 248 MiB of "index" data from the DHT, in
addition to the ~400 MiB of pack data that gets sent to the client.
This is 193 MiB more data to be accessed than the native filesystem
format, but it needs to come over a much smaller pipe (local Ethernet
typically) than the local SATA disk drive.

I also never got around to writing the "repack" support for the DHT
schema, as it turns out to be fairly complex to safely repack data in
the repository while also trying to minimize the amount of changes
made to the database, due to very common limitations on database
mutation rates..

This new DFS storage layer fixes a lot of those issues by taking the
simple approach for storing relatively standard Git pack and index
files on an abstract filesystem. Packs are accessed by an in-process
buffer cache, similar to the WindowCache used by the local filesystem
storage layer. Unlike the local file IO, there are some assumptions
that the storage system has relatively high latency and no concept of
"file handles". Instead it looks at the file more like HTTP byte range
requests, where a read channel is a simply a thunk to trigger a read
request over the network.

The DFS code in this change is still abstract, it does not store on
any particular filesystem, but is fairly well suited to the Amazon S3
or Apache Hadoop HDFS. Storing packs directly on HDFS rather than
HBase removes a layer of abstraction, as most HBase row reads turn
into an HDFS read.

Most of the DFS code in this change was blatently copied from the
local filesystem code. Most parts should be refactored to be shared
between the two storage systems, but right now I am hesistent to do
this due to how well tuned the local filesystem code currently is.

Change-Id: Iec524abdf172e9ec5485d6c88ca6512cd8a6eafb
2011-11-04 11:08:20 -07:00
Shawn Pearce 1783c8a831 Merge "Allow '\' in user names in URI-ish" 2011-11-04 13:10:47 -04:00
Robin Rosenberg afd4f3b0cf Allow '\' in user names in URI-ish
Actually this is not ok according to the RFC, but this implementation is
ment to be Git compatible. A '\' is needed when the authentication
requires or allows authentication to a Windows domain where the
user name can be specified as DOMAIN\user.

Change-Id: If02f258c032486f1afd2e09592a3c7069942eb8b
2011-11-04 17:54:43 +01:00
Shawn Pearce ede88c60a5 Merge "Provide an id for submodule entries." 2011-11-04 10:14:46 -04:00
Carl Myers 85a9ab7410 Fix NPE when PATH environment variable is empty
Change-Id: Ic27d509cd5e2d6c855e7d355fc308399d9dc01c9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-11-04 14:42:12 +01:00
Kevin Sawicki 931b931ee8 Provide an id for submodule entries.
Open a repository for submodule entries that have a child .git
directory and use the resolved HEAD commit as the entry's id.

Change-Id: I68d6e127f018b24ee865865a2dd3011a0e21453c
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-11-04 08:14:53 +01:00
Shawn Pearce 2efbcb7e44 Merge "Implement Config.Entry.toString() to help debugging" 2011-11-03 16:19:17 -04:00
Shawn Pearce c2e828abd6 Merge "DirCacheEntry: accessors for cached creation time (CTIME)" 2011-11-03 16:18:43 -04:00
Kevin Sawicki 5041f738e9 Suppress unused and unchecked warnings
Change-Id: I9f51cc749f5cb9d2e3aa86874e60fca29b779565
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-11-03 11:03:01 +01:00
Marc Strapetz bf81119e62 DirCacheEntry: accessors for cached creation time (CTIME)
Change-Id: I986d5fff63ff1a86cca6bab49c744ea673fe4892
2011-10-31 17:45:51 +01:00
Shawn O. Pearce 9f81c6813a Merge "Ensure the ObjectInserter flushes after a merge" 2011-10-28 21:14:26 -04:00
Robin Rosenberg 3ceb4fac23 Do not resolve path using cygwin unless told to
The system property jgit.cygpath must be set to true in order
for cygwin's cygpath to be used to translate path from cygwin
namespace to Windows namespace.

The cygwin path translation should be considered deprecated.

Bug: 353389
Change-Id: I2b5234c0ab936dac67d1e232f4cd28331bf3226d
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-10-28 14:58:32 +02:00
Matthias Sohn a5f72d6b3b Implement Config.Entry.toString() to help debugging
Change-Id: I86f6359d955d39ab033848b87ed39d20378d3c1f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-10-27 22:55:59 +02:00
Shawn Pearce b6281cac01 Merge "Enable full Transport configuration for JGit API commands" 2011-10-27 10:25:18 -04:00
Shawn O. Pearce b24a61272a Ensure the ObjectInserter flushes after a merge
If this does not happen some databases may discard
objects and not make them available.

Change-Id: I347b3c3724db52c8a6c09f4804071497a3a377ab
2011-10-26 20:34:52 -07:00
Matthias Sohn 34f678643c Merge changes I488e9c97,I30f1049f,I1c088dce
* changes:
  Cosmetic adjustment of relative date format, do not display "0 months"
  Make use of the many date formatting options in the log command
  Define a utility class for handling Git date formats
2011-10-26 17:29:23 -04:00
Robin Rosenberg 57bdb04873 Cosmetic adjustment of relative date format, do not display "0 months"
Though it may seem less precise, "0 months" looks bad and the reference
Git implementation also does not display "0 months"

Change-Id: I488e9c97656f9941788ae88d7c5c1562ab6c26f0
2011-10-26 23:15:28 +02:00
Matthias Sohn 66cb4ac902 Merge "Allow detecting which files were renamed during a revwalk" 2011-10-26 16:18:21 -04:00
Carsten Pfeiffer 98d4bd6d36 Allow detecting which files were renamed during a revwalk
The egit history view shows the files associated with a commit by using
a PathFilter. When following renames with a FollowFilter, the PathFilter
cannot be configured anymore because the affected files are simply not
known.

Thus, it should be possible to get to know which files are renamed.

Bug: 302549
Change-Id: I4761e9f5cfb4f0ef0b0e1e38991401a1d5003bea
2011-10-25 09:22:11 +02:00
Robin Rosenberg 63bb6ff06c Fix compatibilty breakage for SystemReader
Introducing a new abstract method is not nice when one
expects other to subclass them. Create default implementations
so old code that implements SystemReader does not break.
The default methods just delegate to the JVM.

Change-Id: I42cdfdcb6b29f7203697a23833dca85185b0b9b3
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-10-23 22:53:17 +02:00
Robin Rosenberg f4460dda97 Define a utility class for handling Git date formats
Besides the formats known by git-log(1) we also add "locale" 
and "localelocal" that formats dates according to the user's locale.
"locale" does not translate into local timezone, while
localelocal does.

Change-Id: I1c088dcec992c107e43f6c17be4ac9ed6eb428bf
2011-10-23 01:51:30 +02:00
Robin Rosenberg 3a4fa52723 Add locale to the properties manageable by SystemReader
Change-Id: I5e9af40d38bb671cb9fcdb0fa3b4eb3af5f36f6c
2011-10-20 23:49:52 +02:00
Robin Rosenberg 06b183f9b7 Add a method to SystemReader to get the time zone
Change-Id: Ifd31f408ed2c5b7869694b715fea3219e74963ef
2011-10-20 23:49:51 +02:00
Robin Rosenberg fb68c7a4cd Use the SystemReader to get system time
Change-Id: Ib79c0cc964bfe799b204419e552b9aa6243966ce
2011-10-20 23:49:51 +02:00
Robin Rosenberg 2e43dcd645 Fix bad checkout behaviour when a file is removed
We deleted the entry if there was a file and an index
entry, but not when there was just an index entry. Now
delete the file in both cases since the missing file
just means our worktree is dirty. This affected the
implementation of reset --hard.

Bug: 347574
Change-Id: Ie66fa61303472422830f5e33614e93ad65094e5d
2011-10-18 22:32:47 +02:00
Kevin Sawicki 86e96b41e2 Correct typo in RevWalk.parseBody comment
Change-Id: I0e65a5a6809a8d32d256322dbcae94b6aa603e5e
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-10-14 08:49:17 -07:00
Christian Halstrick a66dea1451 Merge "Extend IndexDiff to calculate ignored files and folders" 2011-10-10 09:01:49 -04:00
Shawn O. Pearce cc03e27093 Merge changes I7cdb563b,I7f60ae68,I7bd1e769,I92683805,I0e51a8e6
* changes:
  UploadPack: Fix races in smart HTTP negotiation
  PackWriter: Export more statistics
  Do not requeue state vector in stateless RPC fetch
  Wrap excessively long line in BasePackFetchConnection
  Fix smart HTTP client stream alignment errors
2011-10-07 16:00:21 -04:00
Jens Baumgart 6befabcb15 Extend IndexDiff to calculate ignored files and folders
IndexDiff was extended to calculate ignored files and folders.
The calculation only considers files that are NOT in the index.
This functionality is required by the new EGit decorator implementation.

Bug: 359264
Change-Id: I8f09d6a4d61b64aeea80fd22bf3a2963c2bca347
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
2011-10-05 13:56:23 +02:00
Christian Halstrick f99ce8d6ff Merge "Fix DirCacheEdtor.DeleteTree for empty string argument" 2011-10-05 06:21:01 -04:00
Kevin Sawicki 565e4a06ef Add missing comment text for mergeCommitTree parameter
Change-Id: I35cef13d8be4f06515668f710fd508700b90f44d
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-10-04 11:39:51 +02:00
Robin Rosenberg 602c869d7a Do not attempt to resolve describe-labels with less than four digits
Change-Id: I21dcd3cca3b41102fd898238d8d640dea25e0caf
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-10-03 00:39:50 +02:00
Robin Rosenberg 1570aa9e5c Fix DirCacheEdtor.DeleteTree for empty string argument
Change-Id: I7425da91c0752ae82484e3c29d21b57402d30c61
2011-10-01 16:35:00 +02:00
Kevin Sawicki 654f7235ec Add varargs version of PathFilterGroup.createFromStrings
This allows the following usage pattern:

  PathFilterGroup.createFromStrings("path1", "path2");

Change-Id: I589e758cc55873ce75614602e017ac793435e24d
Signed-off-by: Kevin Sawicki <kevin@github.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-09-30 15:00:53 -07:00
Manuel Doninger 458b5a4042 New config constant for default start-point
This constant determine the default start-point, if the user
don't want to create a branch from the current HEAD.

Change-Id: Iea944e11e80134fbafc4c47383457d5ed11a4164
Signed-off-by: Manuel Doninger <manuel.doninger@googlemail.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-09-30 14:42:44 -07:00
Matthias Sohn 0db0476542 Fire IndexChangedEvent on DirCache.commit()
Since we replaced GitIndex by DirCache JGit didn't fire
IndexChangedEvents anymore. For EGit this still worked with a high
latency since its RepositoryChangeScanner which is scheduled to
run each 10 seconds fires the event in case the index changes.
This scanner is meant to detect index changes induced by a different
process e.g. by calling "git add" from native git.

When the index is changed from within the same process we should fire
the event synchronously. Compare the index checksum on write to index
checksum when index was read earlier to determine if index really
changed. Use IndexChangedListener interface to keep DirCache decoupled
from Repository.

Change-Id: Id4311f7a7859ffe8738863b3d86c83c8b5f513af
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-09-30 00:00:22 +02:00
Kevin Sawicki e630f91305 Remove TODO for generated constructor.
Change-Id: Ie405f6de99b8fa632d7462400e647a37f30e2e31
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-09-28 14:10:24 -07:00
Christian Halstrick 1230d353d8 Fix status in index entries after checkout of paths
The checkout command was producing an inconsistent state of the index
which even confuses native git. The content sha1 of the touched index
entries was updated, but the length and the filemode was not updated.
Later in coding the index entries got automatically corrected (through
Dircache.checkoutEntry()) but the correction was after persisting the
index to disk. So, the correction was lost and we ended up with an index
where length and sha1 don't fit together.
A similar problem is fixed with "lastModified" of DircacheEntry. When
checking out a path without specifying an explicit commit (you want to
checkout what's in the index) the index was not updated regarding
lastModified. Readers of the index will think the checked-out
file is dirty because the file has a younger lastmodified then what's
in the index.

Change-Id: Ifc6d806fbf96f53c94d9ded0befcc932d943aa04
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
Bug: 355205
2011-09-28 12:34:32 +02:00
Christian Halstrick d306c35cea Merge "Fix DirCache,getEntriesWithin for empty string arguemnt" 2011-09-26 04:27:54 -04:00
Robin Rosenberg 23bba6fb48 Merge "Remove duplicate calls to DirCache.unlock on checkout" 2011-09-25 04:44:45 -04:00
Robin Rosenberg b4112c1748 Fix DirCache,getEntriesWithin for empty string arguemnt
Change-Id: I0bea130df611de3ef8c9251093b11c62b5442cd1
2011-09-25 00:17:19 +02:00
Robin Rosenberg a3d7056b45 Merge "Remove use of GitIndex to detect index changes" 2011-09-22 12:24:37 -04:00
Robin Rosenberg 39ad503fcb Append merge strategy to reflog message
Change-Id: Ia0e73208b86c45a3d96698e973f6e70ec5cb7303
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-09-21 23:36:46 +02:00
Robin Rosenberg 4f4e468f6f Fix the reflog prefix for cherry-pick, revert and merge commands
We should see whether the commit was a regular commit or something
else.

Change-Id: I82d8300cf3c53cb2bdcb6495386aadb803e0c6f7
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-09-21 23:36:26 +02:00
Roberto Tyley 791a9fd691 Enable full Transport configuration for JGit API commands
Add a TransportConfigCallback parameter to JGit API commands, to allow
consumers of the JGit command API to perform custom Transport configuration
that would be otherwise difficult to anticipate & expose on the API command
builders.


My specific use-case is configuring additional properties on SshTransport
- I need to take over the SshSessionFactory used by the transport. Using
TransportConfigCallback I can simply do this (rather than reimplement the
API command classes):

public void configure(Transport tn) {
  if (tn instanceof SshTransport) {
    ((SshTransport) tn).setSshSessionFactory(factoryProvider.get());
  }
}

Adding an explicit setSshSessionFactory() method to the JGit command
classes would bloat the API. Also, creating the replacement
SshSessionFactory is unnecessary if the transport is not SSH, but the type
of the Transport is only known once the remote has been resolved and the
URI parsed - consequently it makes sense to perform this step in a
callback, where the transport instance can be inspected to determine if
it's of a relevant type.


A note about where this leaves the API - there are now 4 commands:

CloneCommand
PullCommand
FetchCommand
PushCommand

-that share 3 identical transport-related parameters:

timeout
credentialsProvider
transportConfigurator

I think there's potential for introducing an interface or val-object to
identify/encapsulate this repetition, which I'd be happy to do in a
subsequent commit.

Change-Id: I8983c3627cdd7d7b2aeb0b6a3dadee553378b951
Signed-off-by: Roberto Tyley <roberto.tyley@gmail.com>
2011-09-16 16:04:35 +01:00
Matthias Sohn 46771e9e88 Remove use of GitIndex to detect index changes
We can detect index changes using FileSnapshot. This is more efficient
and removes usage of a deprecated class.

Change-Id: I4a679102c9a1bd8e82b9ca93eb9dbbde445e9be4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-09-16 00:19:39 +02:00
Matthias Sohn 19a366d532 Prepare 1.2.0 builds
Change-Id: I9ec247135d93ef28d732e94f18d0ec1d0e2e6d44
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-09-15 22:51:46 +02:00
Shawn O. Pearce 01888db892 UploadPack: Fix races in smart HTTP negotiation
Clients cache the set of advertised references at the start of a
negotiation, and keep replaying the same "want SHA1" list to the
server on each negotiation step.  If another client pushes into
a branch and moves it by fast-forward, any request to obtain that
branch's prior SHA-1 is still valid, the commit is reachable from
the new position of the reference.  Unfortunately the fast-forward
causes smart HTTP negotations to fail, as the server no longer is
advertising that prior SHA-1.

Instead of causing clients to fail out with a "want invalid" error
and forcing the end-user retry, possibly getting into a never ending
try-fail-retry race while other clients are pushing into the same
busy repository, allow the slightly stale want request so long as
it is still reachable.

C Git implemented this same change recently to fix races on the
smart HTTP protocol when the C Git git-http-backend is used.

The new RequestPolicy feature also allows server authors to make
an even more lenient configuration that exports any SHA-1 to the
client. This might be useful in certain settings where a server
has authenticated the client as the "repository owner" and wants
to allow them to grab any content from the server as a complete
unbroken history chain.

The new setAdvertisedRefs() method allows server authors to manually
fix the references that are advertised, possibly bypassing the
getAllRefs() call on the Repository object.

Change-Id: I7cdb563bf9c55c83653f217f6e53c3add55a0541
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-09-14 15:34:55 -07:00
Shawn O. Pearce 1b6a549ff3 PackWriter: Export more statistics
Export the shallow pack information, and also a handy function to
sum up the total times.  Include the time writing out the index file,
if it was created.

Change-Id: I7f60ae6848455a357b25feedb23743bbf6c153cf
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-09-14 15:34:55 -07:00
Shawn O. Pearce 38b3816d65 Do not requeue state vector in stateless RPC fetch
If the no-done capability was enabled on the connection, don't
queue up the state vector again once the ACK %s ready message
is observed from the remote. The pack will be following in this
response stream, so the state vector is no longer required.

Change-Id: I7bd1e76957cb58c7ff1cdaeef227f1b02a7e5d24
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-09-14 15:34:55 -07:00
Shawn O. Pearce 575a80ac44 Wrap excessively long line in BasePackFetchConnection
Change-Id: I926838058c1de2146e22faa08570406600457acb
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-09-14 15:34:55 -07:00
Shawn O. Pearce c1a9b2ae8b Fix smart HTTP client stream alignment errors
The client's use of UnionInputStream was broken when combined with a
8192 byte buffer used by PackParser. A smart HTTP client connection
always pushes in the execute stateless RPC input stream after the
data stream has ended from the remote peer. At the end of the pack,
PackParser asked to fill a 8192 byte buffer, but if only e.g. 1000
bytes remained UnionInputStream went to the next stream and asked
it for input, which triggered a new RPC, and failed because there
was nothing pending in the request buffer.

Change UnionInputStream to only return what it consumed from a
single InputStream without invoking the next InputStream, just in
case that second InputStream happens to be one of these magical
ones that generates an RPC invocation.

Change-Id: I0e51a8e6fea1647e4d2e08ac9cfc69c2945ce4cb
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-09-14 15:34:55 -07:00
Kevin Sawicki 4005f3c693 Remove duplicate calls to DirCache.unlock on checkout
Calls to unlock the DirCache before throwing an exception
were not needed since checkout calls doCheckout wrapped
in a try block that calls DirCache.unlock in a finally
block.

Change-Id: I2b249a784f9e363430e288aad67fcefb7fac0a6e
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-09-13 15:29:55 -07:00
Matthias Sohn cc4e6109e4 Merge branch 'stable-1.1'
* stable-1.1:
  Allow commit when submodule changes are present
  Ignore submodule on checkout instead of deleting it
  cleanup: Reuse local variable for current DirCacheEntry
  Prepare post v1.1.0.201109071825-rc3 builds
  JGit v1.1.0.201109071825-rc3
  Use commit message best practices for Mylyn Commit template

Change-Id: I6ab9e5cb48c036d2ee2e548f5ec040d93672d8ad
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-09-11 22:43:41 +02:00
Robin Rosenberg a7d3c68015 Allow commit when submodule changes are present
We do not yet check or validate submodules, but can accept that
someone staged a change in a submodule with other tools.

Change-Id: I642ede382314bfbd1892dd509a2222885cc5350a
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-09-08 16:46:20 +02:00
Robin Rosenberg 576abf64d1 Ignore submodule on checkout instead of deleting it
The purpose of this commit is to prevent destruction of
submodules on checkout from a tree with a submodule to
another. For consistency we handle the reverse case too,
when we checkout a branch that has a submodule and the
submodule directory exists. And finally we ignore the
case where the submodule changes.

We do not update the submodules, we just try to ignore
them harder.

Bug: 356664
Change-Id: I202c695a57af99b13d0d7220803fd08def3d9b5e
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-09-08 16:46:20 +02:00
Robin Rosenberg 2bb8da0405 cleanup: Reuse local variable for current DirCacheEntry
Since we already have assigned i.getDirCacheEntry() to dce,
use dce instead.

Change-Id: I107713ad0b356516d75c29203f945b056bad3ac7
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-09-08 16:46:19 +02:00
Matthias Sohn b09d21b6eb Prepare post v1.1.0.201109071825-rc3 builds
Change-Id: I1244f6639263d156a6f9e4530167e5eb1826a535
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-09-08 01:50:41 +02:00
Matthias Sohn 75611a8314 JGit v1.1.0.201109071825-rc3
Change-Id: I1b989d3101272632eacabe25a0b111ad0ff5bb3b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-09-08 00:54:27 +02:00
Dariusz Luksza 570d862ef3 Fix IOOBE in Repository.resolveSimple()
IndexOutOfBoundException is thrown from Repository.resolveSimple() when
'-g' string is located less then 4 characters from the end of this
string.

Change-Id: I1128c2cdfec9db3023d4d0f1f40d863e84b75950
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
2011-09-06 10:12:39 +02:00
Matthias Sohn cfdb09e9db Use commit message best practices for Mylyn Commit template
We should use a template for Mylyn commit messages that matches with our
guidelines for commit messages.

http://wiki.eclipse.org/EGit/Contributor_Guide#Commit_message_guidelines

Bug: 337401
Change-Id: I05812abf0eb0651d22c439142640f173fc2f2ba0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-09-05 23:57:21 +02:00
Robin Rosenberg b695f66487 Fix the names in the reflog for checkouts
We were diverging from the reference implementation. Always use the
ref we checkout to as the to-branch the reflog and avoid the
refs/heads both in the from-name and to-name.

Change-Id: Id973d9102593872e4df41d0788f0eb7c7fd130c4
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-09-05 17:02:16 +02:00
Robin Rosenberg eadc26c0a0 Add a helper for parsing branch switch info out of a reflog entry
Change-Id: I91c7e08c4afd2562df2226887a933d93c78a0371
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-09-05 17:01:56 +02:00
Kevin Sawicki d110fbc300 [blame] Reset rename detector before computing renames.
Bug: 354507
Change-Id: I5e9c65a082d9dee1e87536c5cf2a8de75efa6a33
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-09-01 13:29:43 -07:00
Matthias Sohn df117d3da9 Prepare post-v1.1.0.201109011030-rc2 builds
Change-Id: I8dda83cdbe88beba4a480df9846848bf3aceb9e2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-09-01 17:36:10 +02:00
Matthias Sohn 384ffa7ee9 JGit v1.1.0.201109011030-rc2
Change-Id: Ie6d65fe45ad92c813ce3a227729aa43681922249
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-09-01 16:38:13 +02:00
Roberto Tyley 602b2f0d45 Tolerate zlib deflation with window size < 32Kb
JGit currently identifies loose objects as 'corrupt' if they've been
deflated using a window size less than 32Kb, because the
isStandardFormat() function doesn't recognise the header
byte as a zlib header. This patch makes the method tolerant of
all valid window sizes (15-bit to 8-bit) - but doesn't sacrifice
it's accuracy in distingushing the standard loose-object format
from the experimental (now abandoned) format. It's based on a patch
which has been merged into C-Git master branch:

https://github.com/git/git/commit/7f684a2aff636f44a506

On memory constrained systems zlib may use a much smaller window
size - working on Agit, I found that Android uses a 4KB window;
giving a header byte of 0x48, not 0x78. Consequently all loose
objects generated by the Android platform appear 'corrupt' :(

It might appear that this patch changes isStandardFormat() to the
point where it could incorrectly identify the experimental format as
the standard one, but the two criteria (bitmask & checksum) can only
give a false result for an experimental object where both of the
following are true:

1) object size is exactly 8 bytes when uncompressed (bitmask)
2) [single-byte in-pack git type&size header] * 256
   + [1st byte of the following zlib header] % 31 = 0 (checksum)

As it happens, for all possible combinations of valid object type
(1-4) and window bits (0-7), the only time when the checksum will be
divisible by 31 is for 0x1838 - ie object type *1*, a Commit - which,
due the fields all Commit objects must contain, could never be as
small as 8 bytes in size.

Given this, the combination of the two criteria (bitmask & checksum)
always correctly determines the buffer format, and is more tolerant
than the previous version.

References:

Android uses a 4KB window for deflation:
http://android.git.kernel.org/?p=platform/libcore.git;a=blob;f=luni/src/main/native/java_util_zip_Deflater.cpp;h=c0b2feff196e63a7b85d97cf9ae5bb2583409c28;hb=refs/heads/gingerbread#l53

Code snippet searching for false positives with the zlib checksum:
https://gist.github.com/1118177

Change-Id: Ifd84cd2bd6b46f087c9984fb4cbd8309f483dec0
2011-08-25 22:25:10 +01:00
Stefan Lay 28a4992524 Merge "Unwind loop that iterates over fetch connection refs." 2011-08-25 11:09:52 -04:00
Tomasz Zarna c35c23db8d Use JGitText.refAlreadyExists instead of "ref exists"
Change-Id: I113bcf82c6292db5269271f799d09c80acc40bcd
2011-08-24 10:17:32 +02:00
Kevin Sawicki b127fa19eb Unwind loop that iterates over fetch connection refs.
Create separate loops based on whether the ref specs
collection is empty or not.

Change-Id: I2861b45fe083675e12ff47f591e104f8cf6dd216
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-08-22 13:10:31 -07:00
Christian Halstrick 930875a81a Throw JGit exception when ResetCommand got wrong ref
If the ResetCommand should reset to a invalid ref (e.g. HEAD in a repo
whithout a single commit) it was throwing an NPE. This is fixed now by
throwing a JGitInternalExcpeption. It would be nicer if we could throw
a InvalidRefException, but this would modify our API.

Bug: 339610
Change-Id: Iffcb4f2cca9f702176471d93c3a71e5cb3e700b1
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-08-21 14:11:00 -07:00
Matt Fischer 9952223e06 Implement server support for shallow clones
This implements the server side of shallow clones only (i.e.
git-upload-pack), not the client side.

CQ: 5517
Bug: 301627
Change-Id: Ied5f501f9c8d1fe90ab2ba44fac5fa67ed0035a4
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-08-21 14:04:23 -07:00
Shawn O. Pearce a1a8c6d77e PackWriter: support excluding objects already in other packs
This can be useful when implementing garbage collection and there
are packs that should not be copied, such as huge packs that have
a sibling ".keep" file alongside of them.

Callers driving PackWriter need to initialize the list of packs not
to include objects from by passing each index to excludeObjects().

Change-Id: Id7f34df69df97be406bcae184308e92b0e8690fd
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-08-21 13:59:26 -07:00
Denys Digtiar c580c56c4d Fix ClassCastException in MergeCommand
Test was added which reproduce the ClassCastException when ours or
theirs merge strategy is set to MergeCommand. Merger and MergeCommand
were updated in order to avoid exception.

Change-Id: I4c1284b4e80d82638d0677a05e5d38182526d196
Signed-off-by: Denys Digtiar <duemir@gmail.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-08-21 13:53:02 -07:00
Ketan Padegaonkar e38cf2078d Add ListTagCommand to JGit API
Bug: 355246
Change-Id: I11e019f3c19b4340ac7160ac8fcbadd52499d322
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-08-21 13:43:50 -07:00
Chris Aniszczyk bd691f162c Merge "Add DeleteTagCommand to JGit API" 2011-08-21 16:24:23 -04:00
Tomasz Zarna 5f787bfd62 Add DeleteTagCommand to JGit API
Bug: 353226
Change-Id: I54ae237cab792742333a249eb5a774d5e1775af8
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-08-21 13:18:52 -07:00
Christian Halstrick 12bb76380f Merge "PackWriter: Make want/have actual sets" 2011-08-18 03:43:38 -04:00
Kevin Sawicki a7aaf88b2e Use HEAD as default ref for RefLogCommand.
This mirrors the default command-line behavior.

Change-Id: I4f819410fa6df3064c560beb3184b61fd7bb1f15
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-08-17 08:56:16 -07:00
Matthias Sohn 148595fb54 Merge "Adds DiffEntry.scan(TreeWalk, boolean) method" 2011-08-17 07:31:54 -04:00
Dariusz Luksza 679cab9b32 Adds DiffEntry.scan(TreeWalk, boolean) method
Adds method into DiffEntry class that allows to specify whether changed
trees are included in scanning result list. By default changed trees
aren't added, but in some cases having changed tree would be useful.

Also adds check for tree count in TreeWalk and when it is different from
two it will thrown an IllegalArgumentException.

This change is required by egit
I7ddb21e7ff54333dd6d7ace3209bbcf83da2b219

Change-Id: I5a680a73e1cffa18ade3402cc86008f46c1da1f1
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-08-17 12:43:35 +02:00
Kevin Sawicki ac909ec89d Fix typo in IndexDiff.getModified() comment.
Removes an extra instance of the word 'on'.

Change-Id: Ie5f137f0dda440f5879f6d5c62ebce0431530ad7
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-08-16 13:22:42 -07:00
Shawn O. Pearce 74333e63b6 PackWriter: Make want/have actual sets
During parsing these are used with contains(). If they are a List
type, the contains operation is not efficient. Some callers such
as UploadPack often pass a List here, so convert to Set when the
type isn't efficient for contains().

Change-Id: If948ae3bf1f46e756bd2d5db14795e12ba7a6207
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-08-16 12:18:39 -07:00
Christian Halstrick 100e9429b5 Merge "Add DiffCommand to JGit API" 2011-08-16 08:25:46 -04:00
Tomasz Zarna 714a3ee151 Add DiffCommand to JGit API
Bug: 334766
Change-Id: Iea74c599a956a058608e424d0274f879bc2f064a
2011-08-16 11:47:55 +02:00
Shawn O. Pearce 2610eaf386 Revert "PackWriter: Do not delta compress already packed objects"
This reverts commit 67b064fc9f.

The "tiny optimization" introduced by 67b0 turns out to have a big
savings on wall-clock time when the object store is very slow (e.g.
the DHT support in JGit), but comes with a much bigger penalty in
space used by the output stream.  CGit packed with 67b0 enabled is
7 MiB larger than it should be (36 MiB rather than 28/29 MiB).  The
much bigger Linux kernel repository gained over 200 MiB, though some
of this may have been caused by a smaller window setting.

Revert this patch as PackWriter should be optimizing for space used
rather than time spent, since its primary use is network transfer, and
that isn't free.

Change-Id: I7413a9ef89762208159b4a1adc5a22a4c9245611
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-08-13 17:01:29 -07:00
Shawn O. Pearce 53db854185 Speed up ObjectWalk by 6235 objects/sec
The "Counting objects" phase of packing is the most time consuming
part for any server providing access to Git repositories. Scanning
through the entire project history, including every revision of
every tree that has ever existed is expensive and takes an incredible
amount of CPU time.

Inline the tree parsing logic, unroll a number of loops, and setup
to better handle the common case of seeing another occurrence of
an object that was already marked SEEN.

This change boosts the "Counting objects" phase when JGit is acting
as a server and is packing the linux-2.6 repository for its client.
Compared to CGit on the same hardware, a JGit daemon server is now
21883 objects/sec faster:

CGit:
  Counted 2058062 objects in 38981 ms at 52796.54 objects/sec
  Counted 2058062 objects in 38920 ms at 52879.29 objects/sec
  Counted 2058062 objects in 39059 ms at 52691.11 objects/sec

JGit (before):
  Counted 2058062 objects in 31529 ms at 65275.21 objects/sec
  Counted 2058062 objects in 30359 ms at 67790.84 objects/sec
  Counted 2058062 objects in 30033 ms at 68526.69 objects/sec

JGit (this commit):
  Counted 2058062 objects in 28726 ms at 71644.57 objects/sec
  Counted 2058062 objects in 27652 ms at 74427.24 objects/sec
  Counted 2058062 objects in 27528 ms at 74762.50 objects/sec

Above the first run was a "cold server". For JGit the JVM had just
started up with `jgit daemon`, and for CGit we hadn't touched the
repository "recently" (but it was certainly in kernel buffer cache).
The second and third runs were against the running JGit JVM, allowing
timing tests to better reflect the benefits of JGit's pack and index
caching, as well as any optimizations the JIT may have performed.

The timings are fair.  CGit is opening, checking and mmap'ing both
the pack and index during the timer.  JGit is opening, checking
and malloc+read'ing the pack and index data into its Java heap
during the timer. Both processes are walking the same graph space,
and are computing the "path hash" necessary to sort objects in the
object table for delta compression.  Since this commit only impacts
the "Counting objects" phase, delta compression was obviously not
included in the timings and JGit may still be performing delta
compression slower than CGit, resulting in an overall slower server
experience for clients.

Change-Id: Ieb184bfaed8475d6960a494b1f3c870e0382164a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-08-13 14:53:18 -07:00
Shawn O. Pearce 82e735c3aa Merge "PackWriter: Only search for base objects on thin packs" 2011-08-13 17:33:18 -04:00
Shawn Pearce a2eadf0b67 Merge "Ignore missing MERGE_MSG when deleting MERGE_MSG" 2011-08-13 17:08:40 -04:00
Shawn Pearce ac9d9ee96d Merge "Correct comment on CloneCommand.setRemote method." 2011-08-13 17:00:29 -04:00
Robin Rosenberg 5a3a2b53ee Merge "Fix reading of ref names containing characters that sort before /" 2011-08-10 14:40:25 -04:00
Robin Rosenberg d4db26bb57 Merge "Fix offset64 creation for objects at 2 GiB" 2011-08-10 14:39:30 -04:00
Robin Stocker 8db5b6a013 Add isSuccessful to MergeStatus, RebaseResult.Status and PullResult
This is useful when the result needs to be displayed and it's only of
interest if the operation was successful or not (in egit, it could be
used in MultiPullResultDialog).

Change-Id: Icfc9a9c76763f8a777087a1262c8d6ad251a9068
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-08-09 23:31:50 +02:00
Shawn O. Pearce 3bac5b1d7d Fix offset64 creation for objects at 2 GiB
The offset32 format is used for objects <= 2^31-1, while the offset64
format is used for all other objects.  This condition was missing
the = needed to ensure an object placed exactly at 2^31 would have
its 64 bit offset in the index.

Change-Id: I293fac0e829c9baa12cb59411dffde666051d6c5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-08-08 16:36:56 -07:00
Shawn O. Pearce 99e6cfb131 PackWriter: Only search for base objects on thin packs
A non-thin pack does not need to worry about preferred bases, the pack
will be self-contained and all required delta base objects will appear
within the pack itself. Obtaining the path buffer and length from the
ObjectWalk to build the preferred base table is "expensive", so avoid
the cost unless a thin pack is being constructed.

Change-Id: I16e30cd864f4189d4304e7957a7cd5bdb9e84528
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-08-08 15:10:11 -07:00
Shawn O. Pearce 86ecf141b6 Merge changes I58110f17,I440baa64,Ic77dcac5
* changes:
  PackWriter: Skip progress messages on fast operations
  IndexPack: Defer the "Resolving deltas" progress meter
  IndexPack: Fix "Resolving deltas" progress meter
2011-08-05 21:21:10 -04:00
Kevin Sawicki 4ae9d47130 Correct comment on CloneCommand.setRemote method.
The previous comment stated that the value set was used
to keep track of the branch in the remote repository
which was incorrect.

Updated the method comment to match the format used
for the PushCommand.setRemote and FetchCommand.setRemote
methods.

Change-Id: I11b81eb3125958af29247b485da56fd88c3bfdf5
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-08-05 11:02:10 -07:00
Matthias Sohn 1067f82f56 Reuse ObjectReader for all objects touched during checkout
Bug: 349361
Change-Id: I61ffcb7694eb8b99ebaf4d0d0acd63e0ee91bcb3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-08-02 17:54:20 +02:00
Tomasz Zarna 6d293c7b06 Don't hard-code section names, use ConfigConstants instead
Change-Id: Ie2dde43da491fa27b25a2ad8014866d77d484b24
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-08-02 16:19:09 +02:00
Shawn O. Pearce 68cc21b60d PackWriter: Skip progress messages on fast operations
If the "Finding sources" phase will complete in <1 second with no
delta compression enabled, don't bother showing the progress meter for
this phase.  Small repositories on the local filesystem tend to rip
through this phase always subsecond and the ProgressMonitor display
can actually slow the operation down.

If delta compression is enabled, there are two phases that may run
very quickly. Set the timer to 500 milliseconds instead, reducing the
risk that the user has to wait longer than 1 second before any sort of
output from the packer occurs.

Change-Id: I58110f17e2a5ffa0134f9768b94804d16bbb8399
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-07-28 10:22:50 -07:00
Shawn O. Pearce c81f6ab3ab IndexPack: Defer the "Resolving deltas" progress meter
If delta resolution completes in < 1000 milliseconds, don't bother
showing the progress meter. This is actually very common for a Gerrit
Code Review server, where the client is probably sending 1 commit and
only a few trees/blobs modified... and the base objects are hot in the
process buffer cache.

The 1000 millisecond delay is just a guess at a reasonable time to wait.

Change-Id: I440baa64ab0dfa21be61deae8dcd3ca061bed8ce
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-07-28 10:22:50 -07:00
Shawn O. Pearce e0111b18c8 IndexPack: Fix "Resolving deltas" progress meter
This progress meter never reached 100% as it did not update while
resolving the external bases in thin packs.

Instead of updating in batches at the top level, update once per delta
that is resolved. The batching progress meter type should smooth out
the frequent updates to an update rate that is more reasonable to send
to the UI, while also ensuring a successful pack parse always reaches
100% deltas resolved.

Change-Id: Ic77dcac542cfa97213a6b0194708f9d3c256d223
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-07-28 10:22:50 -07:00
Shawn O. Pearce d16085b3b9 Make PackReverseIndex a public structure
Repository inspection tools may find building a reverse index on a
pack useful, as they can then locate an object by offset. As both
C Git and JGit sometimes produce error messages with the offset
rather than the SHA-1, it may be useful to expose this type.

Change-Id: I487bf32e85a8985cf8ab382d4c82fcbe1fc7da6c
2011-07-28 10:07:10 -07:00
Shawn O. Pearce d60cb2a3f5 Make lookup methods on PackIndex public
There isn't a good reason to hide all of these as package-private.
Make them public so applications can inspect pack files.

Change-Id: Ia418daf65d63e9e015b8dafdf3d06a1ed91d190b
2011-07-28 10:07:10 -07:00
Shawn O. Pearce 38c5b26245 PackIndex: Support reading from any InputStream
Change-Id: If065a9e33a8f3a03e9758eb7612af2fc460c87e5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-07-28 10:07:09 -07:00
Shawn O. Pearce d1f130f7f9 Add String form of PackInvalidException constructor
This way the path can be supplied as a string, without first
converting to a java.io.File.

Change-Id: I54d9bb9867556cd98b378c0762054b31497459cb
2011-07-28 10:07:09 -07:00
Shawn O. Pearce 14680f6e6e Add copy constructor to PackConfig
Some embeddings of UploadPack (e.g. Gerrit Code Review) set their own
PackConfig from a server-wide configuration, overriding any JGit
defaults or settings that may exist at the local repository level.

Make a copy constructor form of PackConfig so this server-wide
configuration object can be copied and then merged with repository
specific configuration data.

Change-Id: I4463c95aeaf7d6536c3ab132dec9c50ee528d9e0
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-07-27 10:00:41 -07:00