Commit Graph

1650 Commits

Author SHA1 Message Date
Kevin Sawicki 3734db9282 Use object id provided by working tree iterator for submodules
The working tree iterator now supports providing an object id
for submodule entries and this value should be used instead
of recomputing it again in AddCommand.

Change-Id: I30082514c23fc65968bb78add5ad69a1ca95cf3a
2012-03-10 10:26:10 -08:00
Kevin Sawicki 5c18fcb81b Keep submodules in index that are missing in working directory
Submodules present in the index but missing from the working
directory should not be staged for deletion when AddCommand
is called with the update flag set to true.

This mirrors the behavior of CGit.  Submodules can still be
staged for deletion by running by using the RmCommand.

Change-Id: Iee508a67f9621269d1c28d422f88c6b8dd9f8e6e
2012-03-10 10:02:58 -08:00
Robin Rosenberg 9a9877da4e Merge "EolCanonicalizingInputStream: binary detection should be optional" 2012-03-09 15:52:11 -05:00
Stefan Lay d725ecb80e Merge "Fix rebase > continue when nothing left to commit." 2012-03-09 08:04:20 -05:00
Markus Duft edc1fee033 Fix rebase > continue when nothing left to commit.
If after resolving all conflicts nothing is left to commit, return
an according result, so that downstreams (EGit, ...) can behave like
cgit, and display a nice message informing the user.

Currently, EGit displays a "HEAD advanced fast forward" message, which
is absolutely not helpful at all.

This is the basic API revamping required to get that state communicated
to the outside world (EGit).

Bug: 336812
Change-Id: If2665005cf54a5b51c0fe80bad019fa42b0205af
2012-03-09 13:56:37 +01:00
Robin Rosenberg 708febedaf cleanup: Remove unnecessary @SuppressWarnings
Change-Id: Ie22ac47e315bff76f224214bc042fc483eb01550
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2012-03-09 13:30:07 +01:00
Robin Rosenberg 48bd58b8ee Merge "Revert non-sense logic in IO.readFully" 2012-03-09 04:47:45 -05:00
Shawn Pearce 500e17e7d6 Merge changes I8277fd45,I7ac4e0ae,Ib475dfc0,Ib26adf95
* changes:
  Try to send HTTP error messages over sideband
  Extract the capability parsing logic in {Upload,Receive}Pack
  Make capability strings in BasePack{Fetch,Push}Connection public
  Fix a typo in "capabilities" in ReceivePack
2012-03-07 22:22:22 -05:00
Dave Borowitz 039c785d9f Try to send HTTP error messages over sideband
When a client POSTs to /git-{upload,receive}-pack, the first line
includes their client capabilities. As soon as the C git client sends
side-band(-64k), it goes into a state where it chokes on data not sent
in a valid sideband channel.

GitSmartHttpTools.sendError() is called early in the request, likely
before a {Upload,Receive}Pack handler is assigned or, even so, before it
has read the request. In some cases we must read the first line manually
within sendError() to tell whether sideband is needed.

Change-Id: I8277fd45a4ec3b71fa8f87404b4f5d1a09e0f384
2012-03-07 15:04:45 -08:00
Dave Borowitz d2787d481e Extract the capability parsing logic in {Upload,Receive}Pack
Change-Id: I7ac4e0ae98872a74b01162b5ca936fb15e2f8cff
2012-03-07 12:53:49 -08:00
Dave Borowitz 2b0044f222 Make capability strings in BasePack{Fetch,Push}Connection public
Change-Id: Ib475dfc087705ea40e1db37ec9ef28a67fde6d72
2012-03-07 12:52:47 -08:00
Dave Borowitz eea8581da5 Fix a typo in "capabilities" in ReceivePack
Change-Id: Ib26adf954dcb90403be9d6ed3b7a425a724c67d0
2012-03-07 12:52:45 -08:00
Tomasz Zarna 90d002c15f Remove ambiguous CheckoutConflictException
Checkout command should throw o.e.j.api.errors.CheckoutConflictException
which is a GitAPIException not o.e.j.errors.CheckoutConflictException.
PullCommand should rethrow the API exception as a JGitInternalException.

Bug: 356922
Change-Id: I865c4905997d9834c85a97fbe7287604daf99075
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-03-06 22:43:25 +01:00
Christian Halstrick e05300b21d Merge "Check connection's error stream before reading from it" 2012-03-06 09:26:38 -05:00
Kevin Sawicki 9e4b4fc41c Set person and message on stash ref update
This will be the message and person used for the commit
of stashed working directory changes.

Bug: 372884
Change-Id: I2501b080f6b94e826cf7dba3fd526ae5c1d969d1
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-03-05 20:59:44 -08:00
Kevin Sawicki 8db5414dcf Return command from StashCreateCommand setters
Previously were void which made them inconsistent with
the fluid setter pattern used in other commands.

Change-Id: Idb81dfc7bb097306f0c5d6e34f91a2bbab501668
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-03-05 20:53:59 -08:00
Kevin Sawicki 9908c203a5 Support insteadOf and pushInsteadOf URL replacement
Bug: 346873
Change-Id: I4116328f93f411da56a633bc32fd064b2ac083f2
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-03-05 20:46:26 -08:00
Chris Aniszczyk db29665e64 Merge "Quickfix for AutoCRLF handling" 2012-03-05 23:44:45 -05:00
Kevin Sawicki 2c6187697c Check connection's error stream before reading from it
HttpURLConnection.getErrorStream can return null which is
currently not guarded against and will throw an NPE preventing
the actual error response code from bubbling up.

Change-Id: I04fb8dbda16b7df3b82fc579088a303b2fd21e87
2012-03-05 17:22:22 -08:00
Tomasz Zarna eedd77a97b RawText#getEOL() does the same thing as RawText#getLineDelimiter()
The duplication has been introduced when merging
I08e1369e142bb19f42a8d7bbb5a7d062cc8533fc and
I18adc63596f4657516ccc6d704a561924c79d445. The former should have been
manually rebased. It also missed a copyright update in ApplyCommandTest.

Change-Id: I18fe6108220f964524fb16b719604222aa7abee6
2012-03-05 12:59:10 +01:00
Christian Halstrick c71fff4ce2 Merge "Update example code for obtaining a locked DirCache" 2012-03-05 03:46:53 -05:00
Tomasz Zarna 92f90eb229 Add ApplyCommand to JGit API
Bug: 361548
CQ: 6243
Change-Id: I08e1369e142bb19f42a8d7bbb5a7d062cc8533fc
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-03-04 21:29:01 -08:00
Robin Rosenberg 8e1bc46061 Merge "Remove null access warning in DirCacheCheckout" 2012-03-04 13:06:59 -05:00
Robin Rosenberg 88fe2836ed Quickfix for AutoCRLF handling
CRLF only works for small files, where small is the size of the
buffer, i.e. about 8K. This QD fix reallocates the buffer to be
large enough.

Bug: 369780
Change-Id: Ifc34ad204fbf5986b257a5c616e4a8c601e8261a
2012-03-03 08:22:48 +01:00
Matthias Sohn e0910edf7c Include eclipse.inf
Commit 9169e7f9ec failed to add
org.eclipse.jgit/META-INF/eclipse.inf in order to fix bug 372845 since
JGit is not yet built by Tycho. Hence explicitly including it.

Bug: 372845
Change-Id: I6cb12327a237d69fbfe3d5e77d8a6ad7de442ad5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-03-03 00:53:00 +01:00
Kevin Sawicki d364fb2d4f Remove null access warning in DirCacheCheckout
Initially fill in the current DirCacheEntry field guarding 
against a null index tree and use that variable instead of
calling getDirCacheEntry() on a possibly null DirCacheBuildIterator.

Change-Id: I16f388a16636aefdb07d66dae5d05655009e2a0e
2012-03-02 15:01:13 -08:00
Kevin Sawicki 014d759d35 Update example code for obtaining a locked DirCache
Previous example was calling a method that no longer exists
on DirCache.

Change-Id: I864842c58df4f116b318dc4a150b789745769a0d
2012-03-02 12:49:38 -08:00
Tomasz Zarna 9c7371a8c4 Allow to get end-of-line characters for a RawText
Bug: 370320
Change-Id: I18adc63596f4657516ccc6d704a561924c79d445
Signed-off-by: Kevin Sawicki <kevin@github.com>
2012-03-02 12:06:09 -08:00
Sascha Scholz a1f877e312 Load .gitmodules config before adding values to it
This prevents existing entries from being cleared when the
.gitmodules config is saved after the new submodule configuration
is added.

Change-Id: I66841f5e758a7527e2e6e25cf1318e5fea91a909
Signed-off-by: Kevin Sawicki <kevin@github.com>
2012-03-02 09:31:09 -08:00
Christian Halstrick 1515d7b7d5 Merge "Exclude org.eclipse.jgit from pack200 packing" 2012-03-02 11:03:14 -05:00
Christian Halstrick 3083146d13 Merge "Reuse existing modes and ids" 2012-03-02 03:46:03 -05:00
Matthias Sohn 9169e7f9ec Exclude org.eclipse.jgit from pack200 packing
It seems pack200 became unable to correctly pack the bundle
org.eclipse.jgit (see bug 372845). Hence mark it to be excluded from
this packing step following the workaround which worked for
org.eclipse.jst.jsf.core (bug 335806).

Bug: 372845
Change-Id: I2e3d20645ac49125472ddc235afbe9f3c7480caf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-03-02 09:11:18 +01:00
Dave Borowitz d023f2c78b Extract filterCommands as a static method on ReceiveCommand
Change-Id: I24501f95185878d09b54562e48cb4e7e45dd3968
2012-02-29 19:09:24 -08:00
Dave Borowitz 903e1b81d4 Remove PreUploadHook.onPreAdvertiseRefs
AdvertiseRefsHook.advertiseRefs subsumes this behavior.

Change-Id: Id2d1ebb2503c9ba79eda58aaea2fd76ec233427f
2012-02-29 19:09:24 -08:00
Dave Borowitz 9d41dbd958 Add an AdvertiseRefsHookChain, similar to the other hook chains
Change-Id: I3bb0dc86047fe0446d18e0055f714092a658d228
2012-02-29 19:09:23 -08:00
Dave Borowitz 1f2022e3a7 Modify refs in UploadPack/ReceivePack using a hook interface
This is intended to replace the RefFilter interface (but does not yet,
for backwards compatibility). That interface required lots of extra
scanning and copying in filter cases such as only advertising a subtree
of the refs directory. Instead, provide a hook that can be executed
right before ref advertisement, using the public methods on
UploadPack/ReceivePack to explicitly set the map of advertised refs.

Change-Id: I0067019a191c8148af2cfb71a675f2258c5af0ca
2012-02-29 19:09:23 -08:00
Dave Borowitz 7acd333e7d Fix a typo referring to RevFilter as RefFilter
Change-Id: I173efca7540b522d386216d1bd229e9a061263b2
2012-02-29 19:09:23 -08:00
Dave Borowitz bb8f0bec4a Minor javadoc wording fixes in ReceivePack
Change-Id: I5b409ef39aee890bcd7d4277e36b85ac4dc48281
2012-02-29 19:09:23 -08:00
Dave Borowitz 27cbdaf497 Expose an OutputStream from ReceivePack for sending client messages
Callers may want to format and flush their own output, for example in a
PreReceiveHook that creates its own TextProgressMonitor. The actual
underlying msgOut can change over the lifetime of ReceivePack, so we
implement a small wrapper.

Change-Id: I57b6d6cad2542aaa93dcadc06cb3e933e81bcd3d
2012-02-29 19:09:23 -08:00
Dave Borowitz 4a01f47e82 Allow creating ReceiveCommands with a specified type
This allows callers who know in advance whether a command is UPDATE or
UPDATE_NONFASTFORWARD to specify this in the constructor rather than
with a separate method call.

Change-Id: Iae483594a4ff370ff75d17a7b0648c5590b3d1bd
2012-02-29 19:09:22 -08:00
Dave Borowitz 4bf22ff6e8 Execute ReceiveCommands via a method rather than in ReceivePack
This allows a PreReceiveHook to easily "take over" all of the
ReceiveCommands passed to it, preventing any of them from being handled
within the ReceivePack core.

Change-Id: I2a8c1fc44e8dcadf22cd97a8ec4ee79d4d9d08f1
2012-02-29 19:09:22 -08:00
Kevin Sawicki 0fb0e84405 Reuse existing modes and ids
This change replaces calls to getEntryObjectId and getEntryFileMode
with the existing method local variables for the index, merge, and
head tree iterators.

Change-Id: I75d1edfdd192a009fc916102ec052434c6302d00
2012-02-29 15:07:37 -08:00
Kevin Sawicki 4de8a84671 Add command support for applying a stashed commit
Applies the changes in a stashed commit to the local working
directory and index

Bug: 309355
Change-Id: I9fd5ede8affc7f0060ffa7c5cec34573b6fa2b1b
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-02-28 13:53:13 -08:00
Kevin Sawicki 03d4dc597e Add support for creating a stashed commit
Adds a new command to stash the index and working directory
changes in a commit stored in refs/stash

Bug: 309355
Change-Id: I2ce85b1601b74b07e286a3f99feb358dfbdfe29c
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-02-28 13:46:35 -08:00
Kevin Sawicki 10c0b34b88 Add all paths option to CheckoutCommand
This will perform the equivalent  of running a
'git checkout -- .' at the root of a repository

Change-Id: I3e2dd563700999bc063effdd3640499c8ed08136
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-26 16:10:57 +01:00
Daniel Megert 709cd52958 Let the date formatter pick the locale.
Instead of using the locale from the SystemReader we let the
SystemReader create the date formats without passing the locale.

Bug 368756
Change-Id: I6be9e07af804a08f3f3ac2d2d526ef594eed19e3
Signed-off-by: Daniel Megert <daniel_megert@ch.ibm.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-25 23:37:02 +01:00
Stefan Lay 54f23873d6 Add support for autosetuprebase to the CloneCommand
Bug: 345536
Change-Id: I93c609235dec4e5e3a2ddc275c28b202bf868d40
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Kevin Sawicki <kevin@github.com>
2012-02-23 09:32:02 -08:00
Matthias Sohn 0211d91001 Merge "Add IGNORE_ERRORS to FileUtils.delete()" 2012-02-21 14:34:42 -05:00
Marc Strapetz 7df17e57d4 EolCanonicalizingInputStream: binary detection should be optional
EolCanonicalizingInputStream may also be used in combination with
.gitattributes. If .gitattributes states that a file is of type text, line
endings have to be canonicalized even if the actual file content seems
to be binary.

Change-Id: Ie4ccdfc5cb91fbd55e06f51146cf5c7c84b8e18b
2012-02-21 15:22:36 +01:00
Christian Halstrick b6d376a177 Add IGNORE_ERRORS to FileUtils.delete()
There are a few situations where you want to delete files or folders but
where you are not interested in getting exceptions if this doesn't
succeed. E.g. if you delete garbage in the GC class you want that if
certain files can't be deleted the command succeeds. Maybe the next
garbage collector run has more luck not to interfere with a virus
scanner run on Windows. Therefore an option is added to
FileUtils.delete() not to report errors in such cases.

Change-Id: I58994d8c481e591dcbb0f2be7dfa562e125f0f08
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2012-02-21 14:23:43 +01:00
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